Skip to content

Commit

Permalink
Replacing reschedule with Set due date
Browse files Browse the repository at this point in the history
  • Loading branch information
Giyutomioka-SS authored and mikehardy committed May 30, 2024
1 parent 10ae201 commit b0de535
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/
package com.ichi2.anki.preferences

import com.ichi2.anki.CollectionManager.TR
import com.ichi2.anki.R
import com.ichi2.anki.cardviewer.ViewerCommand
import com.ichi2.anki.reviewer.MappableBinding.Companion.toPreferenceString
import com.ichi2.anki.ui.internationalization.toSentenceCase
import com.ichi2.annotations.NeedsTest
import com.ichi2.preferences.ControlPreference

Expand All @@ -36,5 +38,13 @@ class ControlsSettingsFragment : SettingsFragment() {
.filterIsInstance<ControlPreference>()
.filter { pref -> pref.value == null }
.forEach { pref -> pref.value = commands[pref.key]?.defaultValue?.toPreferenceString() }

setDynamicTitle()
}

private fun setDynamicTitle() {
findPreference<ControlPreference>(getString(R.string.reschedule_command_key))?.let {
it.title = TR.actionsSetDueDate().toSentenceCase(R.string.sentence_set_due_date)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit
import androidx.preference.Preference
import com.ichi2.anki.CollectionManager.TR
import com.ichi2.anki.R
import com.ichi2.anki.ui.internationalization.toSentenceCase
import com.ichi2.utils.*

class CustomButtonsSettingsFragment : SettingsFragment() {
Expand Down Expand Up @@ -50,6 +52,13 @@ class CustomButtonsSettingsFragment : SettingsFragment() {
}
true
}
setDynamicTitle()
}

private fun setDynamicTitle() {
findPreference<Preference>(getString(R.string.custom_button_schedule_card_key))?.let {
it.title = TR.actionsSetDueDate().toSentenceCase(R.string.sentence_set_due_date)
}
}

@VisibleForTesting(otherwise = VisibleForTesting.NONE)
Expand Down
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/res/xml/preferences_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<!-- Key com.ichi2.ui.BindingPreferences -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/pref_cat_controls"
android:key="@string/pref_controls_screen_key">

Expand Down Expand Up @@ -128,7 +129,7 @@
/>
<com.ichi2.preferences.ControlPreference
android:key="@string/reschedule_command_key"
android:title="@string/card_editor_reschedule_card"
tools:title="Set due date"
android:icon="@drawable/ic_reschedule"
/>
<com.ichi2.preferences.ControlPreference
Expand Down
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/res/xml/preferences_custom_buttons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TODO: Add a unit test
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/custom_buttons"
android:key="@string/pref_app_bar_buttons_screen_key">
<Preference
Expand All @@ -52,7 +53,7 @@ TODO: Add a unit test
android:entries="@array/custom_button_labels"
android:entryValues="@array/custom_button_values"
android:key="@string/custom_button_schedule_card_key"
android:title="@string/card_editor_reschedule_card"
tools:title="Set due date"
app:useSimpleSummaryProvider="true"/>
<ListPreference
android:defaultValue="2"
Expand Down

0 comments on commit b0de535

Please sign in to comment.