Skip to content

Commit 5e6acd0

Browse files
committed
feat: disable logs tab transition
1 parent b384321 commit 5e6acd0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

app/src/main/java/org/lsposed/manager/ui/fragment/LogsFragment.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.lsposed.manager.databinding.SwiperefreshRecyclerviewBinding;
5454
import org.lsposed.manager.receivers.LSPManagerServiceHolder;
5555
import org.lsposed.manager.ui.widget.EmptyStateRecyclerView;
56+
import org.lsposed.manager.util.AccessibilityUtils;
5657

5758
import java.io.BufferedReader;
5859
import java.io.FileInputStream;
@@ -109,7 +110,17 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
109110
binding.toolbar.setSubtitle(ConfigManager.isVerboseLogEnabled() ? R.string.enabled_verbose_log : R.string.disabled_verbose_log);
110111
adapter = new LogPageAdapter(this);
111112
binding.viewPager.setAdapter(adapter);
112-
new TabLayoutMediator(binding.tabLayout, binding.viewPager, (tab, position) -> tab.setText((int) adapter.getItemId(position))).attach();
113+
114+
var isAnimationEnabled = AccessibilityUtils.isAnimationEnabled(requireContext().getContentResolver());
115+
new TabLayoutMediator(
116+
binding.tabLayout,
117+
binding.viewPager,
118+
// `autoRefresh = true` by default. Update the tabs automatically when the data set of the view pager's
119+
// adapter changes.
120+
true,
121+
isAnimationEnabled,
122+
(tab, position) -> tab.setText((int) adapter.getItemId(position))
123+
).attach();
113124

114125
binding.tabLayout.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
115126
ViewGroup vg = (ViewGroup) binding.tabLayout.getChildAt(0);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.lsposed.manager.util;
2+
3+
import android.content.ContentResolver;
4+
import android.provider.Settings;
5+
6+
public class AccessibilityUtils {
7+
public static boolean isAnimationEnabled(ContentResolver cr) {
8+
return !(Settings.Global.getFloat(cr, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f) == 0.0f
9+
&& Settings.Global.getFloat(cr, Settings.Global.TRANSITION_ANIMATION_SCALE, 1.0f) == 0.0f
10+
&& Settings.Global.getFloat(cr, Settings.Global.WINDOW_ANIMATION_SCALE, 1.0f) == 0.0f);
11+
}
12+
}

0 commit comments

Comments
 (0)