diff options
14 files changed, 303 insertions, 47 deletions
diff --git a/app/build.gradle b/app/build.gradle index cdd6dc23..b817d23f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,7 +46,7 @@ dependencies { implementation 'androidx.biometric:biometric:1.2.0-alpha03' implementation 'androidx.browser:browser:1.3.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' def lifecycleVersion = "2.2.0" implementation "androidx.lifecycle:lifecycle-livedata:$lifecycleVersion" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5e6fbdc6..a4275813 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,6 +32,8 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="android:label"> + <activity android:name=".activities.MotionTestActivity" + android:theme="@style/AppTheme.NoActionBar" /> <activity android:name=".activities.LockScreenActivity" android:theme="@style/AppTheme.NoActionBar" /> @@ -430,7 +432,6 @@ android:name=".services.SubmitPostService" android:enabled="true" android:exported="false" /> - <service android:name=".services.MaterialYouService" android:exported="false" /> diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MotionTestActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MotionTestActivity.java new file mode 100644 index 00000000..ba8d0681 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MotionTestActivity.java @@ -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); + } + }); + } +}
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java index 8028cdfc..ae9392f7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java @@ -3,13 +3,24 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers; import android.content.BroadcastReceiver; import android.content.Context; 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.utils.SharedPreferencesUtils; public class WallpaperChangeReceiver extends BroadcastReceiver { + @Inject + @Named("default") + SharedPreferences mSharedPreferences; + @Override public void onReceive(Context context, Intent intent) { - Intent materialYouIntent = new Intent(context, MaterialYouService.class); - context.startService(materialYouIntent); + if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) { + Intent materialYouIntent = new Intent(context, MaterialYouService.class); + context.startService(materialYouIntent); + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/ClickableMotionLayout.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/ClickableMotionLayout.java new file mode 100644 index 00000000..8c0f47ff --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/ClickableMotionLayout.java @@ -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); + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java index ec4448ff..221b980b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java @@ -40,7 +40,8 @@ public class MaterialYouService extends IntentService { @Override protected void onHandleIntent(Intent intent) { ((Infinity) getApplication()).getAppComponent().inject(this); - MaterialYouUtils.changeTheme(this, executor, new Handler(), customThemeWrapper, - lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences); + MaterialYouUtils.changeTheme(this, executor, new Handler(), redditDataRoomDatabase, + customThemeWrapper, lightThemeSharedPreferences, darkThemeSharedPreferences, + amoledThemeSharedPreferences); } }
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java index c4d03d48..2e94f166 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java @@ -50,6 +50,9 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat { private AppCompatActivity activity; @Inject + @Named("default") + SharedPreferences sharedPreferences; + @Inject @Named("light_theme") SharedPreferences lightThemeSharedPreferences; @Inject @@ -79,6 +82,7 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat { Preference customizeAmoledThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_AMOLED_THEME); Preference selectAndCustomizeThemePreference = findPreference(SharedPreferencesUtils.MANAGE_THEMES); SwitchPreference enableMaterialYouSwitchPreference = findPreference(SharedPreferencesUtils.ENABLE_MATERIAL_YOU); + Preference applyMaterialYouPreference = findPreference(SharedPreferencesUtils.APPLY_MATERIAL_YOU); boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; if (themePreference != null && amoledDarkSwitch != null) { @@ -169,15 +173,33 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat { }); } - if (enableMaterialYouSwitchPreference != null) { - Handler handler = new Handler(); + if (enableMaterialYouSwitchPreference != null && applyMaterialYouPreference != null) { + applyMaterialYouPreference.setVisible( + sharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)); + enableMaterialYouSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { - if (true) { - MaterialYouUtils.changeTheme(activity, executor, new Handler(), customThemeWrapper, - lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences); + if ((Boolean) newValue) { + MaterialYouUtils.changeTheme(activity, executor, new Handler(), + redditDataRoomDatabase, customThemeWrapper, + lightThemeSharedPreferences, darkThemeSharedPreferences, + amoledThemeSharedPreferences); + applyMaterialYouPreference.setVisible(true); + } else { + applyMaterialYouPreference.setVisible(false); } 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, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java index e74d7e53..37e92aa1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java @@ -14,11 +14,33 @@ import org.greenrobot.eventbus.EventBus; 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.events.RecreateActivityEvent; 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, + RedditDataRoomDatabase redditDataRoomDatabase, CustomThemeWrapper customThemeWrapper, SharedPreferences lightThemeSharedPreferences, SharedPreferences darkThemeSharedPreferences, @@ -29,6 +51,10 @@ public class MaterialYouUtils { WallpaperColors wallpaperColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM); 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 colorPrimaryDarkInt = shiftColorTo0(colorPrimaryInt, 0.3); int backgroundColor = shiftColorTo255(colorPrimaryInt, 0.6); @@ -39,39 +65,51 @@ public class MaterialYouUtils { int colorPrimaryAppropriateTextColor = getAppropriateTextColor(colorPrimaryInt); int backgroundColorAppropriateTextColor = getAppropriateTextColor(backgroundColor); - lightThemeSharedPreferences.edit().putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_DARK, colorPrimaryDarkInt) - .putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorAccentInt) - .putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.BACKGROUND_COLOR, backgroundColor) - .putInt(CustomThemeSharedPreferencesUtils.CARD_VIEW_BACKGROUND_COLOR, cardViewBackgroundColor) - .putInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR, cardViewBackgroundColor) - .putInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR, cardViewBackgroundColor) - .putInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_BACKGROUND_COLOR, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.PRIMARY_TEXT_COLOR, backgroundColorAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_ICON_COLOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.PRIMARY_ICON_COLOR, backgroundColorAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.FAB_ICON_COLOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.TOOLBAR_SECONDARY_TEXT_COLOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR, colorPrimaryAppropriateTextColor) - .putInt(CustomThemeSharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND, colorPrimaryInt) - .putBoolean(CustomThemeSharedPreferencesUtils.LIGHT_STATUS_BAR, getAppropriateTextColor(colorPrimaryInt) == Color.toArgb(Color.BLACK)) - .apply(); - darkThemeSharedPreferences.edit() - .putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME, colorPrimaryInt) - .apply(); - amoledThemeSharedPreferences.edit() - .putInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT, colorPrimaryInt) - .putInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME, colorPrimaryInt) - .apply(); + lightTheme.colorPrimary = colorPrimaryInt; + lightTheme.colorPrimaryDark = colorPrimaryDarkInt; + lightTheme.colorAccent = colorAccentInt; + lightTheme.colorPrimaryLightTheme = colorPrimaryInt; + lightTheme.backgroundColor = backgroundColor; + lightTheme.cardViewBackgroundColor = cardViewBackgroundColor; + lightTheme.commentBackgroundColor = cardViewBackgroundColor; + lightTheme.awardedCommentBackgroundColor = cardViewBackgroundColor; + lightTheme.bottomAppBarBackgroundColor = colorPrimaryInt; + lightTheme.navBarColor = colorPrimaryInt; + lightTheme.primaryTextColor = backgroundColorAppropriateTextColor; + lightTheme.bottomAppBarIconColor = colorPrimaryAppropriateTextColor; + lightTheme.primaryIconColor = backgroundColorAppropriateTextColor; + lightTheme.fabIconColor = colorPrimaryAppropriateTextColor; + lightTheme.toolbarPrimaryTextAndIconColor = colorPrimaryAppropriateTextColor; + lightTheme.toolbarSecondaryTextColor = colorPrimaryAppropriateTextColor; + lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor; + lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor; + lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = colorPrimaryInt; + lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = colorPrimaryInt; + lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor; + lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor; + lightTheme.circularProgressBarBackground = colorPrimaryInt; + lightTheme.isLightStatusBar = getAppropriateTextColor(colorPrimaryInt) == Color.toArgb(Color.BLACK); + lightTheme.name = "Material You"; + + darkTheme.colorAccent = colorPrimaryInt; + darkTheme.colorPrimaryLightTheme = colorPrimaryInt; + darkTheme.name = "Material You Dark"; + + amoledTheme.colorAccent = colorPrimaryInt; + amoledTheme.colorPrimaryLightTheme = colorPrimaryInt; + 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())); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 5eecceb1..82343e4f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -181,6 +181,7 @@ public class SharedPreferencesUtils { 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 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 MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; diff --git a/app/src/main/res/layout/activity_motion_test.xml b/app/src/main/res/layout/activity_motion_test.xml new file mode 100644 index 00000000..c65afba9 --- /dev/null +++ b/app/src/main/res/layout/activity_motion_test.xml @@ -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>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ac7f028e..f657e724 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -458,8 +458,11 @@ <string name="settings_customize_amoled_theme_title">Amoled Theme</string> <string name="settings_manage_themes_title">Manage Themes</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_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_advanced_master_title">Advanced</string> <string name="settings_delete_all_subreddits_data_in_database_title">Delete All Subreddits in Database</string> diff --git a/app/src/main/res/xml/activity_motion_test_scene.xml b/app/src/main/res/xml/activity_motion_test_scene.xml new file mode 100644 index 00000000..d271b2e1 --- /dev/null +++ b/app/src/main/res/xml/activity_motion_test_scene.xml @@ -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> diff --git a/app/src/main/res/xml/item_post_with_preview_scene.xml b/app/src/main/res/xml/item_post_with_preview_scene.xml new file mode 100644 index 00000000..dc28317a --- /dev/null +++ b/app/src/main/res/xml/item_post_with_preview_scene.xml @@ -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> diff --git a/app/src/main/res/xml/theme_preferences.xml b/app/src/main/res/xml/theme_preferences.xml index 3f726ec0..6bac18e4 100644 --- a/app/src/main/res/xml/theme_preferences.xml +++ b/app/src/main/res/xml/theme_preferences.xml @@ -12,6 +12,7 @@ <SwitchPreference app:defaultValue="false" app:key="amoled_dark" + app:icon="@drawable/ic_amoled_theme_preference_24dp" app:title="@string/settings_amoled_dark_title" /> <PreferenceCategory @@ -40,9 +41,19 @@ app:icon="@drawable/ic_edit_24dp" 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 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 app:defaultValue="false" app:key="enable_material_you" @@ -50,8 +61,8 @@ app:summary="@string/settings_enable_material_you_summary" /> <Preference - app:icon="@drawable/ic_info_preference_24dp" - app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_summary" - app:enabled="false" /> + app:key="apply_material_you" + app:title="@string/settings_apply_material_you_title" + app:summary="@string/settings_apply_material_you_summary" /> </PreferenceScreen>
\ No newline at end of file |