Add an option to show individual timeout bars for each entry

Closes #166
This commit is contained in:
Jakob Nixdorf 2020-04-23 22:10:36 +02:00
parent 36b84ae0bc
commit c5e4ba1e19
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
9 changed files with 541 additions and 499 deletions

View file

@ -583,4 +583,8 @@ public class Settings {
public boolean isHideGlobalTimeoutEnabled() {
return getBoolean(R.string.settings_key_hide_global_timeout, false);
}
public boolean isShowIndividualTimeoutsEnabled() {
return getBoolean(R.string.settings_key_show_individual_timeouts, false);
}
}

View file

@ -23,8 +23,6 @@
package org.shadowice.flocke.andotp.View;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
@ -231,15 +229,17 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
for (Entry e : entries) {
if (e.isTimeBased()) {
boolean cardVisible = !settings.getTapToReveal() || e.isVisible();
boolean item_changed = e.updateOTP();
boolean color_changed = false;
//Check color change only if highlighting token feature is enabled
if(settings.isHighlightTokenOptionEnabled()) {
color_changed = e.hasColorChanged();
}
// Check color change only if highlighting token feature is enabled and the entry is visible
if(settings.isHighlightTokenOptionEnabled())
color_changed = cardVisible && e.hasColorChanged();
change = change || item_changed || e.hasNonDefaultPeriod() || color_changed;
change = change || item_changed || color_changed ||
(cardVisible && (e.hasNonDefaultPeriod() || settings.isShowIndividualTimeoutsEnabled()));
}
}

View file

@ -198,9 +198,13 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, entry.getIssuer(), entry.getLabel(), thumbnailSize, entry.getThumbnail()));
}
if (entry.isTimeBased() && entry.hasNonDefaultPeriod()) {
if (entry.isTimeBased() && (entry.hasNonDefaultPeriod() || settings.isShowIndividualTimeoutsEnabled())) {
if (!this.tapToReveal || entry.isVisible()) {
progressBar.setVisibility(View.VISIBLE);
updateProgress(entry);
} else {
progressBar.setVisibility(View.INVISIBLE);
}
} else {
progressBar.setVisibility(View.GONE);
}

View file

@ -38,6 +38,11 @@
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@ -221,7 +226,6 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/cardProgressBar"
@ -237,4 +241,8 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View file

@ -38,6 +38,11 @@
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@ -221,7 +226,6 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/cardProgressBar"
@ -237,4 +241,8 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View file

@ -38,6 +38,11 @@
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@ -207,7 +212,6 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/cardProgressBar"
@ -223,4 +227,8 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View file

@ -34,6 +34,7 @@
<string name="settings_key_search_includes" translatable="false">pref_search_includes</string>
<string name="settings_key_label_highlight_token" translatable="false">pref_label_highlight_token</string>
<string name="settings_key_hide_global_timeout" translatable="false">pref_hide_global_timeout</string>
<string name="settings_key_show_individual_timeouts" translatable="false">pref_show_individual_timeouts</string>
<string name="settings_key_backup_append_date_time" translatable="false">pref_backup_append_date_time</string>
<string name="settings_key_backup_ask" translatable="false">pref_backup_ask</string>

View file

@ -33,6 +33,7 @@
<string name="settings_title_search_includes">Search behavior</string>
<string name="settings_title_label_highlight_token">Highlight expiring tokens</string>
<string name="settings_title_hide_global_timeout">Hide global timeout bar</string>
<string name="settings_title_show_individual_timeouts">Show individual timeouts</string>
<string name="settings_title_backup_append_date">Append date to filename</string>
<string name="settings_title_backup_ask">Ask for filename</string>
@ -72,7 +73,9 @@
<string name="settings_desc_minimize_on_copy">App will be minimized when you copy the OTP to clipboard</string>
<string name="settings_desc_search_includes">Specify which values should be included when searching</string>
<string name="settings_desc_label_highlight_token">Highlights token in red if it\'s expiring in 8 seconds</string>
<string name="settings_desc_hide_global_timeout">Hide the global timeout bar shown at the top of the screen.</string>
<string name="settings_desc_hide_global_timeout">Hide the global timeout bar shown at the top of the screen</string>
<string name="settings_desc_show_individual_timeouts">Show an individual timeout bar for every entry.
This can slow down the app, only enable if really necessary.</string>
<string name="settings_desc_backup_append_date">Append the current date and time to the suggested
backup filename</string>

View file

@ -167,6 +167,12 @@
android:summary="@string/settings_desc_hide_global_timeout"
android:defaultValue="false" />
<CheckBoxPreference
android:key="@string/settings_key_show_individual_timeouts"
android:title="@string/settings_title_show_individual_timeouts"
android:summary="@string/settings_desc_show_individual_timeouts"
android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory