Skip to content

Commit

Permalink
Preference to hide Android status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Sep 7, 2016
1 parent 74e57bc commit e2a1ecc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
74/1.9.6
Multireddit viewing support
Ability to view custom user pages
Preference to hide Android status bar
Preference to use un-shortened link for "Share Comments" (thanks to fhtagn)
Preference for cache storage location (thanks to ShadowNinja)
Preference to set pinned subreddit sort order (thanks to chippen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
Expand All @@ -43,7 +44,7 @@

public abstract class BaseActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {

private SharedPreferences sharedPreferences;
private SharedPreferences mSharedPreferences;

private static boolean closingAll = false;

Expand Down Expand Up @@ -100,9 +101,19 @@ public final ActionBar getSupportActionBarOrThrow() {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreferences.registerOnSharedPreferenceChangeListener(this);

mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

if(PrefsUtility.pref_appearance_hide_android_status(this, mSharedPreferences)) {
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}


mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
setOrientationFromPrefs();
closeIfNecessary();

Expand Down Expand Up @@ -148,7 +159,7 @@ public void onClick(final View v) {

final PrefsUtility.AppearanceNavbarColour navbarColour = PrefsUtility.appearance_navbar_colour(
this,
sharedPreferences);
mSharedPreferences);

if(navbarColour != PrefsUtility.AppearanceNavbarColour.BLACK) {

Expand Down Expand Up @@ -203,7 +214,7 @@ protected void onResume() {
@Override
protected void onDestroy() {
super.onDestroy();
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
}

private void closeIfNecessary() {
Expand Down Expand Up @@ -260,7 +271,8 @@ public void onRequestPermissionsResult(
}

private void setOrientationFromPrefs() {
PrefsUtility.ScreenOrientation orientation = PrefsUtility.pref_behaviour_screen_orientation(this, sharedPreferences);
PrefsUtility.ScreenOrientation orientation = PrefsUtility.pref_behaviour_screen_orientation(this,
mSharedPreferences);
if (orientation == PrefsUtility.ScreenOrientation.AUTO)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
else if (orientation == PrefsUtility.ScreenOrientation.PORTRAIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static boolean isRestartRequired(Context context, String key) {
|| context.getString(R.string.pref_appearance_navbar_color_key).equals(key)
|| context.getString(R.string.pref_appearance_langforce_key).equals(key)
|| context.getString(R.string.pref_behaviour_bezel_toolbar_swipezone_key).equals(key)
|| context.getString(R.string.pref_appearance_hide_username_main_menu_key).equals(key);
|| context.getString(R.string.pref_appearance_hide_username_main_menu_key).equals(key)
|| context.getString(R.string.pref_appearance_hide_android_status_key).equals(key);
}

///////////////////////////////
Expand Down Expand Up @@ -232,6 +233,10 @@ public static boolean pref_appearance_linkbuttons(final Context context, final S
return getBoolean(R.string.pref_appearance_linkbuttons_key, true, context, sharedPreferences);
}

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

public static boolean pref_appearance_link_text_clickable(final Context context, final SharedPreferences sharedPreferences) {
return getBoolean(R.string.pref_appearance_link_text_clickable_key, true, context, sharedPreferences);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -901,4 +901,8 @@
<string name="pref_appearance_link_text_clickable_title">Make link text clickable</string>
<string name="pref_appearance_link_text_clickable_key">pref_appearance_link_text_clickable</string>

<!-- 2016-09-07 -->
<string name="pref_appearance_hide_android_status_title">Hide Android status bar</string>
<string name="pref_appearance_hide_android_status_key">pref_appearance_hide_android_status</string>

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

<CheckBoxPreference android:title="@string/pref_appearance_hide_android_status_title"
android:key="@string/pref_appearance_hide_android_status_key"
android:defaultValue="false"/>

</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_appearance_locale_header">
Expand Down

0 comments on commit e2a1ecc

Please sign in to comment.