新增主页面APk更新功能,区分强制非强制

This commit is contained in:
18401019693 2023-01-03 16:17:48 +08:00
parent af58ec755d
commit 7a9ed22ec9
11 changed files with 136 additions and 44 deletions

View File

@ -17,6 +17,7 @@ import com.yunbao.common.activity.ErrorActivity;
import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.event.FollowEvent; import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.APKManager;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
@ -200,13 +201,19 @@ public class CommonHttpUtil {
new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString()); new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
} }
if (obj.containsKey("apk_ver")) { 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")) { 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")) { 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) { } catch (Exception e) {
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage(); String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();

View File

@ -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);
}
}

View File

@ -40,33 +40,8 @@ public class IMLoginManager extends BaseCacheManager {
private final String IS_HINT = "is_hint"; private final String IS_HINT = "is_hint";
private final String IS_HINT2 = "is_hint2"; private final String IS_HINT2 = "is_hint2";
private final String SELECT_CLARITY = "selectClarity"; 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));
}
/** /**
* 设置清晰度 * 设置清晰度

View File

@ -17,7 +17,7 @@ import androidx.core.content.FileProvider;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R; 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.APKDownloadUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
@ -41,10 +41,12 @@ public class APKUpdateCustomPopup extends CenterPopupView {
private LinearLayout updateLine; private LinearLayout updateLine;
private ProgressBar progressBar; private ProgressBar progressBar;
private Activity mContext; private Activity mContext;
private boolean mInside;
public APKUpdateCustomPopup(@NonNull Activity context) { public APKUpdateCustomPopup(@NonNull Activity context, boolean inside) {
super(context); super(context);
mContext = context; mContext = context;
mInside = inside;
} }
// 返回自定义弹窗的布局 // 返回自定义弹窗的布局
@ -66,13 +68,33 @@ public class APKUpdateCustomPopup extends CenterPopupView {
} }
private void initView() { 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); updateText = findViewById(R.id.update_text);
versionImmediateUse = findViewById(R.id.version_immediate_use); versionImmediateUse = findViewById(R.id.version_immediate_use);
updateLine = findViewById(R.id.update_line); updateLine = findViewById(R.id.update_line);
progressBar = findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
versionImmediateUse.setVisibility(VISIBLE); versionImmediateUse.setVisibility(VISIBLE);
updateLine.setVisibility(GONE); 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() { ViewClicksAntiShake.clicksAntiShake(versionImmediateUse, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
@ -80,7 +102,7 @@ public class APKUpdateCustomPopup extends CenterPopupView {
if (!CommonAppConfig.IS_GOOGLE_PLAY) { if (!CommonAppConfig.IS_GOOGLE_PLAY) {
versionImmediateUse.setVisibility(GONE); versionImmediateUse.setVisibility(GONE);
updateLine.setVisibility(VISIBLE); updateLine.setVisibility(VISIBLE);
downloadAPK(mContext, IMLoginManager.get(getContext()).getAPKUrl(), new APKDownloadUtil.OnUpdateListener() { downloadAPK(mContext, APKManager.get().getAPKUrl(), new APKDownloadUtil.OnUpdateListener() {
@Override @Override
public void updateFailure(int code, String error) { public void updateFailure(int code, String error) {
ToastUtil.show(error); ToastUtil.show(error);

View File

@ -71,5 +71,13 @@
android:textSize="11sp" /> android:textSize="11sp" />
</LinearLayout> </LinearLayout>
<ImageView
android:id="@+id/dialog_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:src="@mipmap/icon_close_tip" />
</RelativeLayout> </RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -25,7 +25,7 @@ ext {
baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S", baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S",
// true表示谷歌支付 false // true表示谷歌支付 false
isGooglePlay : true, isGooglePlay : false,
// //
isUploadLog : false isUploadLog : false
] ]

View File

@ -17,7 +17,6 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
@ -41,6 +40,7 @@ import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.jakewharton.rxbinding3.view.RxView; import com.jakewharton.rxbinding3.view.RxView;
import com.lxj.xpopup.XPopup;
import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.permission.PermissionUtils; import com.lzf.easyfloat.permission.PermissionUtils;
import com.tencent.imsdk.v2.V2TIMCallback; 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.HttpCallback;
import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.APKManager;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NoviceInstructorManager; import com.yunbao.common.manager.NoviceInstructorManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; 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.ToastUtil;
import com.yunbao.common.utils.VersionUtil; import com.yunbao.common.utils.VersionUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.APKUpdateCustomPopup;
import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.common.views.AbsMainViewHolder;
import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.common.views.weight.LiveFloatView;
import com.yunbao.live.activity.LiveAudienceActivity; 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.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.utils.LiveStorge;
import com.yunbao.live.views.ChatListViewHolder; import com.yunbao.live.views.ChatListViewHolder;
import com.yunbao.main.R; 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()); DialogUitl.showSimpleTipDialog(mContext, WordUtil.getString(R.string.main_maintain_notice), configBean.getMaintainTips());
} }
if (!VersionUtil.isLatest(configBean.getVersion())) { if (!VersionUtil.isLatest(configBean.getVersion())) {
VersionUtil versionUtil = new VersionUtil(); if (!APKManager.get().getApkVerNew()) {
versionUtil.showDialog(mContext, configBean, configBean.getDownloadApkUrl()); new XPopup.Builder(mContext)
.isDestroyOnDismiss(true)
.dismissOnBackPressed(false) // 按返回键是否关闭弹窗默认为true
.dismissOnTouchOutside(false) // 点击外部是否关闭弹窗默认为true
.asCustom(new APKUpdateCustomPopup(mContext, false))
.show();
}
} else { } else {
requestBonus(); requestBonus();
} }

View File

@ -32,6 +32,7 @@ import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.APKManager;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.GlideCatchUtil; import com.yunbao.common.utils.GlideCatchUtil;
@ -286,9 +287,9 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener<
} else if (bean.getId() == 21) {//清除缓存 } else if (bean.getId() == 21) {//清除缓存
startActivity(new Intent(SettingActivity.this, MsgSettActivity.class)); startActivity(new Intent(SettingActivity.this, MsgSettActivity.class));
} else if (bean.getId() == 25) {//版本更新 } else if (bean.getId() == 25) {//版本更新
if (!IMLoginManager.get(mContext).getApkVerNew()) { if (!APKManager.get().getApkVerNew()) {
new XPopup.Builder(mContext) new XPopup.Builder(mContext)
.asCustom(new APKUpdateCustomPopup(mContext)) .asCustom(new APKUpdateCustomPopup(mContext, true))
.show(); .show();
} }

View File

@ -12,6 +12,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.APKManager;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.LogUtil; import com.yunbao.common.utils.LogUtil;
@ -147,7 +148,7 @@ public class SettingAdapter extends RecyclerView.Adapter {
mText.setText(DeviceUtils.getVersionName(itemView.getContext())); mText.setText(DeviceUtils.getVersionName(itemView.getContext()));
mText.setTextColor(Color.parseColor("#969696")); mText.setTextColor(Color.parseColor("#969696"));
} else if (bean.getId() == 25) { } 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.setText(itemView.getContext().getString(R.string.latest_version));
mText.setTextColor(Color.parseColor("#969696")); mText.setTextColor(Color.parseColor("#969696"));

View File

@ -39,7 +39,7 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.OnItemClickListener; 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.RouteUtil;
import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.ToastUtil; 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); 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 @Override