移除设置-检查版本功能、隐藏设置-支付密码入口
This commit is contained in:
@@ -108,7 +108,6 @@ android {
|
||||
java.srcDirs = [
|
||||
'src/main/java',
|
||||
'src/module_public_chat_hall/java',
|
||||
'src/module_upgrade_app/java',
|
||||
'src/module_mentoring_relationship/java',
|
||||
'src/module_labour_union/java',
|
||||
'src/module_room_chat/java',
|
||||
@@ -126,7 +125,6 @@ android {
|
||||
'src/main/res',
|
||||
'src/common/res',
|
||||
'src/module_public_chat_hall/res',
|
||||
'src/module_upgrade_app/res',
|
||||
'src/module_mentoring_relationship/res',
|
||||
'src/module_labour_union/res',
|
||||
'src/module_room_chat/res',
|
||||
|
@@ -38,7 +38,6 @@ import com.netease.nimlib.sdk.team.constant.TeamMessageNotifyTypeEnum;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.chwl.app.upgrade.AppUpgradeHelper;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.chwl.app.application.IReportConstants;
|
||||
import com.chwl.app.application.ReportManager;
|
||||
@@ -246,8 +245,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
mMainTabLayout.setMainTabInfoList(mainTabInfo);
|
||||
}
|
||||
});
|
||||
//检测更新
|
||||
AppUpgradeHelper.checkAppUpgrade(this);
|
||||
initMaterialView();
|
||||
onParseIntent();
|
||||
updateDatas();
|
||||
|
@@ -2,8 +2,6 @@ package com.chwl.app.application;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.chwl.app.upgrade.AppUpgradeHelper;
|
||||
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
|
||||
import com.chwl.app.avroom.newuserchargegift.NewUserChargePrizeDialog;
|
||||
import com.chwl.app.relation.cp.dialog.CpGlobalDialog;
|
||||
import com.chwl.app.ui.widget.LevelUpDialog;
|
||||
@@ -55,7 +53,6 @@ public class GlobalHandleManager {
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onImPushUpdateAppEvent(ImPushUpdateAppEvent event) {
|
||||
AppUpgradeHelper.checkAppUpgrade((RxAppCompatActivity) getActivity(), event.getInfo());
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
|
@@ -18,7 +18,6 @@ import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.example.module_base.support.google.IGoogleService;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.chwl.app.upgrade.AppUpgradeHelper;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.chwl.app.MainActivity;
|
||||
import com.chwl.app.NimMiddleActivity;
|
||||
@@ -67,7 +66,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
||||
onFindViews();
|
||||
onSetListener();
|
||||
setProtocol();
|
||||
AppUpgradeHelper.checkAppUpgrade(this);
|
||||
//登录页展示时
|
||||
HashMap<String, Object> map = new HashMap<>(2);
|
||||
map.put(IReportConstants.MODULE, IReportConstants.PEKO_LOGIN);
|
||||
|
@@ -8,7 +8,6 @@ import android.text.SpannableString
|
||||
import android.view.View
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import com.chwl.app.upgrade.AppUpgradeHelper
|
||||
import com.chwl.app.BuildConfig
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.UIHelper
|
||||
@@ -53,7 +52,6 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun initView() {
|
||||
binding.versions.text = "V${BasicConfig.getLocalVersionName(this)}"
|
||||
val cacheLoginUserInfo = UserModel.get().cacheLoginUserInfo ?: return
|
||||
if (cacheLoginUserInfo.isBindPasswd) {
|
||||
binding.tvLoginPwd.text = ResUtil.getString(R.string.text_reset_password)
|
||||
@@ -69,14 +67,12 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
binding.rlyUpdate.setOnClickListener(this)
|
||||
binding.tvBlackManager.setOnClickListener(this)
|
||||
binding.rlyLoginPwd.setOnClickListener(this)
|
||||
binding.rlyPayPwd.setOnClickListener(this)
|
||||
binding.btnLoginOut.setOnClickListener(this)
|
||||
binding.tvCommunityNorms.setOnClickListener(this)
|
||||
binding.rlyClearCache.setOnClickListener(this)
|
||||
binding.tvNoticeSetting.setOnClickListener(this)
|
||||
binding.tvShieldManager.setOnClickListener(this)
|
||||
binding.rlyPermission.setOnClickListener(this)
|
||||
binding.rlyCheck.setOnClickListener(this)
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
binding.titleBar.setOnTitleClickListener {
|
||||
@@ -118,14 +114,6 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
R.id.rly_update -> startActivity(Intent(applicationContext, AboutActivity::class.java))
|
||||
R.id.tv_black_manager -> BlackListManageActivity.start(this)
|
||||
R.id.rly_login_pwd -> ModifyPwdActivity.start(this, ModifyPwdActivity.LOGIN_PWD)
|
||||
R.id.rly_pay_pwd -> {
|
||||
if (UserModel.get().cacheLoginUserInfo == null) {
|
||||
toast(ResUtil.getString(R.string.ui_setting_settingactivity_06))
|
||||
return
|
||||
}
|
||||
ModifyPwdActivity.start(this, ModifyPwdActivity.PAY_PWD)
|
||||
}
|
||||
|
||||
R.id.btn_login_out -> {
|
||||
val cacheLoginUserInfo = UserModel.get().cacheLoginUserInfo ?: return
|
||||
if (!cacheLoginUserInfo.isBindPasswd && !SPUtils.getBoolean(
|
||||
@@ -172,7 +160,6 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
R.id.tv_notice_setting -> NoticeSettingActivity.start(context)
|
||||
R.id.tv_shield_manager -> ShieldManageActivity.start(context)
|
||||
R.id.rly_permission -> PermissionGuideActivity.start(context)
|
||||
R.id.rly_check -> AppUpgradeHelper.checkAppUpgrade(this, dialogManager)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -94,49 +94,6 @@
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@color/line_353548" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rly_pay_pwd"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:text="@string/text_setting_pay_password"
|
||||
android:textColor="@color/text_title_color"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_pay_pwd_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:src="@drawable/arrow_right" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_pay_modify"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/dp_14"
|
||||
android:layout_toStartOf="@id/iv_pay_pwd_arrow"
|
||||
android:text="@string/text_modify"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@color/line_353548" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_notice_setting"
|
||||
@@ -385,36 +342,6 @@
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@color/line_353548" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rly_check"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:text="@string/text_setting_check_for_update"
|
||||
android:textColor="@color/text_title_color"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/versions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:text=""
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="@dimen/dp_13"
|
||||
tools:ignore="SpUsage" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_login_out"
|
||||
android:layout_width="320dp"
|
||||
|
@@ -1,123 +0,0 @@
|
||||
package com.chwl.app.upgrade;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriHelper;
|
||||
import com.chwl.core.upgrade.bean.NewestVersionInfo;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
|
||||
public class AppUpdateDialog extends DialogFragment implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = "ErbanUpdateDialog";
|
||||
|
||||
private TextView confirmButton;
|
||||
private TextView contentView;
|
||||
private NewestVersionInfo newestVersionInfo;
|
||||
private TextView tvLater;
|
||||
private TextView tvVersion;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
Window window = getDialog().getWindow();
|
||||
// setup window and width
|
||||
|
||||
View view = inflater.inflate(R.layout.dialog_erban_update, window.findViewById(android.R.id.content), false);
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
window.setLayout(UIUtil.dip2px(getContext(), 280), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
setCancelable(false);
|
||||
init(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void init(View view) {
|
||||
confirmButton = view.findViewById(R.id.iv_update_button);
|
||||
tvLater = view.findViewById(R.id.tvLater);
|
||||
confirmButton.setOnClickListener(this);
|
||||
tvLater.setOnClickListener(this);
|
||||
contentView = view.findViewById(R.id.tv_update_dialog_content);
|
||||
tvVersion = view.findViewById(R.id.tvVersion);
|
||||
if (newestVersionInfo != null) {
|
||||
displayVersionDescription();
|
||||
displayCloseIcon();
|
||||
tvVersion.setText(newestVersionInfo.getUpdateVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void displayVersionDescription() {
|
||||
contentView.setText(newestVersionInfo.getUpdateVersionDesc());
|
||||
}
|
||||
|
||||
private void displayCloseIcon() {
|
||||
switch (newestVersionInfo.getUpdateStatus()) {
|
||||
case NewestVersionInfo.STATUS_FORCE_UPDATE:
|
||||
tvLater.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case NewestVersionInfo.STATUS_RECOMMEND_UPDATE:
|
||||
tvLater.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void show(FragmentManager fragmentManager) {
|
||||
this.show(fragmentManager, TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(FragmentManager manager, String tag) {
|
||||
if (manager.findFragmentByTag(tag) == null) {
|
||||
manager.beginTransaction()
|
||||
.add(this, tag)
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.tvLater:
|
||||
dismissAllowingStateLoss();
|
||||
break;
|
||||
|
||||
case R.id.iv_update_button:
|
||||
try {
|
||||
//跳转到浏览器打开更新链接
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("android.intent.action.VIEW");
|
||||
Uri content_url = null;
|
||||
content_url = Uri.parse(UriHelper.applyTimestampForUrl(XConstants.appDownloadUrl));//拼接上时间戳,避免访问缓存文件
|
||||
intent.setData(content_url);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Logger.e("downloadUpgrade:" + e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewestVersionInfo(NewestVersionInfo newestVersionInfo) {
|
||||
this.newestVersionInfo = newestVersionInfo;
|
||||
}
|
||||
|
||||
}
|
@@ -1,118 +0,0 @@
|
||||
package com.chwl.app.upgrade;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.chwl.core.upgrade.bean.UpgradeCache;
|
||||
import com.chwl.core.utils.SharedPreferenceUtils;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 每个版本最多弹三次
|
||||
* 每天最多弹一次
|
||||
*
|
||||
* 如果接口版本号和缓存版本号,不一致
|
||||
* 则说明更新版本出来了,直接弹窗,以前缓存清除
|
||||
*
|
||||
* create by lvzebiao @2019/8/15
|
||||
*/
|
||||
public class AppUpgradeDataMrg {
|
||||
|
||||
private static final String KEY_APP_UPGRADE_DIALOG_COUNT = "app_upgrade_dialog_count";
|
||||
|
||||
/**
|
||||
* 每个版本最多弹窗的次数
|
||||
*/
|
||||
private static final int MAX_COUNT_FOR_EVERY_VERSION = 3;
|
||||
|
||||
private AppUpgradeDataMrg() {}
|
||||
|
||||
private static final class Helper {
|
||||
public static final AppUpgradeDataMrg INSTANCE = new AppUpgradeDataMrg();
|
||||
}
|
||||
|
||||
public static AppUpgradeDataMrg get() {
|
||||
return Helper.INSTANCE;
|
||||
}
|
||||
|
||||
public static UpgradeCache getCache() {
|
||||
UpgradeCache cache = null;
|
||||
try {
|
||||
String string = (String) SharedPreferenceUtils.get(KEY_APP_UPGRADE_DIALOG_COUNT, "");
|
||||
LogUtil.print("getCache=" + string);
|
||||
if (!TextUtils.isEmpty(string)) {
|
||||
cache = new Gson().fromJson(string, UpgradeCache.class);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param netVersion 接口上面的版本号
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNeedDialog(UpgradeCache cache, String netVersion) {
|
||||
try {
|
||||
if (cache == null) {
|
||||
//没缓存,说明第一次弹窗,直接弹
|
||||
return true;
|
||||
}
|
||||
if (TextUtils.isEmpty(netVersion)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(netVersion, cache.getVersion()) && AppVersionUtil.compareVersion(netVersion, cache.getVersion()) > 0) {
|
||||
//接口版本号更新了,也需要弹窗
|
||||
LogUtil.print("more new version and need updateDialog");
|
||||
return true;
|
||||
}
|
||||
if (cache.getCount() >= MAX_COUNT_FOR_EVERY_VERSION) {
|
||||
LogUtil.print("cacheCount more than " + MAX_COUNT_FOR_EVERY_VERSION);
|
||||
return false;
|
||||
}
|
||||
if (TimeUtils.isTomorrow(cache.getTime())) {
|
||||
//第二天,次数不到3次,也要弹窗
|
||||
LogUtil.print("isTomorrow and need updateDialog");
|
||||
return true;
|
||||
} else {
|
||||
LogUtil.print("today has show updateDialog");
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void saveCache(UpgradeCache cache, String netVersion) {
|
||||
try {
|
||||
if (TextUtils.isEmpty(netVersion)) {
|
||||
return;
|
||||
}
|
||||
if (cache == null) {
|
||||
cache = new UpgradeCache();
|
||||
}
|
||||
if (!Objects.equals(cache.getVersion(), netVersion)) {
|
||||
LogUtil.print("[cacheVersion=" + cache.getVersion() + ", netVersion=" + netVersion +
|
||||
", to set count=0]");
|
||||
cache.setCount(0);
|
||||
}
|
||||
cache.setCount(cache.getCount() + 1);
|
||||
cache.setTime(System.currentTimeMillis());
|
||||
cache.setVersion(netVersion);
|
||||
String string = new Gson().toJson(cache);
|
||||
LogUtil.print(string);
|
||||
SharedPreferenceUtils.put(KEY_APP_UPGRADE_DIALOG_COUNT, string);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,151 +0,0 @@
|
||||
package com.chwl.app.upgrade;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.upgrade.bean.NewestVersionInfo;
|
||||
import com.chwl.core.upgrade.bean.UpgradeCache;
|
||||
import com.chwl.core.upgrade.model.UpgradeModel;
|
||||
import com.chwl.core.utils.ActivityUtil;
|
||||
import com.chwl.core.utils.CoreLogger;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.config.BasicConfig;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description
|
||||
* @Date 2018/12/14
|
||||
*/
|
||||
public class AppUpgradeHelper {
|
||||
|
||||
/**
|
||||
* 点击设置
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public static void checkAppUpgrade(RxAppCompatActivity activity,
|
||||
DialogManager dialogManager) {
|
||||
dialogManager.showProgressDialog(activity);
|
||||
UpgradeModel.get()
|
||||
.checkUpgrade()
|
||||
.compose(activity.bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe((newestVersionInfo, throwable) -> {
|
||||
dialogManager.dismissDialog();
|
||||
if (throwable == null) {
|
||||
if (newestVersionInfo.getUpdateStatus() == NewestVersionInfo.STATUS_FORCE_UPDATE ||
|
||||
newestVersionInfo.getUpdateStatus() == NewestVersionInfo.STATUS_RECOMMEND_UPDATE) {
|
||||
if (!ActivityUtil.isCanShowAppCompatDialog(activity)) {
|
||||
return;
|
||||
}
|
||||
if (AppVersionUtil.compareVersion(newestVersionInfo.getUpdateVersion(), BasicConfig.getLocalVersionName(activity)) <= 0) {
|
||||
return;
|
||||
}
|
||||
AppUpdateDialog appUpdateDialog = new AppUpdateDialog();
|
||||
appUpdateDialog.setNewestVersionInfo(newestVersionInfo);
|
||||
appUpdateDialog.show(activity.getSupportFragmentManager());
|
||||
}
|
||||
} else {
|
||||
CoreLogger.error("AppUpgradeHelper",throwable.getMessage());
|
||||
SingleToastUtil.showToastShort(throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 非用户主动点击
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public static void checkAppUpgrade(RxAppCompatActivity activity) {
|
||||
|
||||
if (UpgradeModel.get().isHasShowDialog()) {
|
||||
//如果已经弹窗过,则不再调用接口了
|
||||
return;
|
||||
}
|
||||
|
||||
UpgradeModel.get()
|
||||
.checkUpgrade()
|
||||
.compose(activity.bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe((newestVersionInfo, throwable) -> {
|
||||
if (throwable == null) {
|
||||
if (newestVersionInfo.getUpdateStatus() == NewestVersionInfo.STATUS_FORCE_UPDATE ||
|
||||
newestVersionInfo.getUpdateStatus() == NewestVersionInfo.STATUS_RECOMMEND_UPDATE) {
|
||||
if (!ActivityUtil.isCanShowAppCompatDialog(activity)) {
|
||||
return;
|
||||
}
|
||||
if (AppVersionUtil.compareVersion(newestVersionInfo.getUpdateVersion(), BasicConfig.getLocalVersionName(activity)) <= 0) {
|
||||
return;
|
||||
}
|
||||
//如果是强更就直接弹,不走限制的逻辑
|
||||
boolean forceUpdate = newestVersionInfo.getUpdateStatus()
|
||||
== NewestVersionInfo.STATUS_FORCE_UPDATE;
|
||||
|
||||
boolean needShow = true;
|
||||
if (!forceUpdate) {
|
||||
UpgradeCache cache = AppUpgradeDataMrg.getCache();
|
||||
needShow = AppUpgradeDataMrg.isNeedDialog(
|
||||
cache, newestVersionInfo.getUpdateVersion());
|
||||
if (needShow) {
|
||||
//保存缓存
|
||||
AppUpgradeDataMrg.saveCache(cache,
|
||||
newestVersionInfo.getUpdateVersion());
|
||||
}
|
||||
}
|
||||
//如果是强更,一定要弹窗
|
||||
if (forceUpdate || needShow) {
|
||||
AppUpdateDialog appUpdateDialog = new AppUpdateDialog();
|
||||
appUpdateDialog.setNewestVersionInfo(newestVersionInfo);
|
||||
appUpdateDialog.show(activity.getSupportFragmentManager());
|
||||
UpgradeModel.get().setHasShowDialog(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CoreLogger.error("AppUpgradeHelper",throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送
|
||||
* @param newestVersionInfo 后台返回数据
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public static void checkAppUpgrade(RxAppCompatActivity activity, NewestVersionInfo newestVersionInfo) {
|
||||
if (newestVersionInfo.getUpdateStatus() == NewestVersionInfo.STATUS_FORCE_UPDATE ||
|
||||
newestVersionInfo.getUpdateStatus() == NewestVersionInfo.STATUS_RECOMMEND_UPDATE) {
|
||||
if (!ActivityUtil.isCanShowAppCompatDialog(activity)) {
|
||||
return;
|
||||
}
|
||||
if (!newestVersionInfo.getUpdateOs().equals(Constants.ANDROID) || !newestVersionInfo.getUpdateChannel().equals(AppMetaDataUtil.getChannelID())) {
|
||||
return;
|
||||
}
|
||||
if (AppVersionUtil.compareVersion(newestVersionInfo.getUpdateVersion(), BasicConfig.getLocalVersionName(activity)) <= 0) {
|
||||
return;
|
||||
}
|
||||
//如果是强更就直接弹,不走限制的逻辑
|
||||
boolean forceUpdate = newestVersionInfo.getUpdateStatus()
|
||||
== NewestVersionInfo.STATUS_FORCE_UPDATE;
|
||||
|
||||
boolean needShow = true;
|
||||
if (!forceUpdate) {
|
||||
UpgradeCache cache = AppUpgradeDataMrg.getCache();
|
||||
needShow = AppUpgradeDataMrg.isNeedDialog(
|
||||
cache, newestVersionInfo.getUpdateVersion());
|
||||
if (needShow) {
|
||||
//保存缓存
|
||||
AppUpgradeDataMrg.saveCache(cache,
|
||||
newestVersionInfo.getUpdateVersion());
|
||||
}
|
||||
}
|
||||
//如果是强更,一定要弹窗
|
||||
if (forceUpdate || needShow) {
|
||||
AppUpdateDialog appUpdateDialog = new AppUpdateDialog();
|
||||
appUpdateDialog.setNewestVersionInfo(newestVersionInfo);
|
||||
appUpdateDialog.show(activity.getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package com.chwl.app.upgrade;
|
||||
|
||||
/**
|
||||
* @Author: yangming
|
||||
* @Date: 2019/12/30 15:55
|
||||
* @Description: 版本号判断工具类
|
||||
**/
|
||||
public class AppVersionUtil {
|
||||
|
||||
/**
|
||||
* 比较版本号的大小,前者大则返回一个正数,后者大返回一个负数,相等则返回0
|
||||
*
|
||||
* @param version1
|
||||
* @param version2
|
||||
*/
|
||||
public static int compareVersion(String version1, String version2) {
|
||||
// 注意此处为正则匹配,不能用.;
|
||||
String[] versionArray1 = version1.split("\\.");
|
||||
String[] versionArray2 = version2.split("\\.");
|
||||
int idx = 0;
|
||||
// 取最小长度值
|
||||
int minLength = Math.min(versionArray1.length, versionArray2.length);
|
||||
int diff = 0;
|
||||
// 先比较长度, 再比较字符
|
||||
while (idx < minLength
|
||||
&& (diff = versionArray1[idx].length() - versionArray2[idx].length()) == 0
|
||||
&& (diff = versionArray1[idx].compareTo(versionArray2[idx])) == 0) {
|
||||
++idx;
|
||||
}
|
||||
// 如果已经分出大小,则直接返回,如果未分出大小,则再比较位数,有子版本的为大;
|
||||
diff = (diff != 0) ? diff : versionArray1.length - versionArray2.length;
|
||||
return diff;
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 148 KiB |
Binary file not shown.
Before Width: | Height: | Size: 92 KiB |
Binary file not shown.
Before Width: | Height: | Size: 55 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB |
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/appColor" />
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
@@ -1,103 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
tools:background="@color/black">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="125dp"
|
||||
android:background="@drawable/dialog_update_bg_top"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_update_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_100"
|
||||
android:text="@string/title_upgrade_app"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="@dimen/dp_16"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="SpUsage" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:background="@drawable/dialog_update_bg_bottom"
|
||||
app:layout_constraintTop_toBottomOf="@+id/view_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvVersion"
|
||||
tools:text="1.2.0"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textColor="@color/color_1F1A4E"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_3"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_update_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_update_dialog_content"
|
||||
android:textColor="@color/color_666666"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13"
|
||||
tools:text="1.youhua\n2.shouye\n3.buju"
|
||||
android:minHeight="80dp"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginStart="@dimen/dp_40"
|
||||
android:layout_marginEnd="@dimen/dp_32"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvVersion"
|
||||
app:layout_constraintBottom_toTopOf="@+id/iv_update_button"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/iv_update_button"
|
||||
android:layout_width="154dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/base_shape_theme_30dp"
|
||||
android:text="@string/layout_dialog_erban_update_01"
|
||||
android:textColor="@color/base_color_theme_text"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_update_dialog_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tvLater"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:ignore="ContentDescription"
|
||||
android:gravity="center"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLater"
|
||||
android:text="@string/take_to_you_later"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:textColor="@color/color_B3B3C3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:layout_marginBottom="18dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/viewBottom"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="tips_downloading_percent">·正在更新%s·</string>
|
||||
<string name="title_upgrade_app">新版本升級</string>
|
||||
<string name="title_upgrade_app_en">VERSION UPDATE</string>
|
||||
</resources>
|
Reference in New Issue
Block a user