//如果不为null,弹出一个系统级的dialog,也就是在任何地方都可以弹出的
currentActionState.postValue(
if (result == null) {
+ createNewVersionDialog( "无描述")
//已经是最新版本了
UpdateActionState.LAST_VERSION
} else {
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)
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
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()
//检查一下网络更新
<string name="tips_wifi_connect">Please connect WI-FI</string>
<string name="unsupport_pause_download">Server not support download</string>
<string name="new_version_tips_title">Has new version!</string>
- <string name="local_new_version_tips_title">Tip!</string>
+ <string name="local_new_version_tips_title">Notice!</string>
<string name="local_update_desc_text">Has update in local.</string>
<string name="update_package_not_in_tips_text">No file</string>
<string name="update_result_success_tips">Update success:</string>
<string name="update_failed_tips_text">Update fail!</string>
<string name="update_date_format_text">yyyy-MM-dd HH:mm:ss</string>
<string name="no_update_desc">No update describe...</string>
- <string name="update_tips_title_text">Tip</string>
+ <string name="update_tips_title_text">Notice</string>
+ <string name="update_tips_exit_desc">You need download again after exit continue?</string>
</resources>
\ No newline at end of file
<string name="update_date_format_text">yyyy-MM-dd HH:mm:ss</string>
<string name="no_update_desc">没有更新说明...</string>
<string name="update_tips_title_text">升级提示</string>
+ <string name="update_tips_exit_desc">退出后需要重新下载,是否继续?</string>
</resources>
\ No newline at end of file
<string name="tips_wifi_connect">Please connect WI-FI</string>
<string name="unsupport_pause_download">Server not support download</string>
<string name="new_version_tips_title">Has new version!</string>
- <string name="local_new_version_tips_title">Tip!</string>
+ <string name="local_new_version_tips_title">Notice!</string>
<string name="local_update_desc_text">Has update in local.</string>
<string name="update_package_not_in_tips_text">No file</string>
<string name="update_result_success_tips">Update success:</string>
<string name="update_failed_tips_text">Update fail!</string>
<string name="update_date_format_text">yyyy-MM-dd HH:mm:ss</string>
<string name="no_update_desc">No update describe...</string>
- <string name="update_tips_title_text">Tip</string>
+ <string name="update_tips_title_text">Notice</string>
+ <string name="update_tips_exit_desc">You need download again after exit continue?</string>
</resources>
\ No newline at end of file