|
|
@@ -853,8 +853,10 @@ public class SysAppUtil {
|
|
|
PendingIntent successCallback = PendingIntent.getBroadcast(context, 0, pinnedShortcutCallbackIntent, 0);
|
|
|
|
|
|
ShortcutManagerCompat.requestPinShortcut(context, pinShortcutInfo, successCallback.getIntentSender());
|
|
|
- G.showToast("正在尝试添加桌面快捷方式");
|
|
|
- return true;
|
|
|
+ boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
+ if(hasShortcut)
|
|
|
+ G.showToast("添加桌面快捷方式成功");
|
|
|
+ return hasShortcut;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
@@ -862,9 +864,6 @@ public class SysAppUtil {
|
|
|
//添加有范商城快捷入口
|
|
|
public static void addShortcutTest(Activity activity) {
|
|
|
if(installShortCut(activity)){
|
|
|
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1){
|
|
|
- showShortcutTip(activity);
|
|
|
- }
|
|
|
} else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
|
|
SysAppUtil.addShortcutTest8(activity);
|
|
|
} else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1){
|
|
|
@@ -907,30 +906,36 @@ public class SysAppUtil {
|
|
|
}
|
|
|
|
|
|
//展示提示框
|
|
|
- private static void showShortcutTip(Activity activity) {
|
|
|
- ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("已尝试添加有范商城到桌面").setMsg("若添加失败,请前往系统设置为小绵羊打开\"创建桌面快捷方式\"的权限")
|
|
|
- .setBtnLeftText("重新添加").setBtnLeftOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher())
|
|
|
- .setBtnRightText("前往设置").setBtnRightOnClickListener(view -> {
|
|
|
- try {
|
|
|
- startAppSettings(activity);
|
|
|
- } catch (NoSuchFieldException e) {
|
|
|
- e.printStackTrace();
|
|
|
- if(TestUtil.isDev())
|
|
|
- G.showToast(e);
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- if(TestUtil.isDev())
|
|
|
- G.showToast(e);
|
|
|
- } catch (ActivityNotFoundException e){
|
|
|
- if(RomUtils.checkIsMiuiRom()){
|
|
|
- skipActivity(activity, "com.miui.securitycenter", "com.miui.permcenter.MainAcitivty", null, null);
|
|
|
+ public static void showShortcutTip(Activity activity) {
|
|
|
+ boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
+ if(hasShortcut) {
|
|
|
+ G.showToast("添加桌面快捷方式成功");
|
|
|
+ } else {
|
|
|
+// G.showToast("正在尝试添加桌面快捷方式");
|
|
|
+ ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("已尝试添加有范商城到桌面").setMsg("若添加失败,请前往系统设置为小绵羊打开\"创建桌面快捷方式\"的权限")
|
|
|
+ .setBtnLeftText("重新添加").setBtnLeftOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher())
|
|
|
+ .setBtnRightText("前往设置").setBtnRightOnClickListener(view -> {
|
|
|
+ try {
|
|
|
+ startAppSettings(activity);
|
|
|
+ } catch (NoSuchFieldException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (TestUtil.isDev())
|
|
|
+ G.showToast(e);
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (TestUtil.isDev())
|
|
|
+ G.showToast(e);
|
|
|
+ } catch (ActivityNotFoundException e) {
|
|
|
+ if (RomUtils.checkIsMiuiRom()) {
|
|
|
+ skipActivity(activity, "com.miui.securitycenter", "com.miui.permcenter.MainAcitivty", null, null);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (TestUtil.isDev())
|
|
|
+ G.showToast(e);
|
|
|
}
|
|
|
- } catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- if(TestUtil.isDev())
|
|
|
- G.showToast(e);
|
|
|
- }
|
|
|
- }).setBtnRightNotDissDialog(true));
|
|
|
+ }).setBtnRightNotDissDialog(true));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class CallBackReceiver extends BroadcastReceiver {
|