Allow setting a preferred date format (#2175)
This commit is contained in:
@@ -9,6 +9,8 @@ import android.view.View
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.updater.UpdateChecker
|
||||
import eu.kanade.tachiyomi.data.updater.UpdateResult
|
||||
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
||||
@@ -20,11 +22,11 @@ import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.DateFormat
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
import java.util.*
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
|
||||
class SettingsAboutController : SettingsController() {
|
||||
@@ -34,6 +36,11 @@ class SettingsAboutController : SettingsController() {
|
||||
*/
|
||||
private val updateChecker by lazy { UpdateChecker.getUpdateChecker() }
|
||||
|
||||
|
||||
private val userPreferences: PreferencesHelper by injectLazy()
|
||||
|
||||
val dateFormat: DateFormat = userPreferences.dateFormat().getOrDefault()
|
||||
|
||||
/**
|
||||
* The subscribtion service of the obtained release object
|
||||
*/
|
||||
@@ -179,13 +186,15 @@ class SettingsAboutController : SettingsController() {
|
||||
try {
|
||||
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|
||||
inputDf.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val date = inputDf.parse(BuildConfig.BUILD_TIME)
|
||||
val buildTime = inputDf.parse(BuildConfig.BUILD_TIME)
|
||||
|
||||
val outputDf = DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
|
||||
outputDf.timeZone = TimeZone.getDefault()
|
||||
|
||||
return outputDf.format(date)
|
||||
val date = dateFormat.format(buildTime)
|
||||
val time = DateFormat.getTimeInstance(DateFormat.SHORT).format(buildTime)
|
||||
return "$date $time"
|
||||
} catch (e: ParseException) {
|
||||
return BuildConfig.BUILD_TIME
|
||||
}
|
||||
|
||||
@@ -33,6 +33,20 @@ class SettingsGeneralController : SettingsController() {
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key= Keys.dateFormat
|
||||
titleRes = R.string.pref_date_format
|
||||
entryValues= arrayOf("", "MM/dd/yy", "dd/MM/yy", "yyyy-MM-dd")
|
||||
entries = entryValues.map { value ->
|
||||
if (value == "") {
|
||||
context.getString(R.string.system_default)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
}.toTypedArray()
|
||||
defaultValue = ""
|
||||
summary= "%s"
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.theme
|
||||
titleRes = R.string.pref_theme
|
||||
|
||||
Reference in New Issue
Block a user