Skip to content

Commit

Permalink
Added preference to disable new header toolbars (fixes #742)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Jun 14, 2020
1 parent 46852d0 commit cedd330
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Support for table rendering
Support for new spoiler syntax, and formatting/links inside spoilers
Various improvements to markdown rendering
Added preference to disable new header toolbars

90/1.10
Added toolbar when viewing subreddits and comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public static boolean isRefreshRequired(final Context context, final String key)
|| key.equals(context.getString(R.string.pref_behaviour_postcount_key))
|| key.equals(context.getString(R.string.pref_behaviour_comment_min_key))
|| key.equals(context.getString(R.string.pref_behaviour_pinned_subredditsort_key))
|| key.equals(context.getString(R.string.pref_behaviour_blocked_subredditsort_key));
|| key.equals(context.getString(R.string.pref_behaviour_blocked_subredditsort_key))
|| key.equals(context.getString(R.string.pref_appearance_hide_headertoolbar_commentlist_key))
|| key.equals(context.getString(R.string.pref_appearance_hide_headertoolbar_postlist_key));
}

public static boolean isRestartRequired(Context context, String key) {
Expand Down Expand Up @@ -363,6 +365,14 @@ public static boolean pref_appearance_bottom_toolbar(final Context context, fina
return getBoolean(R.string.pref_appearance_bottom_toolbar_key, false, context, sharedPreferences);
}

public static boolean pref_appearance_hide_headertoolbar_postlist(final Context context, final SharedPreferences sharedPreferences) {
return getBoolean(R.string.pref_appearance_hide_headertoolbar_postlist_key, false, context, sharedPreferences);
}

public static boolean pref_appearance_hide_headertoolbar_commentlist(final Context context, final SharedPreferences sharedPreferences) {
return getBoolean(R.string.pref_appearance_hide_headertoolbar_commentlist_key, false, context, sharedPreferences);
}

public enum AppearancePostSubtitleItem {
AUTHOR, FLAIR, SCORE, AGE, GOLD, SUBREDDIT, DOMAIN, STICKY, SPOILER, NSFW
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public PostListingHeader(

mContext = activity.getApplicationContext();

final SharedPreferences sharedPreferences
= PreferenceManager.getDefaultSharedPreferences(activity);

final float dpScale = activity.getResources().getDisplayMetrics().density;

setOrientation(LinearLayout.VERTICAL);
Expand Down Expand Up @@ -112,7 +115,8 @@ public PostListingHeader(

final RedditAccount currentUser = RedditAccountManager.getInstance(activity).getDefaultAccount();

if(subreddit != null) {
if(subreddit != null
&& !PrefsUtility.pref_appearance_hide_headertoolbar_postlist(activity, sharedPreferences)) {

final LinearLayout buttons = (LinearLayout)inflate(
activity,
Expand All @@ -135,9 +139,6 @@ public PostListingHeader(
final RedditSubredditSubscriptionManager subscriptionManager
= RedditSubredditSubscriptionManager.getSingleton(activity, currentUser);

final SharedPreferences sharedPreferences
= PreferenceManager.getDefaultSharedPreferences(activity);

final SubredditCanonicalId subredditCanonicalId;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.quantumbadger.redreader.views;

import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Typeface;
Expand Down Expand Up @@ -46,6 +47,8 @@ public RedditPostHeaderView(final AppCompatActivity activity, final RedditPrepar

super(activity);

final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);

final float dpScale = activity.getResources().getDisplayMetrics().density;

setOrientation(LinearLayout.VERTICAL);
Expand All @@ -60,7 +63,8 @@ public RedditPostHeaderView(final AppCompatActivity activity, final RedditPrepar

final Typeface tf = Typeface.createFromAsset(activity.getAssets(), "fonts/Roboto-Light.ttf");

final float titleFontScale = PrefsUtility.appearance_fontscale_post_header_titles(activity, PreferenceManager.getDefaultSharedPreferences(activity));
final float titleFontScale = PrefsUtility.appearance_fontscale_post_header_titles(activity,
sharedPreferences);

final TextView title = new TextView(activity);
title.setTextSize(19.0f * titleFontScale);
Expand All @@ -69,7 +73,8 @@ public RedditPostHeaderView(final AppCompatActivity activity, final RedditPrepar
title.setTextColor(Color.WHITE);
greyHeader.addView(title);

final float subtitleFontScale = PrefsUtility.appearance_fontscale_post_header_subtitles(activity, PreferenceManager.getDefaultSharedPreferences(activity));
final float subtitleFontScale = PrefsUtility.appearance_fontscale_post_header_subtitles(activity,
sharedPreferences);

subtitle = new TextView(activity);
subtitle.setTextSize(13.0f * subtitleFontScale);
Expand Down Expand Up @@ -102,7 +107,8 @@ public RedditPostHeaderView(final AppCompatActivity activity, final RedditPrepar

final RedditAccount currentUser = RedditAccountManager.getInstance(activity).getDefaultAccount();

if(!currentUser.isAnonymous()) {
if(!currentUser.isAnonymous()
&& !PrefsUtility.pref_appearance_hide_headertoolbar_commentlist(activity, sharedPreferences)) {

// A user is logged in

Expand Down
6 changes: 6 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1206,4 +1206,10 @@
<string name="props_body_html">Body (HTML)</string>
<string name="props_self_html">Self text (HTML)</string>

<string name="pref_appearance_hide_headertoolbar_postlist_key" translatable="false">pref_appearance_hide_headertoolbar_postlist</string>
<string name="pref_appearance_hide_headertoolbar_postlist_title">Hide post list header toolbar</string>

<string name="pref_appearance_hide_headertoolbar_commentlist_key" translatable="false">pref_appearance_hide_headertoolbar_commentlist</string>
<string name="pref_appearance_hide_headertoolbar_commentlist_title">Hide comment list header toolbar</string>

</resources>
10 changes: 10 additions & 0 deletions src/main/res/xml/prefs_appearance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
android:entryValues="@array/pref_appearance_post_subtitle_items_return"
android:defaultValue="@array/pref_appearance_post_subtitle_items_default" />

<CheckBoxPreference
android:title="@string/pref_appearance_hide_headertoolbar_postlist_title"
android:key="@string/pref_appearance_hide_headertoolbar_postlist_key"
android:defaultValue="false"/>

</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_appearance_comments_header">
Expand Down Expand Up @@ -115,6 +120,11 @@
android:key="@string/pref_appearance_indentlines_key"
android:defaultValue="false"/>

<CheckBoxPreference
android:title="@string/pref_appearance_hide_headertoolbar_commentlist_title"
android:key="@string/pref_appearance_hide_headertoolbar_commentlist_key"
android:defaultValue="false"/>

</PreferenceCategory>

</PreferenceScreen>

0 comments on commit cedd330

Please sign in to comment.