Skip to content

Commit

Permalink
[app] TileService: startActivityAndCollapse
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Mar 19, 2022
1 parent b3d8edb commit a0e501a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand All @@ -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();
Expand All @@ -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();
}
}
2 changes: 1 addition & 1 deletion android/internal/Thanox-Internal

0 comments on commit a0e501a

Please sign in to comment.