added customization preference
parent
c03a002448
commit
912857c9cd
|
|
@ -1,6 +1,7 @@
|
|||
package fr.forum_thalie.tsumugi
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import fr.forum_thalie.tsumugi.preferences.*
|
||||
|
||||
|
||||
|
|
@ -38,4 +39,15 @@ class ParametersActivity : BaseActivity() {
|
|||
.replace(R.id.parameters_host_container, fragmentToLoad)
|
||||
.commit()
|
||||
}
|
||||
|
||||
// Make the Up button function as back instead of always bringing us to the main activity
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package fr.forum_thalie.tsumugi.preferences
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.preference.*
|
||||
import fr.forum_thalie.tsumugi.R
|
||||
|
|
@ -40,5 +37,25 @@ class CustomizeFragment : PreferenceFragmentCompat() {
|
|||
true
|
||||
}
|
||||
|
||||
|
||||
val fetchPeriod = preferenceScreen.findPreference<ListPreference>("fetchPeriod")
|
||||
fetchPeriod?.summaryProvider = ListPreference.SimpleSummaryProvider.getInstance()
|
||||
fetchPeriod?.setOnPreferenceChangeListener { _, newValue ->
|
||||
val builder1 = AlertDialog.Builder(context!!)
|
||||
if (Integer.parseInt(newValue as String) == 0)
|
||||
builder1.setMessage(R.string.restart_the_app)
|
||||
else
|
||||
builder1.setMessage(R.string.restart_the_app)
|
||||
builder1.setCancelable(true)
|
||||
|
||||
builder1.setPositiveButton("Close" ) { dialog, _ ->
|
||||
dialog.cancel()
|
||||
}
|
||||
|
||||
val alert11 = builder1.create()
|
||||
alert11.show()
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="snoozeValues">
|
||||
<item name="0">@string/disable</item>
|
||||
<item name="1">1</item>
|
||||
<item name="2">2</item>
|
||||
<item name="5">5</item>
|
||||
<item name="10">10</item>
|
||||
<item name="15">15</item>
|
||||
<item name="20">20</item>
|
||||
<item name="25">25</item>
|
||||
<item name="30">30</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="fetchPeriodString">
|
||||
<item name="5">Toutes les 5 secondes (mise à jour rapide)</item>
|
||||
<item name="10">Toutes les 10 secondes</item>
|
||||
<item name="15">Toutes les 15 secondes</item>
|
||||
<item name="20">Toutes les 20 secondes</item>
|
||||
<item name="30">Toutes les 30 secondes (moins d\'utilisation de batterie)</item>
|
||||
</string-array>
|
||||
<string-array name="fetchPeriodValues">
|
||||
<item name="5">5</item>
|
||||
<item name="10">10</item>
|
||||
<item name="15">15</item>
|
||||
<item name="20">20</item>
|
||||
<item name="30">30</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
@ -50,5 +50,6 @@
|
|||
<string name="sleepClosesApp">Minuterie avant fermeture de l\'application</string>
|
||||
<string name="setSleepDuration">Choisir une durée (en minutes)</string>
|
||||
<string name="willCloseIn">Extinction dans %1$d minutes</string>
|
||||
<string name="fetchPeriod">Choisir la fréquence de mise à jour quand la radio est stoppée</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -13,4 +13,19 @@
|
|||
<item name="30">30</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="fetchPeriodString">
|
||||
<item name="5">Every 5 seconds (faster update)</item>
|
||||
<item name="10">Every 10 seconds</item>
|
||||
<item name="15">Every 15 seconds</item>
|
||||
<item name="20">Every 20 seconds</item>
|
||||
<item name="30">Every 30 seconds (less battery-intensive)</item>
|
||||
</string-array>
|
||||
<string-array name="fetchPeriodValues">
|
||||
<item name="5">5</item>
|
||||
<item name="10">10</item>
|
||||
<item name="15">15</item>
|
||||
<item name="20">20</item>
|
||||
<item name="30">30</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
@ -70,5 +70,6 @@
|
|||
<string name="sleepClosesApp">Sleep - close app after some time</string>
|
||||
<string name="setSleepDuration">Set duration (minutes)</string>
|
||||
<string name="willCloseIn">Will close in %1$d minutes</string>
|
||||
<string name="fetchPeriod">Set update period when stopped</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -29,4 +29,14 @@
|
|||
app:defaultValue="false"
|
||||
/>
|
||||
|
||||
<ListPreference
|
||||
app:key="fetchPeriod"
|
||||
app:iconSpaceReserved="false"
|
||||
android:title="@string/fetchPeriod"
|
||||
app:singleLineTitle="false"
|
||||
android:entries="@array/fetchPeriodString"
|
||||
android:entryValues="@array/fetchPeriodValues"
|
||||
android:defaultValue="10"
|
||||
/>
|
||||
|
||||
</PreferenceScreen>
|
||||
Loading…
Reference in New Issue