app更新优化,添加立即安装按钮

This commit is contained in:
lijia 2023-09-22 10:41:00 +08:00
parent 50cc329a4d
commit a44df1ee8c
2 changed files with 29 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package com.arpa.hndahesudintocctmsdriver.ui.alert;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -12,6 +13,8 @@ import androidx.annotation.NonNull;
import com.king.app.updater.AppUpdater; import com.king.app.updater.AppUpdater;
import com.king.app.updater.callback.AppUpdateCallback; import com.king.app.updater.callback.AppUpdateCallback;
import com.king.app.updater.constant.Constants;
import com.king.app.updater.util.AppUtils;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.arpa.hndahesudintocctmsdriver.R; import com.arpa.hndahesudintocctmsdriver.R;
@ -27,8 +30,8 @@ import java.io.File;
*/ */
public class UpAppAlert extends CenterPopupView { public class UpAppAlert extends CenterPopupView {
private TextView content,vs; private TextView content,vs,tvContent;
private Button tv_cancel,tv_confirm; private Button tv_cancel,tv_confirm,tvOk;
private LinearLayout up_div; private LinearLayout up_div;
private String url=""; private String url="";
private String body=""; private String body="";
@ -63,6 +66,8 @@ public class UpAppAlert extends CenterPopupView {
content=findViewById(R.id.tv_content); content=findViewById(R.id.tv_content);
tv_cancel=findViewById(R.id.tv_cancel); tv_cancel=findViewById(R.id.tv_cancel);
tv_confirm=findViewById(R.id.tv_confirm); tv_confirm=findViewById(R.id.tv_confirm);
tvContent=findViewById(R.id.tvContent);
tvOk=findViewById(R.id.tvOk);
up_div=findViewById(R.id.up_div); up_div=findViewById(R.id.up_div);
progress_view=findViewById(R.id.progress); progress_view=findViewById(R.id.progress);
content=findViewById(R.id.tv_content); content=findViewById(R.id.tv_content);
@ -109,7 +114,11 @@ public class UpAppAlert extends CenterPopupView {
@Override @Override
public void onFinish(File file) { public void onFinish(File file) {
tvContent.setText("下载完成,请及时安装!");
tvOk.setVisibility(VISIBLE);
tvOk.setOnClickListener(v1 -> {
AppUtils.installApk(getContext(),file,getContext().getPackageName() + Constants.DEFAULT_FILE_PROVIDER);
});
} }
}) })
.start(); .start();

View File

@ -99,6 +99,8 @@
android:textSize="@dimen/sp_17" android:textSize="@dimen/sp_17"
android:background="@null" android:background="@null"
android:layout_marginBottom="@dimen/dp_3"/> android:layout_marginBottom="@dimen/dp_3"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_marginTop="@dimen/dp_8" android:layout_marginTop="@dimen/dp_8"
@ -122,6 +124,7 @@
android:progressDrawable="@drawable/par_bg" android:progressDrawable="@drawable/par_bg"
/> />
<TextView <TextView
android:id="@+id/tvContent"
android:layout_marginTop="@dimen/dp_6" android:layout_marginTop="@dimen/dp_6"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -131,6 +134,20 @@
android:layout_gravity="center" android:layout_gravity="center"
/> />
</LinearLayout> </LinearLayout>
<Button
android:visibility="gone"
android:layout_marginLeft="@dimen/dp_18"
android:layout_marginRight="@dimen/dp_18"
android:id="@+id/tvOk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="立即安装"
android:textColor="@color/theme_color"
android:textSize="@dimen/sp_17"
android:background="@null"
android:layout_marginBottom="@dimen/dp_13"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/force_box" android:id="@+id/force_box"