应用内更新功能修改
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.tongdaxing.erban.upgrade;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
@@ -23,6 +25,8 @@ import androidx.fragment.app.FragmentManager;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.UriHelper;
|
||||
import com.yizhuan.xchat_android_core.upgrade.bean.NewestVersionInfo;
|
||||
import com.yizhuan.xchat_android_core.upgrade.model.UpgradeModel;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
@@ -109,9 +113,19 @@ public class AppUpdateDialog extends DialogFragment implements View.OnClickListe
|
||||
break;
|
||||
|
||||
case R.id.iv_update_button:
|
||||
confirmButton.setVisibility(View.GONE);
|
||||
displayDownloadProgress(true);
|
||||
startDownload();
|
||||
// confirmButton.setVisibility(View.GONE);
|
||||
// displayDownloadProgress(true);
|
||||
// startDownload();
|
||||
try {
|
||||
//跳转到浏览器打开更新链接
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("android.intent.action.VIEW");
|
||||
Uri content_url = Uri.parse(UriHelper.applyTimestampForUrl(XChatConstants.appDownloadUrl));//拼接上时间戳,避免访问缓存文件
|
||||
intent.setData(content_url);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Logger.e("downloadUpgrade:" + e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -278,4 +278,9 @@ public class XChatConstants {
|
||||
*/
|
||||
public static final String ADJUST_APP_TOKEN = "ujzc7mbv3g8w";
|
||||
|
||||
/**
|
||||
* peko谷歌下载地址
|
||||
*/
|
||||
public static String appDownloadUrl = "https://play.google.com/store/apps/details?id=com.vele.peko";
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,74 @@
|
||||
package com.yizhuan.xchat_android_core;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class UriHelper {
|
||||
|
||||
/**
|
||||
* @param url 访问链接
|
||||
* @return 返回增加时间戳,避免重复链接访问缓存内容
|
||||
*/
|
||||
public static String applyTimestampForUrl(String url) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return "";
|
||||
}
|
||||
url = appendUri(url, "t", String.valueOf(System.currentTimeMillis()));
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL增加参数
|
||||
*
|
||||
* @param uri 原始链接
|
||||
* @param appendQueryKey 增加参数,key
|
||||
* @param appendQueryValue 增加参数,value
|
||||
* @return 拼接后的完整链接
|
||||
*/
|
||||
public static String appendUri(String uri, String appendQueryKey, String appendQueryValue) {
|
||||
if (TextUtils.isEmpty(uri)) {
|
||||
return "";
|
||||
}
|
||||
if (TextUtils.isEmpty(appendQueryKey) || TextUtils.isEmpty(appendQueryValue)) {
|
||||
return uri;
|
||||
}
|
||||
Uri oldUri = Uri.parse(uri);
|
||||
|
||||
String value = oldUri.getQueryParameter(appendQueryKey);
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
return uri;
|
||||
}
|
||||
Uri.Builder builder = Uri.parse(uri).buildUpon();
|
||||
builder.appendQueryParameter(appendQueryKey, appendQueryValue);
|
||||
return builder.toString();
|
||||
}
|
||||
/**
|
||||
* URL增加参数 值允许为空字符串
|
||||
*
|
||||
* @param uri 原始链接
|
||||
* @param appendQueryKey 增加参数,key
|
||||
* @param appendQueryValue 增加参数,value
|
||||
* @return 拼接后的完整链接
|
||||
*/
|
||||
public static String appendUriAllowEmpty(String uri, String appendQueryKey, String appendQueryValue) {
|
||||
if (TextUtils.isEmpty(uri)) {
|
||||
return "";
|
||||
}
|
||||
if (TextUtils.isEmpty(appendQueryKey)) {
|
||||
return uri;
|
||||
}
|
||||
Uri oldUri = Uri.parse(uri);
|
||||
|
||||
String value = oldUri.getQueryParameter(appendQueryKey);
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
return uri;
|
||||
}
|
||||
Uri.Builder builder = Uri.parse(uri).buildUpon();
|
||||
if (TextUtils.isEmpty(appendQueryValue)) {
|
||||
builder.appendQueryParameter(appendQueryKey, "");
|
||||
} else {
|
||||
builder.appendQueryParameter(appendQueryKey, appendQueryValue);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user