From a0e501afde8c26d1b48543a1e829d6d34168e5b4 Mon Sep 17 00:00:00 2001 From: tornaco Date: Sat, 19 Mar 2022 18:17:29 +0800 Subject: [PATCH] [app] TileService: startActivityAndCollapse --- .../android/thanos/qs/QuickConfigAppTile.java | 23 +++++++++++++------ android/internal/Thanox-Internal | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/java/github/tornaco/android/thanos/qs/QuickConfigAppTile.java b/android/app/src/main/java/github/tornaco/android/thanos/qs/QuickConfigAppTile.java index 405601a4b..21a93e48e 100644 --- a/android/app/src/main/java/github/tornaco/android/thanos/qs/QuickConfigAppTile.java +++ b/android/app/src/main/java/github/tornaco/android/thanos/qs/QuickConfigAppTile.java @@ -1,5 +1,6 @@ package github.tornaco.android.thanos.qs; +import android.content.Intent; import android.os.Build; import android.service.quicksettings.Tile; import android.service.quicksettings.TileService; @@ -8,7 +9,9 @@ import com.elvishew.xlog.XLog; +import github.tornaco.android.thanos.BuildProp; import github.tornaco.android.thanos.core.app.ThanosManager; +import github.tornaco.android.thanos.core.pm.AppInfo; @RequiresApi(api = Build.VERSION_CODES.N) public class QuickConfigAppTile extends TileService { @@ -33,15 +36,21 @@ public void onClick() { updateState(); return; } - ThanosManager.from(getApplicationContext()) - .ifServiceInstalled(thanosManager -> thanosManager.getActivityManager() - .launchAppDetailsActivity( - thanosManager.getActivityStackSupervisor().getCurrentFrontApp())); - - QsHelper.collp(this); + launchAppDetailsActivity(ThanosManager.from(getApplicationContext()).getActivityStackSupervisor().getCurrentFrontApp()); updateState(); } + public void launchAppDetailsActivity(String pkgName) { + XLog.d("launchAppDetailsActivity: %s", pkgName); + Intent viewer = new Intent(); + viewer.setPackage(BuildProp.THANOS_APP_PKG_NAME); + viewer.setClassName(BuildProp.THANOS_APP_PKG_NAME, BuildProp.ACTIVITY_APP_DETAILS); + AppInfo appInfo = ThanosManager.from(getApplicationContext()).getPkgManager().getAppInfo(pkgName); + viewer.putExtra("app", appInfo); + viewer.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivityAndCollapse(viewer); + } + @Override public void onStartListening() { updateState(); @@ -58,7 +67,7 @@ public void onStopListening() { private void updateState() { if (getQsTile() == null) return; - getQsTile().setState(Tile.STATE_ACTIVE); + getQsTile().setState(Tile.STATE_INACTIVE); getQsTile().updateTile(); } } diff --git a/android/internal/Thanox-Internal b/android/internal/Thanox-Internal index 27a7bc6a4..9396e26a7 160000 --- a/android/internal/Thanox-Internal +++ b/android/internal/Thanox-Internal @@ -1 +1 @@ -Subproject commit 27a7bc6a4e0c578f159b164faf3cb917a417f3fb +Subproject commit 9396e26a7e1628c49108e87e25f2a1c229188a5e