diff --git a/app/build.gradle b/app/build.gradle index d4d5c2f..60803b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,7 +23,7 @@ android { minSdkVersion 21 targetSdkVersion 29 versionCode 1 - versionName "1.0" + versionName "1.0.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { // 设置支持的SO库架构 @@ -128,7 +128,7 @@ dependencies { // 权限请求框架:https://github.com/getActivity/XXPermissions - implementation 'com.github.getActivity:XXPermissions:16.5' + implementation 'com.github.getActivity:XXPermissions:18.6' //BaseRecyclerViewAdapterHelper implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.11' @@ -152,4 +152,7 @@ dependencies { compile 'com.github.lmiot:LoadDialog:V2.1' // api project(path: ':meeting1v1') implementation 'com.alibaba:fastjson:2.0.19.android' + + //版本更新 + implementation 'com.teprinciple:updateapputilsx:2.3.0' } diff --git a/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java b/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java index fe40fa5..40beaa3 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java +++ b/app/src/main/java/com/unionmed/unionmedtv/activity/HomeActivity.java @@ -21,29 +21,40 @@ import androidx.fragment.app.Fragment; import androidx.lifecycle.Observer; import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.widget.ViewPager2; - import com.blankj.utilcode.util.ToastUtils; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; +import com.hjq.http.EasyHttp; +import com.hjq.http.listener.OnHttpListener; import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.Permission; import com.hjq.permissions.XXPermissions; import com.lxj.xpopup.XPopup; import com.unionmed.unionmedtv.R; +import com.unionmed.unionmedtv.api.VersionUpLoadApi; import com.unionmed.unionmedtv.base.BaseActivity; import com.unionmed.unionmedtv.dialog.TipDialog; import com.unionmed.unionmedtv.fragment.MyDoctorFragment; import com.unionmed.unionmedtv.livedatas.LiveDataBus; import com.unionmed.unionmedtv.login.activity.LoginActivity; +import com.unionmed.unionmedtv.network.ApiResponse; +import com.unionmed.unionmedtv.network.HttpData; import com.unionmed.unionmedtv.utils.CacheUtil; import com.unionmed.unionmedtv.utils.Constants; import com.unionmed.unionmedtv.widgets.ScaleConstraintLayout; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.List; +import constant.UiType; import io.rong.imlib.RongCoreClient; import io.rong.imlib.RongIMClient; +import listener.OnInitUiListener; +import model.UiConfig; +import model.UpdateConfig; +import update.UpdateAppUtils; /** * 首页 @@ -75,7 +86,59 @@ public class HomeActivity extends BaseActivity implements View.OnFocusChangeList initBroadCast(); initPermissions(); } + public void uploadVersion() { + EasyHttp.post(HomeActivity.this) + .api(new VersionUpLoadApi()) + .request(new OnHttpListener>>() { + @Override + public void onHttpSuccess(HttpData> versionInfo) { + if (versionInfo.isRequestSucceed()) { + if (versionInfo.getData().isInnerRequestSucceed()) { + VersionUpLoadApi.VersionInfoBean versionInfoBean = versionInfo.getData().getData().getVersionInfo(); + if (versionInfoBean.getIfNeedUpdate().equals("1")) { + // 更新配置 + UpdateConfig updateConfig = new UpdateConfig(); + updateConfig.setForce(versionInfoBean.getIs_force().equals("1")); + updateConfig.setCheckWifi(false); + updateConfig.setNeedCheckMd5(false); + updateConfig.setShowNotification(false); + updateConfig.setAlwaysShowDownLoadDialog(true); + //ui配置 + UiConfig uiConfig = new UiConfig(); + uiConfig.setUiType(UiType.CUSTOM); + uiConfig.setCustomLayoutId(R.layout.view_custom_version); + UpdateAppUtils + .getInstance() + .apkUrl(versionInfoBean.getUpdate_url()) + .updateTitle("发现新版本") + .updateContent(versionInfoBean.getUpdate_info()) + .updateConfig(updateConfig) + .uiConfig(uiConfig) + .setOnInitUiListener(new OnInitUiListener() { + @Override + public void onInitUpdateUi(@org.jetbrains.annotations.Nullable View view, @NotNull UpdateConfig updateConfig, @NotNull UiConfig uiConfig) { + TextView textView = view.findViewById(R.id.tv_version_name); + textView.setText("V" + versionInfoBean.getVersion_number()); + + } + }).update(); + } + } else { + + } + } else { + + } + + } + + @Override + public void onHttpFail(Exception e) { + + } + }); + } public void initPermissions() { XXPermissions.with(HomeActivity.this) // 申请单个权限 @@ -91,6 +154,8 @@ public class HomeActivity extends BaseActivity implements View.OnFocusChangeList if (!all) { // toast("获取部分权限成功,但部分权限未正常授予"); return; + }else { + uploadVersion(); } } diff --git a/app/src/main/java/com/unionmed/unionmedtv/api/VersionUpLoadApi.java b/app/src/main/java/com/unionmed/unionmedtv/api/VersionUpLoadApi.java new file mode 100644 index 0000000..7f8bac5 --- /dev/null +++ b/app/src/main/java/com/unionmed/unionmedtv/api/VersionUpLoadApi.java @@ -0,0 +1,312 @@ +package com.unionmed.unionmedtv.api; + + +import androidx.annotation.NonNull; + +import com.hjq.http.config.IRequestApi; +import com.hjq.http.config.IRequestType; +import com.hjq.http.model.BodyType; + +import java.util.List; + +/** + * desc : 账号登录 + */ +public final class VersionUpLoadApi implements IRequestApi, IRequestType{ + + + /** + * protocol : [{"name":"法律声明及隐私政策","value":"https://mobile.union-med.net/LegalStatement.html"},{"name":"个人用户服务协议","value":"https://mobile.union-med.net/PersonalDelegate.html"},{"name":"平台医生服务协议","value":"https://mobile.union-med.net/DoctorDelegate.html"},{"name":"康联健康服务平台用户支付服务协议","value":"https://mobile.union-med.net/PaymentAgreement.html"},{"name":"医疗机构服务协议","value":"https://mobile.union-med.net/HospitalService.html"}] + * route : [{"pkey":"17","ip":"23.86.174.181","port":"8085","fmsvr":"rtmp://10.120.224.5/livepkgr/","msgsvr":"http://120.195.56.245:3190/msg_server","ipsvr":"https://mini.union-med.net:8085/appintegrate/v1.8","type":"01","msgip":"120.195.56.245","oder_num":0,"memo":"越西","svalue":"rtmp://10.120.224.5/livepkgr/","filesvr":"https://mini.union-med.net:8085/eleand/"}] + * customerServicePhone : 400-998-169-8 + * ifNeedUpdate : 1 + * versionInfo : {"version_number":"1.0.1","client":"iptv","update_info":null,"release_time":"2023-09-11 00:00:00.0","is_force":"0","update_url":"http://47.118.51.167:9000/apk/unionhealthTV_1.0.1_09-11_10.37_release.apk","ifNeedUpdate":"1"} + */ + + private String customerServicePhone; + private String ifNeedUpdate; + private VersionInfoBean versionInfo; + private List protocol; + private List route; + + @NonNull + @Override + public BodyType getBodyType() { + return BodyType.JSON; + } + + @NonNull + @Override + public String getApi() { + return "/login/getConfig"; + } + + public String getCustomerServicePhone() { + return customerServicePhone; + } + + public void setCustomerServicePhone(String customerServicePhone) { + this.customerServicePhone = customerServicePhone; + } + + public String getIfNeedUpdate() { + return ifNeedUpdate; + } + + public void setIfNeedUpdate(String ifNeedUpdate) { + this.ifNeedUpdate = ifNeedUpdate; + } + + public VersionInfoBean getVersionInfo() { + return versionInfo; + } + + public void setVersionInfo(VersionInfoBean versionInfo) { + this.versionInfo = versionInfo; + } + + public List getProtocol() { + return protocol; + } + + public void setProtocol(List protocol) { + this.protocol = protocol; + } + + public List getRoute() { + return route; + } + + public void setRoute(List route) { + this.route = route; + } + + + public static class VersionInfoBean { + /** + * version_number : 1.0.1 + * client : iptv + * update_info : null + * release_time : 2023-09-11 00:00:00.0 + * is_force : 0 + * update_url : http://47.118.51.167:9000/apk/unionhealthTV_1.0.1_09-11_10.37_release.apk + * ifNeedUpdate : 1 + */ + + private String version_number; + private String client; + private String update_info=""; + private String release_time; + private String is_force; + private String update_url; + private String ifNeedUpdate; + + public String getVersion_number() { + return version_number; + } + + public void setVersion_number(String version_number) { + this.version_number = version_number; + } + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public String getUpdate_info() { + return update_info; + } + + public void setUpdate_info(String update_info) { + this.update_info = update_info; + } + + public String getRelease_time() { + return release_time; + } + + public void setRelease_time(String release_time) { + this.release_time = release_time; + } + + public String getIs_force() { + return is_force; + } + + public void setIs_force(String is_force) { + this.is_force = is_force; + } + + public String getUpdate_url() { + return update_url; + } + + public void setUpdate_url(String update_url) { + this.update_url = update_url; + } + + public String getIfNeedUpdate() { + return ifNeedUpdate; + } + + public void setIfNeedUpdate(String ifNeedUpdate) { + this.ifNeedUpdate = ifNeedUpdate; + } + } + + public static class ProtocolBean { + /** + * name : 法律声明及隐私政策 + * value : https://mobile.union-med.net/LegalStatement.html + */ + + private String name; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + + public static class RouteBean { + /** + * pkey : 17 + * ip : 23.86.174.181 + * port : 8085 + * fmsvr : rtmp://10.120.224.5/livepkgr/ + * msgsvr : http://120.195.56.245:3190/msg_server + * ipsvr : https://mini.union-med.net:8085/appintegrate/v1.8 + * type : 01 + * msgip : 120.195.56.245 + * oder_num : 0 + * memo : 越西 + * svalue : rtmp://10.120.224.5/livepkgr/ + * filesvr : https://mini.union-med.net:8085/eleand/ + */ + + private String pkey; + private String ip; + private String port; + private String fmsvr; + private String msgsvr; + private String ipsvr; + private String type; + private String msgip; + private int oder_num; + private String memo; + private String svalue; + private String filesvr; + + public String getPkey() { + return pkey; + } + + public void setPkey(String pkey) { + this.pkey = pkey; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getFmsvr() { + return fmsvr; + } + + public void setFmsvr(String fmsvr) { + this.fmsvr = fmsvr; + } + + public String getMsgsvr() { + return msgsvr; + } + + public void setMsgsvr(String msgsvr) { + this.msgsvr = msgsvr; + } + + public String getIpsvr() { + return ipsvr; + } + + public void setIpsvr(String ipsvr) { + this.ipsvr = ipsvr; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMsgip() { + return msgip; + } + + public void setMsgip(String msgip) { + this.msgip = msgip; + } + + public int getOder_num() { + return oder_num; + } + + public void setOder_num(int oder_num) { + this.oder_num = oder_num; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + public String getSvalue() { + return svalue; + } + + public void setSvalue(String svalue) { + this.svalue = svalue; + } + + public String getFilesvr() { + return filesvr; + } + + public void setFilesvr(String filesvr) { + this.filesvr = filesvr; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/unionmed/unionmedtv/application/MyApplication.java b/app/src/main/java/com/unionmed/unionmedtv/application/MyApplication.java index 278ba8e..2ff6c73 100644 --- a/app/src/main/java/com/unionmed/unionmedtv/application/MyApplication.java +++ b/app/src/main/java/com/unionmed/unionmedtv/application/MyApplication.java @@ -12,6 +12,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; +import com.blankj.utilcode.util.AppUtils; import com.blankj.utilcode.util.ToastUtils; import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.Permission; @@ -93,10 +94,11 @@ public class MyApplication extends Application { .setServer(new RequestServer()) // 设置请求处理策略 .setHandler(new RequestHandler(this)) - .addHeader("client", "IPTV") + .addHeader("client", "iptv") + .addHeader("cur_version", AppUtils.getAppVersionName()) // 添加全局请求参数 //.addParam("token", "6666666") - // 添加全局请求头 + // 添加全局请求头ho .addHeader("Content-Type", "application/json;charset=UTF-8") .into(); //zxing初始化 diff --git a/app/src/main/res/drawable/bg_custom_update.png b/app/src/main/res/drawable/bg_custom_update.png new file mode 100644 index 0000000..98aaef4 Binary files /dev/null and b/app/src/main/res/drawable/bg_custom_update.png differ diff --git a/app/src/main/res/drawable/bg_focus_6.xml b/app/src/main/res/drawable/bg_focus_6.xml new file mode 100644 index 0000000..31f5624 --- /dev/null +++ b/app/src/main/res/drawable/bg_focus_6.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_focus_selector_6.xml b/app/src/main/res/drawable/bg_focus_selector_6.xml new file mode 100644 index 0000000..176307f --- /dev/null +++ b/app/src/main/res/drawable/bg_focus_selector_6.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_update_bg.xml b/app/src/main/res/drawable/btn_update_bg.xml new file mode 100644 index 0000000..668ed68 --- /dev/null +++ b/app/src/main/res/drawable/btn_update_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_close.png b/app/src/main/res/drawable/ic_close.png new file mode 100644 index 0000000..225d19f Binary files /dev/null and b/app/src/main/res/drawable/ic_close.png differ diff --git a/app/src/main/res/drawable/ic_version_close.png b/app/src/main/res/drawable/ic_version_close.png new file mode 100644 index 0000000..c0b55dd Binary files /dev/null and b/app/src/main/res/drawable/ic_version_close.png differ diff --git a/app/src/main/res/drawable/ic_version_close_choose.png b/app/src/main/res/drawable/ic_version_close_choose.png new file mode 100644 index 0000000..ea4fccb Binary files /dev/null and b/app/src/main/res/drawable/ic_version_close_choose.png differ diff --git a/app/src/main/res/layout/view_custom_version.xml b/app/src/main/res/layout/view_custom_version.xml new file mode 100644 index 0000000..9628533 --- /dev/null +++ b/app/src/main/res/layout/view_custom_version.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + +