Show the FAB in anonymous mode.

This commit is contained in:
Alex Ning 2020-12-24 23:07:18 +08:00
parent f376de69e1
commit 3938d9734f
6 changed files with 395 additions and 351 deletions

View File

@ -68,9 +68,9 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.FetchMyInfo;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface; import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
import ml.docilealligator.infinityforreddit.PullNotificationWorker; import ml.docilealligator.infinityforreddit.PullNotificationWorker;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@ -201,11 +201,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
private AppBarLayout.LayoutParams params; private AppBarLayout.LayoutParams params;
private PostTypeBottomSheetFragment postTypeBottomSheetFragment;
private SortTypeBottomSheetFragment sortTypeBottomSheetFragment;
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
private FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment;
private NavigationDrawerRecyclerViewAdapter adapter; private NavigationDrawerRecyclerViewAdapter adapter;
private boolean mNullAccessToken = false; private boolean mNullAccessToken = false;
private String mAccessToken; private String mAccessToken;
@ -226,6 +221,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private boolean mDisableSwipingBetweenTabs; private boolean mDisableSwipingBetweenTabs;
private boolean mShowFavoriteSubscribedSubreddits; private boolean mShowFavoriteSubscribedSubreddits;
private boolean mShowSubscribedSubreddits; private boolean mShowSubscribedSubreddits;
private int fabOption;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -278,12 +274,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
} }
postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
setToolbarGoToTop(toolbar); setToolbarGoToTop(toolbar);
@ -513,8 +503,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
if (mAccessToken == null) { if (mAccessToken == null) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
lp.setAnchorId(View.NO_ID);
lp.gravity = Gravity.END | Gravity.BOTTOM;
fab.setLayoutParams(lp);
bottomAppBar.setVisibility(View.GONE); bottomAppBar.setVisibility(View.GONE);
fab.setVisibility(View.GONE);
} else { } else {
if (showBottomAppBar) { if (showBottomAppBar) {
int optionCount = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4); int optionCount = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
@ -569,8 +562,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
lp.gravity = Gravity.END | Gravity.BOTTOM; lp.gravity = Gravity.END | Gravity.BOTTOM;
fab.setLayoutParams(lp); fab.setLayoutParams(lp);
} }
}
int fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS); fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB,
SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) { switch (fabOption) {
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_REFRESH: case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_REFRESH:
fab.setImageResource(R.drawable.ic_refresh_24dp); fab.setImageResource(R.drawable.ic_refresh_24dp);
@ -594,13 +589,23 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
fab.setImageResource(R.drawable.ic_random_24dp); fab.setImageResource(R.drawable.ic_random_24dp);
break; break;
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS: case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp); fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
}
break; break;
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS: case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
fab.setImageResource(R.drawable.ic_filter_24dp); fab.setImageResource(R.drawable.ic_filter_24dp);
break; break;
default: default:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_add_day_night_24dp); fab.setImageResource(R.drawable.ic_add_day_night_24dp);
}
break; break;
} }
fab.setOnClickListener(view -> { fab.setOnClickListener(view -> {
@ -616,6 +621,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
break; break;
} }
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: { case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
break; break;
} }
@ -644,16 +650,20 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
break; break;
default: default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break; break;
} }
}); });
fab.setOnLongClickListener(view -> { fab.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment= new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccessToken == null);
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag()); fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true; return true;
}); });
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
}
adapter = new NavigationDrawerRecyclerViewAdapter(this, mSharedPreferences, adapter = new NavigationDrawerRecyclerViewAdapter(this, mSharedPreferences,
mNsfwAndSpoilerSharedPreferences, mCustomThemeWrapper, mAccountName, mNsfwAndSpoilerSharedPreferences, mCustomThemeWrapper, mAccountName,
@ -829,8 +839,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (showBottomAppBar) { if (showBottomAppBar) {
bottomAppBar.performShow(); bottomAppBar.performShow();
} }
fab.show();
} }
fab.show();
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
} }
}); });
@ -971,6 +981,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} else { } else {
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false); bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
} }
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
sortTypeBottomSheetFragment.setArguments(bundle); sortTypeBottomSheetFragment.setArguments(bundle);
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
} }
@ -1011,6 +1022,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
return true; return true;
case R.id.action_change_post_layout_main_activity: case R.id.action_change_post_layout_main_activity:
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true; return true;
} }
@ -1074,6 +1086,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override @Override
public void sortTypeSelected(String sortType) { public void sortTypeSelected(String sortType) {
SortTimeBottomSheetFragment sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType); bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType);
sortTimeBottomSheetFragment.setArguments(bundle); sortTimeBottomSheetFragment.setArguments(bundle);
@ -1109,27 +1122,23 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override @Override
public void contentScrollUp() { public void contentScrollUp() {
if (mAccessToken != null) { if (mAccessToken != null && showBottomAppBar && !mLockBottomAppBar) {
if (showBottomAppBar && !mLockBottomAppBar) {
bottomAppBar.performShow(); bottomAppBar.performShow();
} }
if (!(showBottomAppBar && mLockBottomAppBar)) { if (!(mAccessToken != null && showBottomAppBar && mLockBottomAppBar)) {
fab.show(); fab.show();
} }
} }
}
@Override @Override
public void contentScrollDown() { public void contentScrollDown() {
if (mAccessToken != null) { if (!(mAccessToken != null && showBottomAppBar && mLockBottomAppBar)) {
if (!(showBottomAppBar && mLockBottomAppBar)) {
fab.hide(); fab.hide();
} }
if (showBottomAppBar && !mLockBottomAppBar) { if (mAccessToken != null && showBottomAppBar && !mLockBottomAppBar) {
bottomAppBar.performHide(); bottomAppBar.performHide();
} }
} }
}
@Subscribe @Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) { public void onAccountSwitchEvent(SwitchAccountEvent event) {
@ -1190,6 +1199,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
public void fabOptionSelected(int option) { public void fabOptionSelected(int option) {
switch (option) { switch (option) {
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SUBMIT_POST: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SUBMIT_POST:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_REFRESH: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_REFRESH:
@ -1201,6 +1211,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
changeSortType(); changeSortType();
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT:
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:

View File

@ -118,6 +118,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
private SlidrInterface mSlidrInterface; private SlidrInterface mSlidrInterface;
private int fabOption;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -241,6 +242,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
fab.show();
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
if (position == 0) { if (position == 0) {
unlockSwipeRightToGoBack(); unlockSwipeRightToGoBack();
@ -264,7 +266,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}).attach(); }).attach();
fixViewPager2Sensitivity(viewPager2); fixViewPager2Sensitivity(viewPager2);
int fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS); fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) { switch (fabOption) {
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH:
fab.setImageResource(R.drawable.ic_refresh_24dp); fab.setImageResource(R.drawable.ic_refresh_24dp);
@ -290,6 +292,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (mAccessToken == null) { if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp); fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else { } else {
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp); fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
} }
@ -300,6 +303,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
default: default:
if (mAccessToken == null) { if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp); fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else { } else {
fab.setImageResource(R.drawable.ic_add_day_night_24dp); fab.setImageResource(R.drawable.ic_add_day_night_24dp);
} }

View File

@ -222,6 +222,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int collapsedTabIndicatorColor; private int collapsedTabIndicatorColor;
private int unsubscribedColor; private int unsubscribedColor;
private int subscribedColor; private int subscribedColor;
private int fabOption;
private SlidrInterface mSlidrInterface; private SlidrInterface mSlidrInterface;
private MaterialAlertDialogBuilder nsfwWarningBuilder; private MaterialAlertDialogBuilder nsfwWarningBuilder;
@ -687,8 +688,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
lp.gravity = Gravity.END | Gravity.BOTTOM; lp.gravity = Gravity.END | Gravity.BOTTOM;
fab.setLayoutParams(lp); fab.setLayoutParams(lp);
} }
} else {
int fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS); CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
lp.setAnchorId(View.NO_ID);
lp.gravity = Gravity.END | Gravity.BOTTOM;
fab.setLayoutParams(lp);
bottomNavigationView.setVisibility(View.GONE);
}
fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) { switch (fabOption) {
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH:
fab.setImageResource(R.drawable.ic_refresh_24dp); fab.setImageResource(R.drawable.ic_refresh_24dp);
@ -712,13 +719,23 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fab.setImageResource(R.drawable.ic_random_24dp); fab.setImageResource(R.drawable.ic_random_24dp);
break; break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp); fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
}
break; break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
fab.setImageResource(R.drawable.ic_filter_24dp); fab.setImageResource(R.drawable.ic_filter_24dp);
break; break;
default: default:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_add_day_night_24dp); fab.setImageResource(R.drawable.ic_add_day_night_24dp);
}
break; break;
} }
fab.setOnClickListener(view -> { fab.setOnClickListener(view -> {
@ -768,15 +785,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
} }
}); });
fab.setOnLongClickListener(view -> { fab.setOnLongClickListener(view -> {
Bundle bundle = new Bundle();
bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccessToken == null);
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag()); fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true; return true;
}); });
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
} else {
bottomNavigationView.setVisibility(View.GONE);
fab.setVisibility(View.GONE);
}
subscribeSubredditChip.setOnClickListener(view -> { subscribeSubredditChip.setOnClickListener(view -> {
if (mAccessToken == null) { if (mAccessToken == null) {
@ -857,8 +872,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (showBottomAppBar) { if (showBottomAppBar) {
bottomNavigationView.performShow(); bottomNavigationView.performShow();
} }
fab.show();
} }
fab.show();
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
} }

View File

@ -217,6 +217,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private int collapsedTabIndicatorColor; private int collapsedTabIndicatorColor;
private int unsubscribedColor; private int unsubscribedColor;
private int subscribedColor; private int subscribedColor;
private int fabOption;
private boolean showToast = false; private boolean showToast = false;
private boolean showBottomAppBar; private boolean showBottomAppBar;
private boolean lockBottomAppBar; private boolean lockBottomAppBar;
@ -633,8 +634,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (showBottomAppBar) { if (showBottomAppBar) {
bottomNavigationView.performShow(); bottomNavigationView.performShow();
} }
fab.show();
} }
fab.show();
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
} }
@ -710,8 +711,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
lp.gravity = Gravity.END | Gravity.BOTTOM; lp.gravity = Gravity.END | Gravity.BOTTOM;
fab.setLayoutParams(lp); fab.setLayoutParams(lp);
} }
} else {
int fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS); CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
lp.setAnchorId(View.NO_ID);
lp.gravity = Gravity.END | Gravity.BOTTOM;
fab.setLayoutParams(lp);
bottomNavigationView.setVisibility(View.GONE);
}
fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) { switch (fabOption) {
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH:
fab.setImageResource(R.drawable.ic_refresh_24dp); fab.setImageResource(R.drawable.ic_refresh_24dp);
@ -735,13 +742,23 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fab.setImageResource(R.drawable.ic_random_24dp); fab.setImageResource(R.drawable.ic_random_24dp);
break; break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp); fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
}
break; break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
fab.setImageResource(R.drawable.ic_filter_24dp); fab.setImageResource(R.drawable.ic_filter_24dp);
break; break;
default: default:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_add_day_night_24dp); fab.setImageResource(R.drawable.ic_add_day_night_24dp);
}
break; break;
} }
fab.setOnClickListener(view -> { fab.setOnClickListener(view -> {
@ -792,15 +809,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}); });
fab.setOnLongClickListener(view -> { fab.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment(); FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccessToken == null);
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag()); fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true; return true;
}); });
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
} else {
bottomNavigationView.setVisibility(View.GONE);
fab.setVisibility(View.GONE);
}
} }
private void bottomAppBarOptionAction(int option) { private void bottomAppBarOptionAction(int option) {

View File

@ -184,7 +184,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:tint="@android:color/white"
app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" /> app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -151,7 +151,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:tint="@android:color/white"
app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" /> app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>