aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java103
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java141
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java251
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java80
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java2
5 files changed, 330 insertions, 247 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 12616a96..d3a2fb78 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -310,7 +310,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
toggle.syncState();
- showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true);
+ showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
mBackButtonAction = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION, "0"));
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
mDisableSwipingBetweenTabs = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false);
@@ -496,21 +496,18 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_HIDDEN: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(MainActivity.this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_HIDDEN);
startActivity(intent);
break;
}
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SAVED: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(MainActivity.this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
startActivity(intent);
break;
}
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GILDED: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(MainActivity.this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_GILDED);
startActivity(intent);
break;
@@ -579,66 +576,58 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return;
}
- 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);
- } else {
- if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
- int option2 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS);
+ if (showBottomAppBar) {
+ int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ int option2 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS);
- bottomAppBar.setVisibility(View.VISIBLE);
+ bottomAppBar.setVisibility(View.VISIBLE);
- if (optionCount == 2) {
- linearLayoutBottomAppBar.setWeightSum(3);
- option1BottomAppBar.setVisibility(View.GONE);
- option3BottomAppBar.setVisibility(View.GONE);
+ if (optionCount == 2) {
+ linearLayoutBottomAppBar.setWeightSum(3);
+ option1BottomAppBar.setVisibility(View.GONE);
+ option3BottomAppBar.setVisibility(View.GONE);
- option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
- option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
+ option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
+ option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
- option2BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option1);
- });
+ option2BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option1);
+ });
- option4BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option2);
- });
- } else {
- int option3 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_PROFILE);
+ option4BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option2);
+ });
+ } else {
+ int option3 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, mAccessToken == null ? SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, mAccessToken == null ? SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE : SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_PROFILE);
- option1BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
- option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
- option3BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option3));
- option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option4));
+ option1BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
+ option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
+ option3BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option3));
+ option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option4));
- option1BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option1);
- });
+ option1BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option1);
+ });
- option2BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option2);
- });
+ option2BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option2);
+ });
- option3BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option3);
- });
+ option3BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option3);
+ });
- option4BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option4);
- });
- }
- } else {
- CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
- lp.setAnchorId(View.NO_ID);
- lp.gravity = Gravity.END | Gravity.BOTTOM;
- fab.setLayoutParams(lp);
+ option4BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option4);
+ });
}
+ } else {
+ CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
+ lp.setAnchorId(View.NO_ID);
+ lp.gravity = Gravity.END | Gravity.BOTTOM;
+ fab.setLayoutParams(lp);
}
fabOption = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB,
@@ -1208,20 +1197,20 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public void contentScrollUp() {
- if (mAccessToken != null && showBottomAppBar && !mLockBottomAppBar) {
+ if (showBottomAppBar && !mLockBottomAppBar) {
bottomAppBar.performShow();
}
- if (!(mAccessToken != null && showBottomAppBar && mLockBottomAppBar)) {
+ if (!(showBottomAppBar && mLockBottomAppBar)) {
fab.show();
}
}
@Override
public void contentScrollDown() {
- if (!(mAccessToken != null && showBottomAppBar && mLockBottomAppBar)) {
+ if (!(showBottomAppBar && mLockBottomAppBar)) {
fab.hide();
}
- if (mAccessToken != null && showBottomAppBar && !mLockBottomAppBar) {
+ if (showBottomAppBar && !mLockBottomAppBar) {
bottomAppBar.performHide();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 727a35fe..55b73a0a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -76,7 +76,6 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
-import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
@@ -338,7 +337,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
});
}
- showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true);
+ showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
boolean hideSubredditDescription = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_DESCRIPTION, false);
@@ -658,35 +657,30 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_UPVOTED: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_UPVOTED);
startActivity(intent);
break;
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_DOWNVOTED: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_DOWNVOTED);
startActivity(intent);
break;
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HIDDEN: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_HIDDEN);
startActivity(intent);
break;
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SAVED: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
startActivity(intent);
break;
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED: {
Intent intent = new Intent(this, AccountPostsActivity.class);
- intent = new Intent(this, AccountPostsActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_GILDED);
startActivity(intent);
break;
@@ -752,81 +746,74 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
private void bindView() {
- if (mAccessToken != null) {
- if (mMessageFullname != null) {
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
- @Override
- public void readSuccess() {
- mMessageFullname = null;
- }
+ if (mMessageFullname != null) {
+ ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
+ @Override
+ public void readSuccess() {
+ mMessageFullname = null;
+ }
- @Override
- public void readFailed() {
+ @Override
+ public void readFailed() {
- }
- });
- }
+ }
+ });
+ }
- if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
- int option2 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ if (showBottomAppBar) {
+ int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
+ int option2 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
- bottomNavigationView.setVisibility(View.VISIBLE);
+ bottomNavigationView.setVisibility(View.VISIBLE);
- if (optionCount == 2) {
- linearLayoutBottomAppBar.setWeightSum(3);
- option1BottomAppBar.setVisibility(View.GONE);
- option3BottomAppBar.setVisibility(View.GONE);
+ if (optionCount == 2) {
+ linearLayoutBottomAppBar.setWeightSum(3);
+ option1BottomAppBar.setVisibility(View.GONE);
+ option3BottomAppBar.setVisibility(View.GONE);
- option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
- option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
+ option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
+ option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
- option2BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option1);
- });
+ option2BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option1);
+ });
- option4BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option2);
- });
- } else {
- int option3 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
+ option4BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option2);
+ });
+ } else {
+ int option3 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, mAccessToken == null ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, mAccessToken == null ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
- option1BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
- option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
- option3BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option3));
- option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option4));
+ option1BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
+ option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
+ option3BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option3));
+ option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option4));
- option1BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option1);
- });
+ option1BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option1);
+ });
- option2BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option2);
- });
+ option2BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option2);
+ });
- option3BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option3);
- });
+ option3BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option3);
+ });
- option4BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option4);
- });
- }
- } else {
- CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
- lp.setAnchorId(View.NO_ID);
- lp.gravity = Gravity.END | Gravity.BOTTOM;
- fab.setLayoutParams(lp);
+ option4BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option4);
+ });
}
} else {
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 = mBottomAppBarSharedPreference.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:
@@ -1042,10 +1029,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
lockSwipeRightToGoBack();
}
- if (mAccessToken != null) {
- if (showBottomAppBar) {
- bottomNavigationView.performShow();
- }
+ if (showBottomAppBar) {
+ bottomNavigationView.performShow();
}
fab.show();
@@ -1268,25 +1253,21 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override
public void contentScrollUp() {
- if (mAccessToken != null) {
- if (showBottomAppBar && !lockBottomAppBar) {
- bottomNavigationView.performShow();
- }
- if (!(showBottomAppBar && lockBottomAppBar)) {
- fab.show();
- }
+ if (showBottomAppBar && !lockBottomAppBar) {
+ bottomNavigationView.performShow();
+ }
+ if (!(showBottomAppBar && lockBottomAppBar)) {
+ fab.show();
}
}
@Override
public void contentScrollDown() {
- if (mAccessToken != null) {
- if (!(showBottomAppBar && lockBottomAppBar)) {
- fab.hide();
- }
- if (showBottomAppBar && !lockBottomAppBar) {
- bottomNavigationView.performHide();
- }
+ if (!(showBottomAppBar && lockBottomAppBar)) {
+ fab.hide();
+ }
+ if (showBottomAppBar && !lockBottomAppBar) {
+ bottomNavigationView.performHide();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index e1b5314c..f77cd015 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.net.Uri;
+import android.opengl.Visibility;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -71,7 +72,6 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.DeleteThing;
-import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
@@ -261,6 +261,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
+ showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
+ lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
if (savedInstanceState == null) {
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
@@ -359,9 +361,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
});
}
- showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true);
- lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
-
glide = Glide.with(this);
Locale locale = getResources().getConfiguration().locale;
@@ -639,10 +638,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
lockSwipeRightToGoBack();
}
- if (mAccessToken != null) {
- if (showBottomAppBar) {
- bottomNavigationView.performShow();
- }
+ if (showBottomAppBar) {
+ bottomNavigationView.performShow();
}
fab.show();
@@ -652,81 +649,74 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fixViewPager2Sensitivity(viewPager2);
- if (mAccessToken != null) {
- if (mMessageFullname != null) {
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
- @Override
- public void readSuccess() {
- mMessageFullname = null;
- }
+ if (mMessageFullname != null) {
+ ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
+ @Override
+ public void readSuccess() {
+ mMessageFullname = null;
+ }
- @Override
- public void readFailed() {
+ @Override
+ public void readFailed() {
- }
- });
- }
+ }
+ });
+ }
- if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
- int option2 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ if (showBottomAppBar) {
+ int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
+ int option2 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
- bottomNavigationView.setVisibility(View.VISIBLE);
+ bottomNavigationView.setVisibility(View.VISIBLE);
- if (optionCount == 2) {
- linearLayoutBottomAppBar.setWeightSum(3);
- option1BottomAppBar.setVisibility(View.GONE);
- option3BottomAppBar.setVisibility(View.GONE);
+ if (optionCount == 2) {
+ linearLayoutBottomAppBar.setWeightSum(3);
+ option1BottomAppBar.setVisibility(View.GONE);
+ option3BottomAppBar.setVisibility(View.GONE);
- option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
- option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
+ option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
+ option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
- option2BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option1);
- });
+ option2BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option1);
+ });
- option4BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option2);
- });
- } else {
- int option3 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
+ option4BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option2);
+ });
+ } else {
+ int option3 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, mAccessToken == null ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, mAccessToken == null ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
- option1BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
- option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
- option3BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option3));
- option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option4));
+ option1BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option1));
+ option2BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option2));
+ option3BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option3));
+ option4BottomAppBar.setImageResource(getBottomAppBarOptionDrawableResource(option4));
- option1BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option1);
- });
+ option1BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option1);
+ });
- option2BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option2);
- });
+ option2BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option2);
+ });
- option3BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option3);
- });
+ option3BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option3);
+ });
- option4BottomAppBar.setOnClickListener(view -> {
- bottomAppBarOptionAction(option4);
- });
- }
- } else {
- CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
- lp.setAnchorId(View.NO_ID);
- lp.gravity = Gravity.END | Gravity.BOTTOM;
- fab.setLayoutParams(lp);
+ option4BottomAppBar.setOnClickListener(view -> {
+ bottomAppBarOptionAction(option4);
+ });
}
} else {
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 = mBottomAppBarSharedPreference.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:
@@ -856,6 +846,85 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
startActivity(intent);
break;
}
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.refresh();
+ }
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE: {
+ userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: {
+ PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH: {
+ Intent intent = new Intent(this, SearchActivity.class);
+ startActivity(intent);
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_SUBREDDIT:
+ goToSubreddit();
+ break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_USER:
+ goToUser();
+ break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_RANDOM:
+ random();
+ break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HIDE_READ_POSTS:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.hideReadPosts();
+ }
+ break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_FILTER_POSTS:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_UPVOTED: {
+ Intent intent = new Intent(this, AccountPostsActivity.class);
+ intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_UPVOTED);
+ startActivity(intent);
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_DOWNVOTED: {
+ Intent intent = new Intent(this, AccountPostsActivity.class);
+ intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_DOWNVOTED);
+ startActivity(intent);
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HIDDEN: {
+ Intent intent = new Intent(this, AccountPostsActivity.class);
+ intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_HIDDEN);
+ startActivity(intent);
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SAVED: {
+ Intent intent = new Intent(this, AccountPostsActivity.class);
+ intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
+ startActivity(intent);
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED: {
+ Intent intent = new Intent(this, AccountPostsActivity.class);
+ intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_GILDED);
+ startActivity(intent);
+ break;
+ }
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
+ }
+ default:
+ PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
+ postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
+ break;
}
}
@@ -869,6 +938,38 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
return R.drawable.ic_inbox_24dp;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS:
return R.drawable.ic_multi_reddit_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBMIT_POSTS:
+ return R.drawable.ic_add_day_night_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH:
+ return R.drawable.ic_refresh_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE:
+ return R.drawable.ic_sort_toolbar_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT:
+ return R.drawable.ic_post_layout_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH:
+ return R.drawable.ic_search_black_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_SUBREDDIT:
+ return R.drawable.ic_subreddit_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_USER:
+ return R.drawable.ic_user_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_RANDOM:
+ return R.drawable.ic_random_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HIDE_READ_POSTS:
+ return R.drawable.ic_hide_read_posts_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_FILTER_POSTS:
+ return R.drawable.ic_filter_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_UPVOTED:
+ return R.drawable.ic_arrow_upward_black_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_DOWNVOTED:
+ return R.drawable.ic_arrow_downward_black_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HIDDEN:
+ return R.drawable.ic_outline_lock_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SAVED:
+ return R.drawable.ic_outline_bookmarks_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED:
+ return R.drawable.ic_star_border_24dp;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP:
+ return R.drawable.ic_keyboard_double_arrow_up_24;
default:
return R.drawable.ic_account_circle_24dp;
}
@@ -1309,25 +1410,21 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
public void contentScrollUp() {
- if (mAccessToken != null) {
- if (showBottomAppBar && !lockBottomAppBar) {
- bottomNavigationView.performShow();
- }
- if (!(showBottomAppBar && lockBottomAppBar)) {
- fab.show();
- }
+ if (showBottomAppBar && !lockBottomAppBar) {
+ bottomNavigationView.performShow();
+ }
+ if (!(showBottomAppBar && lockBottomAppBar)) {
+ fab.show();
}
}
@Override
public void contentScrollDown() {
- if (mAccessToken != null) {
- if (!(showBottomAppBar && lockBottomAppBar)) {
- fab.hide();
- }
- if (showBottomAppBar && !lockBottomAppBar) {
- bottomNavigationView.performHide();
- }
+ if (!(showBottomAppBar && lockBottomAppBar)) {
+ fab.hide();
+ }
+ if (showBottomAppBar && !lockBottomAppBar) {
+ bottomNavigationView.performHide();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
index d80442eb..2c8b917f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
@@ -121,6 +121,8 @@ public class CustomizeBottomAppBarFragment extends Fragment {
Resources resources = activity.getResources();
String[] mainActivityOptions = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options);
+ String[] mainActivityOptionAnonymous = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options_anonymous);
+ String[] mainActivityOptionAnonymousValues = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options_anonymous_values);
String[] fabOptions;
if (accountName == null) {
fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options_anonymous);
@@ -156,10 +158,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption1LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_1)
- .setSingleChoiceItems(mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> {
mainActivityOption1 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, mainActivityOption1).apply();
- mainActivityOption1TextView.setText(mainActivityOptions[mainActivityOption1]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption1;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
+ mainActivityOption1TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -168,10 +171,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption2LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_2)
- .setSingleChoiceItems(mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> {
mainActivityOption2 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, mainActivityOption2).apply();
- mainActivityOption2TextView.setText(mainActivityOptions[mainActivityOption2]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption2;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
+ mainActivityOption2TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -180,10 +184,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption3LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_3)
- .setSingleChoiceItems(mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> {
mainActivityOption3 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, mainActivityOption3).apply();
- mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption3;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
+ mainActivityOption3TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -192,10 +197,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption4LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_4)
- .setSingleChoiceItems(mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> {
mainActivityOption4 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, mainActivityOption4).apply();
- mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption4;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
+ mainActivityOption4TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -205,16 +211,18 @@ public class CustomizeBottomAppBarFragment extends Fragment {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_fab)
.setSingleChoiceItems(fabOptions, mainActivityFAB, (dialogInterface, i) -> {
+ mainActivityFAB = i;
+ int optionToSaveInPreference;
if (accountName == null) {
if (i == 7) {
- mainActivityFAB = 9;
+ optionToSaveInPreference = 9;
} else {
- mainActivityFAB = i + 1;
+ optionToSaveInPreference = i + 1;
}
} else {
- mainActivityFAB = i;
+ optionToSaveInPreference = i;
}
- sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, mainActivityFAB).apply();
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, optionToSaveInPreference).apply();
mainActivityFABTextView.setText(fabOptions[mainActivityFAB]);
dialogInterface.dismiss();
})
@@ -222,6 +230,8 @@ public class CustomizeBottomAppBarFragment extends Fragment {
});
String[] otherActivitiesOptions = resources.getStringArray(R.array.settings_other_activities_bottom_app_bar_options);
+ String[] otherActivitiesOptionAnonymous = resources.getStringArray(R.array.settings_other_activities_bottom_app_bar_options_anonymous);
+ String[] otherActivitiesOptionAnonymousValues = resources.getStringArray(R.array.settings_other_activities_bottom_app_bar_options_anonymous_values);
otherActivitiesOptionCount = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
otherActivitiesOption1 = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, 0);
otherActivitiesOption2 = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, 1);
@@ -251,10 +261,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption1LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_1)
- .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> {
otherActivitiesOption1 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, otherActivitiesOption1).apply();
- otherActivitiesOption1TextView.setText(otherActivitiesOptions[otherActivitiesOption1]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption1;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
+ otherActivitiesOption1TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -263,10 +274,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption2LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_2)
- .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> {
otherActivitiesOption2 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, otherActivitiesOption2).apply();
- otherActivitiesOption2TextView.setText(otherActivitiesOptions[otherActivitiesOption2]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption2;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
+ otherActivitiesOption2TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -275,10 +287,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption3LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_3)
- .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> {
otherActivitiesOption3 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, otherActivitiesOption3).apply();
- otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption3;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
+ otherActivitiesOption3TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -287,10 +300,11 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption4LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_4)
- .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> {
otherActivitiesOption4 = i;
- sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, otherActivitiesOption4).apply();
- otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]);
+ int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption4;
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
+ otherActivitiesOption4TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
.show();
@@ -300,16 +314,18 @@ public class CustomizeBottomAppBarFragment extends Fragment {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_fab)
.setSingleChoiceItems(fabOptions, otherActivitiesFAB, (dialogInterface, i) -> {
+ otherActivitiesFAB = i;
+ int optionToSaveInPreference;
if (accountName == null) {
if (i == 7) {
- otherActivitiesFAB = 9;
+ optionToSaveInPreference = 9;
} else {
- otherActivitiesFAB = i + 1;
+ optionToSaveInPreference = i + 1;
}
} else {
- otherActivitiesFAB = i;
+ optionToSaveInPreference = i;
}
- sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, otherActivitiesFAB).apply();
+ sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, optionToSaveInPreference).apply();
otherActivitiesFABTextView.setText(fabOptions[otherActivitiesFAB]);
dialogInterface.dismiss();
})
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java
index 831755c2..882455ef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java
@@ -56,7 +56,7 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
return true;
});
- if (sharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true)) {
+ if (sharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false)) {
lockBottomAppBarSwitch.setVisible(true);
lockBottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeLockBottomAppBarEvent((Boolean) newValue));