Skip to content

Commit

Permalink
Merge pull request #1078 from UweTrottmann/improve-show-filter-dialog
Browse files Browse the repository at this point in the history
Improve show filter dialog, filter and sort strings
  • Loading branch information
UweTrottmann authored Nov 29, 2024
2 parents f7f1488 + dd71e08 commit 19fcf1f
Show file tree
Hide file tree
Showing 56 changed files with 253 additions and 403 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Releases marked with 🧪 (or previously with the "beta" suffix) were released o

### Unreleased

* 🔧 Shows: when viewing the stream or purchase provider filters, the reset button is shown as
disabled when no provider is selected. Also tabs are renamed and display icons to differentiate
filter from sort options.
* 🔨 Show scrollbars for show filter and sort options.
* 🔧 Use common "Sort by" action name.
* 📝 Latest user interface translations from Crowdin.

### 2024.5.1 - 2024-11-21 🧪
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceGroup
import com.battlelancer.seriesguide.R
import com.battlelancer.seriesguide.ui.BasePreferencesFragment
import com.battlelancer.seriesguide.settings.WidgetSettings
import com.battlelancer.seriesguide.ui.BasePreferencesFragment
import com.battlelancer.seriesguide.util.Utils

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ class ListWidgetPreferenceFragment : BasePreferencesFragment() {
// Shows only sort order.
showsSortPref = createListPref(
WidgetSettings.KEY_PREFIX_WIDGET_SHOWS_SORT_ORDER + appWidgetId,
R.string.action_shows_sort,
R.string.sort,
R.array.widgetShowSortOrder,
R.array.widgetShowSortOrderData,
getString(R.string.widget_default_show_sort_order)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
class ShowsDistillationFragment : AppCompatDialogFragment() {

private val model: ShowsDistillationViewModel by viewModels()
private var binding: DialogShowsDistillationBinding? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -178,11 +177,6 @@ class ShowsDistillationFragment : AppCompatDialogFragment() {

}

override fun onDestroyView() {
super.onDestroyView()
binding = null
}

companion object {

private const val TAG = "shows-distillation-dialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.battlelancer.seriesguide.shows

import android.content.res.Configuration
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -21,6 +22,7 @@ import androidx.compose.material3.Checkbox
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PlainTooltip
import androidx.compose.material3.Surface
Expand All @@ -29,6 +31,7 @@ import androidx.compose.material3.TooltipBox
import androidx.compose.material3.TooltipDefaults
import androidx.compose.material3.rememberTooltipState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -84,16 +87,25 @@ fun WatchProviderList(
}
HorizontalDivider()
Row {
// Disabling makes it easier to see if any of the shown provider filters is enabled,
// however, it prevents re-setting not shown providers. Which should not matter as
// only shown ones are considered for filtering (see
// SgWatchProviderHelper.filterLocalWatchProviders).
val isResetEnabled = watchProviders.find { it.filter_local } != null
Row(
modifier = Modifier
.weight(1f)
.clickable(
enabled = isResetEnabled,
role = Role.Button,
onClick = onProviderIncludeAny
)
.padding(16.dp)
) {
Text(stringResource(id = R.string.action_reset))
TextWithDisabledState(
id = R.string.action_reset,
enabled = isResetEnabled
)
}
val descriptionStreamSettingsButton =
stringResource(id = R.string.action_stream_settings)
Expand All @@ -117,6 +129,23 @@ fun WatchProviderList(
}
}

@Composable
fun TextWithDisabledState(@StringRes id: Int, enabled: Boolean) {
// https://developer.android.com/develop/ui/compose/designsystems/material2-material3#emphasis-and
// https://developer.android.com/develop/ui/compose/designsystems/material3#emphasis
CompositionLocalProvider(
LocalContentColor.provides(
if (enabled) {
MaterialTheme.colorScheme.onSurface
} else {
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
}
)
) {
Text(stringResource(id = id))
}
}

@Composable
fun WatchProviderFilterItem(
item: SgWatchProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class EpisodesFragment : Fragment() {
R.array.epsortingData,
EpisodesSettings.getEpisodeSortOrder(requireActivity()).index(),
EpisodesSettings.KEY_EPISODE_SORT_ORDER,
R.string.pref_episodesorting,
R.string.sort,
"episodeSortOrderDialog"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class SeasonsFragment() : Fragment() {
parentFragmentManager,
R.array.sesorting,
R.array.sesortingData, sortOrder.index,
SeasonsSettings.KEY_SEASON_SORT_ORDER, R.string.pref_seasonsorting,
SeasonsSettings.KEY_SEASON_SORT_ORDER, R.string.sort,
"seasonSortOrderDialog"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ShowsDiscoverAdapter(
}
binding.buttonDiscoverHeader.apply {
setIconResource(R.drawable.ic_filter_white_24dp)
contentDescription = context.getString(R.string.action_shows_filter)
contentDescription = context.getString(R.string.action_filter)
TooltipCompat.setTooltipText(this, contentDescription)
setOnClickListener { view ->
itemClickListener.onHeaderButtonClick(view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ interface SgWatchProviderHelper {
@Query("SELECT sg_watch_provider.* FROM sg_watch_provider JOIN sg_watch_provider_show_mappings ON sg_watch_provider.provider_id=sg_watch_provider_show_mappings.provider_id WHERE type=:type GROUP BY _id ORDER BY provider_name COLLATE UNICODE ASC")
fun usedWatchProvidersFlow(type: Int): Flow<List<SgWatchProvider>>

/* Note: never just get those with filter_local=1 as once a show does not longer use a provider
it is not longer shown in the filter UI, so it can not be disabled. */
/* Note: never just get those with filter_local=1 as once a show does no longer use a provider
it is no longer shown in the filter UI, so it can not be disabled. */
@Query("SELECT sg_watch_provider.* FROM sg_watch_provider JOIN sg_watch_provider_show_mappings ON sg_watch_provider.provider_id=sg_watch_provider_show_mappings.provider_id WHERE type=:type AND filter_local=1 GROUP BY _id")
fun filterLocalWatchProviders(type: Int): Flow<List<SgWatchProvider>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ class WatchProviderFilterDialogFragment : AppCompatDialogFragment() {
val binding = DialogWatchProviderFilterBinding.inflate(layoutInflater)
.also { binding = it }

val titleRes = when (type) {
Type.SHOWS -> R.string.action_shows_filter
Type.MOVIES -> R.string.action_movies_filter
}
binding.textViewTitle.setText(titleRes)

// watch region button
binding.buttonWatchRegion.apply {
text = StreamingSearch.getCurrentRegionOrSelectString(requireContext())
Expand All @@ -80,6 +74,7 @@ class WatchProviderFilterDialogFragment : AppCompatDialogFragment() {
}

return MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.action_stream)
.setView(binding.root)
.setPositiveButton(R.string.dismiss, null)
.setNegativeButton(R.string.action_reset) { _, _ ->
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/res/layout/dialog_shows_distillation.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/linearLayoutShowsDistillation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -9,24 +10,28 @@
android:id="@+id/tabLayoutShowsDistillation"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="?attr/sgColorDivider">
android:background="?attr/sgColorDivider"
app:tabMode="scrollable">

<!-- Note: can not use IDs as the TabItems below are just informational for TabLayout
which removes them once tabs are created. -->
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_shows_filter" />
android:icon="@drawable/ic_filter_white_24dp"
android:text="@string/title_filter_general" />

<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_filter_white_24dp"
android:text="@string/action_stream" />

<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_shows_sort" />
android:icon="@drawable/ic_sort_white_24dp"
android:text="@string/sort" />

</com.google.android.material.tabs.TabLayout>

Expand Down
19 changes: 0 additions & 19 deletions app/src/main/res/layout/dialog_watch_provider_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/textViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:textAppearance="@style/TextAppearance.SeriesGuide.TitleLarge.Bold"
tools:text="@string/action_shows_filter" />

<TextView
android:id="@+id/textViewSubTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:text="@string/action_stream"
android:textAppearance="@style/TextAppearance.SeriesGuide.Subtitle1.Bold" />

<com.google.android.material.chip.Chip
android:id="@+id/buttonWatchRegion"
android:layout_width="wrap_content"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/view_filter_shows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollViewFilterShows"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:scrollbars="vertical">

<LinearLayout
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/view_sort_shows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollViewSortShows"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:scrollbars="vertical">

<LinearLayout
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/lists_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:id="@+id/menu_action_lists_sort"
android:icon="@drawable/ic_sort_white_24dp"
android:orderInCategory="3"
android:title="@string/action_lists_sort"
android:title="@string/sort"
app:showAsAction="never">
<menu>
<item
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/movies_lists_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<item
android:id="@+id/menu_action_movies_sort"
android:icon="@drawable/ic_sort_white_24dp"
android:title="@string/action_movies_sort"
android:title="@string/sort"
app:showAsAction="ifRoom">
<menu>
<item
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/shows_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:id="@+id/menu_action_shows_filter"
android:icon="@drawable/ic_filter_white_24dp"
android:orderInCategory="1"
android:title="@string/action_shows_filter"
android:title="@string/action_filter_and_sort"
app:showAsAction="ifRoom" />

<item
Expand Down
14 changes: 5 additions & 9 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
<string name="hidden">تم الإخفاء</string>
<string name="unhidden">تم إظهار المسلسل</string>
<string name="action_shows_add">إضافة مسلسل</string>
<string name="action_shows_filter">فلترة المسلسلات</string>
<string name="action_filter_and_sort">Filter and sort</string>
<string name="title_filter_general">General</string>
<string name="empty_filter">إزالة كل عوامل التصفية</string>
<string name="action_shows_filter_favorites">المفضلة</string>
<string name="action_shows_filter_unwatched">الغير مشاهدة</string>
Expand All @@ -164,7 +165,6 @@
<string name="state_shows_filter_excluded">مستبعدة</string>
<string name="action_shows_make_all_visible">اظهار الجميع</string>
<string name="description_make_all_visible_format">هل تريد إظهار كل المسلسلات المخفية %s مرة أخرى؟</string>
<string name="action_shows_sort">ترتيب المسلسلات</string>
<string name="action_shows_sort_title">العنوان</string>
<string name="action_shows_sort_latest_episode">آخر حلقة</string>
<string name="action_shows_sort_oldest_episode">أقدم حلقة</string>
Expand Down Expand Up @@ -267,8 +267,10 @@
<!-- Similar shows -->
<string name="action_similar">Similar</string>
<string name="title_similar_shows">مسلسلات مشابهة</string>
<!-- Popular -->
<!-- Discover -->
<string name="title_discover">استكشاف</string>
<string name="title_popular">الأكثر شعبية</string>
<string name="action_filter">Filter</string>
<string name="filter_year">Year</string>
<string name="filter_year_current">Current year</string>
<string name="filter_language">Language</string>
Expand All @@ -286,12 +288,10 @@
<string name="list_item_remove">إزالة من القائمة</string>
<string name="ack_list_item_removed">Removed from list</string>
<string name="list_empty">يمكنك إضافة مسلسلات إلى هذه القائمة</string>
<string name="action_lists_sort">ترتيب القوائم</string>
<string name="action_lists_reorder">إعادة ترتيب القوائم</string>
<string name="ack_lists_reordered">Lists reordered</string>
<string name="error_name_already_exists">يوجد بالفعل قائمة بهذا الإسم</string>
<!-- Movies -->
<string name="title_discover">استكشاف</string>
<string name="title_digital_releases">الإصدارات الرقمية</string>
<string name="title_disc_releases">إصدارات القرص</string>
<string name="movies_in_theatres">حاليا في السينما</string>
Expand All @@ -308,10 +308,8 @@
<string name="trailer">العرض الدعائي</string>
<string name="movie_cast">طاقم التمثيل</string>
<string name="movie_crew">طاقم</string>
<string name="action_movies_sort">فرز الأفلام</string>
<string name="action_movies_sort_title">العنوان</string>
<string name="action_movies_sort_release">تاريخ الإصدار</string>
<string name="action_movies_filter">تصفية الأفلام</string>
<string name="title_similar_movies">Similar movies</string>
<string name="title_release_dates">Release dates</string>
<!-- Statistics -->
Expand Down Expand Up @@ -435,8 +433,6 @@
<string name="pref_exactdates_summary">\"31 أكتوبر\" بدلاً من \"في 3 أيام\"</string>
<string name="pref_nospoilers">منع المفسدين</string>
<string name="pref_nospoilers_summary">إخفاء التفاصيل حتى هو شاهد الحلقة</string>
<string name="pref_seasonsorting">ترتيب المواسم حسب&#8230;</string>
<string name="pref_episodesorting">ترتيب الحلقات حسب&#8230;</string>
<string name="pref_language">اللغة المفضلة</string>
<string name="pref_language_fallback">اللغة البديلة</string>
<string name="pref_updatewifionly">تحميل الصور بواسطة الواي فاي فقط</string>
Expand Down
Loading

0 comments on commit 19fcf1f

Please sign in to comment.