1. add _systemAlertWindow and _enableStartOnBoot options.

2. opt settings_page.dart state variables
This commit is contained in:
csf
2023-02-28 11:31:30 +09:00
parent 8cd9f8745d
commit 48100c9e91
5 changed files with 116 additions and 21 deletions

View File

@@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:icon="@mipmap/ic_launcher"

View File

@@ -13,6 +13,7 @@ import android.content.Intent
import android.content.ServiceConnection
import android.os.Build
import android.os.IBinder
import android.preference.PreferenceManager
import android.provider.Settings
import android.util.Log
import android.view.WindowManager
@@ -149,6 +150,25 @@ class MainActivity : FlutterActivity() {
result.success(true)
}
}
GET_START_ON_BOOT_OPT -> {
val prefs = getSharedPreferences(KEY_SHARED_PREFERENCES, MODE_PRIVATE)
result.success(prefs.getBoolean(KEY_START_ON_BOOT_OPT, false))
}
SET_START_ON_BOOT_OPT -> {
try {
if (call.arguments is Boolean) {
val prefs = getSharedPreferences(KEY_SHARED_PREFERENCES, MODE_PRIVATE)
val edit = prefs.edit()
edit.putBoolean(KEY_START_ON_BOOT_OPT, call.arguments as Boolean)
edit.apply()
result.success(true)
} else {
result.success(false)
}
} finally {
result.success(false)
}
}
else -> {
result.error("-1", "No such method", null)
}

View File

@@ -37,9 +37,14 @@ const val REQ_REQUEST_MEDIA_PROJECTION = 201
const val RES_FAILED = -100
// Flutter channel
const val START_ACTION = "start_action";
const val IGNORE_BATTERY_OPTIMIZATIONS = "ignore_battery_optimizations";
const val START_ACTION = "start_action"
const val GET_START_ON_BOOT_OPT = "get_start_on_boot_opt"
const val SET_START_ON_BOOT_OPT = "set_start_on_boot_opt"
const val IGNORE_BATTERY_OPTIMIZATIONS = "ignore_battery_optimizations"
const val KEY_SHARED_PREFERENCES = "KEY_SHARED_PREFERENCES"
const val KEY_START_ON_BOOT_OPT = "KEY_START_ON_BOOT_OPT"
@SuppressLint("ConstantLocale")
val LOCAL_NAME = Locale.getDefault().toString()