From 38ce80068565f503f77994366caab11636c33667 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Wed, 8 Sep 2021 20:51:43 +0200 Subject: [PATCH] Fixed feed when animations are off Introduced a check if corresponding animations on the devices are enabled --- .../java/org/schabi/newpipe/local/feed/FeedFragment.kt | 9 +++++++-- .../main/java/org/schabi/newpipe/util/DeviceUtils.java | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index e65661725..70cbf760a 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -73,6 +73,7 @@ import org.schabi.newpipe.local.feed.item.StreamItem import org.schabi.newpipe.local.feed.service.FeedLoadService import org.schabi.newpipe.local.subscription.SubscriptionManager import org.schabi.newpipe.player.helper.PlayerHolder +import org.schabi.newpipe.util.DeviceUtils import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.StreamDialogEntry @@ -624,8 +625,12 @@ class FeedFragment : BaseStateFragment() { 250L, delay = 100, execOnEnd = { - // Hide the new items-"popup" after 10s - hideNewItemsLoaded(true, 10000) + // Disabled animations would result in immediately hiding the button + // after it showed up + if (DeviceUtils.hasAnimationsAnimatorDurationEnabled(context)) { + // Hide the new items-"popup" after 10s + hideNewItemsLoaded(true, 10000) + } } ) } diff --git a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java index bdf5e8ce4..bbe9a7edb 100644 --- a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java @@ -6,6 +6,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.os.BatteryManager; import android.os.Build; +import android.provider.Settings; import android.util.TypedValue; import android.view.KeyEvent; @@ -144,4 +145,11 @@ public final class DeviceUtils { public static boolean isInMultiWindow(final AppCompatActivity activity) { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode(); } + + public static boolean hasAnimationsAnimatorDurationEnabled(final Context context) { + return Settings.System.getFloat( + context.getContentResolver(), + Settings.Global.ANIMATOR_DURATION_SCALE, + 1F) != 0F; + } }