Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object DisplaySettings {
const val KEY_LAST_ACTIVE_MOVIES_TAB = "com.battlelancer.seriesguide.moviesActiveTab"
const val KEY_DISPLAY_EXACT_DATE = "com.battlelancer.seriesguide.shows.exactdate"
const val KEY_PREVENT_SPOILERS = "com.battlelancer.seriesguide.PREVENT_SPOILERS"
const val KEY_DISABLE_ANIMATIONS = "seriesguide.DISABLE_ANIMATIONS"

/**
* Returns true for all screens with dpi higher than [DisplayMetrics.DENSITY_HIGH].
Expand Down Expand Up @@ -231,4 +232,13 @@ object DisplaySettings {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(KEY_PREVENT_SPOILERS, false)
}

/**
* If the app should disable or reduce animations to avoid sickness
* that are not covered by the Remove animations accessibility setting of the system.
*/
fun isDisableAnimations(context: Context): Boolean {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(KEY_DISABLE_ANIMATIONS, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.provider.Settings
import android.text.TextUtils
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.TaskStackBuilder
import androidx.core.content.edit
import androidx.core.content.getSystemService
import androidx.preference.ListPreference
Expand All @@ -34,9 +35,10 @@ import com.battlelancer.seriesguide.streaming.StreamingSearch
import com.battlelancer.seriesguide.streaming.StreamingSearchConfigureDialog
import com.battlelancer.seriesguide.sync.SgSyncAdapter
import com.battlelancer.seriesguide.ui.SeriesGuidePreferences
import com.battlelancer.seriesguide.ui.ShowsActivity
import com.battlelancer.seriesguide.ui.dialogs.L10nDialogFragment
import com.battlelancer.seriesguide.ui.dialogs.NotificationSelectionDialogFragment
import com.battlelancer.seriesguide.ui.dialogs.NotificationThresholdDialogFragment
import com.battlelancer.seriesguide.ui.dialogs.L10nDialogFragment
import com.battlelancer.seriesguide.ui.dialogs.TimeOffsetDialogFragment
import com.battlelancer.seriesguide.util.LanguageTools
import com.battlelancer.seriesguide.util.ThemeUtils
Expand Down Expand Up @@ -114,6 +116,17 @@ class SgPreferencesFragment : PreferenceFragmentCompat(),
setListPreferenceSummary(this)
}

findPreference<SwitchPreferenceCompat>(DisplaySettings.KEY_DISABLE_ANIMATIONS)!!.apply {
setOnPreferenceClickListener {
// restart to apply animation settings, go back to this settings screen
TaskStackBuilder.create(requireActivity())
.addNextIntent(Intent(activity, ShowsActivity::class.java))
.addNextIntent(requireActivity().intent)
.startActivities()
true
}
}

// show currently set values for list prefs
setListPreferenceSummary(findPreference(DisplaySettings.KEY_NUMBERFORMAT))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.annotation.AttrRes
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import com.battlelancer.seriesguide.R
import com.battlelancer.seriesguide.settings.DisplaySettings
import com.battlelancer.seriesguide.ui.SeriesGuidePreferences
import com.uwetrottmann.androidutils.AndroidUtils
import com.uwetrottmann.seriesguide.widgets.SlidingTabLayout
Expand Down Expand Up @@ -48,5 +49,6 @@ object ThemeUtils {
setCustomTabView(R.layout.tabstrip_item_transparent, R.id.textViewTabStripItem)
setSelectedIndicatorColors(getColorFromAttribute(context, R.attr.colorPrimary))
setUnderlineColor(getColorFromAttribute(context, R.attr.sgColorDivider))
setDisableAnimations(DisplaySettings.isDisableAnimations(context))
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
<string name="pref_updatewifionly">Images via Wi-Fi only</string>
<string name="pref_updatewifionlysummary">To reduce data charges, don\'t download over mobile or metered networks</string>
<string name="pref_error_reports">Report errors to app developer</string>
<string name="pref_disable_animations">Reduce animations</string>

<plurals name="days_before_plural">
<item quantity="one">%d day before</item>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/settings_root.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
app:key="numberformat"
app:title="@string/pref_number" />

<SwitchPreferenceCompat
app:defaultValue="False"
app:iconSpaceReserved="false"
app:key="seriesguide.DISABLE_ANIMATIONS"
app:title="@string/pref_disable_animations" />

</PreferenceCategory>

<PreferenceCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public interface TabTitleSupplier {

private int tabViewLayoutId;
private int tabViewTextViewId;
private boolean disableAnimations;

private ViewPager viewPager;
private ViewPager2.OnPageChangeCallback viewPagerPageChangeListener;
Expand Down Expand Up @@ -107,6 +108,10 @@ public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) {
addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}

public void setDisableAnimations(boolean disableAnimations) {
this.disableAnimations = disableAnimations;
}

/**
* Set the custom {@link SlidingTabLayout.TabColorizer} to
* be used.
Expand Down Expand Up @@ -359,10 +364,10 @@ public void onClick(View v) {
onTabClickListener.onTabClick(i);
}
if (viewPager != null) {
viewPager.setCurrentItem(i);
viewPager.setCurrentItem(i, !disableAnimations);
}
if (viewPager2 != null) {
viewPager2.setCurrentItem(i);
viewPager2.setCurrentItem(i, !disableAnimations);
}
return;
}
Expand Down