Commit 9c512e82 authored by jyx's avatar jyx

强升代码优化

parent cedec2f8
...@@ -8,7 +8,9 @@ import android.content.Intent; ...@@ -8,7 +8,9 @@ import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.net.Uri; import android.net.Uri;
import android.os.IBinder; import android.os.IBinder;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod; import android.text.method.ScrollingMovementMethod;
import android.view.KeyEvent; import android.view.KeyEvent;
...@@ -57,6 +59,7 @@ public class VersionUpdatePresenter { ...@@ -57,6 +59,7 @@ public class VersionUpdatePresenter {
Button btnDuUpdate; Button btnDuUpdate;
private Subscription subscription; private Subscription subscription;
private UpdateService mUpdateService;
public void updateVersion(Activity activity) { public void updateVersion(Activity activity) {
if (activity == null) if (activity == null)
...@@ -211,6 +214,16 @@ public class VersionUpdatePresenter { ...@@ -211,6 +214,16 @@ public class VersionUpdatePresenter {
btnDuUpdate.setOnClickListener(new View.OnClickListener() { btnDuUpdate.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (TextUtils.equals(btnDuUpdate.getText(), "立即安装")) {
if (mUpdateService != null) {
mUpdateService.autoInstallApk();
} else {
ToastUtil.show(loanApplication.getApplicationContext(), "安装失败!");
System.exit(0);
}
return;
}
boolean url = CommonUtils.isUrl(appFileUrl); boolean url = CommonUtils.isUrl(appFileUrl);
if (url) { if (url) {
updateApp(appFileUrl, granted); updateApp(appFileUrl, granted);
...@@ -255,10 +268,10 @@ public class VersionUpdatePresenter { ...@@ -255,10 +268,10 @@ public class VersionUpdatePresenter {
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
// //返回一个MsgService对象 // //返回一个MsgService对象
UpdateService updateService = ((UpdateService.UpdateBinder) service).getService(); mUpdateService = ((UpdateService.UpdateBinder) service).getService();
// //
// //注册回调接口来接收下载进度的变化 // //注册回调接口来接收下载进度的变化
updateService.setUpdateNotification(new UpdateService.UpdateNotification() { mUpdateService.setUpdateNotification(new UpdateService.UpdateNotification() {
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
if (pbDuUpdating != null) { if (pbDuUpdating != null) {
...@@ -271,7 +284,10 @@ public class VersionUpdatePresenter { ...@@ -271,7 +284,10 @@ public class VersionUpdatePresenter {
@Override @Override
public void finishProgress() { public void finishProgress() {
if (btnDuUpdate != null) {
btnDuUpdate.setEnabled(true);
btnDuUpdate.setText("立即安装");
}
} }
}); });
......
...@@ -16,9 +16,11 @@ import androidx.core.app.NotificationCompat; ...@@ -16,9 +16,11 @@ import androidx.core.app.NotificationCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import com.wenshu.youyou.MintsApplication;
import com.wenshu.youyou.R; import com.wenshu.youyou.R;
import com.wenshu.youyou.common.Constant; import com.wenshu.youyou.common.Constant;
import com.wenshu.youyou.ui.activitys.MainActivity; import com.wenshu.youyou.ui.activitys.MainActivity;
import com.wenshu.youyou.utils.ToastUtil;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -202,6 +204,18 @@ public class UpdateService extends Service { ...@@ -202,6 +204,18 @@ public class UpdateService extends Service {
}).start(); }).start();
} }
/**
* 安装 apk 文件
*/
public void autoInstallApk() {
if (updateFile != null) {
autoInstallApk(updateFile);
} else {
ToastUtil.show(MintsApplication.getContext(), "安装失败!");
System.exit(0);
}
}
/** /**
* 安装 apk 文件 * 安装 apk 文件
*/ */
......
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
DEBUG_URL="http://39.97.65.143:9082/api/"
#DEBUG_URL="http://192.168.31.193:8101/"
RELEASE_URL="https://api.mints-id.com/gsnew-api/"
RELEASE_KEY_PASSWORD=mints.youyou
RELEASE_KEY_ALIAS=mints_youyou
RELEASE_STORE_PASSWORD=mints.youyou
RELEASE_STORE_FILE=mints_youyou.jks
#ShareSDK
RELEASE_SHARESDK_KEY=328d2edfe42fa
RELEASE_SHARESDK_SECRET=3586272d2ddd7d9de497cdede529ced3
#友盟
RELEASE_UMENG_KEY=604869326ee47d382b7ae112
#JPush
RELEASE_JPUSH_KEY=35f3e95b2d3f0b63ca5a4a0e
android.useAndroidX=true
android.enableJetifier=true
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment