Allow logo to be toggled; see #146

This commit is contained in:
Marius Lindvall 2020-07-31 23:04:38 +02:00
parent 148d64b0bc
commit f3b94ce567
6 changed files with 33 additions and 0 deletions

View file

@ -47,6 +47,7 @@ public enum Constants {
public static final Preference<Boolean> PREF_ALLOW_ADOPTION = new Preference.Boolean("allowAdoption", true);
public static final Preference<NightModeStyle> PREF_NIGHT_MODE = new Preference.Enum<>("nightMode", NightModeStyle.FOLLOW_SYSTEM);
public static final Preference<Boolean> PREF_CONFIRM_STOP = new Preference.Boolean("confirmStop", true);
public static final Preference<Boolean> PREF_HIDE_LOGO = new Preference.Boolean("hideLogo", false);
@Deprecated // Use PREF_SERVER_ENCRYPTED instead
public static final Preference<String> PREF_SERVER = new Preference.String("server", "");

View file

@ -163,6 +163,15 @@ public final class MainActivity extends AppCompatActivity {
super.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
// Set app logo visibility.
PreferenceManager prefs = new PreferenceManager(this);
findViewById(R.id.imgLogo).setVisibility(prefs.get(Constants.PREF_HIDE_LOGO) ? View.GONE : View.VISIBLE);
}
/**
* On-tap handler for the "start sharing" and "stop sharing" button.
*/
@ -332,6 +341,8 @@ public final class MainActivity extends AppCompatActivity {
// Set night mode preference.
AppCompatDelegate.setDefaultNightMode(prefs.get(Constants.PREF_NIGHT_MODE).resolve());
// Set app logo visibility.
findViewById(R.id.imgLogo).setVisibility(prefs.get(Constants.PREF_HIDE_LOGO) ? View.GONE : View.VISIBLE);
}
/**

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?attr/colorControlNormal"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
</vector>

View file

@ -32,6 +32,7 @@
<!-- Logo displayed at the top of the activity. -->
<ImageView
android:id="@+id/imgLogo"
android:layout_width="match_parent"
android:layout_height="143dp"
android:contentDescription="@string/img_alt_logo"

View file

@ -165,6 +165,9 @@
<string name="pref_confirmStop_title">Confirm before stopping shares</string>
<string name="pref_confirmStop_on">Prompt for confirmation when stopping shares in the app</string>
<string name="pref_confirmStop_off">Do not prompt for confirmation when stopping shares in the app</string>
<string name="prefs_hideLogo_title">Hide logo on main screen</string>
<string name="pref_hideLogo_on">Hide the Hauk logo from the app\'s main screen</string>
<string name="pref_hideLogo_off">Show the Hauk logo at the top of the app\'s main screen</string>
<!-- About section -->
<string name="prefs_header_about">About Hauk</string>

View file

@ -122,6 +122,13 @@
app:summaryOff="@string/pref_confirmStop_off"
app:summaryOn="@string/pref_confirmStop_on" />
<SwitchPreference
app:key="hideLogo"
app:icon="@drawable/ic_image"
app:title="@string/prefs_hideLogo_title"
app:summaryOff="@string/pref_hideLogo_off"
app:summaryOn="@string/pref_hideLogo_on" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/prefs_header_about">