Kaynağa Gözat

尝试优化快捷方式入口

zengjiebin 7 yıl önce
ebeveyn
işleme
001f10b373

+ 38 - 2
app/src/main/java/com/sheep/gamegroup/util/SysAppUtil.java

@@ -796,8 +796,43 @@ public class SysAppUtil {
      * 启动应用的设置
      */
     public static void startAppSettings(Activity activity) {
-        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
-        intent.setData(Uri.parse("package:" + BuildConfig.APPLICATION_ID));
+//        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+//        intent.setData(Uri.parse("package:" + BuildConfig.APPLICATION_ID));
+//        activity.startActivity(intent);
+        // vivo 点击设置图标>加速白名单>我的app
+        //      点击软件管理>软件管理权限>软件>我的app>信任该软件
+        Intent appIntent = activity.getPackageManager().getLaunchIntentForPackage("com.iqoo.secure");
+        if(appIntent != null){
+            activity.startActivity(appIntent);
+            return;
+        }
+
+        // oppo 点击设置图标>应用权限管理>按应用程序管理>我的app>我信任该应用
+        //      点击权限隐私>自启动管理>我的app
+        appIntent = activity.getPackageManager().getLaunchIntentForPackage("com.oppo.safe");
+        if(appIntent != null){
+            activity.startActivity(appIntent);
+            return;
+        }
+
+        Intent intent = new Intent();
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
+            intent.putExtra(Settings.EXTRA_APP_PACKAGE, activity.getPackageName());
+        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
+            intent.putExtra("app_package", activity.getPackageName());
+            intent.putExtra("app_uid", activity.getApplicationInfo().uid);
+        } else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD){
+            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+            intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
+        } else {
+            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            intent.setAction(Intent.ACTION_VIEW);
+            intent.setClassName("com.android.settings","com.android.settings.InstalledAppDetails");
+            intent.putExtra("com.android.settings.ApplicationPkgName", activity.getPackageName());
+        }
         activity.startActivity(intent);
     }
 
@@ -892,6 +927,7 @@ 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);
             G.showToast("添加成功");
         } else {
             G.showToast("已经添加成功");

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java

@@ -128,11 +128,11 @@ public class ActWebX5 extends BaseActWeb {
     public static final String KEY_IGNORE_ADD_YOU_FAN_LAUNCHER = "ignore_add_you_fan_launcher";
     private void checkWebParams(WebParams webParams) {
         if(webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0])) {//检测是否是有范商城地址
-            boolean isIgnore = DataUtil.getAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, false);
+            boolean isIgnore = SpUtils.getAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, false);
             if (!isIgnore && !CommonUtil.getInstance().hasYouFanLauncher()) {//未忽略并且没有添加有范商品入口
                 ViewUtil.showMsgDialog(this, new DialogConfig().setTitle("温馨提示")
-                        .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!")
-                        .setBtnLeftText("否").setBtnLeftOnClickListener(view -> DataUtil.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
+                        .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!(点击否将不再提示)")
+                        .setBtnLeftText("否").setBtnLeftOnClickListener(view -> SpUtils.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
                         .setBtnRightText("是").setBtnRightOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher()));
             }
         }

+ 11 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/SpUtils.java

@@ -147,5 +147,16 @@ public class SpUtils {
         SharedPreferences sp = SheepApp.getInstance().getSharedPreferences("first", Context.MODE_PRIVATE);
         return sp.getBoolean("first.personcenter.voucher", true);
     }
+    public static void putAsBoolean(String key, boolean value){
+        SharedPreferences sp = SheepApp.getInstance().getSharedPreferences("app", Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = sp.edit();
+        editor.putBoolean(key, value);
+        editor.commit();
+    }
+
+    public static boolean getAsBoolean(String key, boolean defaultValue) {
+        SharedPreferences sp = SheepApp.getInstance().getSharedPreferences("app", Context.MODE_PRIVATE);
+        return sp.getBoolean(key, defaultValue);
+    }
 
 }