Explorar el Código

屏蔽发现资讯中网页缩放的功能;
修复8.1.0 360 手机不能跳转通知设置界面,修改为跳转应用详情设置界面

zengjiebin hace 7 años
padre
commit
5dac317ea1

+ 17 - 1
app/src/main/java/com/sheep/gamegroup/util/TestUtil.java

@@ -223,7 +223,8 @@ public class TestUtil {
      */
     public static void test(final Activity activity) {
         final String[] items = {"复制token","复制打点数据","从jenkins下载小绵羊安装包","龙猫竞猜","龙猫竞猜-scheme",
-                "测试通知栏", "测试自定义通知栏","测试自定义通知栏2",
+                "手机型号测试","测试通知栏", "测试自定义通知栏","测试自定义通知栏2",
+                "开启通知栏权限0","开启通知栏权限1","开启通知栏权限2","开启通知栏权限3",
                 "开启通知栏权限","通知栏权限1","通知栏权限2","通知栏权限8.0","测试支付","测试内部h5", "测试外部h5",
                 "会长推广游戏","移动积分兑换","审核中心","检查正版","crc32","loading","progress","查看截图",
                 "复制IMEI","小米游戏","测试可用金额","测试定位信息","测试apk的渠道","幂动科技","游戏搜索",
@@ -268,9 +269,24 @@ public class TestUtil {
                                 bdIntent2.putExtras(bundle2);
                                 activity.sendBroadcast(bdIntent2);
                                 break;
+                            case "手机型号测试":
+                                G.showToast(android.os.Build.BRAND);
+                                break;
                             case "开启通知栏权限":
                                 NotificationsUtils.goToNotificationSetting(activity);
                                 break;
+                            case "开启通知栏权限0":
+                                NotificationsUtils.goToNotificationSetting0(activity);
+                                break;
+                            case "开启通知栏权限1":
+                                NotificationsUtils.goToNotificationSetting1(activity);
+                                break;
+                            case "开启通知栏权限2":
+                                NotificationsUtils.goToNotificationSetting2(activity);
+                                break;
+                            case "开启通知栏权限3":
+                                NotificationsUtils.goToNotificationSetting3(activity);
+                                break;
                             case "通知栏权限1":
                                 G.showToast(""+NotificationManagerCompat.from(activity).areNotificationsEnabled());
                                 break;

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

@@ -173,9 +173,9 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
         webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
         webSetting.setAllowFileAccess(true);
         webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
-        webSetting.setSupportZoom(true);
-        webSetting.setBuiltInZoomControls(true);
-        webSetting.setUseWideViewPort(true);
+//        webSetting.setSupportZoom(true);
+//        webSetting.setBuiltInZoomControls(true);
+//        webSetting.setUseWideViewPort(true);
         //下面这行会影响setDownloadListener,暂时注释掉,等有空研究一下
 //        webSetting.setSupportMultipleWindows(true);
         webSetting.setAppCacheEnabled(true);

+ 57 - 6
app/src/main/java/com/sheep/gamegroup/view/activity/NotificationsUtils.java

@@ -7,6 +7,8 @@ import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.net.Uri;
 import android.os.Build;
+import android.provider.Settings;
+import android.text.TextUtils;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -81,21 +83,70 @@ public class NotificationsUtils {
      */
     public static void goToNotificationSetting(Context context) {
         Intent intent = new Intent();
-        if (Build.VERSION.SDK_INT >= 26) {
-            // android 8.0引导
-            intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
-            intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
-        } else if (Build.VERSION.SDK_INT >= 21) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && TextUtils.equals(android.os.Build.BRAND, "360")){// 360 8.1.0 不能跳转成功,直接跳转应用详情设置界面
+                intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+                intent.setData(Uri.fromParts("package", context.getPackageName(), null));
+            } else {
+                // android 8.0引导
+                intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
+                intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
+            }
+        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             // android 5.0-7.0
             intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
             intent.putExtra("app_package", context.getPackageName());
             intent.putExtra("app_uid", context.getApplicationInfo().uid);
         } else {
             // 其他
-            intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
+            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
             intent.setData(Uri.fromParts("package", context.getPackageName(), null));
         }
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         context.startActivity(intent);
     }
+    /**
+     * 打开允许通知的设置页
+     */
+    public static void goToNotificationSetting0(Context context) {
+        Intent intent = new Intent();
+        // android 8.0引导
+        intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        context.startActivity(intent);
+    }
+    /**
+     * 打开允许通知的设置页
+     */
+    public static void goToNotificationSetting1(Context context) {
+        Intent intent = new Intent();
+        // android 8.0引导
+        intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
+        intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        context.startActivity(intent);
+    }
+    /**
+     * 打开允许通知的设置页
+     */
+    public static void goToNotificationSetting2(Context context) {
+        Intent intent = new Intent();
+        // android 5.0-7.0
+        intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
+        intent.putExtra("app_package", context.getPackageName());
+        intent.putExtra("app_uid", context.getApplicationInfo().uid);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        context.startActivity(intent);
+    }
+    /**
+     * 打开允许通知的设置页
+     */
+    public static void goToNotificationSetting3(Context context) {
+        Intent intent = new Intent();
+        // 其他
+        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+        intent.setData(Uri.fromParts("package", context.getPackageName(), null));
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        context.startActivity(intent);
+    }
 }

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSmallSheep.java

@@ -15,6 +15,7 @@ import android.os.Looper;
 import android.os.Message;
 import android.support.annotation.NonNull;
 import android.support.design.widget.TabLayout;
+import android.support.v4.app.NotificationManagerCompat;
 import android.support.v4.view.ViewPager;
 import android.support.v4.widget.NestedScrollView;
 import android.support.v7.app.AlertDialog;
@@ -1506,7 +1507,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
      */
     private void showPDialog() {
         boolean isShowDialog = DataUtil.getAsBoolean("isShowDialog", true);
-        if (isShowDialog && !NotificationsUtils.isNotificationEnabled(SheepApp.getInstance())) {//没有开启通知权限
+        if (isShowDialog && !NotificationManagerCompat.from(activity).areNotificationsEnabled()) {//没有开启通知权限
             AlertDialog.Builder builder = new AlertDialog.Builder(activity);
             builder.setTitle("提示");
             builder.setMessage("是否开启推送?");