Skip to content

Commit c9db498

Browse files
Okuro3499dogi
andauthored
teams: smoother voices filtering (fixes #12195) (#12197)
Co-authored-by: dogi <dogi@users.noreply.github.com>
1 parent 199aa92 commit c9db498

11 files changed

Lines changed: 72 additions & 14 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "org.ole.planet.myplanet"
1313
minSdk = 26
1414
targetSdk = 36
15-
versionCode = 4984
16-
versionName = "0.49.84"
15+
versionCode = 4985
16+
versionName = "0.49.85"
1717
ndkVersion = '26.3.11579264'
1818
vectorDrawables.useSupportLibrary = true
1919
}

app/src/main/java/org/ole/planet/myplanet/base/BaseRecyclerFragment.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
3636
var gradeLevel = ""
3737
var subjectLevel = ""
3838
lateinit var recyclerView: RecyclerView
39-
lateinit var tvMessage: TextView
39+
var tvMessage: View? = null
4040
lateinit var tvFragmentInfo: TextView
4141
var tvDelete: TextView? = null
4242
var list: MutableList<LI>? = null
@@ -340,8 +340,10 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
340340
private val noDataMessages = mapOf(
341341
"courses" to R.string.no_courses,
342342
"resources" to R.string.no_resources,
343+
"resources_filtered" to R.string.no_results_for_filter,
343344
"finances" to R.string.no_finance_record,
344345
"news" to R.string.no_voices_available,
346+
"news_filtered" to R.string.no_results_for_filter,
345347
"teamCourses" to R.string.no_team_courses,
346348
"teamResources" to R.string.no_team_resources,
347349
"tasks" to R.string.no_tasks,
@@ -362,13 +364,15 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
362364
v.visibility = if (count == 0) View.VISIBLE else View.GONE
363365
val messageRes = noDataMessages[source]
364366
?: R.string.no_data_available_please_check_and_try_again
365-
(v as TextView).setText(messageRes)
367+
val textView = if (v is TextView) v else v.findViewById<TextView>(R.id.tv_empty_message)
368+
textView?.setText(messageRes)
366369
}
367370

368371
fun showNoFilter(v: View?, count: Int) {
369372
v ?: return
370373
v.visibility = if (count == 0) View.VISIBLE else View.GONE
371-
(v as TextView).setText(R.string.no_course_matched_filter)
374+
val textView = if (v is TextView) v else v.findViewById<TextView>(R.id.tv_empty_message)
375+
textView?.setText(R.string.no_course_matched_filter)
372376
}
373377
}
374378
}

app/src/main/java/org/ole/planet/myplanet/ui/voices/VoicesFragment.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ class VoicesFragment : BaseVoicesFragment() {
170170
return "$planetCode@$parentCode"
171171
}
172172

173+
private val currentEmptyStateSource: String
174+
get() = if (etSearch.text.isNotEmpty() || selectedLabel != "All") "news_filtered" else "news"
175+
173176
override fun setData(list: List<RealmNews?>?) {
174177
if (!isAdded || list == null) return
175178

@@ -269,7 +272,7 @@ class VoicesFragment : BaseVoicesFragment() {
269272
} else {
270273
(binding.rvNews.adapter as? VoicesAdapter)?.updateList(list)
271274
}
272-
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, "news") }
275+
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, currentEmptyStateSource) }
273276
}
274277

275278
override fun onNewsItemClick(news: RealmNews?) {
@@ -311,15 +314,15 @@ class VoicesFragment : BaseVoicesFragment() {
311314

312315
private val observer: AdapterDataObserver = object : AdapterDataObserver() {
313316
override fun onChanged() {
314-
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, "news") }
317+
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, currentEmptyStateSource) }
315318
}
316319

317320
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
318-
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, "news") }
321+
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, currentEmptyStateSource) }
319322
}
320323

321324
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
322-
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, "news") }
325+
adapterNews?.let { showNoData(binding.tvMessage, it.itemCount, currentEmptyStateSource) }
323326
}
324327
}
325328

