--- /dev/null
+{
+ "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
private fun checkRemote() {
App.sHandler.postDelayed({
checkVersion(VersionCheckFrom.BOOT_CHECK)
+
}, Constants.TIME_DELAY_BOOT)
}
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
//升级数据
val otaInfo = MutableLiveData<OtaInfo?>()
+ val testObserver = Transformations.switchMap(otaInfo) { otaInfo ->
+ val mutableLiveData = MutableLiveData<String>()
+ mutableLiveData.value = otaInfo?.versionCode
+ mutableLiveData
+ }
+
//下载进度,百分比
val downloadProgress = MutableLiveData<Int>()
return
}
checkRemote(from)
+ //记录一下更新的时间
+ SPUtil.getSharePreference().edit()
+ .putLong(SPUtil.KEY_CHECK_UPDATE_TIME, System.currentTimeMillis())
+ .apply()
}
/**
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
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
}
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);
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() {
//检查一下网络更新
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?) {
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"
<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