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/Activity/MainActivity.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java1
4 files changed, 35 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index 240f4b4a..d6eeba0c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -3,11 +3,14 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -24,6 +27,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.core.widget.NestedScrollView;
import androidx.drawerlayout.widget.DrawerLayout;
@@ -139,6 +143,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
LinearLayout profileLinearLayout;
@BindView(R.id.subscriptions_linear_layout_main_activity)
LinearLayout subscriptionLinearLayout;
+ @BindView(R.id.multi_reddits_linear_layout_main_activity)
+ LinearLayout multiRedditsLinearLayout;
@BindView(R.id.inbox_linear_layout_main_activity)
LinearLayout inboxLinearLayout;
@BindView(R.id.post_label_main_activity)
@@ -448,7 +454,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bottomNavigationView.setVisibility(View.GONE);
fab.setVisibility(View.GONE);
} else {
- bottomNavigationView.setVisibility(View.VISIBLE);
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false)) {
+ bottomNavigationView.setVisibility(View.VISIBLE);
+ } else {
+ CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
+ lp.setAnchorId(View.NO_ID);
+ lp.gravity = Gravity.END | Gravity.BOTTOM;
+ fab.setLayoutParams(lp);
+ fab.setImageTintList(ColorStateList.valueOf(Color.WHITE));
+ fab.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.backgroundColorPrimary)));
+ }
+
fab.setVisibility(View.VISIBLE);
subscriptionsBottomAppBar.setOnClickListener(view -> {
Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
@@ -603,6 +619,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
accountLabelTextView.setVisibility(View.GONE);
profileLinearLayout.setVisibility(View.GONE);
subscriptionLinearLayout.setVisibility(View.GONE);
+ multiRedditsLinearLayout.setVisibility(View.GONE);
inboxLinearLayout.setVisibility(View.GONE);
postLabelTextView.setVisibility(View.GONE);
upvotedLinearLayout.setVisibility(View.GONE);
@@ -642,6 +659,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
drawer.closeDrawers();
});
+ multiRedditsLinearLayout.setOnClickListener(view -> {
+ Intent intent = new Intent(this, MultiRedditListingActivity.class);
+ startActivity(intent);
+ drawer.closeDrawers();
+ });
+
inboxLinearLayout.setOnClickListener(view -> {
Intent intent = new Intent(this, ViewMessageActivity.class);
startActivity(intent);
@@ -956,7 +979,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private PostFragment allPostFragment;
SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
+ super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
index 061c3c06..1ed80213 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
@@ -244,7 +244,7 @@ public class SubscribedThingListingActivity extends BaseActivity {
private FollowedUsersListingFragment followedUsersListingFragment;
public SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
+ super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
index 99d06569..8228333e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
@@ -49,6 +49,7 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
+ SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
@@ -78,6 +79,13 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
}
}
+ if (bottomAppBarSwitch != null) {
+ bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new RecreateActivityEvent());
+ return true;
+ });
+ }
+
if (voteButtonsOnTheRightSwitch != null) {
voteButtonsOnTheRightSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeVoteButtonsPositionEvent((Boolean) newValue));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
index 6fe83045..ef6354aa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -30,6 +30,7 @@ public class SharedPreferencesUtils {
public static final String CONTENT_FONT_SIZE_KEY = "content_font_size";
public static final String AMOLED_DARK_KEY = "amoled_dark";
public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface";
+ public static final String BOTTOM_APP_BAR_KEY = "bottom_app_bar";
public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right";
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
public static final String SORT_TIME_BEST_POST = "sort_time_best_post";