From 7a9ed22ec9a08b6a27b810ecd478956295dbb507 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Tue, 3 Jan 2023 16:17:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E9=A1=B5=E9=9D=A2AP?= =?UTF-8?q?k=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E5=BC=BA=E5=88=B6=E9=9D=9E=E5=BC=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/http/CommonHttpUtil.java | 13 +++- .../com/yunbao/common/manager/APKManager.java | 73 ++++++++++++++++++ .../yunbao/common/manager/IMLoginManager.java | 25 ------ .../common/views/APKUpdateCustomPopup.java | 30 ++++++- .../res/layout/apk_update_custom_popup.xml | 8 ++ .../main/res/mipmap-xxhdpi/icon_close_tip.png | Bin 0 -> 1276 bytes config.gradle | 2 +- .../yunbao/main/activity/MainActivity.java | 17 ++-- .../yunbao/main/activity/SettingActivity.java | 5 +- .../yunbao/main/adapter/SettingAdapter.java | 3 +- .../yunbao/main/views/MainMeViewHolder.java | 4 +- 11 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/manager/APKManager.java create mode 100644 common/src/main/res/mipmap-xxhdpi/icon_close_tip.png diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index 114d2452e..6e74a4db4 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -17,6 +17,7 @@ import com.yunbao.common.activity.ErrorActivity; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.event.FollowEvent; import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.manager.APKManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.utils.L; @@ -200,13 +201,19 @@ public class CommonHttpUtil { new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString()); } if (obj.containsKey("apk_ver")) { - IMLoginManager.get(context).setApkVer(obj.getString("apk_ver")); + APKManager.get().setApkVer(obj.getString("apk_ver")); } if (obj.containsKey("apk_url")) { - IMLoginManager.get(context).setAPKUrl(obj.getString("apk_url")); + APKManager.get().setAPKUrl(obj.getString("apk_url")); } if (obj.containsKey("apk_des")) { - IMLoginManager.get(context).setAPKDes(obj.getString("apk_des")); + APKManager.get().setAPKDes(obj.getString("apk_des")); + } + if (obj.containsKey("google_isup")) { + APKManager.get().setAPKGoogleIsUp(obj.getInteger("google_isup")); + } + if (obj.containsKey("isup")) { + APKManager.get().setAPKIsUp(obj.getInteger("isup")); } } catch (Exception e) { String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage(); diff --git a/common/src/main/java/com/yunbao/common/manager/APKManager.java b/common/src/main/java/com/yunbao/common/manager/APKManager.java new file mode 100644 index 000000000..266e22827 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/APKManager.java @@ -0,0 +1,73 @@ +package com.yunbao.common.manager; + +import android.content.Context; +import android.text.TextUtils; + +import com.yunbao.common.CommonAppContext; +import com.yunbao.common.manager.base.BaseCacheManager; +import com.yunbao.common.utils.VersionUtil; + +public class APKManager extends BaseCacheManager { + private static APKManager manager; + private final String APK_VER = "apk_ver"; + private final String APK_URL = "apk_url"; + private final String APK_DES = "apk_des"; + private final String APK_IS_UP = "isup"; + private final String APK_GOOGLE_IS_UP = "google_isup"; + + public APKManager(Context context) { + super(context); + } + + /** + * 获取单利 + * + * @return + */ + public static APKManager get() { + if (null == manager) { + manager = new APKManager(CommonAppContext.sInstance.getBaseContext()); + } + return manager; + } + + public void setAPKUrl(String apkUrl) { + put(APK_URL, apkUrl); + } + + public void setAPKDes(String apkDes) { + put(APK_DES, apkDes); + } + + public String getAPKUrl() { + return getString(APK_URL); + } + + public String getAPKDes() { + return getString(APK_DES); + } + + public void setApkVer(String apkVer) { + put(APK_VER, apkVer); + } + + public boolean getApkVerNew() { + return TextUtils.equals(VersionUtil.getVersion(), getString(APK_VER)); + } + + public void setAPKIsUp(int apkIsUp) { + put(APK_IS_UP, apkIsUp); + } + + public void setAPKGoogleIsUp(int apkGoogleIsUp) { + put(APK_GOOGLE_IS_UP, apkGoogleIsUp); + } + + public int getApkIsUp() { + return getInt(APK_IS_UP, 0); + } + + public int getAPKGoogleIsUp() { + return getInt(APK_GOOGLE_IS_UP, 0); + } +} diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index 846d7afa0..84f7b7879 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -40,33 +40,8 @@ public class IMLoginManager extends BaseCacheManager { private final String IS_HINT = "is_hint"; private final String IS_HINT2 = "is_hint2"; private final String SELECT_CLARITY = "selectClarity"; - private final String APK_VER = "apk_ver"; - private final String APK_URL = "apk_url"; - private final String APK_DES = "apk_des"; - public void setAPKUrl(String apkUrl) { - put(APK_URL, apkUrl); - } - public void setAPKDes(String apkDes) { - put(APK_DES, apkDes); - } - - public String getAPKUrl() { - return getString(APK_URL); - } - - public String getAPKDes() { - return getString(APK_DES); - } - - public void setApkVer(String apkVer) { - put(APK_VER, apkVer); - } - - public boolean getApkVerNew() { - return TextUtils.equals(VersionUtil.getVersion(), getString(APK_VER)); - } /** * 设置清晰度 diff --git a/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java b/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java index 429be45e7..025bdd14e 100644 --- a/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java @@ -17,7 +17,7 @@ import androidx.core.content.FileProvider; import com.lxj.xpopup.core.CenterPopupView; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.R; -import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.APKManager; import com.yunbao.common.utils.APKDownloadUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -41,10 +41,12 @@ public class APKUpdateCustomPopup extends CenterPopupView { private LinearLayout updateLine; private ProgressBar progressBar; private Activity mContext; + private boolean mInside; - public APKUpdateCustomPopup(@NonNull Activity context) { + public APKUpdateCustomPopup(@NonNull Activity context, boolean inside) { super(context); mContext = context; + mInside = inside; } // 返回自定义弹窗的布局 @@ -66,13 +68,33 @@ public class APKUpdateCustomPopup extends CenterPopupView { } private void initView() { + if (!mInside) { + if (!CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getAPKGoogleIsUp() == 1) { + findViewById(R.id.dialog_close).setVisibility(GONE); + } + if (!CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getAPKGoogleIsUp() == 1) { + findViewById(R.id.dialog_close).setVisibility(GONE); + } + } updateText = findViewById(R.id.update_text); versionImmediateUse = findViewById(R.id.version_immediate_use); updateLine = findViewById(R.id.update_line); progressBar = findViewById(R.id.progressBar); versionImmediateUse.setVisibility(VISIBLE); updateLine.setVisibility(GONE); - updateText.setText(IMLoginManager.get(getContext()).getAPKDes()); + updateText.setText(APKManager.get().getAPKDes()); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.dialog_close), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getAPKGoogleIsUp() != 1) { + dismiss(); + } + if (!CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getApkIsUp() != 1) { + dismiss(); + } + } + } + ); ViewClicksAntiShake.clicksAntiShake(versionImmediateUse, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { @@ -80,7 +102,7 @@ public class APKUpdateCustomPopup extends CenterPopupView { if (!CommonAppConfig.IS_GOOGLE_PLAY) { versionImmediateUse.setVisibility(GONE); updateLine.setVisibility(VISIBLE); - downloadAPK(mContext, IMLoginManager.get(getContext()).getAPKUrl(), new APKDownloadUtil.OnUpdateListener() { + downloadAPK(mContext, APKManager.get().getAPKUrl(), new APKDownloadUtil.OnUpdateListener() { @Override public void updateFailure(int code, String error) { ToastUtil.show(error); diff --git a/common/src/main/res/layout/apk_update_custom_popup.xml b/common/src/main/res/layout/apk_update_custom_popup.xml index 4a4f1f9a7..a59817e4d 100644 --- a/common/src/main/res/layout/apk_update_custom_popup.xml +++ b/common/src/main/res/layout/apk_update_custom_popup.xml @@ -71,5 +71,13 @@ android:textSize="11sp" /> + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_close_tip.png b/common/src/main/res/mipmap-xxhdpi/icon_close_tip.png new file mode 100644 index 0000000000000000000000000000000000000000..f64e53e8288b005083135ed6a8938e3a59ac4476 GIT binary patch literal 1276 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGojKx9jP7LeL$-HD>VA=@dJk$`XaLRC6o6>L`D57DK0La-s~DEvb6Z!lHzxK$!Ag-o^RIqU11>; z_wdAit7hK=$BrHQYHe-(o}uDV1GDVa(%K{&x&JrBTc%E(y7TAHpXLlU?0=sBU$}4W z>t8=AZ2qlV|L5?x(`pLmKYwSmF@4COZ}t4$`c<#mZwN^J09y9E$537E&F^rAY?m+5 zZ~l1xP8OW-{3lz(`Y4%*5>DNR@58I-cFfDaXnadZk8wR?Ms>nPm6DeG4u4xa^19u& zAMJ}^5pn%EvH0CZvD$CbS-d|q+)uGqI%V~RC+?I|LT&9|-Q+VX`*QcHRvgNI_1DqG zyyT7KmN~8tfg=5u&(Bqwywy=;s0)5CtWwSYn(F^S@nQi(?3d>qD+x68H+E}vRHXoaD`Fh2kf*U_0-^{5mRs0rwVLvxZ zobasW%Qwq~A4qx7?RUU#hXZHqPjyy%PDVjL_gqyKc6&)i9-&Ds^QSb(sj6_>TQb^u zcu3VvVp8(*kgMCoG%G1PJNx^YGiN3|U#r$*xIQO0cW!2N>$E8KU$zf6H0SMmsHdY- z^J0#*9K*9kTfa44%=l7!z^>}Pi6!I22k)D`sKQ1orR^ND{ z&M6&u{FfpBN28FA;8_;Iw>u2G8*I+sXZuicI`7~IW|bJVMN6mIF4lQ0^g*S8Kgy(! z?SAl~beAsy-SaL^+rSYK7dJ0HCPv2c`MX&cY^?tD3BA%e{Z5*%-Oil*o>K&i$y;Fj z-;VmN+7Qi`@q2plyO7Y(v#Zza{qy$jqB_0@FBln1i@SYX-hUIaOI)7A^iAbX$n~$M zkIk6OkjMI=`t!0~#qUgx&(>VMdbRnvbLaLkJSb$?&iq68K&#H_a|QLEzR%sj_26HL puk$=Efo)5unVWHx1wZyPX7k(CZ{8Sm4_KTrc)I$ztaD0e0sz*VKvw_& literal 0 HcmV?d00001 diff --git a/config.gradle b/config.gradle index 9c0a1cfbb..88d9c1761 100644 --- a/config.gradle +++ b/config.gradle @@ -25,7 +25,7 @@ ext { baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S", // true表示谷歌支付 false - isGooglePlay : true, + isGooglePlay : false, //是否上报异常日志 isUploadLog : false ] diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index b69a1bab3..584273828 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -17,7 +17,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.Display; @@ -41,6 +40,7 @@ import com.google.firebase.messaging.FirebaseMessaging; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.jakewharton.rxbinding3.view.RxView; +import com.lxj.xpopup.XPopup; import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.permission.PermissionUtils; import com.tencent.imsdk.v2.V2TIMCallback; @@ -75,6 +75,7 @@ import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.manager.APKManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.NoviceInstructorManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; @@ -88,16 +89,14 @@ import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.VersionUtil; import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.APKUpdateCustomPopup; import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.activity.LiveRyAnchorActivity; -import com.yunbao.live.dialog.RandomPkDialogFragment; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; -import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.views.ChatListViewHolder; import com.yunbao.main.R; @@ -682,8 +681,14 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene DialogUitl.showSimpleTipDialog(mContext, WordUtil.getString(R.string.main_maintain_notice), configBean.getMaintainTips()); } if (!VersionUtil.isLatest(configBean.getVersion())) { - VersionUtil versionUtil = new VersionUtil(); - versionUtil.showDialog(mContext, configBean, configBean.getDownloadApkUrl()); + if (!APKManager.get().getApkVerNew()) { + new XPopup.Builder(mContext) + .isDestroyOnDismiss(true) + .dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true + .dismissOnTouchOutside(false) // 点击外部是否关闭弹窗,默认为true + .asCustom(new APKUpdateCustomPopup(mContext, false)) + .show(); + } } else { requestBonus(); } diff --git a/main/src/main/java/com/yunbao/main/activity/SettingActivity.java b/main/src/main/java/com/yunbao/main/activity/SettingActivity.java index f45bd0653..1da67ee61 100644 --- a/main/src/main/java/com/yunbao/main/activity/SettingActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/SettingActivity.java @@ -32,6 +32,7 @@ import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.APKManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.GlideCatchUtil; @@ -286,9 +287,9 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener< } else if (bean.getId() == 21) {//清除缓存 startActivity(new Intent(SettingActivity.this, MsgSettActivity.class)); } else if (bean.getId() == 25) {//版本更新 - if (!IMLoginManager.get(mContext).getApkVerNew()) { + if (!APKManager.get().getApkVerNew()) { new XPopup.Builder(mContext) - .asCustom(new APKUpdateCustomPopup(mContext)) + .asCustom(new APKUpdateCustomPopup(mContext, true)) .show(); } diff --git a/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java index 6ab9de77f..f59ae20c1 100644 --- a/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java @@ -12,6 +12,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.Constants; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.APKManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.LogUtil; @@ -147,7 +148,7 @@ public class SettingAdapter extends RecyclerView.Adapter { mText.setText(DeviceUtils.getVersionName(itemView.getContext())); mText.setTextColor(Color.parseColor("#969696")); } else if (bean.getId() == 25) { - if (IMLoginManager.get(itemView.getContext()).getApkVerNew()) { + if (APKManager.get().getApkVerNew()) { mText.setText(itemView.getContext().getString(R.string.latest_version)); mText.setTextColor(Color.parseColor("#969696")); diff --git a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java index 1346e2103..4d8c38d39 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java @@ -39,7 +39,7 @@ import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; -import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.APKManager; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; @@ -180,7 +180,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); } }); - redPoint.setVisibility(IMLoginManager.get(mContext).getApkVerNew() ? View.GONE : View.VISIBLE); + redPoint.setVisibility(APKManager.get().getApkVerNew() ? View.GONE : View.VISIBLE); } @Override