Apply it to the Launcher clock / date display

This commit is contained in:
Finn M Glas 2020-08-17 13:41:35 +02:00
parent 86e9f9c597
commit 32ca93fce1
No known key found for this signature in database
GPG key ID: 902A30146014DFBF
4 changed files with 22 additions and 3 deletions

View file

@ -105,8 +105,13 @@ class HomeActivity: UIObject, AppCompatActivity(),
if (home_background_image != null && getSavedTheme(this) == "custom") if (home_background_image != null && getSavedTheme(this) == "custom")
home_background_image.setImageBitmap(background) home_background_image.setImageBitmap(background)
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) // Applying the date / time format (changeable in settings)
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault()) val dFormat = launcherPreferences.getInt(PREF_DATE_FORMAT, 0)
val upperFMT = resources.getStringArray(R.array.settings_time_formats_upper)
val lowerFMT = resources.getStringArray(R.array.settings_time_formats_lower)
val dateFormat = SimpleDateFormat(upperFMT[dFormat], Locale.getDefault())
val timeFormat = SimpleDateFormat(lowerFMT[dFormat], Locale.getDefault())
clockTimer = fixedRateTimer("clockTimer", true, 0L, 100) { clockTimer = fixedRateTimer("clockTimer", true, 0L, 100) {
this@HomeActivity.runOnUiThread { this@HomeActivity.runOnUiThread {

View file

@ -185,7 +185,6 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
settings_launcher_format_spinner.setSelection(launcherPreferences.getInt(PREF_DATE_FORMAT, 0)) settings_launcher_format_spinner.setSelection(launcherPreferences.getInt(PREF_DATE_FORMAT, 0))
settings_launcher_format_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { settings_launcher_format_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
launcherPreferences.edit() launcherPreferences.edit()

View file

@ -153,6 +153,7 @@
android:id="@+id/settings_launcher_format_spinner" android:id="@+id/settings_launcher_format_spinner"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:entries="@array/settings_launcher_time_formats"
android:spinnerMode="dropdown" android:spinnerMode="dropdown"
app:layout_constraintBottom_toBottomOf="@id/settings_launcher_text_time_format" app:layout_constraintBottom_toBottomOf="@id/settings_launcher_text_time_format"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View file

@ -58,6 +58,20 @@
<item>german</item> <item>german</item>
</string-array> </string-array>
<string-array name="settings_time_formats_upper">
<item>yyyy-MM-dd</item>
<item>HH:mm:ss</item>
<item>HH:mm:ss</item>
<item>HH:mm:ss</item>
</string-array>
<string-array name="settings_time_formats_lower">
<item>HH:mm:ss</item>
<item>yyyy-MM-dd</item>
<item> </item>
<item>dd.MM.yyyy</item>
</string-array>
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#en</string> <string name="settings_footer_repo">https://github.com/finnmglas/Launcher#en</string>
<string name="settings_footer_web">https://www.finnmglas.com</string> <string name="settings_footer_web">https://www.finnmglas.com</string>