Use AppDetailsActivity (#2274)

This commit is contained in:
南宫雪珊 2022-12-05 04:02:07 +08:00 committed by GitHub
parent b9c470f7cd
commit 4b66d556db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -18,6 +18,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import org.lsposed.manager.App;
import org.lsposed.manager.R;
@ -104,14 +105,17 @@ public class ShortcutUtil {
public static void requestPinLaunchShortcut(Runnable afterPinned) {
if (!App.isParasitic()) throw new RuntimeException();
var context = App.getInstance();
var info = new ShortcutInfo.Builder(context, SHORTCUT_ID)
var builder = new ShortcutInfo.Builder(context, SHORTCUT_ID)
.setShortLabel(context.getString(R.string.app_name))
.setIntent(getLaunchIntent(context))
.setActivity(new ComponentName(context.getPackageName(), "android.__dummy__"))
.setIcon(Icon.createWithAdaptiveBitmap(getBitmap(context, R.drawable.ic_launcher)))
.build();
.setIcon(Icon.createWithAdaptiveBitmap(getBitmap(context, R.drawable.ic_launcher)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
var activity = new ComponentName(context.getPackageName(),
"android.app.AppDetailsActivity");
builder.setActivity(activity);
}
var sm = context.getSystemService(ShortcutManager.class);
sm.requestPinShortcut(info, registerReceiver(context, afterPinned));
sm.requestPinShortcut(builder.build(), registerReceiver(context, afterPinned));
}
public static boolean isLaunchShortcutPinned() {