aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/drawable/subreddit_default_icon.pngbin0 -> 16621 bytes
-rw-r--r--app/src/main/res/drawable/subreddit_default_icon_2.jpg (renamed from app/src/main/res/drawable/subreddit_default_icon.jpg)bin51471 -> 51471 bytes
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/interface_preferences.xml5
9 files changed, 66 insertions, 1 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 83b8a2c9..18955498 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -95,6 +95,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeDisableSwipingBetweenTa
import ml.docilealligator.infinityforreddit.events.ChangeLockBottomAppBarEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.events.ChangeRequireAuthToAccountSectionEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
@@ -1162,7 +1163,30 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Subscribe
public void onChangeRequireAuthToAccountSectionEvent(ChangeRequireAuthToAccountSectionEvent changeRequireAuthToAccountSectionEvent) {
- adapter.setRequireAuthToAccountSection(changeRequireAuthToAccountSectionEvent.requireAuthToAccountSection);
+ if (adapter != null) {
+ adapter.setRequireAuthToAccountSection(changeRequireAuthToAccountSectionEvent.requireAuthToAccountSection);
+ }
+ }
+
+ @Subscribe
+ public void onChangeShowAvatarOnTheRightInTheNavigationDrawerEvent(ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent event) {
+ if (adapter != null) {
+ adapter.setShowAvatarOnTheRightInTheNavigationDrawer(event.showAvatarOnTheRightInTheNavigationDrawer);
+ int previousPosition = -1;
+ if (navDrawerRecyclerView.getLayoutManager() != null) {
+ previousPosition = ((LinearLayoutManager) navDrawerRecyclerView.getLayoutManager()).findFirstVisibleItemPosition();
+ }
+
+ RecyclerView.LayoutManager layoutManager = navDrawerRecyclerView.getLayoutManager();
+ navDrawerRecyclerView.setAdapter(null);
+ navDrawerRecyclerView.setLayoutManager(null);
+ navDrawerRecyclerView.setAdapter(adapter);
+ navDrawerRecyclerView.setLayoutManager(layoutManager);
+
+ if (previousPosition > 0) {
+ navDrawerRecyclerView.scrollToPosition(previousPosition);
+ }
+ }
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java
index 744e6ad8..d6de3458 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java
@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -64,6 +65,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
private int karma;
private boolean isNSFWEnabled;
private boolean requireAuthToAccountSection;
+ private boolean showAvatarOnTheRightInTheNavigationDrawer;
private ItemClickListener itemClickListener;
private boolean isLoggedIn;
private boolean isInMainPage = true;
@@ -86,6 +88,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
this.accountName = accountName;
isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
requireAuthToAccountSection = sharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
+ showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT_IN_THE_NAVIGATION_DRAWER, false);
isLoggedIn = accountName != null;
this.itemClickListener = itemClickListener;
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
@@ -173,6 +176,15 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof NavHeaderViewHolder) {
+ if (showAvatarOnTheRightInTheNavigationDrawer) {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ((NavHeaderViewHolder) holder).profileImageView.getLayoutParams();
+ params.addRule(RelativeLayout.ALIGN_PARENT_END);
+ ((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
+ } else {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ((NavHeaderViewHolder) holder).profileImageView.getLayoutParams();
+ params.removeRule(RelativeLayout.ALIGN_PARENT_END);
+ ((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
+ }
if (isLoggedIn) {
((NavHeaderViewHolder) holder).karmaTextView.setText(appCompatActivity.getString(R.string.karma_info, karma));
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
@@ -564,6 +576,10 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
this.requireAuthToAccountSection = requireAuthToAccountSection;
}
+ public void setShowAvatarOnTheRightInTheNavigationDrawer(boolean showAvatarOnTheRightInTheNavigationDrawer) {
+ this.showAvatarOnTheRightInTheNavigationDrawer = showAvatarOnTheRightInTheNavigationDrawer;
+ }
+
class NavHeaderViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.name_text_view_nav_header_main)
TextView accountNameTextView;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent.java
new file mode 100644
index 00000000..b36fa732
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent {
+ public boolean showAvatarOnTheRightInTheNavigationDrawer;
+
+ public ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent(boolean showAvatarOnTheRightInTheNavigationDrawer) {
+ this.showAvatarOnTheRightInTheNavigationDrawer = showAvatarOnTheRightInTheNavigationDrawer;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java
index 2ef43ebf..0d16cb45 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java
@@ -11,6 +11,7 @@ import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent;
import ml.docilealligator.infinityforreddit.events.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -23,6 +24,7 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY);
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
+ SwitchPreference showAvatarOnTheRightInTheNavigationDrawer = findPreference(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT_IN_THE_NAVIGATION_DRAWER);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
if (immersiveInterfaceEntryPreference != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -36,6 +38,13 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
});
}
+ if (showAvatarOnTheRightInTheNavigationDrawer != null) {
+ showAvatarOnTheRightInTheNavigationDrawer.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent((Boolean) newValue));
+ 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 aa2d7c3f..be8489a9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -38,6 +38,7 @@ public class SharedPreferencesUtils {
public static final String DISABLE_IMMERSIVE_INTERFACE_IN_LANDSCAPE_MODE = "disable_immersive_interface_in_landscape_mode";
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 SHOW_AVATAR_ON_THE_RIGHT_IN_THE_NAVIGATION_DRAWER = "show_avatar_on_the_right_in_the_navigation_drawer";
public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.sort_type";
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
diff --git a/app/src/main/res/drawable/subreddit_default_icon.png b/app/src/main/res/drawable/subreddit_default_icon.png
new file mode 100644
index 00000000..072c8e24
--- /dev/null
+++ b/app/src/main/res/drawable/subreddit_default_icon.png
Binary files differ
diff --git a/app/src/main/res/drawable/subreddit_default_icon.jpg b/app/src/main/res/drawable/subreddit_default_icon_2.jpg
index 4e9bc2fc..4e9bc2fc 100644
--- a/app/src/main/res/drawable/subreddit_default_icon.jpg
+++ b/app/src/main/res/drawable/subreddit_default_icon_2.jpg
Binary files differ
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5278ec55..81cc184b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -540,6 +540,7 @@
<string name="settings_hide_subreddit_and_user_prefix">Hide Subreddit and User Prefix</string>
<string name="settings_hide_the_number_of_votes">Hide the Number of Votes</string>
<string name="settings_hide_the_number_of_comments">Hide the Number of Comments</string>
+ <string name="settings_show_avatar_on_the_right_in_the_navigation_drawer">Show Avatar on the Left in the Navigation Drawer</string>
<string name="no_link_available">Cannot get the link</string>
diff --git a/app/src/main/res/xml/interface_preferences.xml b/app/src/main/res/xml/interface_preferences.xml
index d6f8dc68..e40f5b25 100644
--- a/app/src/main/res/xml/interface_preferences.xml
+++ b/app/src/main/res/xml/interface_preferences.xml
@@ -29,6 +29,11 @@
app:title="@string/settings_enable_bottom_app_bar_title"
app:summary="@string/settings_enable_bottom_app_bar_summary" />
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="show_avatar_on_the_right_in_the_navigation_drawer"
+ app:title="@string/settings_show_avatar_on_the_right_in_the_navigation_drawer" />
+
<Preference
app:title="@string/settings_time_format_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.TimeFormatPreferenceFragment" />