Save light, dark and amoled Material You themes to database. Add 'Apply Material You' option. Test MotionLayout.

This commit is contained in:
Alex Ning 2021-07-02 23:16:18 +08:00
parent 992cf0dda1
commit e3578c59dd
14 changed files with 303 additions and 47 deletions

View File

@ -46,7 +46,7 @@ dependencies {
implementation 'androidx.biometric:biometric:1.2.0-alpha03' implementation 'androidx.biometric:biometric:1.2.0-alpha03'
implementation 'androidx.browser:browser:1.3.0' implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.0-beta02'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
def lifecycleVersion = "2.2.0" def lifecycleVersion = "2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata:$lifecycleVersion"

View File

@ -32,6 +32,8 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
tools:replace="android:label"> tools:replace="android:label">
<activity android:name=".activities.MotionTestActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity <activity
android:name=".activities.LockScreenActivity" android:name=".activities.LockScreenActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />
@ -430,7 +432,6 @@
android:name=".services.SubmitPostService" android:name=".services.SubmitPostService"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="false" />
<service <service
android:name=".services.MaterialYouService" android:name=".services.MaterialYouService"
android:exported="false" /> android:exported="false" />

View File

@ -0,0 +1,41 @@
package ml.docilealligator.infinityforreddit.activities;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.motion.widget.MotionLayout;
import ml.docilealligator.infinityforreddit.R;
public class MotionTestActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_motion_test);
MotionLayout motionLayout = findViewById(R.id.motion_layout);
motionLayout.addTransitionListener(new MotionLayout.TransitionListener() {
@Override
public void onTransitionStarted(MotionLayout motionLayout, int i, int i1) {
Log.i("asdfasdf", "start " + (i == R.id.start) + " " + (i1 == R.id.end));
}
@Override
public void onTransitionChange(MotionLayout motionLayout, int i, int i1, float v) {
Log.i("asdfasdf", "start " + (i == R.id.start) + " " + (i1 == R.id.end) + " " + v);
}
@Override
public void onTransitionCompleted(MotionLayout motionLayout, int i) {
Log.i("asdfasdf", "complete " + (i == R.id.start));
}
@Override
public void onTransitionTrigger(MotionLayout motionLayout, int i, boolean b, float v) {
Log.i("asdfasdf", "trigger " + (i == R.id.start) + " " + v + " " + b);
}
});
}
}

View File

@ -3,13 +3,24 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import javax.inject.Inject;
import javax.inject.Named;
import ml.docilealligator.infinityforreddit.services.MaterialYouService; import ml.docilealligator.infinityforreddit.services.MaterialYouService;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class WallpaperChangeReceiver extends BroadcastReceiver { public class WallpaperChangeReceiver extends BroadcastReceiver {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Intent materialYouIntent = new Intent(context, MaterialYouService.class); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
context.startService(materialYouIntent); Intent materialYouIntent = new Intent(context, MaterialYouService.class);
context.startService(materialYouIntent);
}
} }
} }

View File

@ -0,0 +1,39 @@
package ml.docilealligator.infinityforreddit.customviews;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.motion.widget.MotionLayout;
public class ClickableMotionLayout extends MotionLayout {
private long mStartTime = 0;
public ClickableMotionLayout(@NonNull Context context) {
super(context);
}
public ClickableMotionLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public ClickableMotionLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if ( event.getAction() == MotionEvent.ACTION_DOWN ) {
mStartTime = event.getEventTime();
} else if ( event.getAction() == MotionEvent.ACTION_UP ) {
if ( event.getEventTime() - mStartTime <= ViewConfiguration.getTapTimeout() ) {
return false;
}
}
return super.onInterceptTouchEvent(event);
}
}

View File

@ -40,7 +40,8 @@ public class MaterialYouService extends IntentService {
@Override @Override
protected void onHandleIntent(Intent intent) { protected void onHandleIntent(Intent intent) {
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
MaterialYouUtils.changeTheme(this, executor, new Handler(), customThemeWrapper, MaterialYouUtils.changeTheme(this, executor, new Handler(), redditDataRoomDatabase,
lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences); customThemeWrapper, lightThemeSharedPreferences, darkThemeSharedPreferences,
amoledThemeSharedPreferences);
} }
} }

View File

@ -50,6 +50,9 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
private AppCompatActivity activity; private AppCompatActivity activity;
@Inject @Inject
@Named("default")
SharedPreferences sharedPreferences;
@Inject
@Named("light_theme") @Named("light_theme")
SharedPreferences lightThemeSharedPreferences; SharedPreferences lightThemeSharedPreferences;
@Inject @Inject
@ -79,6 +82,7 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
Preference customizeAmoledThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_AMOLED_THEME); Preference customizeAmoledThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_AMOLED_THEME);
Preference selectAndCustomizeThemePreference = findPreference(SharedPreferencesUtils.MANAGE_THEMES); Preference selectAndCustomizeThemePreference = findPreference(SharedPreferencesUtils.MANAGE_THEMES);
SwitchPreference enableMaterialYouSwitchPreference = findPreference(SharedPreferencesUtils.ENABLE_MATERIAL_YOU); SwitchPreference enableMaterialYouSwitchPreference = findPreference(SharedPreferencesUtils.ENABLE_MATERIAL_YOU);
Preference applyMaterialYouPreference = findPreference(SharedPreferencesUtils.APPLY_MATERIAL_YOU);
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
if (themePreference != null && amoledDarkSwitch != null) { if (themePreference != null && amoledDarkSwitch != null) {
@ -169,15 +173,33 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
if (enableMaterialYouSwitchPreference != null) { if (enableMaterialYouSwitchPreference != null && applyMaterialYouPreference != null) {
Handler handler = new Handler(); applyMaterialYouPreference.setVisible(
sharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false));
enableMaterialYouSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { enableMaterialYouSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> {
if (true) { if ((Boolean) newValue) {
MaterialYouUtils.changeTheme(activity, executor, new Handler(), customThemeWrapper, MaterialYouUtils.changeTheme(activity, executor, new Handler(),
lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences); redditDataRoomDatabase, customThemeWrapper,
lightThemeSharedPreferences, darkThemeSharedPreferences,
amoledThemeSharedPreferences);
applyMaterialYouPreference.setVisible(true);
} else {
applyMaterialYouPreference.setVisible(false);
} }
return true; return true;
}); });
applyMaterialYouPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
MaterialYouUtils.changeTheme(activity, executor, new Handler(),
redditDataRoomDatabase, customThemeWrapper,
lightThemeSharedPreferences, darkThemeSharedPreferences,
amoledThemeSharedPreferences);
return true;
}
});
} }
customThemeViewModel = new ViewModelProvider(this, customThemeViewModel = new ViewModelProvider(this,

View File

@ -14,11 +14,33 @@ import org.greenrobot.eventbus.EventBus;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
public class MaterialYouUtils { public class MaterialYouUtils {
public interface CheckThemeNameListener {
void themeNotExists();
void themeExists();
}
public static void checkThemeName(Executor executor, Handler handler,
RedditDataRoomDatabase redditDataRoomDatabase,
CheckThemeNameListener checkThemeNameListener) {
executor.execute(() -> {
if (redditDataRoomDatabase.customThemeDao().getCustomTheme("Material You") != null
|| redditDataRoomDatabase.customThemeDao().getCustomTheme("Material You Dark") != null
|| redditDataRoomDatabase.customThemeDao().getCustomTheme("Material You Amoled") != null) {
handler.post(checkThemeNameListener::themeExists);
} else {
handler.post(checkThemeNameListener::themeNotExists);
}
});
}
public static void changeTheme(Context context, Executor executor, Handler handler, public static void changeTheme(Context context, Executor executor, Handler handler,
RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
SharedPreferences lightThemeSharedPreferences, SharedPreferences lightThemeSharedPreferences,
SharedPreferences darkThemeSharedPreferences, SharedPreferences darkThemeSharedPreferences,
@ -29,6 +51,10 @@ public class MaterialYouUtils {
WallpaperColors wallpaperColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM); WallpaperColors wallpaperColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
if (wallpaperColors != null) { if (wallpaperColors != null) {
CustomTheme lightTheme = CustomThemeWrapper.getIndigo(context);
CustomTheme darkTheme = CustomThemeWrapper.getIndigoDark(context);
CustomTheme amoledTheme = CustomThemeWrapper.getIndigoAmoled(context);
int colorPrimaryInt = shiftColorTo255(wallpaperColors.getPrimaryColor().toArgb(), 0.4); int colorPrimaryInt = shiftColorTo255(wallpaperColors.getPrimaryColor().toArgb(), 0.4);
int colorPrimaryDarkInt = shiftColorTo0(colorPrimaryInt, 0.3); int colorPrimaryDarkInt = shiftColorTo0(colorPrimaryInt, 0.3);
int backgroundColor = shiftColorTo255(colorPrimaryInt, 0.6); int backgroundColor = shiftColorTo255(colorPrimaryInt, 0.6);
@ -39,39 +65,51 @@ public class MaterialYouUtils {
int colorPrimaryAppropriateTextColor = getAppropriateTextColor(colorPrimaryInt); int colorPrimaryAppropriateTextColor = getAppropriateTextColor(colorPrimaryInt);
int backgroundColorAppropriateTextColor = getAppropriateTextColor(backgroundColor); int backgroundColorAppropriateTextColor = getAppropriateTextColor(backgroundColor);
lightThemeSharedPreferences.edit().putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY, colorPrimaryInt) lightTheme.colorPrimary = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_DARK, colorPrimaryDarkInt) lightTheme.colorPrimaryDark = colorPrimaryDarkInt;
.putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorAccentInt) lightTheme.colorAccent = colorAccentInt;
.putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME, colorPrimaryInt) lightTheme.colorPrimaryLightTheme = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.BACKGROUND_COLOR, backgroundColor) lightTheme.backgroundColor = backgroundColor;
.putInt(CustomThemeSharedPreferencesUtils.CARD_VIEW_BACKGROUND_COLOR, cardViewBackgroundColor) lightTheme.cardViewBackgroundColor = cardViewBackgroundColor;
.putInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR, cardViewBackgroundColor) lightTheme.commentBackgroundColor = cardViewBackgroundColor;
.putInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR, cardViewBackgroundColor) lightTheme.awardedCommentBackgroundColor = cardViewBackgroundColor;
.putInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_BACKGROUND_COLOR, colorPrimaryInt) lightTheme.bottomAppBarBackgroundColor = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR, colorPrimaryInt) lightTheme.navBarColor = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.PRIMARY_TEXT_COLOR, backgroundColorAppropriateTextColor) lightTheme.primaryTextColor = backgroundColorAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_ICON_COLOR, colorPrimaryAppropriateTextColor) lightTheme.bottomAppBarIconColor = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.PRIMARY_ICON_COLOR, backgroundColorAppropriateTextColor) lightTheme.primaryIconColor = backgroundColorAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.FAB_ICON_COLOR, colorPrimaryAppropriateTextColor) lightTheme.fabIconColor = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR, colorPrimaryAppropriateTextColor) lightTheme.toolbarPrimaryTextAndIconColor = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.TOOLBAR_SECONDARY_TEXT_COLOR, colorPrimaryAppropriateTextColor) lightTheme.toolbarSecondaryTextColor = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR, colorPrimaryAppropriateTextColor) lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR, colorPrimaryAppropriateTextColor) lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND, colorPrimaryInt) lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND, colorPrimaryInt) lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR, colorPrimaryAppropriateTextColor) lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR, colorPrimaryAppropriateTextColor) lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
.putInt(CustomThemeSharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND, colorPrimaryInt) lightTheme.circularProgressBarBackground = colorPrimaryInt;
.putBoolean(CustomThemeSharedPreferencesUtils.LIGHT_STATUS_BAR, getAppropriateTextColor(colorPrimaryInt) == Color.toArgb(Color.BLACK)) lightTheme.isLightStatusBar = getAppropriateTextColor(colorPrimaryInt) == Color.toArgb(Color.BLACK);
.apply(); lightTheme.name = "Material You";
darkThemeSharedPreferences.edit()
.putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorPrimaryInt) darkTheme.colorAccent = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME, colorPrimaryInt) darkTheme.colorPrimaryLightTheme = colorPrimaryInt;
.apply(); darkTheme.name = "Material You Dark";
amoledThemeSharedPreferences.edit()
.putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorPrimaryInt) amoledTheme.colorAccent = colorPrimaryInt;
.putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME, colorPrimaryInt) amoledTheme.colorPrimaryLightTheme = colorPrimaryInt;
.apply(); amoledTheme.name = "Material You Amoled";
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
redditDataRoomDatabase.customThemeDao().insert(lightTheme);
redditDataRoomDatabase.customThemeDao().insert(darkTheme);
redditDataRoomDatabase.customThemeDao().insert(amoledTheme);
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(lightTheme, lightThemeSharedPreferences);
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(darkTheme, darkThemeSharedPreferences);
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(amoledTheme, amoledThemeSharedPreferences);
handler.post(() -> EventBus.getDefault().post(new RecreateActivityEvent())); handler.post(() -> EventBus.getDefault().post(new RecreateActivityEvent()));
} }

View File

@ -181,6 +181,7 @@ public class SharedPreferencesUtils {
public static final String DISABLE_NSFW_FOREVER = "disable_nsfw_forever"; public static final String DISABLE_NSFW_FOREVER = "disable_nsfw_forever";
public static final String SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR = "show_only_one_comment_level_indicator"; public static final String SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR = "show_only_one_comment_level_indicator";
public static final String ENABLE_MATERIAL_YOU = "enable_material_you"; public static final String ENABLE_MATERIAL_YOU = "enable_material_you";
public static final String APPLY_MATERIAL_YOU = "apply_material_you";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences"; public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ml.docilealligator.infinityforreddit.customviews.ClickableMotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/motion_layout"
tools:context=".activities.MotionTestActivity"
app:layoutDescription="@xml/activity_motion_test_scene">
<View
android:id="@+id/button"
android:background="@color/colorAccent"
android:layout_width="64dp"
android:layout_height="64dp" />
</ml.docilealligator.infinityforreddit.customviews.ClickableMotionLayout>

View File

@ -458,8 +458,11 @@
<string name="settings_customize_amoled_theme_title">Amoled Theme</string> <string name="settings_customize_amoled_theme_title">Amoled Theme</string>
<string name="settings_manage_themes_title">Manage Themes</string> <string name="settings_manage_themes_title">Manage Themes</string>
<string name="settings_category_material_you_title">Material You</string> <string name="settings_category_material_you_title">Material You</string>
<string name="settings_enable_material_you_warning_summary">Make sure you don\'t have themes named\n\"Material You\",\n\"Material You Dark\" or\n\"Material You Amoled\".\nOtherwise, rename them before enabling Material You.</string>
<string name="settings_enable_material_you_title">Enable Material You</string> <string name="settings_enable_material_you_title">Enable Material You</string>
<string name="settings_enable_material_you_summary">Personalize Infinity based on Your Wallpaper</string> <string name="settings_enable_material_you_summary">Personalize Infinity based on Your Wallpaper</string>
<string name="settings_apply_material_you_title">Apply Material You</string>
<string name="settings_apply_material_you_summary">In case Infinity did not change the theme</string>
<string name="settings_custom_theme_cannot_apply_to_settings_page_summary">Custom themes cannot be applied to settings page (except toolbar, status bar and navigation bar).</string> <string name="settings_custom_theme_cannot_apply_to_settings_page_summary">Custom themes cannot be applied to settings page (except toolbar, status bar and navigation bar).</string>
<string name="settings_advanced_master_title">Advanced</string> <string name="settings_advanced_master_title">Advanced</string>
<string name="settings_delete_all_subreddits_data_in_database_title">Delete All Subreddits in Database</string> <string name="settings_delete_all_subreddits_data_in_database_title">Delete All Subreddits in Database</string>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
android:id="@+id/transition_to_end"
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:autoTransition="animateToStart"
motion:duration="100">
<OnSwipe
motion:touchAnchorId="@+id/button"
motion:touchAnchorSide="right"
motion:onTouchUp="autoCompleteToEnd"
motion:dragDirection="dragRight" />
</Transition>
<Transition
android:id="@+id/transition_to_start"
motion:constraintSetStart="@+id/end"
motion:constraintSetEnd="@+id/start"
motion:autoTransition="animateToEnd">
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintStart_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent"/>
</ConstraintSet>
</MotionScene>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ConstraintSet android:id="@+id/start">
<Constraint android:id="@+id/material_card_view_item_post_with_preview" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint android:id="@id/material_card_view_item_post_with_preview"
android:layout_width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.7" />
</ConstraintSet>
<Transition
app:constraintSetEnd="@id/end"
app:constraintSetStart="@+id/start">
<OnSwipe
app:dragDirection="dragRight"
app:touchAnchorId="@id/material_card_view_item_post_with_preview"
app:touchAnchorSide="right" />
</Transition>
</MotionScene>

View File

@ -12,6 +12,7 @@
<SwitchPreference <SwitchPreference
app:defaultValue="false" app:defaultValue="false"
app:key="amoled_dark" app:key="amoled_dark"
app:icon="@drawable/ic_amoled_theme_preference_24dp"
app:title="@string/settings_amoled_dark_title" /> app:title="@string/settings_amoled_dark_title" />
<PreferenceCategory <PreferenceCategory
@ -40,9 +41,19 @@
app:icon="@drawable/ic_edit_24dp" app:icon="@drawable/ic_edit_24dp"
app:title="@string/settings_manage_themes_title" /> app:title="@string/settings_manage_themes_title" />
<Preference
app:icon="@drawable/ic_info_preference_24dp"
app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_summary"
app:enabled="false" />
<PreferenceCategory <PreferenceCategory
app:title="@string/settings_category_material_you_title" /> app:title="@string/settings_category_material_you_title" />
<Preference
app:icon="@drawable/ic_info_preference_24dp"
app:summary="@string/settings_enable_material_you_warning_summary"
app:enabled="false" />
<SwitchPreference <SwitchPreference
app:defaultValue="false" app:defaultValue="false"
app:key="enable_material_you" app:key="enable_material_you"
@ -50,8 +61,8 @@
app:summary="@string/settings_enable_material_you_summary" /> app:summary="@string/settings_enable_material_you_summary" />
<Preference <Preference
app:icon="@drawable/ic_info_preference_24dp" app:key="apply_material_you"
app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_summary" app:title="@string/settings_apply_material_you_title"
app:enabled="false" /> app:summary="@string/settings_apply_material_you_summary" />
</PreferenceScreen> </PreferenceScreen>