|
|
@@ -862,6 +862,16 @@ public class SysAppUtil {
|
|
|
}
|
|
|
|
|
|
//添加有范商城快捷入口
|
|
|
+ public static void addShortcut(Activity activity) {
|
|
|
+ boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
+ if(hasShortcut){
|
|
|
+ showShortcutTip(activity);
|
|
|
+ } else {
|
|
|
+ addShortcutTest(activity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加有范商城快捷入口
|
|
|
public static void addShortcutTest(Activity activity) {
|
|
|
if(installShortCut(activity)){
|
|
|
} else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
|
|
@@ -899,7 +909,12 @@ public class SysAppUtil {
|
|
|
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(activity, 0, new Intent(activity, CallBackReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
shortcutManager.requestPinShortcut(info, shortcutCallbackIntent.getIntentSender());
|
|
|
- showShortcutTip(activity);
|
|
|
+ boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
+ if(hasShortcut) {
|
|
|
+ G.showToast("添加桌面快捷方式成功");
|
|
|
+ } else {
|
|
|
+ showShortcutTip(activity);
|
|
|
+ }
|
|
|
} else {
|
|
|
G.showToast("暂不支持");
|
|
|
}
|
|
|
@@ -907,35 +922,29 @@ public class SysAppUtil {
|
|
|
|
|
|
//展示提示框
|
|
|
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);
|
|
|
+ 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);
|
|
|
}
|
|
|
- }).setBtnRightNotDissDialog(true));
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (TestUtil.isDev())
|
|
|
+ G.showToast(e);
|
|
|
+ }
|
|
|
+ }).setBtnRightNotDissDialog(true));
|
|
|
}
|
|
|
|
|
|
class CallBackReceiver extends BroadcastReceiver {
|
|
|
@@ -966,7 +975,12 @@ public class SysAppUtil {
|
|
|
.build();
|
|
|
//这样就可以通过长按图标显示出快捷方式了
|
|
|
systemService.setDynamicShortcuts(ListUtil.asList(shortcutInfo));
|
|
|
- showShortcutTip(activity);
|
|
|
+ boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
+ if(hasShortcut) {
|
|
|
+ G.showToast("添加桌面快捷方式成功");
|
|
|
+ } else {
|
|
|
+ showShortcutTip(activity);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void addShortcutTest6(Activity activity) {
|
|
|
@@ -978,7 +992,12 @@ public class SysAppUtil {
|
|
|
if (!ShortcutSuperUtils.isShortCutExist(activity, mShortcutName, getShortCutIntent(activity))) {
|
|
|
ShortcutUtils.addShortcut(activity, getShortCutIntent(activity), mShortcutName, false,
|
|
|
BitmapFactory.decodeResource(activity.getResources(), R.drawable.icon_yf));
|
|
|
- showShortcutTip(activity);
|
|
|
+ boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
|
|
|
+ if(hasShortcut) {
|
|
|
+ G.showToast("添加桌面快捷方式成功");
|
|
|
+ } else {
|
|
|
+ showShortcutTip(activity);
|
|
|
+ }
|
|
|
} else {
|
|
|
G.showToast("已经添加成功");
|
|
|
}
|