From 14cd548dffb3fbd2c5bb369ae84012e855425b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Tue, 5 Nov 2019 18:49:40 +0100 Subject: [PATCH] [Sync] Add more AppManager intents to launch. --- .../szczodrzynski/edziennik/MainActivity.kt | 39 ++++++++----------- .../edziennik/utils/AppManagerIntentList.kt | 24 ++++++++++++ 2 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/utils/AppManagerIntentList.kt diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt index 183d00de..11f7155b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt @@ -2,10 +2,15 @@ package pl.szczodrzynski.edziennik import android.app.Activity import android.app.ActivityManager -import android.content.* +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.content.pm.PackageManager import android.graphics.BitmapFactory import android.graphics.drawable.BitmapDrawable import android.os.* +import android.provider.Settings import android.view.Gravity import android.view.View import android.widget.Toast @@ -64,6 +69,7 @@ import pl.szczodrzynski.edziennik.utils.Themes import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.Utils.dpToPx +import pl.szczodrzynski.edziennik.utils.appManagerIntentList import pl.szczodrzynski.edziennik.utils.models.NavTarget import pl.szczodrzynski.navlib.* import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_HALF_TRANSPARENT @@ -582,29 +588,18 @@ class MainActivity : AppCompatActivity() { .setMessage(R.string.app_manager_dialog_text) .setPositiveButton(R.string.ok) { dialog, which -> try { - val intent = Intent() - intent.component = ComponentName( - "com.huawei.systemmanager", - "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity" - ) - startActivity(intent) - } catch (e: Exception) { - e.printStackTrace() - try { - val intent = Intent() - intent.component = ComponentName( - "com.asus.mobilemanager", - "com.asus.mobilemanager.MainActivity" - ) - startActivity(intent) - } catch (e: Exception) { - try { - startActivity(Intent(android.provider.Settings.ACTION_SETTINGS)) - } catch (e: Exception) { - e.printStackTrace() - Toast.makeText(this, R.string.app_manager_open_failed, Toast.LENGTH_SHORT).show() + for (intent in appManagerIntentList) { + if (packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) { + startActivity(intent) } } + } catch (e: Exception) { + try { + startActivity(Intent(Settings.ACTION_SETTINGS)) + } catch (e: Exception) { + e.printStackTrace() + Toast.makeText(this, R.string.app_manager_open_failed, Toast.LENGTH_SHORT).show() + } } } .setNeutralButton(R.string.dont_ask_again) { dialog, which -> diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/AppManagerIntentList.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/AppManagerIntentList.kt new file mode 100644 index 00000000..5e802dba --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/AppManagerIntentList.kt @@ -0,0 +1,24 @@ +package pl.szczodrzynski.edziennik.utils + +import android.content.ComponentName +import android.content.Intent + +val appManagerIntentList = listOf( + Intent().setClassName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity") + .putExtra("packageName", "pl.szczodrzynski.edziennik") + .putExtra("package_label", "Szkolny.eu"), + Intent().setComponent(ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")), + Intent().setComponent(ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")), + Intent().setComponent(ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")), + Intent().setComponent(ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")), + Intent().setComponent(ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity")), + Intent().setComponent(ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")), + Intent().setComponent(ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")), + Intent().setComponent(ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")), + Intent().setComponent(ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")), + Intent().setComponent(ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")), + Intent().setComponent(ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")), + Intent().setComponent(ComponentName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity")), + Intent().setComponent(ComponentName("com.htc.pitroad", "com.htc.pitroad.landingpage.activity.LandingPageActivity")), + Intent().setComponent(ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.MainActivity")) +) \ No newline at end of file