mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 02:48:23 +01:00
Add option to have circular FAB icon
This commit is contained in:
parent
fd14753a1d
commit
d4b107bc79
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -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";
|
||||
|
@ -1346,4 +1346,5 @@
|
||||
<string name="upload_image">Upload an image</string>
|
||||
<string name="mentions">Mentions</string>
|
||||
<string name="replies">Replies</string>
|
||||
<string name="use_circular_fab">Use Circular FAB</string>
|
||||
</resources>
|
||||
|
@ -29,6 +29,11 @@
|
||||
app:key="hide_fab_in_post_feed"
|
||||
app:title="@string/settings_hide_fab_in_post_feed" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="use_circular_fab"
|
||||
app:title="@string/use_circular_fab" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="bottom_app_bar"
|
||||
|
Loading…
Reference in New Issue
Block a user