Update project
This commit is contained in:
@@ -18,7 +18,7 @@ if (keystorePropertiesFile.exists()) {
|
||||
android {
|
||||
namespace = "com.nearle.gear"
|
||||
compileSdk = 36
|
||||
ndkVersion = "27.0.12077973"
|
||||
ndkVersion = "28.2.13676358"
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.nearle.gear"
|
||||
@@ -59,6 +59,9 @@ android {
|
||||
)}
|
||||
}
|
||||
}
|
||||
configurations.all {
|
||||
exclude(group = "com.google.firebase", module = "firebase-iid")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
|
||||
15
android/app/proguard-rules.pro
vendored
15
android/app/proguard-rules.pro
vendored
@@ -53,3 +53,18 @@
|
||||
# Keep annotations
|
||||
###############################
|
||||
-keepattributes *Annotation*
|
||||
|
||||
###############################
|
||||
# Firebase InstanceID (legacy, referenced by mlkit-linkfirebase only)
|
||||
###############################
|
||||
-dontwarn com.google.firebase.iid.**
|
||||
|
||||
###############################
|
||||
# ML Kit text recognition — language packs not bundled
|
||||
###############################
|
||||
-dontwarn com.google.mlkit.vision.text.chinese.**
|
||||
-dontwarn com.google.mlkit.vision.text.devanagari.**
|
||||
-dontwarn com.google.mlkit.vision.text.japanese.**
|
||||
-dontwarn com.google.mlkit.vision.text.korean.**
|
||||
-dontwarn com.google.mlkit.linkfirebase.**
|
||||
-dontwarn com.google.mlkit.**
|
||||
@@ -2,20 +2,17 @@
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <!-- For Android 13+ -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
|
||||
<uses-permission android:name="android.permission.READ_SMS"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA"/>
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
||||
|
||||
<application
|
||||
@@ -27,10 +24,13 @@
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
|
||||
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyBhkGfnq27sN0wV5y_S-M2KojpFTk_by-Q"/>
|
||||
|
||||
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||
android:value="nearle_channel" />
|
||||
@@ -63,6 +63,7 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
<!-- Google Maps API Key -->
|
||||
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBhkGfnq27sN0wV5y_S-M2KojpFTk_by-Q" />
|
||||
|
||||
|
||||
|
||||
@@ -74,16 +75,50 @@
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@mipmap/ic_launcher" />
|
||||
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<!-- Deep linking for product sharing -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="nearle" android:host="product" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- Google Assistant App Actions -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="nearle" android:host="order"/>
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
|
||||
<receiver android:name=".HomeWidgetProvider" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/home_widget_info" />
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.nearle.gear
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.BitmapFactory
|
||||
import android.widget.RemoteViews
|
||||
import es.antonborri.home_widget.HomeWidgetProvider as BaseHomeWidgetProvider
|
||||
|
||||
class HomeWidgetProvider : BaseHomeWidgetProvider() {
|
||||
|
||||
override fun onUpdate(
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetIds: IntArray,
|
||||
widgetData: SharedPreferences
|
||||
) {
|
||||
val path = widgetData.getString("banner_path", null) ?: return
|
||||
val bitmap = BitmapFactory.decodeFile(path) ?: return
|
||||
|
||||
appWidgetIds.forEach { widgetId ->
|
||||
val views = RemoteViews(context.packageName, R.layout.home_widget_layout).apply {
|
||||
setImageViewBitmap(R.id.widget_banner_image, bitmap)
|
||||
}
|
||||
appWidgetManager.updateAppWidget(widgetId, views)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,44 @@
|
||||
// MainActivity.kt
|
||||
package com.nearle.gear
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.ComponentName
|
||||
import android.os.Build
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugins.webviewflutter.WebViewFlutterPlugin
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
private val CHANNEL = "com.nearle.gear/widget"
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
// Register the WebViewFlutterPlugin
|
||||
flutterEngine.plugins.add(WebViewFlutterPlugin())
|
||||
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
|
||||
when (call.method) {
|
||||
"requestPinWidget" -> result.success(requestPinWidget())
|
||||
"isWidgetPinned" -> result.success(isWidgetPinned())
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestPinWidget(): Boolean {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val appWidgetManager = AppWidgetManager.getInstance(this)
|
||||
val provider = ComponentName(this, HomeWidgetProvider::class.java)
|
||||
if (appWidgetManager.isRequestPinAppWidgetSupported) {
|
||||
appWidgetManager.requestPinAppWidget(provider, null, null)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun isWidgetPinned(): Boolean {
|
||||
val appWidgetManager = AppWidgetManager.getInstance(this)
|
||||
val provider = ComponentName(this, HomeWidgetProvider::class.java)
|
||||
val ids = appWidgetManager.getAppWidgetIds(provider)
|
||||
return ids.isNotEmpty()
|
||||
}
|
||||
}
|
||||
12
android/app/src/main/res/layout/home_widget_layout.xml
Normal file
12
android/app/src/main/res/layout/home_widget_layout.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_banner_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
</FrameLayout>
|
||||
8
android/app/src/main/res/xml/home_widget_info.xml
Normal file
8
android/app/src/main/res/xml/home_widget_info.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="250dp"
|
||||
android:minHeight="100dp"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:initialLayout="@layout/home_widget_layout"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen" />
|
||||
10
android/app/src/main/res/xml/shortcuts.xml
Normal file
10
android/app/src/main/res/xml/shortcuts.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<capability android:name="actions.intent.ORDER_MENU_ITEM">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetPackage="com.nearle.gear"
|
||||
android:targetClass="com.nearle.gear.MainActivity"
|
||||
android:data="nearle://order?item={menuItem.name}&budget={price.text}"/>
|
||||
</capability>
|
||||
</shortcuts>
|
||||
Reference in New Issue
Block a user