Make the font size of the labels configurable

Closes #18
This commit is contained in:
Jakob Nixdorf 2017-07-30 21:38:45 +02:00
parent 372e9d1610
commit 73772126b8
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
8 changed files with 46 additions and 4 deletions

View file

@ -72,6 +72,7 @@ If you want to discuss this app, share ideas for features or get help with bugs
* [LicensesDialog](https://github.com/PSDev/LicensesDialog) * [LicensesDialog](https://github.com/PSDev/LicensesDialog)
* [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar) * [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar)
* [OpenPGP API library](https://github.com/open-keychain/openpgp-api) * [OpenPGP API library](https://github.com/open-keychain/openpgp-api)
* [VNTNumberPickerPreference](https://github.com/vanniktech/VNTNumberPickerPreference)
* [ZXing Android Embedded](https://github.com/journeyapps/zxing-android-embedded) * [ZXing Android Embedded](https://github.com/journeyapps/zxing-android-embedded)
#### Code examples used: #### Code examples used:

View file

@ -38,4 +38,5 @@ dependencies {
compile 'commons-codec:commons-codec:1.5' compile 'commons-codec:commons-codec:1.5'
compile 'me.zhanghai.android.materialprogressbar:library:1.4.1' compile 'me.zhanghai.android.materialprogressbar:library:1.4.1'
compile 'org.sufficientlysecure:openpgp-api:12.0' compile 'org.sufficientlysecure:openpgp-api:12.0'
compile 'com.vanniktech:vntnumberpickerpreference:1.0.0'
} }

View file

@ -32,6 +32,7 @@ import android.preference.PreferenceManager;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -56,6 +57,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
implements ItemTouchHelperAdapter, Filterable { implements ItemTouchHelperAdapter, Filterable {
private Context context; private Context context;
private SharedPreferences sharedPrefs;
private EntryFilter filter; private EntryFilter filter;
private ArrayList<Entry> entries; private ArrayList<Entry> entries;
private ArrayList<Integer> displayedEntries; private ArrayList<Integer> displayedEntries;
@ -64,6 +66,8 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
public EntriesCardAdapter(Context context) { public EntriesCardAdapter(Context context) {
this.context = context; this.context = context;
this.sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
loadEntries(); loadEntries();
} }
@ -140,12 +144,14 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
entryViewHolder.customPeriodLayout.setVisibility(View.GONE); entryViewHolder.customPeriodLayout.setVisibility(View.GONE);
} }
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); if (sharedPrefs.getBoolean(context.getString(R.string.settings_key_tap_to_reveal), false)) {
if (sharedPref.getBoolean(context.getString(R.string.settings_key_tap_to_reveal), false)) {
entryViewHolder.enableTapToReveal(); entryViewHolder.enableTapToReveal();
} else { } else {
entryViewHolder.disableTapToReveal(); entryViewHolder.disableTapToReveal();
} }
int fontSize = sharedPrefs.getInt(context.getString(R.string.settings_key_label_size), context.getResources().getInteger(R.integer.settings_default_label_size));
entryViewHolder.OTPLabel.setTextSize(TypedValue.COMPLEX_UNIT_PT, fontSize);
} }
@Override @Override

View file

@ -57,7 +57,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textSize="8pt" />
</LinearLayout> </LinearLayout>

View file

@ -18,6 +18,12 @@
<copyright>Copyright (C) 2015 Dominik Schürmann</copyright> <copyright>Copyright (C) 2015 Dominik Schürmann</copyright>
<license>Apache Software License 2.0</license> <license>Apache Software License 2.0</license>
</notice> </notice>
<notice>
<name>VNTNumberPickerPreference</name>
<url>https://github.com/vanniktech/VNTNumberPickerPreference</url>
<copyright>Copyright (C) 2014-2016 Vanniktech - Niklas Baudy</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice> <notice>
<name>ZXing Android Embedded</name> <name>ZXing Android Embedded</name>
<url>https://github.com/journeyapps/zxing-android-embedded</url> <url>https://github.com/journeyapps/zxing-android-embedded</url>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default values -->
<integer name="settings_default_label_size">8</integer>
<!-- Constraints -->
<integer name="settings_min_label_size">4</integer>
<integer name="settings_max_label_size">12</integer>
</resources>

View file

@ -4,6 +4,7 @@
<!-- Categories --> <!-- Categories -->
<string name="settings_category_title_security">Security</string> <string name="settings_category_title_security">Security</string>
<string name="settings_category_title_ui">User interface</string>
<string name="settings_category_title_openpgp">OpenPGP</string> <string name="settings_category_title_openpgp">OpenPGP</string>
<!-- Titles --> <!-- Titles -->
@ -11,6 +12,8 @@
<string name="settings_title_auth_device">Require device credentials</string> <string name="settings_title_auth_device">Require device credentials</string>
<string name="settings_title_backup_password">Backup password</string> <string name="settings_title_backup_password">Backup password</string>
<string name="settings_title_label_size">Label font size</string>
<string name="settings_title_openpgp_provider">Select OpenPGP provider</string> <string name="settings_title_openpgp_provider">Select OpenPGP provider</string>
<string name="settings_title_openpgp_keyid">Select OpenPGP key</string> <string name="settings_title_openpgp_keyid">Select OpenPGP key</string>
<string name="settings_title_openpgp_sign">Sign encrypted backups</string> <string name="settings_title_openpgp_sign">Sign encrypted backups</string>
@ -40,6 +43,8 @@
<string name="settings_key_auth_device" translatable="false">pref_auth_device</string> <string name="settings_key_auth_device" translatable="false">pref_auth_device</string>
<string name="settings_key_backup_password" translatable="false">pref_backup_password</string> <string name="settings_key_backup_password" translatable="false">pref_backup_password</string>
<string name="settings_key_label_size" translatable="false">pref_label_size</string>
<string name="settings_key_openpgp_provider">pref_openpgp_provider</string> <string name="settings_key_openpgp_provider">pref_openpgp_provider</string>
<string name="settings_key_openpgp_keyid">pref_openpgp_keyid</string> <string name="settings_key_openpgp_keyid">pref_openpgp_keyid</string>
<string name="settings_key_openpgp_sign">pref_openpgp_sign</string> <string name="settings_key_openpgp_sign">pref_openpgp_sign</string>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_title_security"> android:title="@string/settings_category_title_security">
@ -24,6 +26,18 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory
android:title="@string/settings_category_title_ui">
<com.vanniktech.vntnumberpickerpreference.VNTNumberPickerPreference
android:key="@string/settings_key_label_size"
android:title="@string/settings_title_label_size"
android:defaultValue="@integer/settings_default_label_size"
app:vnt_maxValue="@integer/settings_max_label_size"
app:vnt_minValue="@integer/settings_min_label_size" />
</PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_title_openpgp"> android:title="@string/settings_category_title_openpgp">