Add an option to scroll overlong labels instead of simply truncating them

This commit is contained in:
Jakob Nixdorf 2017-11-13 14:48:34 +01:00
parent 3890c5c675
commit 6d9473b277
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
7 changed files with 31 additions and 1 deletions

View file

@ -363,7 +363,8 @@ public class MainActivity extends BaseActivity
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (key.equals(getString(R.string.settings_key_label_size)) || if (key.equals(getString(R.string.settings_key_label_size)) ||
key.equals(getString(R.string.settings_key_tap_to_reveal))) { key.equals(getString(R.string.settings_key_tap_to_reveal)) ||
key.equals(getString(R.string.settings_key_label_scroll))) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} else if (key.equals(getString(R.string.settings_key_theme))) { } else if (key.equals(getString(R.string.settings_key_theme))) {
recreate(); recreate();

View file

@ -206,6 +206,10 @@ public class Settings {
return getString(R.string.settings_key_theme, R.string.settings_default_theme); return getString(R.string.settings_key_theme, R.string.settings_default_theme);
} }
public boolean getScrollLabel() {
return getBoolean(R.string.settings_key_label_scroll, false);
}
public boolean getFirstTimeWarningShown() { public boolean getFirstTimeWarningShown() {
return getBoolean(R.string.settings_key_security_backup_warning, false); return getBoolean(R.string.settings_key_security_backup_warning, false);
} }

View file

@ -135,6 +135,8 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
int fontSize = sharedPrefs.getInt(context.getString(R.string.settings_key_label_size), context.getResources().getInteger(R.integer.settings_default_label_size)); int fontSize = sharedPrefs.getInt(context.getString(R.string.settings_key_label_size), context.getResources().getInteger(R.integer.settings_default_label_size));
entryViewHolder.setLabelSize(fontSize); entryViewHolder.setLabelSize(fontSize);
entryViewHolder.setLabelScroll(sharedPrefs.getBoolean(context.getString(R.string.settings_key_label_scroll), false));
} }
@Override @Override

View file

@ -26,6 +26,7 @@ import android.content.Context;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -116,6 +117,18 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
label.setTextSize(TypedValue.COMPLEX_UNIT_PT, size); label.setTextSize(TypedValue.COMPLEX_UNIT_PT, size);
} }
public void setLabelScroll(boolean active) {
if (active) {
label.setEllipsize(TextUtils.TruncateAt.MARQUEE);
label.setHorizontallyScrolling(true);
label.setSelected(true);
} else {
label.setEllipsize(TextUtils.TruncateAt.END);
label.setHorizontallyScrolling(false);
label.setSelected(false);
}
}
public void enableTapToReveal() { public void enableTapToReveal() {
valueLayout.setVisibility(View.GONE); valueLayout.setVisibility(View.GONE);
coverLayout.setVisibility(View.VISIBLE); coverLayout.setVisibility(View.VISIBLE);

View file

@ -13,6 +13,7 @@
<string name="settings_key_theme" translatable="false">pref_theme</string> <string name="settings_key_theme" translatable="false">pref_theme</string>
<string name="settings_key_label_size" translatable="false">pref_label_size</string> <string name="settings_key_label_size" translatable="false">pref_label_size</string>
<string name="settings_key_label_scroll" translatable="false">pref_label_scroll</string>
<string name="settings_key_backup_ask" translatable="false">pref_backup_ask</string> <string name="settings_key_backup_ask" translatable="false">pref_backup_ask</string>
<string name="settings_key_backup_directory" translatable="false">pref_backup_directory</string> <string name="settings_key_backup_directory" translatable="false">pref_backup_directory</string>

View file

@ -16,6 +16,7 @@
<string name="settings_title_theme">Theme</string> <string name="settings_title_theme">Theme</string>
<string name="settings_title_label_size">Label font size</string> <string name="settings_title_label_size">Label font size</string>
<string name="settings_title_label_scroll">Scroll label</string>
<string name="settings_title_backup_ask">Ask for filename</string> <string name="settings_title_backup_ask">Ask for filename</string>
<string name="settings_title_backup_directory">Backup directory</string> <string name="settings_title_backup_directory">Backup directory</string>
@ -30,6 +31,8 @@
revealed manually</string> revealed manually</string>
<string name="settings_desc_panic">Decide what happens when a Panic Trigger is received</string> <string name="settings_desc_panic">Decide what happens when a Panic Trigger is received</string>
<string name="settings_desc_label_scroll">Scroll overlong labels instead of truncating them</string>
<string name="settings_desc_backup_ask">Ask for the filename every time a backup is created or <string name="settings_desc_backup_ask">Ask for the filename every time a backup is created or
restored</string> restored</string>
<string name="settings_desc_backup_directory">Directory for the backups (filenames will depend <string name="settings_desc_backup_directory">Directory for the backups (filenames will depend

View file

@ -52,6 +52,12 @@
app:vnt_maxValue="@integer/settings_max_label_size" app:vnt_maxValue="@integer/settings_max_label_size"
app:vnt_minValue="@integer/settings_min_label_size" /> app:vnt_minValue="@integer/settings_min_label_size" />
<CheckBoxPreference
android:key="@string/settings_key_label_scroll"
android:title="@string/settings_title_label_scroll"
android:summary="@string/settings_desc_label_scroll"
android:defaultValue="false" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory