Skip to content

Commit

Permalink
Create shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Aug 23, 2024
1 parent acbf12d commit c9798fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions android/app/src/main/java/now/fortuitous/thanos/ThanosApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import github.tornaco.thanos.module.component.manager.initRules
import io.reactivex.plugins.RxJavaPlugins
import now.fortuitous.app.Init
import now.fortuitous.app.Stats
import now.fortuitous.thanos.power.ShortcutHelper
import org.lsposed.hiddenapibypass.HiddenApiBypass
import tornaco.apps.thanox.ThanosLite

Expand Down Expand Up @@ -74,5 +75,8 @@ class ThanosApp : MultipleModulesApp() {
}

ThanosLite.init(this)
ThanosLite.installShortcut = { context, app ->
ShortcutHelper.addShortcut(context, app)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
import github.tornaco.android.thanos.util.ShortcutReceiver;

@SuppressWarnings("UnstableApiUsage")
class ShortcutHelper {
public class ShortcutHelper {
private static final String STUB_APK_TEMPLATE_PATH = "shortcut_stub_template.apk";
private static final String OUT_APK_PATH = "shortcut_stub_apks";
private static final String WORK_DIR_PATH = "tmp_";
private static final String ICON_DIR_PATH = "icon.png";

static void addShortcut(Context context, AppInfo appInfo) {
public static void addShortcut(Context context, AppInfo appInfo) {
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
// Post load with glide.
GlideApp.with(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import github.tornaco.android.thanos.core.app.ThanosManager;
import github.tornaco.android.thanos.core.pm.Pkg;
import tornaco.apps.thanox.ThanosLite;

public class ShortcutStubActivity extends Activity {

Expand Down Expand Up @@ -65,8 +66,10 @@ private void internalResolveIntent() {

int userId = intent.getIntExtra(EXTRA_TARGET_USER_ID, 0);

ThanosManager.from(getApplicationContext())
.ifServiceInstalled(thanosManager ->
thanosManager.getPkgManager().launchSmartFreezePkg(new Pkg(target, userId)));
if (ThanosManager.from(getApplicationContext()).isServiceInstalled()) {
ThanosManager.from(getApplicationContext()).getPkgManager().launchSmartFreezePkg(new Pkg(target, userId));
} else {
ThanosLite.Companion.launchShortcut(new Pkg(target, userId));
}
}
}
2 changes: 1 addition & 1 deletion android/internal/Thanox-Internal

0 comments on commit c9798fd

Please sign in to comment.