mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
Merge pull request #64 from finnmglas/feature/date-formats
Feature/date formats
This commit is contained in:
commit
8f731969a6
7 changed files with 97 additions and 7 deletions
|
@ -56,6 +56,7 @@ const val PREF_WALLPAPER = "background_uri"
|
|||
const val PREF_THEME = "theme"
|
||||
|
||||
const val PREF_SCREEN_TIMEOUT_DISABLED = "disableTimeout"
|
||||
const val PREF_DATE_FORMAT = "dateFormat"
|
||||
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
|
||||
|
||||
const val PREF_STARTED = "startedBefore"
|
||||
|
|
|
@ -105,8 +105,13 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
if (home_background_image != null && getSavedTheme(this) == "custom")
|
||||
home_background_image.setImageBitmap(background)
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||
// Applying the date / time format (changeable in settings)
|
||||
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) {
|
||||
this@HomeActivity.runOnUiThread {
|
||||
|
|
|
@ -7,16 +7,20 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.util.DisplayMetrics
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.palette.graphics.Palette
|
||||
import com.finnmglas.launcher.*
|
||||
import com.finnmglas.launcher.settings.intendedSettingsPause
|
||||
import kotlinx.android.synthetic.main.settings_theme.*
|
||||
import kotlinx.android.synthetic.main.settings_launcher.*
|
||||
|
||||
|
||||
/**
|
||||
* The [SettingsFragmentLauncher] is a used as a tab in the SettingsActivity.
|
||||
|
@ -29,7 +33,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.settings_theme, container, false)
|
||||
return inflater.inflate(R.layout.settings_launcher, container, false)
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
@ -170,5 +174,27 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
// visually load settings
|
||||
settings_launcher_switch_screen_timeout.isChecked =
|
||||
launcherPreferences.getBoolean(PREF_SCREEN_TIMEOUT_DISABLED, false)
|
||||
|
||||
// Load values into the date-format spinner
|
||||
val staticAdapter = ArrayAdapter.createFromResource(
|
||||
activity!!, R.array.settings_launcher_time_formats,
|
||||
android.R.layout.simple_spinner_item )
|
||||
|
||||
staticAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
settings_launcher_format_spinner.adapter = staticAdapter
|
||||
|
||||
settings_launcher_format_spinner.setSelection(launcherPreferences.getInt(PREF_DATE_FORMAT, 0))
|
||||
|
||||
settings_launcher_format_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
launcherPreferences.edit()
|
||||
.putInt(PREF_DATE_FORMAT, position)
|
||||
.apply()
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,8 +18,8 @@
|
|||
android:id="@+id/settings_theme_scroller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/settings_launcher_text_screen_timeout"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/settings_launcher_text_time_format"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
@ -139,6 +139,26 @@
|
|||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_launcher_text_time_format"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:text="@string/settings_launcher_time_format"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/settings_launcher_text_screen_timeout"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/settings_launcher_format_spinner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/settings_launcher_time_formats"
|
||||
android:spinnerMode="dropdown"
|
||||
app:layout_constraintBottom_toBottomOf="@id/settings_launcher_text_time_format"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/settings_launcher_text_time_format" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_launcher_text_screen_timeout"
|
||||
android:layout_width="wrap_content"
|
|
@ -42,6 +42,14 @@
|
|||
<string name="settings_select_image">Bild ändern</string>
|
||||
|
||||
<string name="settings_launcher_disable_timeout">Bildschirm wach halten</string>
|
||||
<string name="settings_launcher_time_format">Datumsformat</string>
|
||||
|
||||
<string-array name="settings_launcher_time_formats">
|
||||
<item>Standard</item>
|
||||
<item>Invertiert</item>
|
||||
<item>Uhrzeit</item>
|
||||
<item>Deutsch</item>
|
||||
</string-array>
|
||||
|
||||
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#de</string>
|
||||
<string name="settings_footer_web">https://www.finnmglas.com/de/</string>
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
<string name="settings_select_image">Changer Image</string>
|
||||
<string name="settings_theme_examples">Examples</string>
|
||||
<string name="settings_launcher_disable_timeout">Gardez l\'écran allumé</string>
|
||||
<string name="settings_launcher_time_format">Format de date</string>
|
||||
|
||||
<string-array name="settings_launcher_time_formats">
|
||||
<item>Défaut</item>
|
||||
<item>Inversé</item>
|
||||
<item>Temps</item>
|
||||
<item>Allemand</item>
|
||||
</string-array>
|
||||
|
||||
<string name="settings_footer_web">https://www.finnmglas.com/fr/</string>
|
||||
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher</string>
|
||||
|
|
|
@ -49,6 +49,28 @@
|
|||
<string name="settings_select_image">Change Image</string>
|
||||
<string name="settings_theme_examples">Examples</string>
|
||||
<string name="settings_launcher_disable_timeout">Keep screen on</string>
|
||||
<string name="settings_launcher_time_format">Date format</string>
|
||||
|
||||
<string-array name="settings_launcher_time_formats">
|
||||
<item>Default</item>
|
||||
<item>Inverse</item>
|
||||
<item>Time only</item>
|
||||
<item>German</item>
|
||||
</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_web">https://www.finnmglas.com</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue