fixed tips dialog title.
authorTrillGates <williamtrillgates@gmail.com>
Sat, 20 Mar 2021 11:08:39 +0000 (19:08 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Sat, 20 Mar 2021 11:08:39 +0000 (19:08 +0800)
app/FotaBrand8541e/release/FotaBrand8541e_V1_202103181928_release.apk [new file with mode: 0644]
app/FotaBrand8541e/release/output-metadata.json [new file with mode: 0644]
app/src/main/java/com/ic/icfotaclient/presenter/OtaService.kt
app/src/main/java/com/ic/icfotaclient/presenter/OtaViewModel.kt
app/src/main/java/com/ic/icfotaclient/utils/SPUtil.kt
app/src/main/java/com/ic/icfotaclient/view/SystemUpdateActivity.kt
app/src/main/res/layout/activity_main.xml
app/src/main/res/values/strings.xml

diff --git a/app/FotaBrand8541e/release/FotaBrand8541e_V1_202103181928_release.apk b/app/FotaBrand8541e/release/FotaBrand8541e_V1_202103181928_release.apk
new file mode 100644 (file)
index 0000000..0b41367
Binary files /dev/null and b/app/FotaBrand8541e/release/FotaBrand8541e_V1_202103181928_release.apk differ
diff --git a/app/FotaBrand8541e/release/output-metadata.json b/app/FotaBrand8541e/release/output-metadata.json
new file mode 100644 (file)
index 0000000..aac2068
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "version": 2,
+  "artifactType": {
+    "type": "APK",
+    "kind": "Directory"
+  },
+  "applicationId": "com.ic.icfotaclient",
+  "variantName": "processFotaBrand8541eReleaseResources",
+  "elements": [
+    {
+      "type": "SINGLE",
+      "filters": [],
+      "versionCode": 1,
+      "versionName": "1.0",
+      "outputFile": "FotaBrand8541e_V1_202103181928_release.apk"
+    }
+  ]
+}
\ No newline at end of file
index 8681432..123811f 100644 (file)
@@ -117,6 +117,7 @@ class OtaService : Service(), ViewModelStoreOwner, LifecycleOwner {
     private fun checkRemote() {
         App.sHandler.postDelayed({
             checkVersion(VersionCheckFrom.BOOT_CHECK)
+
         }, Constants.TIME_DELAY_BOOT)
     }
 
index 9f6e828..fcf28ac 100644 (file)
@@ -16,6 +16,7 @@ import android.widget.Button
 import android.widget.TextView
 import android.widget.Toast
 import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.Transformations
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
 import com.ic.icfotaclient.App
@@ -55,6 +56,12 @@ class OtaViewModel : ViewModel() {
     //升级数据
     val otaInfo = MutableLiveData<OtaInfo?>()
 
+    val testObserver = Transformations.switchMap(otaInfo) { otaInfo ->
+        val mutableLiveData = MutableLiveData<String>()
+        mutableLiveData.value = otaInfo?.versionCode
+        mutableLiveData
+    }
+
     //下载进度,百分比
     val downloadProgress = MutableLiveData<Int>()
 
@@ -103,6 +110,10 @@ class OtaViewModel : ViewModel() {
             return
         }
         checkRemote(from)
+        //记录一下更新的时间
+        SPUtil.getSharePreference().edit()
+            .putLong(SPUtil.KEY_CHECK_UPDATE_TIME, System.currentTimeMillis())
+            .apply()
     }
 
     /**
@@ -140,8 +151,7 @@ class OtaViewModel : ViewModel() {
         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 deleteBtn: TextView = view.findViewById(R.id.button_delete)
         deleteBtn.visibility = View.VISIBLE
@@ -379,9 +389,12 @@ class OtaViewModel : ViewModel() {
 
         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)
         if (TextUtils.isEmpty(desc)) {
-            descText.text = "没有更新说明..."
+            descText.text = view.context.getString(R.string.no_update_desc)
         } else {
             descText.text = desc
         }
index d40bf0d..952f4e7 100644 (file)
@@ -10,6 +10,7 @@ object SPUtil {
     const val SP_NAME = "update_record"
     const val KEY_TARGET_VERSION_CODE = "key_target_version_code"
     const val KEY_SERVER_INC = "key_server_inc"
+    const val KEY_CHECK_UPDATE_TIME = "key_check_update_time"
 
     fun getSharePreference(): SharedPreferences {
         return App.sContext.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
index f3c7622..265e091 100644 (file)
@@ -10,11 +10,9 @@ import androidx.lifecycle.Observer
 import com.ic.icfotaclient.R
 import com.ic.icfotaclient.presenter.OtaService
 import com.ic.icfotaclient.presenter.OtaViewModel
-import com.ic.icfotaclient.utils.Constants
-import com.ic.icfotaclient.utils.OtaViewModelCreator
-import com.ic.icfotaclient.utils.UpdateActionState
-import com.ic.icfotaclient.utils.VersionCheckFrom
+import com.ic.icfotaclient.utils.*
 import kotlinx.android.synthetic.main.activity_main.*
+import java.text.SimpleDateFormat
 
 class SystemUpdateActivity : AppCompatActivity() {
 
@@ -36,6 +34,15 @@ class SystemUpdateActivity : AppCompatActivity() {
         //检查一下网络更新
         val otaViewModel = OtaViewModelCreator.getOtaViewModel(null)
         otaViewModel?.checkNetWork()
+        //显示上一次检查更新的时间
+        val lastUpdateTime = SPUtil.getSharePreference().getLong(SPUtil.KEY_CHECK_UPDATE_TIME, 0L)
+        if (lastUpdateTime != 0L) {
+            lastCheckUpdateTime.visibility = View.VISIBLE
+            lastCheckUpdateTime.text =
+                SimpleDateFormat(getString(R.string.update_date_format_text)).format(lastUpdateTime)
+        } else {
+            lastCheckUpdateTime.visibility = View.GONE
+        }
     }
 
     override fun onCreate(savedInstanceState: Bundle?) {
index af9c491..51c344f 100644 (file)
                 app:layout_constraintTop_toTopOf="parent"
                 tools:layout_editor_absoluteX="5dp" />
 
+            <TextView
+                android:layout_width="match_parent"
+                android:id="@+id/lastCheckUpdateTime"
+                android:layout_height="wrap_content" />
+
             <!--current version code.-->
             <TextView
                 android:id="@+id/versionTitle"
index d190326..c7471b3 100644 (file)
@@ -33,4 +33,7 @@
     <string name="update_result_failed_tips">升级结果失败:</string>
     <string name="update_success_tips_text">系统升级成功!</string>
     <string name="update_failed_tips_text">系统升级失败!</string>
+    <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>
 </resources>
\ No newline at end of file