From: k.liang Date: Sat, 3 Jul 2021 12:43:15 +0000 (+0800) Subject: 修改升级dialog得大小和下载界面的返回逻辑 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=d6d1df8a9da98c621fd0ee7ef857e9a87f65de30;p=icfotaclient.git 修改升级dialog得大小和下载界面的返回逻辑 --- diff --git a/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt b/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt index fcf28ac..c14e07b 100644 --- a/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt +++ b/app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt @@ -227,6 +227,7 @@ class OtaViewModel : ViewModel() { //如果不为null,弹出一个系统级的dialog,也就是在任何地方都可以弹出的 currentActionState.postValue( if (result == null) { + createNewVersionDialog( "无描述") //已经是最新版本了 UpdateActionState.LAST_VERSION } else { @@ -380,15 +381,15 @@ class OtaViewModel : ViewModel() { val layoutParams = WindowManager.LayoutParams() layoutParams.gravity = Gravity.CENTER layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT - layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT + val screenWidth = manager.defaultDisplay.width + layoutParams.width = screenWidth - 40; layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT layoutParams.alpha = 1.0f layoutParams.packageName = App.sContext.getPackageName() layoutParams.buttonBrightness = 1f layoutParams.windowAnimations = android.R.style.Animation_Dialog - val view: View = - View.inflate(App.sContext, R.layout.dialog_tips, null) + val view: View = View.inflate(App.sContext, R.layout.dialog_tips, null) val descText: TextView = view.findViewById(R.id.description) val titleText: TextView = view.findViewById(R.id.notify) diff --git a/app/src/main/java/com/ic/icfotaclient/view/SystemUpdateActivity.kt b/app/src/main/java/com/ic/icfotaclient/view/SystemUpdateActivity.kt index 265e091..cf26a72 100644 --- a/app/src/main/java/com/ic/icfotaclient/view/SystemUpdateActivity.kt +++ b/app/src/main/java/com/ic/icfotaclient/view/SystemUpdateActivity.kt @@ -1,12 +1,18 @@ package com.ic.icfotaclient.view +import android.content.Context import android.content.Intent import android.os.Bundle import android.text.TextUtils import android.util.Log +import android.view.Gravity import android.view.View +import android.view.WindowManager +import android.widget.Button +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.Observer +import com.ic.icfotaclient.App import com.ic.icfotaclient.R import com.ic.icfotaclient.presenter.OtaService import com.ic.icfotaclient.presenter.OtaViewModel @@ -18,17 +24,45 @@ class SystemUpdateActivity : AppCompatActivity() { override fun onBackPressed() { //不让退出了哇 - val checkNetWork = OtaViewModelCreator.getOtaViewModel(null)?.checkNetWork() + /**val checkNetWork = OtaViewModelCreator.getOtaViewModel(null)?.checkNetWork() val currentActionState = OtaViewModelCreator.getOtaViewModel(null)?.currentActionState val tipsWifiConnect = OtaViewModelCreator.getOtaViewModel(null)?.isTipsWifiConnect - if (checkNetWork != true || - currentActionState?.value == UpdateActionState.LAST_VERSION - || tipsWifiConnect?.value == true - ) { + if (checkNetWork != true || currentActionState?.value == UpdateActionState.LAST_VERSION || tipsWifiConnect?.value == true) { super.onBackPressed() + }*/ + createNewVersionDialog() + } + + private fun createNewVersionDialog() { + val manager = App.sContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager + val layoutParams = WindowManager.LayoutParams() + layoutParams.gravity = Gravity.CENTER + layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT + val screenWidth = windowManager.defaultDisplay.width + layoutParams.width = screenWidth - 40; + layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT + layoutParams.alpha = 1.0f + layoutParams.packageName = App.sContext.getPackageName() + layoutParams.buttonBrightness = 1f + layoutParams.windowAnimations = android.R.style.Animation_Dialog + + val view: View = View.inflate(App.sContext, R.layout.dialog_tips, null) + + val descText: TextView = view.findViewById(R.id.description) + val titleText: TextView = view.findViewById(R.id.notify) + titleText.text = view.context.getString(R.string.update_tips_title_text) + descText.text = view.context.getString(R.string.update_tips_exit_desc) + val yesButton: Button = view.findViewById(R.id.button_ok) as Button + val noButton: Button = view.findViewById(R.id.button_cancel) as Button + yesButton.setOnClickListener { + manager.removeView(view) + finish() } + noButton.setOnClickListener { manager.removeView(view) } + manager.addView(view, layoutParams) } + override fun onResume() { super.onResume() //检查一下网络更新 diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index f30329a..7f7d11d 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -26,7 +26,7 @@ Please connect WI-FI Server not support download Has new version! - Tip! + Notice! Has update in local. No file Update success: @@ -35,5 +35,6 @@ Update fail! yyyy-MM-dd HH:mm:ss No update describe... - Tip + Notice + You need download again after exit continue? \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index c7471b3..ad4467b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -36,4 +36,5 @@ yyyy-MM-dd HH:mm:ss 没有更新说明... 升级提示 + 退出后需要重新下载,是否继续? \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f30329a..7f7d11d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,7 +26,7 @@ Please connect WI-FI Server not support download Has new version! - Tip! + Notice! Has update in local. No file Update success: @@ -35,5 +35,6 @@ Update fail! yyyy-MM-dd HH:mm:ss No update describe... - Tip + Notice + You need download again after exit continue? \ No newline at end of file