Hide Karma (#1168)

* feature/ability to hide karma

* only hide karma in nav bar

* center account name vertically when not showing karma
This commit is contained in:
Patrick Demers 2022-10-22 01:39:36 -05:00 committed by GitHub
parent 5e3eaafe26
commit 4cc6c2b21a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -47,6 +47,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private boolean isLoggedIn;
private boolean isInMainPage = true;
private PageToggle pageToggle;
private boolean showKarma;
public HeaderSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
RequestManager glide, String accountName,
@ -64,6 +65,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
requireAuthToAccountSection = securitySharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
showAvatarOnTheRightInTheNavigationDrawer = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
this.showKarma = !navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_ACCOUNT_KARMA_NAV_BAR, false);
}
@NonNull
@ -84,7 +86,12 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
if (isLoggedIn) {
if (showKarma) {
((NavHeaderViewHolder) holder).karmaTextView.setText(baseActivity.getString(R.string.karma_info, karma));
} else {
int karmaTextHeight = ((NavHeaderViewHolder) holder).karmaTextView.getHeight();
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(karmaTextHeight / 2);
}
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
if (profileImageUrl != null && !profileImageUrl.equals("")) {
glide.load(profileImageUrl)

View File

@ -196,6 +196,7 @@ public class SharedPreferencesUtils {
public static final String REMEMBER_MUTING_OPTION_IN_POST_FEED = "remember_muting_option_in_post_feed";
public static final String DEFAULT_LINK_POST_LAYOUT_KEY = "default_link_post_layout";
public static final String USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER = "use_bottom_toolbar_in_media_viewer";
public static final String HIDE_ACCOUNT_KARMA_NAV_BAR = "hide_account_karma";
public static final String LOCK_SCREEN_ANIMATION = "lock_screen_animation";
public static final String ENABLE_FOLD_SUPPORT = "enable_fold_support";
public static final String LOOP_VIDEO = "loop_video";

View File

@ -611,6 +611,7 @@
<string name="settings_separate_post_and_comments_in_landscape_mode_title">Separate Post And Comments in Landscape Mode</string>
<string name="settings_separate_post_and_comments_summary">Video autoplay will be disabled in the post detail page</string>
<string name="settings_use_bottom_toolbar_in_media_viewer_title">Use Bottom Toolbar in Media Viewer</string>
<string name="settings_navigation_drawer_enable_hide_karma_title">Hide Account Karma</string>
<string name="settings_secure_mode_title">Secure Mode</string>
<string name="settings_secure_mode_summary">Screenshot and video recording are not allowed. No preview in recent app screen.</string>
<string name="settings_credits_lock_screen_animation_title">Lock Screen Animation</string>

View File

@ -51,4 +51,10 @@
app:key="hide_subscribed_subreddits_sections"
app:title="@string/settings_hide_subscribed_subreddits_sections_title" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
app:defaultValue="false"
app:key="hide_account_karma"
app:title="@string/settings_navigation_drawer_enable_hide_karma_title" />
</PreferenceScreen>