|
@@ -1,16 +1,10 @@
|
|
|
package eu.kanade.tachiyomi.ui.more
|
|
|
|
|
|
-import android.app.Dialog
|
|
|
-import android.os.Bundle
|
|
|
-import androidx.core.os.bundleOf
|
|
|
import androidx.preference.PreferenceScreen
|
|
|
-import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
|
import eu.kanade.tachiyomi.BuildConfig
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
-import eu.kanade.tachiyomi.data.updater.GithubUpdateChecker
|
|
|
-import eu.kanade.tachiyomi.data.updater.GithubUpdateResult
|
|
|
-import eu.kanade.tachiyomi.data.updater.UpdaterService
|
|
|
-import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
|
|
+import eu.kanade.tachiyomi.data.updater.AppUpdateChecker
|
|
|
+import eu.kanade.tachiyomi.data.updater.AppUpdateResult
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
|
@@ -33,12 +27,10 @@ import java.util.TimeZone
|
|
|
|
|
|
class AboutController : SettingsController(), NoToolbarElevationController {
|
|
|
|
|
|
- private val updateChecker by lazy { GithubUpdateChecker() }
|
|
|
+ private val updateChecker by lazy { AppUpdateChecker() }
|
|
|
|
|
|
private val dateFormat: DateFormat = preferences.dateFormat()
|
|
|
|
|
|
- private val isUpdaterEnabled = BuildConfig.INCLUDE_UPDATER
|
|
|
-
|
|
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
|
|
titleRes = R.string.pref_category_about
|
|
|
|
|
@@ -60,7 +52,7 @@ class AboutController : SettingsController(), NoToolbarElevationController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (isUpdaterEnabled) {
|
|
|
+ if (BuildConfig.INCLUDE_UPDATER) {
|
|
|
preference {
|
|
|
key = "pref_about_check_for_updates"
|
|
|
titleRes = R.string.check_for_updates
|
|
@@ -103,14 +95,10 @@ class AboutController : SettingsController(), NoToolbarElevationController {
|
|
|
launchNow {
|
|
|
try {
|
|
|
when (val result = updateChecker.checkForUpdate()) {
|
|
|
- is GithubUpdateResult.NewUpdate -> {
|
|
|
- val body = result.release.info
|
|
|
- val url = result.release.getDownloadLink()
|
|
|
-
|
|
|
- // Create confirmation window
|
|
|
- NewUpdateDialogController(body, url).showDialog(router)
|
|
|
+ is AppUpdateResult.NewUpdate -> {
|
|
|
+ NewUpdateDialogController(result).showDialog(router)
|
|
|
}
|
|
|
- is GithubUpdateResult.NoNewUpdate -> {
|
|
|
+ is AppUpdateResult.NoNewUpdate -> {
|
|
|
activity?.toast(R.string.update_check_no_new_updates)
|
|
|
}
|
|
|
}
|
|
@@ -121,34 +109,6 @@ class AboutController : SettingsController(), NoToolbarElevationController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) {
|
|
|
-
|
|
|
- constructor(body: String, url: String) : this(
|
|
|
- bundleOf(BODY_KEY to body, URL_KEY to url)
|
|
|
- )
|
|
|
-
|
|
|
- override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
|
|
- return MaterialAlertDialogBuilder(activity!!)
|
|
|
- .setTitle(R.string.update_check_notification_update_available)
|
|
|
- .setMessage(args.getString(BODY_KEY) ?: "")
|
|
|
- .setPositiveButton(R.string.update_check_confirm) { _, _ ->
|
|
|
- val appContext = applicationContext
|
|
|
- if (appContext != null) {
|
|
|
- // Start download
|
|
|
- val url = args.getString(URL_KEY) ?: ""
|
|
|
- UpdaterService.start(appContext, url)
|
|
|
- }
|
|
|
- }
|
|
|
- .setNegativeButton(R.string.update_check_ignore, null)
|
|
|
- .create()
|
|
|
- }
|
|
|
-
|
|
|
- private companion object {
|
|
|
- const val BODY_KEY = "NewUpdateDialogController.body"
|
|
|
- const val URL_KEY = "NewUpdateDialogController.key"
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private fun getFormattedBuildTime(): String {
|
|
|
return try {
|
|
|
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|