From 399ac289f80b7a40aa4210341db6b447cacdcf14 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 09 八月 2022 17:42:33 +0800
Subject: [PATCH] 广告升级,隐私政策整改

---
 app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java |  213 +++++++++++++++++++++-------------------------------
 1 files changed, 86 insertions(+), 127 deletions(-)

diff --git a/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java b/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java
index f854955..07ca102 100644
--- a/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java
+++ b/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java
@@ -11,12 +11,6 @@
 import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentActivity;
-
-import android.util.Log;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
@@ -27,25 +21,11 @@
 import android.widget.LinearLayout;
 import android.widget.RadioButton;
 import android.widget.RadioGroup;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.app.hubert.guide.util.ScreenUtils;
-import com.coloros.mcssdk.PushManager;
-import com.huawei.android.hms.agent.HMSAgent;
-import com.huawei.android.hms.agent.push.handler.GetTokenHandler;
-import com.tejia.lijin.app.entity.TrendsCategory;
-import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity;
-import com.tejia.lijin.app.ui.trends.SendCircleFragmet;
-import com.tejia.lijin.app.util.TopStatusSettings;
-import com.tejia.lijin.app.util.ui.HomeUIUtil;
-import com.umeng.analytics.MobclickAgent;
-import com.vivo.push.PushClient;
-import com.wpc.library.okhttp.OkHttpUtils;
-import com.wpc.library.util.FragmentSwitchHelper;
-import com.wpc.library.util.MobileUtil;
-import com.wpc.library.util.NetUtils;
-import com.wpc.library.util.common.StringUtils;
-import com.xiaomi.mipush.sdk.MiPushMessage;
+import com.heytap.msp.push.HeytapPushManager;
 import com.tejia.lijin.app.BasicTextHttpResponseHandler;
 import com.tejia.lijin.app.BuXinConstant;
 import com.tejia.lijin.app.R;
@@ -56,14 +36,12 @@
 import com.tejia.lijin.app.callBack.LonginTaobaoCallback;
 import com.tejia.lijin.app.callBack.MessagePush;
 import com.tejia.lijin.app.entity.EventMessageEntity;
+import com.tejia.lijin.app.entity.TrendsCategory;
 import com.tejia.lijin.app.entity.eventbus.HomeTabChangeEvent;
 import com.tejia.lijin.app.entity.eventbus.UserProtocolEvent;
-import com.tejia.lijin.app.receiver.HWPushMessageReceiver;
 import com.tejia.lijin.app.receiver.MiPushMessageReceiver;
-import com.tejia.lijin.app.service.OPPOPushService;
-import com.tejia.lijin.app.service.VIVOPushService;
-import com.tejia.lijin.app.ui.BrandRebate.BrandFragment;
 import com.tejia.lijin.app.ui.HMPushReceiveActivity;
+import com.tejia.lijin.app.ui.PushOpenClickActivity;
 import com.tejia.lijin.app.ui.dialog.LoginFirstDialog;
 import com.tejia.lijin.app.ui.mine.ShoppingTrolleyActivity;
 import com.tejia.lijin.app.util.DragFloatActionButton;
@@ -74,8 +52,20 @@
 import com.tejia.lijin.app.util.clipboard.ClipboardUtil;
 import com.tejia.lijin.app.util.clipboard.IClipboardContentListener;
 import com.tejia.lijin.app.util.ui.ClipboardContentRecommendUtil;
+import com.tejia.lijin.app.util.ui.HomeUIUtil;
 import com.tejia.lijin.app.util.umengCustomEvent.MainCustomEvent;
 import com.tejia.lijin.app.util.user.UserUtil;
+import com.umeng.analytics.MobclickAgent;
+import com.vivo.push.PushClient;
+import com.wpc.library.okhttp.OkHttpUtils;
+import com.wpc.library.util.FragmentSwitchHelper;
+import com.wpc.library.util.NetUtils;
+import com.wpc.library.util.common.StringUtils;
+import com.xiaomi.mipush.sdk.MiPushMessage;
+import com.yeshi.push.PushAppInfoFactory;
+import com.yeshi.push.PushUtil;
+import com.yeshi.push.entity.PushApps;
+import com.yeshi.push.entity.PushRomType;
 
 import org.apache.http.Header;
 import org.json.JSONArray;
