diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/BaseActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/BaseActivity.java index aaee933a..94f35a26 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/BaseActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/BaseActivity.java @@ -39,6 +39,9 @@ import androidx.viewpager2.widget.ViewPager2; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.shape.CornerFamily; +import com.google.android.material.shape.MaterialShapeDrawable; +import com.google.android.material.shape.ShapeAppearanceModel; import com.google.android.material.tabs.TabLayout; import java.lang.reflect.Field; @@ -377,9 +380,18 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo button.setTextColor(customThemeWrapper.getFABIconColor()); } - protected void applyFABTheme(FloatingActionButton fab) { + protected void applyFABTheme(FloatingActionButton fab, boolean isCircular) { fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent())); fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor())); + if (isCircular) { + ShapeAppearanceModel shapeAppearanceModel = ShapeAppearanceModel.builder() + .setAllCorners(CornerFamily.ROUNDED, 100) // Adjust the radius value to control the roundness + .build(); + + // Apply the circular shape to the FAB + MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel); + fab.setShapeAppearanceModel(shapeAppearanceModel); + } } protected void fixViewPager2Sensitivity(ViewPager2 viewPager2) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/CustomThemeListingActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/CustomThemeListingActivity.java index 5b7befb0..677a25ba 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/CustomThemeListingActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/CustomThemeListingActivity.java @@ -51,6 +51,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeViewModel; import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper; import eu.toldi.infinityforlemmy.events.RecreateActivityEvent; import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils; +import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; import eu.toldi.infinityforlemmy.utils.Utils; public class CustomThemeListingActivity extends BaseActivity implements @@ -154,7 +155,7 @@ public class CustomThemeListingActivity extends BaseActivity implements @Override protected void applyCustomTheme() { applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); } @Override diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/FilteredPostsActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/FilteredPostsActivity.java index 3a105fed..29def7d5 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/FilteredPostsActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/FilteredPostsActivity.java @@ -265,7 +265,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); } private void bindView(PostFilter postFilter, boolean initializeFragment) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/InboxActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/InboxActivity.java index 122cff54..6cf4c290 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/InboxActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/InboxActivity.java @@ -229,7 +229,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar); applyTabLayoutTheme(tabLayout); - applyFABTheme(fab); + applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); } private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/MainActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/MainActivity.java index d35a0a25..a623d4ca 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/MainActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/MainActivity.java @@ -107,6 +107,7 @@ import eu.toldi.infinityforlemmy.events.ChangeLockBottomAppBarEvent; import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent; import eu.toldi.infinityforlemmy.events.ChangeRequireAuthToAccountSectionEvent; import eu.toldi.infinityforlemmy.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent; +import eu.toldi.infinityforlemmy.events.ChangeUseCircularFabEvent; import eu.toldi.infinityforlemmy.events.RecreateActivityEvent; import eu.toldi.infinityforlemmy.events.SwitchAccountEvent; import eu.toldi.infinityforlemmy.fragments.PostFragment; @@ -233,6 +234,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb private String mMessageFullname; private String mNewAccountName; private boolean hideFab; + + private boolean useCircularFab; private boolean showBottomAppBar; private int mBackButtonAction; private boolean mLockBottomAppBar; @@ -259,6 +262,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb ButterKnife.bind(this); hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); + useCircularFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), @@ -385,7 +389,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb navigationView.setBackgroundColor(backgroundColor); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); applyTabLayoutTheme(tabLayout); - applyFABTheme(navigationWrapper.floatingActionButton); + applyFABTheme(navigationWrapper.floatingActionButton, useCircularFab); } private void initializeNotificationAndBindView() { @@ -1336,6 +1340,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE); } + @Subscribe + public void onChangeUseCircularFab(ChangeUseCircularFabEvent event) { + useCircularFab = event.isUseCircularFab(); + applyFABTheme(navigationWrapper.floatingActionButton, useCircularFab); + } + @Override public void onLongPress() { if (sectionsPagerAdapter != null) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterPreferenceActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterPreferenceActivity.java index 78890c9a..f2cafb74 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterPreferenceActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterPreferenceActivity.java @@ -33,6 +33,7 @@ import eu.toldi.infinityforlemmy.post.Post; import eu.toldi.infinityforlemmy.postfilter.DeletePostFilter; import eu.toldi.infinityforlemmy.postfilter.PostFilter; import eu.toldi.infinityforlemmy.postfilter.PostFilterViewModel; +import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; public class PostFilterPreferenceActivity extends BaseActivity { @@ -205,7 +206,7 @@ public class PostFilterPreferenceActivity extends BaseActivity { @Override protected void applyCustomTheme() { applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor()); } diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterUsageListingActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterUsageListingActivity.java index 277fc751..1a1c1dfe 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterUsageListingActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostFilterUsageListingActivity.java @@ -39,6 +39,7 @@ import eu.toldi.infinityforlemmy.postfilter.PostFilter; import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage; import eu.toldi.infinityforlemmy.postfilter.PostFilterUsageViewModel; import eu.toldi.infinityforlemmy.postfilter.SavePostFilterUsage; +import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; import eu.toldi.infinityforlemmy.utils.Utils; public class PostFilterUsageListingActivity extends BaseActivity { @@ -206,7 +207,7 @@ public class PostFilterUsageListingActivity extends BaseActivity { @Override protected void applyCustomTheme() { applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor()); } } \ No newline at end of file diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java index f4d52886..ae151664 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java @@ -475,8 +475,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF nsfwTextView.setTextColor(primaryTextColor); titleEditText.setTextColor(primaryTextColor); titleEditText.setHintTextColor(secondaryTextColor); - applyFABTheme(captureFab); - applyFABTheme(selectFromLibraryFab); + boolean circleFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false); + applyFABTheme(captureFab, circleFab); + applyFABTheme(selectFromLibraryFab, circleFab); selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); if (typeface != null) { subredditNameTextView.setTypeface(typeface); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java index 551ec3a8..b9ed5fd6 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java @@ -447,8 +447,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF nsfwTextView.setTextColor(primaryTextColor); titleEditText.setTextColor(primaryTextColor); titleEditText.setHintTextColor(secondaryTextColor); - applyFABTheme(captureFab); - applyFABTheme(selectFromLibraryFab); + boolean circularFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false); + applyFABTheme(captureFab, circularFab); + applyFABTheme(selectFromLibraryFab, circularFab); selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); if (typeface != null) { subredditNameTextView.setTypeface(typeface); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SearchResultActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SearchResultActivity.java index bf83c7e0..2ddc39ac 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SearchResultActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SearchResultActivity.java @@ -238,7 +238,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); applyTabLayoutTheme(tabLayout); - applyFABTheme(fab); + applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); } private void bindView(Bundle savedInstanceState) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SelectedSubredditsAndUsersActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SelectedSubredditsAndUsersActivity.java index 44a233b5..6e5484af 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SelectedSubredditsAndUsersActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SelectedSubredditsAndUsersActivity.java @@ -194,7 +194,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); - applyFABTheme(fab); + applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); } @Override diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubscribedThingListingActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubscribedThingListingActivity.java index f13ed273..1b47dd83 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubscribedThingListingActivity.java @@ -221,7 +221,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); applyTabLayoutTheme(tabLayout); - applyFABTheme(fab); + applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor()); } diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewMultiRedditDetailActivity.java index 3eed25e6..225f65a0 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewMultiRedditDetailActivity.java @@ -853,7 +853,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar); navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor()); - applyFABTheme(navigationWrapper.floatingActionButton); + applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); } @Override diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewPostDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewPostDetailActivity.java index 720e2631..eb552144 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewPostDetailActivity.java @@ -335,7 +335,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele protected void applyCustomTheme() { mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar); - applyFABTheme(fab); + applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); searchPanelMaterialCardView.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimary())); int searchPanelTextAndIconColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(); searchTextInputLayout.setBoxStrokeColor(searchPanelTextAndIconColor); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java index 7bc52e7b..0a9e2372 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java @@ -420,7 +420,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp descriptionTextView.setTextColor(primaryTextColor); navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor()); applyTabLayoutTheme(tabLayout); - applyFABTheme(navigationWrapper.floatingActionButton); + applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); if (typeface != null) { subredditNameTextView.setTypeface(typeface); subscribeSubredditChip.setTypeface(typeface); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java index 3390e42f..7b7c0c77 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java @@ -631,7 +631,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor()); - applyFABTheme(navigationWrapper.floatingActionButton); + applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false)); descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor()); applyTabLayoutTheme(tabLayout); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/events/ChangeUseCircularFabEvent.java b/app/src/main/java/eu/toldi/infinityforlemmy/events/ChangeUseCircularFabEvent.java new file mode 100644 index 00000000..126a8a15 --- /dev/null +++ b/app/src/main/java/eu/toldi/infinityforlemmy/events/ChangeUseCircularFabEvent.java @@ -0,0 +1,14 @@ +package eu.toldi.infinityforlemmy.events; + +public class ChangeUseCircularFabEvent { + + private boolean useCircularFab; + + public ChangeUseCircularFabEvent(boolean useCircularFab) { + this.useCircularFab = useCircularFab; + } + + public boolean isUseCircularFab() { + return useCircularFab; + } +} diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/settings/InterfacePreferenceFragment.java b/app/src/main/java/eu/toldi/infinityforlemmy/settings/InterfacePreferenceFragment.java index 171a0ffa..91586f39 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/settings/InterfacePreferenceFragment.java @@ -12,6 +12,7 @@ import org.greenrobot.eventbus.EventBus; import eu.toldi.infinityforlemmy.R; import eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceFragmentCompat; import eu.toldi.infinityforlemmy.events.ChangeHideFabInPostFeedEvent; +import eu.toldi.infinityforlemmy.events.ChangeUseCircularFabEvent; import eu.toldi.infinityforlemmy.events.ChangeVoteButtonsPositionEvent; import eu.toldi.infinityforlemmy.events.RecreateActivityEvent; import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; @@ -23,6 +24,7 @@ public class InterfacePreferenceFragment extends CustomFontPreferenceFragmentCom Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY); SwitchPreference hideFabInPostFeedSwitchPreference = findPreference(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED); + SwitchPreference useCircularFAbSwitchPreference = findPreference(SharedPreferencesUtils.USE_CIRCULAR_FAB); SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY); SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY); @@ -37,6 +39,13 @@ public class InterfacePreferenceFragment extends CustomFontPreferenceFragmentCom }); } + if (useCircularFAbSwitchPreference != null) { + useCircularFAbSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeUseCircularFabEvent((Boolean) newValue)); + return true; + }); + } + if (bottomAppBarSwitch != null) { bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new RecreateActivityEvent()); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java b/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java index 25feac18..d61910e5 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java @@ -46,6 +46,8 @@ public class SharedPreferencesUtils { public static final String REDDIT_USER_AGREEMENT_KEY = "reddit_user_agreement"; public static final String HIDE_FAB_IN_POST_FEED = "hide_fab_in_post_feed"; + public static final String USE_CIRCULAR_FAB = "use_circular_fab"; + public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "eu.toldi.infinityforlemmy.sort_type"; public static final String SORT_TYPE_BEST_POST = "sort_type_best_post"; public static final String SORT_TIME_BEST_POST = "sort_time_best_post"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ea060afd..4b815c19 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1346,4 +1346,5 @@ Upload an image Mentions Replies + Use Circular FAB diff --git a/app/src/main/res/xml/interface_preferences.xml b/app/src/main/res/xml/interface_preferences.xml index 1caa4c75..d5945058 100644 --- a/app/src/main/res/xml/interface_preferences.xml +++ b/app/src/main/res/xml/interface_preferences.xml @@ -29,6 +29,11 @@ app:key="hide_fab_in_post_feed" app:title="@string/settings_hide_fab_in_post_feed" /> + +