More MD3 ugly components (#1816)

This commit is contained in:
LoveSy 2022-04-06 21:12:27 +08:00 committed by GitHub
parent be1bbf7b9b
commit 2cb973656d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 72 deletions

View File

@ -131,7 +131,7 @@ materialThemeBuilder {
} }
// Add Material Design 3 color tokens (such as palettePrimary100) in generated theme // Add Material Design 3 color tokens (such as palettePrimary100) in generated theme
// rikka.material >= 2.0.0 provides such attributes // rikka.material >= 2.0.0 provides such attributes
generatePalette = false generatePalette = true
} }
dependencies { dependencies {
@ -158,11 +158,12 @@ dependencies {
implementation("dev.rikka.rikkax.appcompat:appcompat:1.4.1") implementation("dev.rikka.rikkax.appcompat:appcompat:1.4.1")
implementation("dev.rikka.rikkax.core:core:1.3.4") implementation("dev.rikka.rikkax.core:core:1.3.4")
implementation("dev.rikka.rikkax.insets:insets:1.2.0") implementation("dev.rikka.rikkax.insets:insets:1.2.0")
implementation("dev.rikka.rikkax.material:material:1.6.6") implementation("dev.rikka.rikkax.material:material:2.1.1")
implementation("dev.rikka.rikkax.material:material-preference:1.0.0")
implementation("dev.rikka.rikkax.preference:simplemenu-preference:1.0.3") implementation("dev.rikka.rikkax.preference:simplemenu-preference:1.0.3")
implementation("dev.rikka.rikkax.recyclerview:recyclerview-ktx:1.3.1") implementation("dev.rikka.rikkax.recyclerview:recyclerview-ktx:1.3.1")
implementation("dev.rikka.rikkax.widget:borderview:1.1.0") implementation("dev.rikka.rikkax.widget:borderview:1.1.0")
implementation("dev.rikka.rikkax.widget:switchbar:1.0.2") implementation("dev.rikka.rikkax.widget:mainswitchbar:1.0.0")
implementation("dev.rikka.rikkax.layoutinflater:layoutinflater:1.2.0") implementation("dev.rikka.rikkax.layoutinflater:layoutinflater:1.2.0")
implementation("me.zhanghai.android.appiconloader:appiconloader:1.3.1") implementation("me.zhanghai.android.appiconloader:appiconloader:1.3.1")
implementation("org.lsposed.hiddenapibypass:hiddenapibypass:4.3") implementation("org.lsposed.hiddenapibypass:hiddenapibypass:4.3")

View File

@ -48,6 +48,7 @@ import android.widget.CompoundButton;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -85,7 +86,7 @@ import java.util.stream.Collectors;
import rikka.core.util.ResourceUtils; import rikka.core.util.ResourceUtils;
import rikka.material.app.LocaleDelegate; import rikka.material.app.LocaleDelegate;
import rikka.widget.switchbar.SwitchBar; import rikka.widget.mainswitchbar.OnMainSwitchChangeListener;
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<ScopeAdapter.ViewHolder> implements Filterable { public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<ScopeAdapter.ViewHolder> implements Filterable {
@ -104,19 +105,18 @@ public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<Scope
private List<AppInfo> showList = new ArrayList<>(); private List<AppInfo> showList = new ArrayList<>();
private List<String> denyList = new ArrayList<>(); private List<String> denyList = new ArrayList<>();
private final SwitchBar.OnCheckedChangeListener switchBarOnCheckedChangeListener = new SwitchBar.OnCheckedChangeListener() { private final OnMainSwitchChangeListener switchBarOnCheckedChangeListener = new OnMainSwitchChangeListener() {
@Override @Override
public boolean onCheckedChanged(SwitchBar view, boolean isChecked) { public void onSwitchChanged(Switch view, boolean isChecked) {
if (!moduleUtil.setModuleEnabled(module.packageName, isChecked)) { if (!moduleUtil.setModuleEnabled(module.packageName, isChecked)) {
return false; view.setChecked(!isChecked);
} }
var tmpChkList = new HashSet<>(checkedList); var tmpChkList = new HashSet<>(checkedList);
if (isChecked && !tmpChkList.isEmpty() && !ConfigManager.setModuleScope(module.packageName, tmpChkList)) { if (isChecked && !tmpChkList.isEmpty() && !ConfigManager.setModuleScope(module.packageName, tmpChkList)) {
return false; view.setChecked(false);
} }
enabled = isChecked; enabled = isChecked;
notifyDataSetChanged(); notifyDataSetChanged();
return true;
} }
}; };
@ -480,9 +480,9 @@ public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<Scope
public void refresh(boolean force) { public void refresh(boolean force) {
setLoaded(null, false); setLoaded(null, false);
enabled = moduleUtil.isModuleEnabled(module.packageName); enabled = moduleUtil.isModuleEnabled(module.packageName);
fragment.binding.masterSwitch.setOnCheckedChangeListener(null); fragment.binding.masterSwitch.addOnSwitchChangeListener(null);
fragment.binding.masterSwitch.setChecked(enabled); fragment.binding.masterSwitch.setChecked(enabled);
fragment.binding.masterSwitch.setOnCheckedChangeListener(switchBarOnCheckedChangeListener); fragment.binding.masterSwitch.addOnSwitchChangeListener(switchBarOnCheckedChangeListener);
fragment.runAsync(() -> { fragment.runAsync(() -> {
List<PackageInfo> appList = AppHelper.getAppList(force); List<PackageInfo> appList = AppHelper.getAppList(force);
denyList = AppHelper.getDenyList(force); denyList = AppHelper.getDenyList(force);

View File

@ -54,7 +54,7 @@ public class BaseActivity extends MaterialActivity {
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (ThemeUtil.isSystemAccent()) { if (ThemeUtil.isSystemAccent()) {
DynamicColors.applyIfAvailable(this); DynamicColors.applyToActivityIfAvailable(this);
} }
// make sure the versions are consistent // make sure the versions are consistent
if (BuildConfig.DEBUG) return; if (BuildConfig.DEBUG) return;
@ -107,6 +107,7 @@ public class BaseActivity extends MaterialActivity {
theme.applyStyle(ThemeUtil.getColorThemeStyleRes(), true); theme.applyStyle(ThemeUtil.getColorThemeStyleRes(), true);
} }
theme.applyStyle(ThemeUtil.getNightThemeStyleRes(this), true); theme.applyStyle(ThemeUtil.getNightThemeStyleRes(this), true);
theme.applyStyle(rikka.material.preference.R.style.ThemeOverlay_Rikka_Material3_Preference, true);
} }
@Override @Override

View File

@ -20,7 +20,6 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_container" android:id="@+id/fragment_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -58,13 +57,6 @@
app:layout_collapseMode="pin" /> app:layout_collapseMode="pin" />
</com.google.android.material.appbar.SubtitleCollapsingToolbarLayout> </com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>
<rikka.widget.switchbar.SwitchBar
android:id="@+id/master_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:switchOffText="@string/enable_module"
app:switchOnText="@string/enable_module" />
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
@ -82,30 +74,41 @@
app:layout_fitsSystemWindowsInsets="@integer/internal_fragment_bottom_insets" app:layout_fitsSystemWindowsInsets="@integer/internal_fragment_bottom_insets"
app:tint="?attr/colorOnPrimary" /> app:tint="?attr/colorOnPrimary" />
<LinearLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior">
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:ignore="MissingPrefix">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.core.widget.NestedScrollView
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<org.lsposed.manager.ui.widget.EmptyStateRecyclerView <LinearLayout
android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:orientation="vertical">
android:fadeScrollbars="true"
android:scrollbarStyle="insideOverlay" <rikka.widget.mainswitchbar.MainSwitchBar
android:scrollbars="vertical" android:id="@+id/master_switch"
app:borderBottomVisibility="never" android:layout_width="match_parent"
app:borderTopDrawable="@null" android:layout_height="wrap_content"
app:borderTopVisibility="whenTop" android:fillViewport="true"
app:fitsSystemWindowsInsets="@integer/internal_fragment_bottom_insets" /> android:text="@string/enable_module" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout> <org.lsposed.manager.ui.widget.EmptyStateRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:fadeScrollbars="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
app:borderBottomVisibility="never"
app:borderTopDrawable="@null"
app:borderTopVisibility="whenTop"
app:fitsSystemWindowsInsets="@integer/internal_fragment_bottom_insets" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -19,7 +19,10 @@
<resources> <resources>
<style name="Base.AppTheme.Light" parent="Theme.Material.Light.LightStatusBar"> <style name="Base.AppTheme.Light" parent="Theme.Material3.DynamicColors.Light.Rikka">
<item name="android:windowLightStatusBar">true</item>
<item name="colorPrimaryVariant">@color/primary_dark_light_light_status_bar</item>
<item name="android:statusBarColor">?android:colorBackground</item> <item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:windowActionBar">false</item> <item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
@ -37,7 +40,7 @@
<style name="Theme.Light" parent="Base.AppTheme.Light" /> <style name="Theme.Light" parent="Base.AppTheme.Light" />
<style name="Base.AppTheme" parent="Theme.Material"> <style name="Base.AppTheme" parent="Theme.Material3.DynamicColors.Dark.Rikka">
<item name="android:windowActionBar">false</item> <item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>

View File

@ -45,21 +45,6 @@
<style name="ThemeOverlay.Material.Dialog.ColorPicker" parent="@style/ThemeOverlay.Material3.MaterialAlertDialog.Centered" tools:override="true" /> <style name="ThemeOverlay.Material.Dialog.ColorPicker" parent="@style/ThemeOverlay.Material3.MaterialAlertDialog.Centered" tools:override="true" />
<style name="PreferenceSummaryTextStyle" tools:override="true">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:letterSpacing">0.0178571429</item>
</style>
<style name="Preference.Category.Material" tools:override="true">
<item name="android:layout">@layout/preference_category_material</item>
<item name="iconSpaceReserved">false</item>
<item name="allowDividerAbove">false</item>
<item name="allowDividerBelow">false</item>
</style>
<!-- Base themes --> <!-- Base themes -->
<style name="Base.Light" parent="Theme.Material3.Light" tools:override="true"> <style name="Base.Light" parent="Theme.Material3.Light" tools:override="true">
<item name="android:statusBarColor">?android:colorBackground</item> <item name="android:statusBarColor">?android:colorBackground</item>
@ -76,12 +61,6 @@
<item name="colorInactive" tools:ignore="PrivateResource">@color/material_grey_600</item> <item name="colorInactive" tools:ignore="PrivateResource">@color/material_grey_600</item>
<item name="navigationBarDividerColor">@android:color/transparent</item> <item name="navigationBarDividerColor">@android:color/transparent</item>
<!-- SwitchBar -->
<item name="switchBarStyle">@style/Widget.SwitchBar.Light</item>
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar</item>
<item name="switchBarBackgroundNormal">@color/switchbar_background_light</item>
<item name="switchBarBackgroundDisabled">@color/switchbar_background_light</item>
</style> </style>
<style name="Base" parent="Theme.Material3.Dark" tools:override="true"> <style name="Base" parent="Theme.Material3.Dark" tools:override="true">
@ -96,18 +75,7 @@
<item name="colorAlert">@color/material_red_A100</item> <item name="colorAlert">@color/material_red_A100</item>
<item name="colorSafe">@color/material_green_A100</item> <item name="colorSafe">@color/material_green_A100</item>
<item name="colorWarning">@color/material_orange_A100</item> <item name="colorWarning">@color/material_orange_A100</item>
<item name="colorInactive">@color/material_grey_500</item>
<item name="navigationBarDividerColor">@android:color/transparent</item> <item name="navigationBarDividerColor">@android:color/transparent</item>
<!-- SwitchBar -->
<item name="switchBarStyle">@style/Widget.SwitchBar</item>
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar</item>
<item name="switchBarBackgroundNormal">@color/switchbar_background_dark</item>
<item name="switchBarBackgroundDisabled">@color/switchbar_background_dark</item>
</style>
<style name="ThemeOverlay.SwitchBar" parent="android:Widget" tools:override="true">
<item name="android:colorControlActivated">@color/primary_text_material_inverse</item>
</style> </style>
</resources> </resources>