@@ -86,17 +76,17 @@
 import java.text.ParseException;
 import java.util.List;
 
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
 import de.greenrobot.event.EventBus;
-
-import static com.tejia.lijin.app.receiver.HWPushMessageReceiver.ACTION_TOKEN;
-import static com.tejia.lijin.app.receiver.HWPushMessageReceiver.ACTION_UPDATEUI;
 
 
 /**
  * 涓婚〉
  */
 public class MainActivity extends FragmentActivity
-        implements HWPushMessageReceiver.IPushCallback, DragFloatActionInterface {
+        implements DragFloatActionInterface {
 
     private RadioGroup rg_nav;
     private View v_no_login;
@@ -104,7 +94,8 @@
 
 
     private SharedPreferences spkefu;
-    private ImageView img, tv_msg_num2;
+    private ImageView img;
+    private TextView tv_msg_count;
     private DragFloatActionButton acbutton;
 
     String tag1 = "systemclient/getsystemclientparams";
@@ -170,6 +161,9 @@
             window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
             window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                     | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+
+//            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+
             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
             window.setStatusBarColor(Color.TRANSPARENT);
             int result = 0;
@@ -178,12 +172,12 @@
             if (resourceId > 0) {
                 result = getResources().getDimensionPixelSize(resourceId);
             }
-            //璁剧疆鐘舵�佹爮鏂囧瓧棰滆壊鍙婂浘鏍囦负娣辫壊
-//            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+
+
             LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                     result);
             findViewById(R.id.v_status_bar).setLayoutParams(params);
-            findViewById(R.id.v_status_bar).setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E"));
+            findViewById(R.id.v_status_bar).setBackground(HomeUIUtil.getHomeTopBg(getApplicationContext()));
         } else {
             findViewById(R.id.v_status_bar).setVisibility(View.GONE);
         }
@@ -231,12 +225,12 @@
         getSystemParams();
         v_no_login = findViewById(R.id.v_no_login);
         acbutton = findViewById(R.id.actionButton);
-        tv_msg_num2 = findViewById(R.id.tv_msg_num2);//鎴戠殑绾㈢偣
+        tv_msg_count = findViewById(R.id.tv_msg_count);//娑堟伅鏁伴噺
         acbutton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 //鐧婚檰
-                if (getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
+                if (UserUtil.isLogin(getApplicationContext())) {
                     LoginTaobao.getLoginTaobao(MainActivity.this, new LonginTaobaoCallback() {
                         @Override
                         public void onSuccess() {
@@ -257,12 +251,6 @@
 
         spkefu = getSharedPreferences("kefurecord", Context.MODE_PRIVATE);//鏄惁鎵撳紑杩囧鏈�  璁板綍
 
-        if (MobileUtil.getDeviceBrand().equalsIgnoreCase("HUAWEI")
-                || MobileUtil.getDeviceBrand().equalsIgnoreCase("HONOR")) {
-            HWPushMessageReceiver.registerPushCallback(this);//鎺ㄩ�侀泦鎴愬埌ToolUtil閲岄潰浜�
-            getToken();
-        }
-
         //鑾峰彇 鍙栨秷鎮诞鎺т欢鐨勫楂�
         ViewTreeObserver vto2 = img.getViewTreeObserver();
         vto2.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@@ -280,23 +268,32 @@
             choiceTab(fromTab, fromSubTab);
         } else
             ((RadioButton) findViewById(R.id.rb_nav_recommend)).setChecked(true);
-        registeredOPPOId();//涓婁紶OPPO_RegId
-//        onPush_OFF_NO();//妫�娴嬫槸鍚︽墦寮�鎺ㄩ��
-        registeredVIVOId();//涓婁紶VIVO_RegId
+
+        //娉ㄥ唽鎺ㄩ��
+        initPush();
 
 
-        tv_msg_num2.postDelayed(new Runnable() {
+    }
+
+    private void initPush() {
+        PushApps pushApps = new PushApps();
+        pushApps.setHw(PushAppInfoFactory.createHuaWei(getResources().getString(R.string.push_hw_appid)));
+        pushApps.setOppo(PushAppInfoFactory.createOPPO(getResources().getString(R.string.push_oppo_app_key), getResources().getString(R.string.push_oppo_app_secret)));
+        pushApps.setVivo(PushAppInfoFactory.createVIVO(getResources().getString(R.string.push_vivo_app_id), getResources().getString(R.string.push_vivo_api_key)));
+        pushApps.setXm(PushAppInfoFactory.createXM(getResources().getString(R.string.mipush_appid), getResources().getString(R.string.mipush_appkey)));
+        PushUtil.inintPush(ShoppingApplication.application, pushApps, new PushUtil.ITokenListener() {
+
             @Override
-            public void run() {
-                //娴嬭瘯
-                Bundle bundle = new Bundle();
-                bundle.putString("goodsId", "19711731038");
-                bundle.putString("goodsType", 1+"");
-                startActivity(new Intent(getApplicationContext(), GoodsDetailActivity.class).putExtras(bundle));
+            public void onToken(final PushRomType romType,final String regId) {
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        ShoppingApi.bindPushToken(getApplicationContext(), UserUtil.getUid(getApplicationContext()), romType, regId, null);
+                    }
+                });
+
             }
-        },5000);
-
-
+        });
     }
 
     private void choiceTab(Integer tab, Integer subTab) {
@@ -325,43 +322,6 @@
         }
     }
 
