mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Add an FloatingActionButton in SearchResultActivity.
This commit is contained in:
parent
c979e79ee6
commit
f376de69e1
@ -48,5 +48,5 @@ public interface FragmentCommunicator {
|
|||||||
|
|
||||||
default void filterPosts() {
|
default void filterPosts() {
|
||||||
|
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
public interface PostFragmentContentScrollingInterface {
|
||||||
|
void contentScrollUp();
|
||||||
|
|
||||||
|
void contentScrollDown();
|
||||||
|
}
|
@ -34,6 +34,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
||||||
import ml.docilealligator.infinityforreddit.PostFilter;
|
import ml.docilealligator.infinityforreddit.PostFilter;
|
||||||
|
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
@ -55,7 +56,8 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
|||||||
|
|
||||||
public class FilteredPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class FilteredPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface,
|
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface,
|
||||||
MarkPostAsReadInterface, FilteredThingFABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback {
|
MarkPostAsReadInterface, FilteredThingFABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
||||||
|
PostFragmentContentScrollingInterface {
|
||||||
|
|
||||||
public static final String EXTRA_NAME = "ESN";
|
public static final String EXTRA_NAME = "ESN";
|
||||||
public static final String EXTRA_QUERY = "EQ";
|
public static final String EXTRA_QUERY = "EQ";
|
||||||
@ -549,10 +551,12 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentScrollUp() {
|
public void contentScrollUp() {
|
||||||
fab.show();
|
fab.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentScrollDown() {
|
public void contentScrollDown() {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ 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.PullNotificationWorker;
|
import ml.docilealligator.infinityforreddit.PullNotificationWorker;
|
||||||
@ -115,7 +116,7 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
|
|||||||
public class MainActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class MainActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
||||||
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
||||||
RandomBottomSheetFragment.RandomOptionSelectionCallback, MarkPostAsReadInterface {
|
RandomBottomSheetFragment.RandomOptionSelectionCallback, MarkPostAsReadInterface, PostFragmentContentScrollingInterface {
|
||||||
|
|
||||||
static final String EXTRA_MESSSAGE_FULLNAME = "ENF";
|
static final String EXTRA_MESSSAGE_FULLNAME = "ENF";
|
||||||
static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||||
@ -1106,7 +1107,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
sectionsPagerAdapter.changePostLayout(postLayout);
|
sectionsPagerAdapter.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postScrollUp() {
|
@Override
|
||||||
|
public void contentScrollUp() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (showBottomAppBar && !mLockBottomAppBar) {
|
if (showBottomAppBar && !mLockBottomAppBar) {
|
||||||
bottomAppBar.performShow();
|
bottomAppBar.performShow();
|
||||||
@ -1117,7 +1119,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postScrollDown() {
|
@Override
|
||||||
|
public void contentScrollDown() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (!(showBottomAppBar && mLockBottomAppBar)) {
|
if (!(showBottomAppBar && mLockBottomAppBar)) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.activities;
|
package ml.docilealligator.infinityforreddit.activities;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -10,6 +11,8 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -22,6 +25,8 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
|||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.google.android.material.tabs.TabLayoutMediator;
|
import com.google.android.material.tabs.TabLayoutMediator;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
@ -36,8 +41,18 @@ import javax.inject.Named;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||||
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
|
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.RandomBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchPostSortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchPostSortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchUserAndSubredditSortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchUserAndSubredditSortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
|
||||||
@ -47,19 +62,15 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
|||||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||||
import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment;
|
import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment;
|
||||||
import ml.docilealligator.infinityforreddit.fragments.UserListingFragment;
|
import ml.docilealligator.infinityforreddit.fragments.UserListingFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
|
||||||
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import ml.docilealligator.infinityforreddit.recentsearchquery.InsertRecentSearchQuery;
|
import ml.docilealligator.infinityforreddit.recentsearchquery.InsertRecentSearchQuery;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface,
|
||||||
|
FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
||||||
|
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostFragmentContentScrollingInterface {
|
||||||
static final String EXTRA_QUERY = "QK";
|
static final String EXTRA_QUERY = "QK";
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
|
|
||||||
@ -77,6 +88,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
TabLayout tabLayout;
|
TabLayout tabLayout;
|
||||||
@BindView(R.id.view_pager_search_result_activity)
|
@BindView(R.id.view_pager_search_result_activity)
|
||||||
ViewPager2 viewPager2;
|
ViewPager2 viewPager2;
|
||||||
|
@BindView(R.id.fab_search_result_activity)
|
||||||
|
FloatingActionButton fab;
|
||||||
@Inject
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@ -89,6 +102,12 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
@Named("post_layout")
|
@Named("post_layout")
|
||||||
SharedPreferences mPostLayoutSharedPreferences;
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("bottom_app_bar")
|
||||||
|
SharedPreferences bottomAppBarSharedPreference;
|
||||||
|
@Inject
|
||||||
|
@Named("nsfw_and_spoiler")
|
||||||
|
SharedPreferences mNsfwAndSpoilerSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
@ -98,10 +117,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
private boolean mInsertSearchQuerySuccess;
|
private boolean mInsertSearchQuerySuccess;
|
||||||
private FragmentManager fragmentManager;
|
private FragmentManager fragmentManager;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
private SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment;
|
|
||||||
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
|
|
||||||
private SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment;
|
|
||||||
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
|
||||||
private SlidrInterface mSlidrInterface;
|
private SlidrInterface mSlidrInterface;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,6 +153,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||||
}
|
}
|
||||||
adjustToolbar(toolbar);
|
adjustToolbar(toolbar);
|
||||||
|
|
||||||
|
int navBarHeight = getNavBarHeight();
|
||||||
|
if (navBarHeight > 0) {
|
||||||
|
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
||||||
|
params.bottomMargin += navBarHeight;
|
||||||
|
fab.setLayoutParams(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,19 +190,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
if (!mNullAccessToken && mAccessToken == null) {
|
if (!mNullAccessToken && mAccessToken == null) {
|
||||||
getCurrentAccountAndInitializeViewPager();
|
getCurrentAccountAndInitializeViewPager();
|
||||||
} else {
|
} else {
|
||||||
initializeViewPager();
|
bindView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
searchPostSortTypeBottomSheetFragment.setArguments(bundle);
|
|
||||||
|
|
||||||
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
|
||||||
|
|
||||||
searchUserAndSubredditSortTypeBottomSheetFragment = new SearchUserAndSubredditSortTypeBottomSheetFragment();
|
|
||||||
|
|
||||||
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -206,6 +218,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
|
applyFABTheme(fab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getCurrentAccountAndInitializeViewPager() {
|
private void getCurrentAccountAndInitializeViewPager() {
|
||||||
@ -216,11 +229,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
mAccessToken = account.getAccessToken();
|
mAccessToken = account.getAccessToken();
|
||||||
mAccountName = account.getUsername();
|
mAccountName = account.getUsername();
|
||||||
}
|
}
|
||||||
initializeViewPager();
|
bindView();
|
||||||
}).execute();
|
}).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeViewPager() {
|
private void bindView() {
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(3);
|
viewPager2.setOffscreenPageLimit(3);
|
||||||
@ -251,12 +264,130 @@ 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);
|
||||||
|
switch (fabOption) {
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH:
|
||||||
|
fab.setImageResource(R.drawable.ic_refresh_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE:
|
||||||
|
fab.setImageResource(R.drawable.ic_sort_toolbar_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT:
|
||||||
|
fab.setImageResource(R.drawable.ic_post_layout_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH:
|
||||||
|
fab.setImageResource(R.drawable.ic_search_black_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT:
|
||||||
|
fab.setImageResource(R.drawable.ic_subreddit_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER:
|
||||||
|
fab.setImageResource(R.drawable.ic_user_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM:
|
||||||
|
fab.setImageResource(R.drawable.ic_random_24dp);
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
fab.setImageResource(R.drawable.ic_filter_24dp);
|
||||||
|
} else {
|
||||||
|
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
|
||||||
|
fab.setImageResource(R.drawable.ic_filter_24dp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
fab.setImageResource(R.drawable.ic_filter_24dp);
|
||||||
|
} else {
|
||||||
|
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fab.setOnClickListener(view -> {
|
||||||
|
switch (fabOption) {
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH: {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.refresh();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: {
|
||||||
|
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment();
|
||||||
|
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: {
|
||||||
|
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||||
|
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: {
|
||||||
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT:
|
||||||
|
goToSubreddit();
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER:
|
||||||
|
goToUser();
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM:
|
||||||
|
random();
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.hideReadPosts();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.filterPosts();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
|
||||||
|
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
if (mAccountName != null && mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
|
if (mAccountName != null && mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
|
||||||
InsertRecentSearchQuery.insertRecentSearchQueryListener(mRedditDataRoomDatabase, mAccountName,
|
InsertRecentSearchQuery.insertRecentSearchQueryListener(mRedditDataRoomDatabase, mAccountName,
|
||||||
mQuery, () -> mInsertSearchQuerySuccess = true);
|
mQuery, () -> mInsertSearchQuerySuccess = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displaySortTypeBottomSheetFragment() {
|
||||||
|
switch (viewPager2.getCurrentItem()) {
|
||||||
|
case 0: {
|
||||||
|
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment();
|
||||||
|
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment
|
||||||
|
= new SearchUserAndSubredditSortTypeBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt(SearchUserAndSubredditSortTypeBottomSheetFragment.EXTRA_FRAGMENT_POSITION, viewPager2.getCurrentItem());
|
||||||
|
searchUserAndSubredditSortTypeBottomSheetFragment.setArguments(bundle);
|
||||||
|
searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.search_result_activity, menu);
|
getMenuInflater().inflate(R.menu.search_result_activity, menu);
|
||||||
@ -271,19 +402,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
onBackPressed();
|
onBackPressed();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_sort_search_result_activity:
|
case R.id.action_sort_search_result_activity:
|
||||||
switch (viewPager2.getCurrentItem()) {
|
displaySortTypeBottomSheetFragment();
|
||||||
case 0: {
|
|
||||||
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(SearchUserAndSubredditSortTypeBottomSheetFragment.EXTRA_FRAGMENT_POSITION, viewPager2.getCurrentItem());
|
|
||||||
searchUserAndSubredditSortTypeBottomSheetFragment.setArguments(bundle);
|
|
||||||
searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_search_search_result_activity:
|
case R.id.action_search_search_result_activity:
|
||||||
Intent intent = new Intent(this, SearchActivity.class);
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
@ -300,6 +419,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_change_post_layout_search_result_activity:
|
case R.id.action_change_post_layout_search_result_activity:
|
||||||
|
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||||
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -333,6 +453,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
public void sortTypeSelected(String sortType) {
|
public void sortTypeSelected(String sortType) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType);
|
bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType);
|
||||||
|
SortTimeBottomSheetFragment sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||||
sortTimeBottomSheetFragment.setArguments(bundle);
|
sortTimeBottomSheetFragment.setArguments(bundle);
|
||||||
sortTimeBottomSheetFragment.show(getSupportFragmentManager(), sortTimeBottomSheetFragment.getTag());
|
sortTimeBottomSheetFragment.show(getSupportFragmentManager(), sortTimeBottomSheetFragment.getTag());
|
||||||
}
|
}
|
||||||
@ -379,6 +500,153 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fabOptionSelected(int option) {
|
||||||
|
switch (option) {
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SUBMIT_POST:
|
||||||
|
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
|
||||||
|
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_REFRESH:
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.refresh();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_SORT_TYPE:
|
||||||
|
displaySortTypeBottomSheetFragment();
|
||||||
|
break;
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT:
|
||||||
|
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||||
|
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||||
|
break;
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
|
||||||
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
|
||||||
|
goToSubreddit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_USER: {
|
||||||
|
goToUser();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||||
|
random();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.hideReadPosts();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FABMoreOptionsBottomSheetFragment.FAB_FILTER_POSTS: {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.filterPosts();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void goToSubreddit() {
|
||||||
|
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||||
|
thingEditText.requestFocus();
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
if (imm != null) {
|
||||||
|
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||||
|
}
|
||||||
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.go_to_subreddit)
|
||||||
|
.setView(thingEditText)
|
||||||
|
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||||
|
-> {
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||||
|
startActivity(subredditIntent);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.setOnDismissListener(dialogInterface -> {
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void goToUser() {
|
||||||
|
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||||
|
thingEditText.requestFocus();
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
if (imm != null) {
|
||||||
|
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||||
|
}
|
||||||
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.go_to_user)
|
||||||
|
.setView(thingEditText)
|
||||||
|
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||||
|
-> {
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||||
|
startActivity(userIntent);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.setOnDismissListener(dialogInterface -> {
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void random() {
|
||||||
|
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
|
||||||
|
randomBottomSheetFragment.setArguments(bundle);
|
||||||
|
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postTypeSelected(int postType) {
|
||||||
|
Intent intent;
|
||||||
|
switch (postType) {
|
||||||
|
case PostTypeBottomSheetFragment.TYPE_TEXT:
|
||||||
|
intent = new Intent(this, PostTextActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
case PostTypeBottomSheetFragment.TYPE_LINK:
|
||||||
|
intent = new Intent(this, PostLinkActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
case PostTypeBottomSheetFragment.TYPE_IMAGE:
|
||||||
|
intent = new Intent(this, PostImageActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
case PostTypeBottomSheetFragment.TYPE_VIDEO:
|
||||||
|
intent = new Intent(this, PostVideoActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contentScrollUp() {
|
||||||
|
fab.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contentScrollDown() {
|
||||||
|
fab.hide();
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||||
|
|
||||||
public SectionsPagerAdapter(FragmentActivity fa) {
|
public SectionsPagerAdapter(FragmentActivity fa) {
|
||||||
@ -505,6 +773,20 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void filterPosts() {
|
||||||
|
Fragment fragment = fragmentManager.findFragmentByTag("f0");
|
||||||
|
if (fragment instanceof PostFragment) {
|
||||||
|
((PostFragment) fragment).filterPosts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void hideReadPosts() {
|
||||||
|
Fragment fragment = fragmentManager.findFragmentByTag("f0");
|
||||||
|
if (fragment instanceof PostFragment) {
|
||||||
|
((PostFragment) fragment).hideReadPosts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -66,6 +66,7 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
|
|||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
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.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
@ -102,7 +103,7 @@ import retrofit2.Retrofit;
|
|||||||
public class ViewSubredditDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class ViewSubredditDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
||||||
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
||||||
RandomBottomSheetFragment.RandomOptionSelectionCallback, MarkPostAsReadInterface {
|
RandomBottomSheetFragment.RandomOptionSelectionCallback, MarkPostAsReadInterface, PostFragmentContentScrollingInterface {
|
||||||
|
|
||||||
public static final String EXTRA_SUBREDDIT_NAME_KEY = "ESN";
|
public static final String EXTRA_SUBREDDIT_NAME_KEY = "ESN";
|
||||||
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
|
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
|
||||||
@ -1053,6 +1054,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
sectionsPagerAdapter.changePostLayout(postLayout);
|
sectionsPagerAdapter.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentScrollUp() {
|
public void contentScrollUp() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (showBottomAppBar && !lockBottomAppBar) {
|
if (showBottomAppBar && !lockBottomAppBar) {
|
||||||
@ -1064,6 +1066,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentScrollDown() {
|
public void contentScrollDown() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (!(showBottomAppBar && lockBottomAppBar)) {
|
if (!(showBottomAppBar && lockBottomAppBar)) {
|
||||||
|
@ -70,6 +70,7 @@ import ml.docilealligator.infinityforreddit.DeleteThing;
|
|||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
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.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
@ -108,7 +109,7 @@ import retrofit2.Retrofit;
|
|||||||
public class ViewUserDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class ViewUserDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
||||||
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
ActivityToolbarInterface, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
|
||||||
RandomBottomSheetFragment.RandomOptionSelectionCallback, MarkPostAsReadInterface {
|
RandomBottomSheetFragment.RandomOptionSelectionCallback, MarkPostAsReadInterface, PostFragmentContentScrollingInterface {
|
||||||
|
|
||||||
public static final String EXTRA_USER_NAME_KEY = "EUNK";
|
public static final String EXTRA_USER_NAME_KEY = "EUNK";
|
||||||
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
|
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
|
||||||
@ -1198,6 +1199,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentScrollUp() {
|
public void contentScrollUp() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (showBottomAppBar && !lockBottomAppBar) {
|
if (showBottomAppBar && !lockBottomAppBar) {
|
||||||
@ -1209,6 +1211,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentScrollDown() {
|
public void contentScrollDown() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (!(showBottomAppBar && lockBottomAppBar)) {
|
if (!(showBottomAppBar && lockBottomAppBar)) {
|
||||||
|
@ -17,6 +17,7 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
|
|
||||||
public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_ANONYMOUS_MODE = "EAM";
|
||||||
public static final int FAB_OPTION_SUBMIT_POST = 0;
|
public static final int FAB_OPTION_SUBMIT_POST = 0;
|
||||||
public static final int FAB_OPTION_REFRESH = 1;
|
public static final int FAB_OPTION_REFRESH = 1;
|
||||||
public static final int FAB_OPTION_CHANGE_SORT_TYPE = 2;
|
public static final int FAB_OPTION_CHANGE_SORT_TYPE = 2;
|
||||||
@ -62,10 +63,20 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
|
|||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
submitPostTextView.setOnClickListener(view -> {
|
if (getArguments() != null && getArguments().getBoolean(EXTRA_ANONYMOUS_MODE, false)) {
|
||||||
activity.fabOptionSelected(FAB_OPTION_SUBMIT_POST);
|
submitPostTextView.setVisibility(View.GONE);
|
||||||
dismiss();
|
hideReadPostsTextView.setVisibility(View.GONE);
|
||||||
});
|
} else {
|
||||||
|
submitPostTextView.setOnClickListener(view -> {
|
||||||
|
activity.fabOptionSelected(FAB_OPTION_SUBMIT_POST);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
hideReadPostsTextView.setOnClickListener(view -> {
|
||||||
|
activity.fabOptionSelected(FAB_HIDE_READ_POSTS);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
refreshTextView.setOnClickListener(view -> {
|
refreshTextView.setOnClickListener(view -> {
|
||||||
activity.fabOptionSelected(FAB_OPTION_REFRESH);
|
activity.fabOptionSelected(FAB_OPTION_REFRESH);
|
||||||
@ -102,11 +113,6 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
hideReadPostsTextView.setOnClickListener(view -> {
|
|
||||||
activity.fabOptionSelected(FAB_HIDE_READ_POSTS);
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
filterPostsTextView.setOnClickListener(view -> {
|
filterPostsTextView.setOnClickListener(view -> {
|
||||||
activity.fabOptionSelected(FAB_FILTER_POSTS);
|
activity.fabOptionSelected(FAB_FILTER_POSTS);
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -67,14 +67,12 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.PostFilter;
|
import ml.docilealligator.infinityforreddit.PostFilter;
|
||||||
|
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.MainActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.adapters.PostRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.adapters.PostRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.CustomToroContainer;
|
import ml.docilealligator.infinityforreddit.customviews.CustomToroContainer;
|
||||||
@ -407,47 +405,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (activity instanceof MainActivity) {
|
if (activity instanceof PostFragmentContentScrollingInterface) {
|
||||||
mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||||
if (dy > 0) {
|
if (dy > 0) {
|
||||||
((MainActivity) activity).postScrollDown();
|
((PostFragmentContentScrollingInterface) activity).contentScrollDown();
|
||||||
} else if (dy < 0) {
|
} else if (dy < 0) {
|
||||||
((MainActivity) activity).postScrollUp();
|
((PostFragmentContentScrollingInterface) activity).contentScrollUp();
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (activity instanceof ViewSubredditDetailActivity) {
|
|
||||||
mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
if (dy > 0) {
|
|
||||||
((ViewSubredditDetailActivity) activity).contentScrollDown();
|
|
||||||
} else if (dy < 0) {
|
|
||||||
((ViewSubredditDetailActivity) activity).contentScrollUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (activity instanceof ViewUserDetailActivity) {
|
|
||||||
mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
if (dy > 0) {
|
|
||||||
((ViewUserDetailActivity) activity).contentScrollDown();
|
|
||||||
} else if (dy < 0) {
|
|
||||||
((ViewUserDetailActivity) activity).contentScrollUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (activity instanceof FilteredPostsActivity) {
|
|
||||||
mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
if (dy > 0) {
|
|
||||||
((FilteredPostsActivity) activity).contentScrollDown();
|
|
||||||
} else if (dy < 0) {
|
|
||||||
((FilteredPostsActivity) activity).contentScrollUp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -47,4 +47,11 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab_search_result_activity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:layout_gravity="bottom|end" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue
Block a user