Implement edge-to-edge experience (#24)
This commit is contained in:
parent
27e58a30df
commit
4a9f0959bc
|
|
@ -54,6 +54,7 @@ public class AppListActivity extends BaseActivity {
|
||||||
scopeAdapter.setHasStableIds(true);
|
scopeAdapter.setHasStableIds(true);
|
||||||
binding.recyclerView.setAdapter(scopeAdapter);
|
binding.recyclerView.setAdapter(scopeAdapter);
|
||||||
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
|
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
|
||||||
|
setupRecyclerViewInsets(binding.recyclerView, binding.getRoot());
|
||||||
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
|
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
|
||||||
if (!preferences.getBoolean("md2", true)) {
|
if (!preferences.getBoolean("md2", true)) {
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
@ -15,6 +17,10 @@ import androidx.annotation.StyleRes;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
|
|
@ -98,6 +104,18 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
theme = getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", true);
|
theme = getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setupRecyclerViewInsets(View recyclerView, View root) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, (v, insets) -> {
|
||||||
|
Insets insets1 = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime());
|
||||||
|
root.setPadding(insets1.left, insets1.top, insets1.right, 0);
|
||||||
|
v.setPadding(0, 0, 0, insets1.bottom);
|
||||||
|
return WindowInsetsCompat.CONSUMED;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getThemedColor(int id) {
|
public int getThemedColor(int id) {
|
||||||
TypedArray typedArray = getTheme().obtainStyledAttributes(new int[]{id});
|
TypedArray typedArray = getTheme().obtainStyledAttributes(new int[]{id});
|
||||||
int color = typedArray.getColor(0, 0);
|
int color = typedArray.getColor(0, 0);
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ public class LogsActivity extends BaseActivity {
|
||||||
binding.recyclerView.setAdapter(adapter);
|
binding.recyclerView.setAdapter(adapter);
|
||||||
layoutManager = new LinearLayoutManagerFix(this);
|
layoutManager = new LinearLayoutManagerFix(this);
|
||||||
binding.recyclerView.setLayoutManager(layoutManager);
|
binding.recyclerView.setLayoutManager(layoutManager);
|
||||||
|
setupRecyclerViewInsets(binding.recyclerView, binding.getRoot());
|
||||||
if (Files.exists(Paths.get(Constants.getBaseDir(), "conf/disable_verbose_log"))) {
|
if (Files.exists(Paths.get(Constants.getBaseDir(), "conf/disable_verbose_log"))) {
|
||||||
binding.slidingTabs.setVisibility(View.GONE);
|
binding.slidingTabs.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import io.github.lsposed.manager.Constants;
|
||||||
import io.github.lsposed.manager.R;
|
import io.github.lsposed.manager.R;
|
||||||
import io.github.lsposed.manager.adapters.AppHelper;
|
import io.github.lsposed.manager.adapters.AppHelper;
|
||||||
import io.github.lsposed.manager.adapters.ScopeAdapter;
|
import io.github.lsposed.manager.adapters.ScopeAdapter;
|
||||||
import io.github.lsposed.manager.databinding.ActivityModulesBinding;
|
import io.github.lsposed.manager.databinding.ActivityAppListBinding;
|
||||||
import io.github.lsposed.manager.util.GlideApp;
|
import io.github.lsposed.manager.util.GlideApp;
|
||||||
import io.github.lsposed.manager.util.LinearLayoutManagerFix;
|
import io.github.lsposed.manager.util.LinearLayoutManagerFix;
|
||||||
import io.github.lsposed.manager.util.ModuleUtil;
|
import io.github.lsposed.manager.util.ModuleUtil;
|
||||||
|
|
@ -42,7 +42,7 @@ import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
|
||||||
|
|
||||||
public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleListener {
|
public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleListener {
|
||||||
|
|
||||||
ActivityModulesBinding binding;
|
ActivityAppListBinding binding;
|
||||||
private int installedXposedVersion;
|
private int installedXposedVersion;
|
||||||
private ApplicationFilter filter;
|
private ApplicationFilter filter;
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
|
|
@ -94,10 +94,11 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
binding = ActivityModulesBinding.inflate(getLayoutInflater());
|
binding = ActivityAppListBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
binding.toolbar.setNavigationOnClickListener(view -> finish());
|
binding.toolbar.setNavigationOnClickListener(view -> onBackPressed());
|
||||||
|
binding.masterSwitch.setVisibility(View.GONE);
|
||||||
ActionBar bar = getSupportActionBar();
|
ActionBar bar = getSupportActionBar();
|
||||||
if (bar != null) {
|
if (bar != null) {
|
||||||
bar.setDisplayHomeAsUpEnabled(true);
|
bar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
@ -118,6 +119,7 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
||||||
moduleUtil.addListener(this);
|
moduleUtil.addListener(this);
|
||||||
binding.recyclerView.setAdapter(adapter);
|
binding.recyclerView.setAdapter(adapter);
|
||||||
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
|
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
|
||||||
|
setupRecyclerViewInsets(binding.recyclerView, binding.getRoot());
|
||||||
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
|
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
|
||||||
if (!preferences.getBoolean("md2", true)) {
|
if (!preferences.getBoolean("md2", true)) {
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,24 @@ package io.github.lsposed.manager.ui.activity;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.SwitchPreferenceCompat;
|
import androidx.preference.SwitchPreferenceCompat;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||||
import com.takisoft.preferencex.SimpleMenuPreference;
|
import com.takisoft.preferencex.SimpleMenuPreference;
|
||||||
|
|
@ -27,6 +35,7 @@ import io.github.lsposed.manager.R;
|
||||||
import io.github.lsposed.manager.databinding.ActivitySettingsBinding;
|
import io.github.lsposed.manager.databinding.ActivitySettingsBinding;
|
||||||
import io.github.lsposed.manager.ui.fragment.StatusDialogBuilder;
|
import io.github.lsposed.manager.ui.fragment.StatusDialogBuilder;
|
||||||
import io.github.lsposed.manager.ui.widget.IntegerListPreference;
|
import io.github.lsposed.manager.ui.widget.IntegerListPreference;
|
||||||
|
import io.github.lsposed.manager.ui.widget.RecyclerViewBugFixed;
|
||||||
|
|
||||||
public class SettingsActivity extends BaseActivity {
|
public class SettingsActivity extends BaseActivity {
|
||||||
private static final String KEY_PREFIX = SettingsActivity.class.getName() + '.';
|
private static final String KEY_PREFIX = SettingsActivity.class.getName() + '.';
|
||||||
|
|
@ -63,6 +72,14 @@ public class SettingsActivity extends BaseActivity {
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.container, new SettingsFragment()).commit();
|
.add(R.id.container, new SettingsFragment()).commit();
|
||||||
}
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), (v, insets) -> {
|
||||||
|
Insets insets1 = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime());
|
||||||
|
binding.getRoot().setPadding(insets1.left, insets1.top, insets1.right, 0);
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restart() {
|
private void restart() {
|
||||||
|
|
@ -271,5 +288,20 @@ public class SettingsActivity extends BaseActivity {
|
||||||
return (enabled == Files.exists(flag));
|
return (enabled == Files.exists(flag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
RecyclerView recyclerView = getListView();
|
||||||
|
recyclerView.setClipToPadding(false);
|
||||||
|
recyclerView.setEdgeEffectFactory(new RecyclerViewBugFixed.AlwaysClipToPaddingEdgeEffectFactory());
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, (v, insets) -> {
|
||||||
|
Insets insets1 = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime());
|
||||||
|
v.setPadding(0, 0, 0, insets1.bottom);
|
||||||
|
return WindowInsetsCompat.CONSUMED;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@
|
||||||
android:id="@+id/swipeRefreshLayout"
|
android:id="@+id/swipeRefreshLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipChildren="false"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
|
@ -46,10 +44,7 @@
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipChildren="false"
|
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical"
|
||||||
|
android:clipToPadding="false" />
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/snackbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:theme="?actionBarTheme"
|
|
||||||
app:liftOnScrollTargetViewId="@id/recyclerView">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:background="?colorActionBar"
|
|
||||||
app:popupTheme="?actionBarPopupTheme" />
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
||||||
android:id="@+id/swipeRefreshLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
|
||||||
|
|
||||||
<io.github.lsposed.manager.ui.widget.RecyclerViewBugFixed
|
|
||||||
android:id="@+id/recyclerView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
||||||
Loading…
Reference in New Issue