-    /***娉ㄥ唽VIVO_ID**/
-    private void registeredVIVOId() {
-        if (PushClient.getInstance(img.getContext()).isSupport()) {
-            if (NetUtils.isNetConnected(img.getContext())) {
-                ToolUtil.registeredVIVORegId(img.getContext());
-            } else {
-                startService(new Intent(img.getContext(), VIVOPushService.class));
-            }
-        }
-    }
-
-    /**
-     * 娉ㄥ唽oppoid
-     */
-    private void registeredOPPOId() {
-        if (PushManager.isSupportPush(getApplicationContext())) {
-            if (NetUtils.isNetConnected(getApplicationContext())) {
-                ToolUtil.registeredOPPOId(getApplicationContext());
-            } else {
-                startService(new Intent(getApplicationContext(), OPPOPushService.class));
-            }
-        }
-    }
-
-    /*
-       鍗庝负鎺ㄩ�佽幏鍙杢oken
-        */
-    private void getToken() {
-        Log.e("mResult", "get token: begin");
-        HMSAgent.Push.getToken(new GetTokenHandler() {
-            @Override
-            public void onResult(int rst) {
-                Log.e("mResult", "get token end: " + rst);
-            }
-        });
-    }
-
     SharedPreferences sp;
 
     /**
@@ -375,7 +335,7 @@
                     JSONArray array = jsonObject.optJSONObject("data").optJSONArray("systemClientParamsList");
                     SystemParamsUtil.saveParams(getApplicationContext(), array);
                     boolean input = sp.getBoolean("isFirstInput", true);
-                    boolean isLogin = sp.getBoolean("isLogin", false);
+                    boolean isLogin = UserUtil.isLogin(getApplicationContext());
                     //鏂颁汉濂界ぜ1鍏冪孩鍖�
                     if (input && !isLogin && sp.getString("newuser", "1").equalsIgnoreCase("0")) {
                         isFirstInput();
@@ -385,7 +345,7 @@
                     textVideo.isRecord(jsonObject);
                     //鏈嶅姟鍣ㄨ鏄剧ず 璐墿杞�&&鏈湴涔熻鏄剧ず
                     if (textVideo.getCart_float().equals("1") && textVideo.getLocalCart_float() != 1
-                            && getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
+                            && UserUtil.isLogin(getApplicationContext())) {
                         acbutton.setVisibility(View.VISIBLE);
                     } else {//闅愯棌璐墿杞�
                         acbutton.setVisibility(View.GONE);
@@ -420,7 +380,7 @@
             BuXinConstant.GO_SCAN = false;
             ((RadioButton) findViewById(R.id.rb_nav_recommend)).setChecked(true);
         }
-        boolean isLogin = sp.getBoolean("isLogin", false);
+        boolean isLogin = UserUtil.isLogin(getApplicationContext());
         v_no_login.setVisibility(isLogin ? View.INVISIBLE : View.VISIBLE);
         getUnReadMsgCount(UserUtil.getUid(ShoppingApplication.application));//娑堟伅 鏈鏁伴噺
 
@@ -448,7 +408,7 @@
             RecordImageTextVideo textVideo = new RecordImageTextVideo(MainActivity.this);
             //鏈嶅姟鍣ㄨ鏄剧ず 璐墿杞�&&鏈湴涔熻鏄剧ず涓嶄负1
             if (textVideo.getCart_float().equals("1") && textVideo.getLocalCart_float() != 1 &&
-                    getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
+                    UserUtil.isLogin(getApplicationContext())) {
                 acbutton.setVisibility(View.VISIBLE);
                 //鐐瑰嚮杩� 鍐嶆樉绀猴紙璁╂寜閽浣嶏級
                 if (textVideo.getLocalCart_float() == 2) {
@@ -462,6 +422,7 @@
                 acbutton.setVisibility(View.GONE);
             }
         }
+        PushOpenClickActivity.resumeJumpActivity(this);
     }
 
     private void getRecommendInfoFromClipboard() {
@@ -511,11 +472,15 @@
                     } else {
                         totalCount = 0;
                     }
-                    totalCount = 0;
                 } else {
                     totalCount = 0;
-                    tv_msg_num2.setVisibility(View.INVISIBLE);//闅愯棌鎴戠殑绾㈢偣
                 }
+
+                tv_msg_count.setVisibility(totalCount > 0 ? View.VISIBLE : View.INVISIBLE);
+                if (totalCount > 0) {
+                    tv_msg_count.setText(totalCount >= 100 ? "99+" : (totalCount + ""));
+                }
+
                 setUnReadMsgCount(jsonObject);
                 getgetHomeMsgList();//鑾峰彇鏈娑堟伅鏉℃暟
             }
@@ -543,7 +508,7 @@
             }
         }
         //灞曠ず鎴戠殑 绾㈢偣
-        tv_msg_num2.setVisibility(jsonObject.optJSONObject("data").optInt("mineCount") > 0 ? View.VISIBLE : View.INVISIBLE);
+//        int msgCount = jsonObject.optJSONObject("data").optInt("mineCount");
     }
 
     private void isFirstInput() {
@@ -567,8 +532,6 @@
     @Override
     protected void onPause() {
         super.onPause();
-        MobclickAgent.onPageEnd("涓婚〉");
-        MobclickAgent.onPause(this);
         //娉ㄩ攢缇庢唇瀹㈡湇骞挎挱
     }
 
@@ -866,32 +829,6 @@
 
     private static long lastBindHWTime = 0;
 
-    @Override
-    public void onReceive(Intent intent) {
-        Log.e("eee", "onReceive: ");
-        if (intent != null) {
-            String token = "";
-            String action = intent.getAction();
-            Bundle b = intent.getExtras();
-            if (b != null && ACTION_TOKEN.equals(action)) {
-                token = b.getString(ACTION_TOKEN);
-            } else if (b != null && ACTION_UPDATEUI.equals(action)) {
-            }
-            Log.e("eee", "onReceive: token" + token);
-            SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
-            if (MobileUtil.getDeviceBrand().equalsIgnoreCase("HUAWEI")
-                    || MobileUtil.getDeviceBrand().equalsIgnoreCase("HONOR")) {
-                Log.e("eee", "HONOR: ");
-                //闃叉澶氭璇锋眰
-                if (System.currentTimeMillis() - lastBindHWTime > 1000 * 5) {//5s鍚庡啀璇锋眰
-                    lastBindHWTime = System.currentTimeMillis();
-                    Log.e("eee", "涓婁紶token");
-                    ShoppingApi.bindHMPush(MainActivity.this, token, UserUtil.getUid(ShoppingApplication.application), null);
-                }
-            }
-        }
-    }
-
     /**
      * 寮�鍚垨鍏抽棴鎺ㄩ��
      */
@@ -944,4 +881,26 @@
             }
         }
     }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        int p = intent.getIntExtra("p", 0);
+        switch (p) {
+            case 0:
+                rg_nav.check(R.id.rb_nav_recommend);
+
+                break;
+            case 1:
+                rg_nav.check(R.id.rb_nav_hot_sale);
+                break;
+            case 2:
+                rg_nav.check(R.id.rb_nav_better_goods);
+                break;
+            case 3:
+                rg_nav.check(R.id.rb_nav_mine);
+                break;
+        }
+
+    }
 }

--
Gitblit v1.8.0