app/src/main/res/layout/fragment_my_library.xml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,35 @@
132132
android:id="@+id/recycler"
133133
android:layout_width="match_parent"
134134
android:layout_height="match_parent" />
135-
<TextView
135+
<LinearLayout
136136
android:id="@+id/tv_message"
137-
android:textColor="@color/daynight_textColor"
138137
android:layout_width="wrap_content"
139138
android:layout_height="wrap_content"
140-
android:layout_gravity="center" />
139+
android:layout_gravity="center"
140+
android:gravity="center"
141+
android:orientation="vertical"
142+
android:padding="24dp"
143+
android:visibility="gone">
144+
145+
<ImageView
146+
android:id="@+id/iv_empty_icon"
147+
android:layout_width="72dp"
148+
android:layout_height="72dp"
149+
android:layout_gravity="center"
150+
android:layout_marginBottom="16dp"
151+
android:alpha="0.4"
152+
android:src="@drawable/ic_folder"
153+
android:tint="@color/daynight_textColor"
154+
android:contentDescription="@null"
155+
android:importantForAccessibility="no" />
156+
<TextView
157+
android:id="@+id/tv_empty_message"
158+
android:layout_width="wrap_content"
159+
android:layout_height="wrap_content"
160+
android:gravity="center"
161+
android:textColor="@color/daynight_textColor"
162+
android:textSize="16sp" />
163+
</LinearLayout>
141164
</FrameLayout>
142165
</LinearLayout>
143166

app/src/main/res/layout/fragment_voices.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,35 @@
139139
android:layout_width="match_parent"
140140
android:layout_height="match_parent"
141141
android:padding="@dimen/padding_normal" />
142-
<TextView
142+
<LinearLayout
143143
android:id="@+id/tv_message"
144144
android:layout_width="wrap_content"
145145
android:layout_height="wrap_content"
146146
android:layout_gravity="center"
147147
android:gravity="center"
148-
android:textColor="@color/daynight_textColor" />
148+
android:orientation="vertical"
149+
android:padding="24dp"
150+
android:visibility="gone">
151+
152+
<ImageView
153+
android:id="@+id/iv_empty_icon"
154+
android:layout_width="72dp"
155+
android:layout_height="72dp"
156+
android:layout_gravity="center"
157+
android:layout_marginBottom="16dp"
158+
android:alpha="0.4"
159+
android:src="@drawable/ic_mic"
160+
android:tint="@color/daynight_textColor"
161+
android:contentDescription="@null"
162+
android:importantForAccessibility="no" />
163+
<TextView
164+
android:id="@+id/tv_empty_message"
165+
android:layout_width="wrap_content"
166+
android:layout_height="wrap_content"
167+
android:gravity="center"
168+
android:textColor="@color/daynight_textColor"
169+
android:textSize="16sp" />
170+
</LinearLayout>
149171
</FrameLayout>
150172
</LinearLayout>
151173
</FrameLayout>

app/src/main/res/values-ar/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,5 +1218,6 @@
12181218
<string name="select_open_with">افتح</string>
12191219
<string name="select_media">وسائط</string>
12201220
<string name="select_resource_type">نوع المورد</string>
1221+
<string name="no_results_for_filter">لا توجد نتائج تطابق الفلتر الحالي</string>
12211222

12221223
</resources>

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,5 +1202,6 @@
12021202
<string name="select_open_with">Abrir</string>
12031203
<string name="select_media">Medios</string>
12041204
<string name="select_resource_type">Tipo de recurso</string>
1205+
<string name="no_results_for_filter">No hay resultados que coincidan con tu filtro actual</string>
12051206

12061207
</resources>

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,5 +1206,6 @@
12061206
<string name="select_open_with">Ouvrir</string>
12071207
<string name="select_media">Médias</string>
12081208
<string name="select_resource_type">Type de ressource</string>
1209+
<string name="no_results_for_filter">Aucun résultat ne correspond à votre filtre actuel</string>
12091210

12101211
</resources>

app/src/main/res/values-ne/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,5 +1202,6 @@
12021202
<string name="select_open_with">खोल्नुहोस्</string>
12031203
<string name="select_media">मिडिया</string>
12041204
<string name="select_resource_type">स्रोत प्रकार</string>
1205+
<string name="no_results_for_filter">तपाईंको हालको फिल्टरसँग कुनै परिणाम मेल खाँदैन</string>
12051206

12061207
</resources>

app/src/main/res/values-so/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,5 +1202,6 @@
12021202
<string name="select_open_with">Fur</string>
12031203
<string name="select_media">Warbaahinta</string>
12041204
<string name="select_resource_type">Nooca Kheyraadka</string>
1205+
<string name="no_results_for_filter">Natiijooyin ma jiraan oo la jaanqaadaya shaandhadaada hadda</string>
12051206

12061207
</resources>

0 commit comments

Comments
 (0)