Skip to content

Commit 1c6d7e3

Browse files
ericli3690lukstbit
authored andcommitted
feat(reminders): show placeholder for zero review reminders
GSoC 2025: Review Reminders If there are no review reminders, show a placeholder icon and text which says "You have no review reminders" in ScheduleReminders. Added a new outline_notifications_off_24 icon for this, obtained from the vector assets library. In adding it to fragment_schedule_reminders, I tried my best to copy the formatting of DeckPicker's XML file (i.e., I used a LinearLayout nested inside a FrameLayout, etc.) Added two lines to ScheduleReminders's `triggerUIUpdate` to enable the placeholder visual if the adapter is displaying no review reminders.
1 parent ef468ce commit 1c6d7e3

4 files changed

Lines changed: 55 additions & 15 deletions

File tree

AnkiDroid/src/main/java/com/ichi2/anki/reviewreminders/ScheduleReminders.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import android.content.Context
2020
import android.content.Intent
2121
import android.os.Bundle
2222
import android.view.View
23+
import android.widget.LinearLayout
2324
import android.widget.TextView
2425
import androidx.appcompat.app.AppCompatActivity
2526
import androidx.core.os.BundleCompat
27+
import androidx.core.view.isVisible
2628
import androidx.fragment.app.Fragment
2729
import androidx.fragment.app.setFragmentResult
2830
import androidx.fragment.app.setFragmentResultListener
@@ -376,14 +378,16 @@ class ScheduleReminders :
376378

377379
/**
378380
* Trigger a RecyclerView UI update for ScheduleReminders.
381+
* If there are no reminders to display, show the "No Reminders" placeholder icon and text.
379382
*/
380383
private fun triggerUIUpdate() {
381-
adapter.submitList(
384+
val listToDisplay =
382385
reminders
383386
.values
384387
.sortedBy { it.time.toSecondsFromMidnight() }
385-
.toList(),
386-
)
388+
.toList()
389+
adapter.submitList(listToDisplay)
390+
view?.findViewById<LinearLayout>(R.id.no_reminders_placeholder)?.isVisible = listToDisplay.isEmpty()
387391
}
388392

389393
companion object {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?attr/colorControlNormal" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
2+
3+
<path android:fillColor="@android:color/white" android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zM12,6.5c2.49,0 4,2.02 4,4.5v0.1l2,2L18,11c0,-3.07 -1.63,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68c-0.24,0.06 -0.47,0.15 -0.69,0.23l1.64,1.64c0.18,-0.02 0.36,-0.05 0.55,-0.05zM5.41,3.35L4,4.76l2.81,2.81C6.29,8.57 6,9.74 6,11v5l-2,2v1h14.24l1.74,1.74 1.41,-1.41L5.41,3.35zM16,17L8,17v-6c0,-0.68 0.12,-1.32 0.34,-1.9L16,16.76L16,17z"/>
4+
5+
</vector>

AnkiDroid/src/main/res/layout/fragment_schedule_reminders.xml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,49 @@
2121
android:background="@drawable/browser_heading_bottom_divider"
2222
app:navigationIcon="?attr/homeAsUpIndicator" />
2323

24-
<androidx.recyclerview.widget.RecyclerView
25-
android:id="@+id/schedule_reminders_recycler_view"
24+
<FrameLayout
2625
android:layout_width="match_parent"
27-
android:layout_height="match_parent"
28-
android:background="?android:attr/colorBackground"
29-
android:overScrollFooter="@color/transparent"
30-
android:clipToPadding="false"
31-
android:drawSelectorOnTop="true"
32-
android:paddingBottom="84dp"
33-
android:scrollbars="vertical"
34-
android:contentDescription="List of scheduled review reminders"
35-
tools:listitem="@layout/schedule_reminders_list_item"
36-
tools:ignore="HardcodedText" />
26+
android:layout_height="match_parent">
27+
28+
<androidx.recyclerview.widget.RecyclerView
29+
android:id="@+id/schedule_reminders_recycler_view"
30+
android:layout_width="match_parent"
31+
android:layout_height="match_parent"
32+
android:background="?android:attr/colorBackground"
33+
android:overScrollFooter="@color/transparent"
34+
android:clipToPadding="false"
35+
android:drawSelectorOnTop="true"
36+
android:paddingBottom="84dp"
37+
android:scrollbars="vertical"
38+
android:contentDescription="List of scheduled review reminders"
39+
tools:listitem="@layout/schedule_reminders_list_item"
40+
tools:ignore="HardcodedText" />
41+
42+
<LinearLayout
43+
android:id="@+id/no_reminders_placeholder"
44+
android:layout_width="match_parent"
45+
android:layout_height="match_parent"
46+
android:gravity="center_vertical"
47+
android:orientation="vertical">
48+
49+
<ImageView
50+
android:layout_width="96dp"
51+
android:layout_height="96dp"
52+
android:layout_marginBottom="24dp"
53+
android:layout_gravity="center_horizontal"
54+
app:srcCompat="@drawable/outline_notifications_off_24" />
55+
56+
<com.ichi2.ui.FixedTextView
57+
android:layout_width="match_parent"
58+
android:layout_height="wrap_content"
59+
android:layout_marginBottom="8dp"
60+
android:gravity="center"
61+
android:text="@string/you_have_no_review_reminders"
62+
style="@style/TextAppearance.AppCompat.Medium" />
63+
64+
</LinearLayout>
65+
66+
</FrameLayout>
3767

3868
</LinearLayout>
3969

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
<string name="add_reminder" comment="Label for the add reminder button in the screen for adding and editing review reminders">Add reminder</string>
224224
<string name="add_review_reminder" comment="Title of the screen for creating a new review reminder">Add review reminder</string>
225225
<string name="edit_review_reminder" comment="Title of the screen for editing an existing review reminder">Edit review reminder</string>
226+
<string name="you_have_no_review_reminders" comment="Text that appears in the review reminder editing screen when there are no reminders set">You have no review reminders</string>
226227

227228
<!-- studyoptions -->
228229
<string name="studyoptions_limit_select_tags">Select tags</string>

0 commit comments

Comments
 (0)