Ver código fonte

修复部分华为手机无法直接通过浏览器打开小绵羊的兼容性问题

zengjiebin 7 anos atrás
pai
commit
1beb971e6a

+ 11 - 0
app/src/main/java/com/sheep/gamegroup/module/home/api/MainAction.java

@@ -0,0 +1,11 @@
+package com.sheep.gamegroup.module.home.api;
+
+/**
+ * Created by realicing on 2019/2/26.
+ * realicing@sina.com
+ */
+public enum MainAction {
+    CHECK_COPY,//检查粘贴板
+    CHECK_SCHEME,//检查启动项
+    ;
+}

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -2615,7 +2615,8 @@ public class CommonUtil {
         LogUtil.println("checkCopyText", "\ntext\t", text);
         if (!TextUtils.isEmpty(text)) {//内容不为空时尝试检查
             String textString = text.toString();
-            View.OnClickListener closeListener = view -> StringUtils.CopyText("\t");//清除粘贴板内容,直接填空不行,不知道为什么
+            StringUtils.CopyText("\t");//清除粘贴板内容,直接填空不行,不知道为什么
+            View.OnClickListener closeListener = view -> {};
             DialogConfig dialogConfig = new DialogConfig().setTitle("小绵羊提示").setBtnCloseOnClickListener(closeListener);
             String url;
             if ((url = StringUtils.findUrl(text)) != null) {//如果是链接,直接跳转外部浏览器

+ 8 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -1,6 +1,7 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.content.Intent;
+import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
@@ -22,6 +23,7 @@ import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.helper.DownloadHelper;
 import com.sheep.gamegroup.model.entity.Container;
 import com.sheep.gamegroup.model.entity.UserEntity;
+import com.sheep.gamegroup.module.home.api.MainAction;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.ChannelContent;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -360,6 +362,12 @@ public class ActMain extends BaseActYmPermissionCheck {
             } else {
                 new DialogGameOrTaskOrGift(this, game_id).showDialog();
             }
+        } else if (action instanceof Uri) {
+            MiddleSchemeAct.parseAndJumpUri(this, (Uri) action);
+        } else if (action instanceof MainAction) {
+            if(action == MainAction.CHECK_COPY){
+                CommonUtil.getInstance().checkCopyText();
+            }
         } else if (action instanceof MainTab) {
             switchFragment(((MainTab) action).ordinal());
         }

+ 23 - 7
app/src/main/java/com/sheep/gamegroup/view/activity/MiddleSchemeAct.java

@@ -1,6 +1,7 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
@@ -11,11 +12,14 @@ import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.model.api.BaseMessageConverter;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
 import com.sheep.gamegroup.model.entity.SlideshowEty;
+import com.sheep.gamegroup.module.home.api.MainAction;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.bean.UserCenterModule;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
@@ -44,14 +48,20 @@ public class MiddleSchemeAct extends Activity {
             return;
         switch (action) {
             case Intent.ACTION_VIEW:
+                finish();
                 Uri uri = intent.getData();
                 if (uri != null) {
                     // 完整的url信息
-                    if (TestUtil.isTest())
-                        G.showToast(uri.toString());
-                    parseAndJumpUri(this, uri);
+//                    if (TestUtil.isTest())
+//                        G.showToast(uri.toString());
+                    LogUtil.println("SheepApp mActivityCount" + SheepApp.getInstance().mActivityCount);
+                    if(SheepApp.getInstance().mActivityCount == 0) {
+                        ActionUtil.getInstance().addNextAction(ActMain.class.getSimpleName(), uri);
+                        tryGoSplashAct(SheepApp.getInstance(), uri);
+                    } else {
+                        parseAndJumpUri(SheepApp.getInstance().getCurrentActivity(), uri);
+                    }
                 }
-                finish();
                 break;
         }
     }
@@ -125,6 +135,13 @@ public class MiddleSchemeAct extends Activity {
                     runApp(activity, packageName, className);
                 }
                 break;
+            //sheep://small.kfzs.com/xmy?type=cc
+            case "check_copy":
+            case "cc":
+//                ActionUtil.getInstance().addNextAction(ActMain.class.getSimpleName(), MainAction.CHECK_COPY);
+//                tryGoSplashAct(activity, uri);
+                CommonUtil.getInstance().checkCopyText();
+                break;
         }
 //                    LogUtil.println("ActMain", "checkScheme","url: " + url);
 //                    // scheme部分
@@ -173,12 +190,11 @@ public class MiddleSchemeAct extends Activity {
      * ActMain checkScheme query: code=976873
      * ActMain checkScheme code: 976873
      */
-    public static void tryGoSplashAct(Activity activity, Uri uri) {
+    public static void tryGoSplashAct(Context context, Uri uri) {
         String game_id = uri.getQueryParameter("game_id");
         if(!TextUtils.isEmpty(game_id))//有game_id时设置game_id的回调到主页,用于展示会长推广弹出框
             ActionUtil.getInstance().addNextAction(SHOW_DIALOG_GAME_OR_GIFT_TASK, game_id);
-        Jump2View.getInstance().newTaskTopStartAct(activity, SplashAct.class, null);
-
+        Jump2View.getInstance().newTaskTopStartAct(context, SplashAct.class, null);
     }
 
     //展示会长推广弹出框的key

+ 8 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -26,9 +26,11 @@ import com.sheep.gamegroup.di.components.DaggerNetComponent;
 import com.sheep.gamegroup.di.components.NetComponent;
 import com.sheep.gamegroup.di.modules.NetModule;
 import com.sheep.gamegroup.module.ad_htxd.model.ArticleAd;
+import com.sheep.gamegroup.module.home.api.MainAction;
 import com.sheep.gamegroup.module.login.LoginAct;
 import com.sheep.gamegroup.module.skin.util.SkinUtil;
 import com.sheep.gamegroup.usage.AppUsageManager;
+import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.AppUtil;
 import com.sheep.gamegroup.util.CertificationUtil;
 import com.sheep.gamegroup.util.ChannelContent;
@@ -45,6 +47,7 @@ import com.sheep.gamegroup.util.RefreshUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TextToSpeechUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.GameCertificationActivity;
 import com.sheep.gamegroup.view.activity.SplashAct;
 import com.sheep.jiuyan.samllsheep.service.AutoCheckService;
@@ -523,8 +526,11 @@ public class SheepApp extends MultiDexApplication {
             if (activityRef != null) activityRef.clear();
             activityRef = new WeakReference<>(activity);
             if (mActivityCount == 1) { // 应用回到前台
-                if (getCurrentActivity() != null && !(getCurrentActivity() instanceof SplashAct)) { // 当前activity存在
-                    CommonUtil.getInstance().checkCopyText();
+                if (activity != null) {
+                    if (getCurrentActivity() instanceof SplashAct) { // 启动页面
+                    } else {
+                        CommonUtil.getInstance().checkCopyText();
+                    }
                 }
             }
         }