Skip to content

Commit 36fd5fe

Browse files
committed
feat(new study screen): statistics command/menu action
it improves the ecosystem compatibility. It also reduces any kind of complaints related to the new study screen not using a navigation drawer like the old one did
1 parent 3646217 commit 36fd5fe

File tree

8 files changed

+49
-2
lines changed

8 files changed

+49
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2025 Brayan Oliveira <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation; either version 3 of the License, or (at your option) any later
7+
* version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
package com.ichi2.anki.pages
17+
18+
import android.content.Context
19+
import android.content.Intent
20+
import com.ichi2.anki.utils.Destination
21+
22+
class StatisticsDestination : Destination {
23+
override fun toIntent(context: Context): Intent = PageFragment.getIntent(context, "graphs", null, Statistics::class)
24+
}

AnkiDroid/src/main/java/com/ichi2/anki/preferences/ControlsSettingsFragment.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.ichi2.anki.CollectionManager.TR
2525
import com.ichi2.anki.R
2626
import com.ichi2.anki.cardviewer.ViewerCommand
2727
import com.ichi2.anki.common.annotations.NeedsTest
28+
import com.ichi2.anki.preferences.reviewer.ViewerAction
2829
import com.ichi2.anki.previewer.PreviewerAction
2930
import com.ichi2.anki.reviewer.MappableAction
3031
import com.ichi2.anki.reviewer.MappableBinding.Companion.toPreferenceString
@@ -135,6 +136,13 @@ class ControlsSettingsFragment :
135136
val key = getString(keyRes)
136137
findPreference<Preference>(key)?.isVisible = false
137138
}
139+
requirePreference<ControlPreference>(R.string.statistics_command_key).apply {
140+
title = TR.statisticsTitle()
141+
isVisible = true
142+
if (value == null) {
143+
value = ViewerAction.STATISTICS.getBindings(sharedPrefs()).toPreferenceString()
144+
}
145+
}
138146
}
139147

140148
companion object {

AnkiDroid/src/main/java/com/ichi2/anki/preferences/reviewer/ViewerAction.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum class ViewerAction(
6464
DELETE(R.id.action_delete, R.drawable.ic_delete_white, R.string.menu_delete_note, MENU_ONLY),
6565

6666
// Disabled
67+
STATISTICS(R.id.action_statistics, R.drawable.ic_bar_chart_black, R.string.empty_string, DISABLED),
6768
DECK_OPTIONS(R.id.action_deck_options, R.drawable.ic_tune_white, R.string.menu__deck_options, DISABLED),
6869
CARD_INFO(R.id.action_card_info, R.drawable.ic_dialog_info, R.string.card_info_title, DISABLED),
6970
ADD_NOTE(R.id.action_add_note, R.drawable.ic_add, R.string.menu_add_note, DISABLED),
@@ -137,6 +138,7 @@ enum class ViewerAction(
137138
SHOW_ALL_HINTS -> listOf(keycode(KeyEvent.KEYCODE_G))
138139
RECORD_VOICE -> listOf(keycode(KeyEvent.KEYCODE_V, shift()))
139140
REPLAY_VOICE -> listOf(keycode(KeyEvent.KEYCODE_V))
141+
STATISTICS -> listOf(keycode(KeyEvent.KEYCODE_T))
140142
TOGGLE_FLAG_RED ->
141143
listOf(
142144
keycode(KeyEvent.KEYCODE_1, ctrl()),
@@ -237,6 +239,7 @@ enum class ViewerAction(
237239

238240
fun title(context: Context): String =
239241
when (this) {
242+
STATISTICS -> TR.statisticsTitle()
240243
RESCHEDULE_NOTE -> TR.actionsSetDueDate().toSentenceCase(context, R.string.sentence_set_due_date)
241244
else -> context.getString(titleRes)
242245
}

AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import com.ichi2.anki.observability.undoableOp
4444
import com.ichi2.anki.pages.AnkiServer
4545
import com.ichi2.anki.pages.CardInfoDestination
4646
import com.ichi2.anki.pages.DeckOptionsDestination
47+
import com.ichi2.anki.pages.StatisticsDestination
4748
import com.ichi2.anki.preferences.reviewer.ViewerAction
4849
import com.ichi2.anki.previewer.CardViewerViewModel
4950
import com.ichi2.anki.previewer.TypeAnswer
@@ -672,6 +673,7 @@ class ReviewerViewModel :
672673
ViewerAction.USER_ACTION_9 -> userAction(9)
673674
ViewerAction.SUSPEND_MENU -> suspendCard()
674675
ViewerAction.BURY_MENU -> buryCard()
676+
ViewerAction.STATISTICS -> destinationFlow.emit(StatisticsDestination())
675677
ViewerAction.FLAG_MENU -> {}
676678
}
677679
}

AnkiDroid/src/main/res/drawable/ic_bar_chart_black.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
android:width="24dp"
2424
android:height="24dp"
2525
android:viewportWidth="24"
26-
android:viewportHeight="24">
26+
android:viewportHeight="24"
27+
android:tint="?colorControlNormal"
28+
>
2729
<path
28-
android:fillColor="#FF000000"
30+
android:fillColor="#FFFFFF"
2931
android:pathData="M5,13.2h3L8,19L5,19zM10.6,5h2.8v14h-2.8zM16.2,9L19,9v10h-2.8z"/>
3032
</vector>

AnkiDroid/src/main/res/values/ids.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<item type="id" name="action_toggle_auto_advance"/>
4242
<item type="id" name="action_record_voice"/>
4343
<item type="id" name="action_set_due_date"/>
44+
<item type="id" name="action_statistics"/>
4445

4546
<item type="id" name="user_action_1"/>
4647
<item type="id" name="user_action_2"/>

AnkiDroid/src/main/res/values/preferences.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<string name="remove_flag_command_key">binding_UNSET_FLAG</string>
123123
<string name="page_up_command_key">binding_PAGE_UP</string>
124124
<string name="page_down_command_key">binding_PAGE_DOWN</string>
125+
<string name="statistics_command_key">binding_STATISTICS</string>
125126
<string name="tag_command_key">binding_TAG</string>
126127
<string name="card_info_command_key">binding_CARD_INFO</string>
127128
<string name="record_voice_command_key">binding_RECORD_VOICE</string>

AnkiDroid/src/main/res/xml/preferences_reviewer_controls.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
android:title="@string/gesture_page_down"
149149
android:icon="@drawable/ic_double_arrow_down"
150150
/>
151+
<com.ichi2.preferences.ReviewerControlPreference
152+
android:key="@string/statistics_command_key"
153+
android:icon="@drawable/ic_bar_chart_black"
154+
app:isPreferenceVisible="false"
155+
tools:title="Statistics"
156+
/>
151157
<com.ichi2.preferences.ReviewerControlPreference
152158
android:key="@string/abort_command_key"
153159
android:title="@string/gesture_abort_learning"

0 commit comments

Comments
 (0)