mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-23 23:39:14 +00:00
Add ability to hide account name in tiles mode
This commit is contained in:
parent
e79c2c174b
commit
71c0ad2a08
5 changed files with 42 additions and 27 deletions
|
@ -116,7 +116,7 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||||
_prefs.setCurrentViewMode(ViewMode.fromInteger(i));
|
_prefs.setCurrentViewMode(ViewMode.fromInteger(i));
|
||||||
viewModePreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.view_mode_titles)[i]));
|
viewModePreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.view_mode_titles)[i]));
|
||||||
overrideAccountNamePosition(ViewMode.fromInteger(i) == ViewMode.TILES);
|
refreshAccountNamePositionText();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
@ -156,6 +156,7 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||||
_prefs.setAccountNamePosition(AccountNamePosition.fromInteger(i));
|
_prefs.setAccountNamePosition(AccountNamePosition.fromInteger(i));
|
||||||
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[i]));
|
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[i]));
|
||||||
|
refreshAccountNamePositionText();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
@ -164,15 +165,15 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
overrideAccountNamePosition(_prefs.getCurrentViewMode() == ViewMode.TILES);
|
refreshAccountNamePositionText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void overrideAccountNamePosition(boolean override) {
|
private void refreshAccountNamePositionText() {
|
||||||
|
boolean override = (_prefs.getCurrentViewMode() == ViewMode.TILES && _prefs.getAccountNamePosition() == AccountNamePosition.END);
|
||||||
|
|
||||||
if (override) {
|
if (override) {
|
||||||
_currentAccountNamePositionPreference.setEnabled(false);
|
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s. %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[_prefs.getAccountNamePosition().ordinal()], getString(R.string.pref_account_name_position_summary_override)));
|
||||||
_currentAccountNamePositionPreference.setSummary(getString(R.string.pref_account_name_position_summary_override));
|
|
||||||
} else {
|
} else {
|
||||||
_currentAccountNamePositionPreference.setEnabled(true);
|
|
||||||
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[_prefs.getAccountNamePosition().ordinal()]));
|
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[_prefs.getAccountNamePosition().ordinal()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
case SINGLETAP:
|
case SINGLETAP:
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
_view.onEntryCopy(entry);
|
_view.onEntryCopy(entry);
|
||||||
entryHolder.animateCopyText(_viewMode != ViewMode.TILES);
|
entryHolder.animateCopyText();
|
||||||
_clickedEntry = null;
|
_clickedEntry = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -559,7 +559,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
|
|
||||||
if(entry == _clickedEntry) {
|
if(entry == _clickedEntry) {
|
||||||
_view.onEntryCopy(entry);
|
_view.onEntryCopy(entry);
|
||||||
entryHolder.animateCopyText(_viewMode != ViewMode.TILES);
|
entryHolder.animateCopyText();
|
||||||
_clickedEntry = null;
|
_clickedEntry = null;
|
||||||
} else {
|
} else {
|
||||||
_clickedEntry = entry;
|
_clickedEntry = entry;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.beemdevelopment.aegis.ui.views;
|
package com.beemdevelopment.aegis.ui.views;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
@ -108,6 +110,9 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
_codeGrouping = groupSize;
|
_codeGrouping = groupSize;
|
||||||
_viewMode = viewMode;
|
_viewMode = viewMode;
|
||||||
_accountNamePosition = accountNamePosition;
|
_accountNamePosition = accountNamePosition;
|
||||||
|
if (viewMode.equals(ViewMode.TILES) && _accountNamePosition == AccountNamePosition.END) {
|
||||||
|
_accountNamePosition = AccountNamePosition.BELOW;
|
||||||
|
}
|
||||||
|
|
||||||
_selected.clearAnimation();
|
_selected.clearAnimation();
|
||||||
_selected.setVisibility(View.GONE);
|
_selected.setVisibility(View.GONE);
|
||||||
|
@ -143,15 +148,25 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAccountNameLayout(AccountNamePosition accountNamePosition, Boolean hasBothIssuerAndName) {
|
private void setAccountNameLayout(AccountNamePosition accountNamePosition, Boolean hasBothIssuerAndName) {
|
||||||
if (_viewMode == ViewMode.TILES) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams profileNameLayoutParams;
|
RelativeLayout.LayoutParams profileNameLayoutParams;
|
||||||
RelativeLayout.LayoutParams copiedLayoutParams;
|
|
||||||
switch (accountNamePosition) {
|
switch (accountNamePosition) {
|
||||||
case HIDDEN:
|
case HIDDEN:
|
||||||
_profileName.setVisibility(View.GONE);
|
_profileName.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (_viewMode == ViewMode.TILES) {
|
||||||
|
_profileCopied.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
((RelativeLayout.LayoutParams)_profileCopied.getLayoutParams()).removeRule(RelativeLayout.BELOW);
|
||||||
|
_profileCopied.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
_profileCopied.setTextSize(14);
|
||||||
|
|
||||||
|
_profileIssuer.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
_profileIssuer.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
_profileIssuer.setTextSize(14);
|
||||||
|
|
||||||
|
_profileName.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BELOW:
|
case BELOW:
|
||||||
|
@ -349,7 +364,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
animateAlphaTo(DEFAULT_ALPHA);
|
animateAlphaTo(DEFAULT_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void animateCopyText(boolean includeSlideAnimation) {
|
public void animateCopyText() {
|
||||||
_animationHandler.removeCallbacksAndMessages(null);
|
_animationHandler.removeCallbacksAndMessages(null);
|
||||||
|
|
||||||
Animation slideDownFadeIn = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.slide_down_fade_in);
|
Animation slideDownFadeIn = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.slide_down_fade_in);
|
||||||
|
@ -357,23 +372,25 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
||||||
Animation fadeOut = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.fade_out);
|
Animation fadeOut = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.fade_out);
|
||||||
Animation fadeIn = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.fade_in);
|
Animation fadeIn = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.fade_in);
|
||||||
|
|
||||||
if (includeSlideAnimation) {
|
// Use slideDown animation when user is not using Tiles mode
|
||||||
|
if (_viewMode != ViewMode.TILES) {
|
||||||
_profileCopied.startAnimation(slideDownFadeIn);
|
_profileCopied.startAnimation(slideDownFadeIn);
|
||||||
View fadeOutView = (_accountNamePosition == AccountNamePosition.BELOW) ? _profileName : _description;
|
View fadeOutView = (_accountNamePosition == AccountNamePosition.BELOW) ? _profileName : _description;
|
||||||
|
fadeOutView.startAnimation(slideDownFadeOut);
|
||||||
fadeOutView.startAnimation(slideDownFadeOut);
|
|
||||||
|
|
||||||
_animationHandler.postDelayed(() -> {
|
_animationHandler.postDelayed(() -> {
|
||||||
_profileCopied.startAnimation(fadeOut);
|
_profileCopied.startAnimation(fadeOut);
|
||||||
fadeOutView.startAnimation(fadeIn);
|
fadeOutView.startAnimation(fadeIn);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
} else {
|
} else {
|
||||||
|
View visibleProfileText = _accountNamePosition == AccountNamePosition.BELOW ? _profileName : _profileIssuer;
|
||||||
|
|
||||||
_profileCopied.startAnimation(fadeIn);
|
_profileCopied.startAnimation(fadeIn);
|
||||||
_profileName.startAnimation(fadeOut);
|
visibleProfileText.startAnimation(fadeOut);
|
||||||
|
|
||||||
_animationHandler.postDelayed(() -> {
|
_animationHandler.postDelayed(() -> {
|
||||||
_profileCopied.startAnimation(fadeOut);
|
_profileCopied.startAnimation(fadeOut);
|
||||||
_profileName.startAnimation(fadeIn);
|
visibleProfileText.startAnimation(fadeIn);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,9 @@
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="24dp"
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_toEndOf="@+id/layoutImage">
|
android:layout_toEndOf="@id/layoutImage">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -80,19 +80,16 @@
|
||||||
android:textSize="11sp"
|
android:textSize="11sp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"/>
|
android:maxLines="1"/>
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/profile_copied"
|
android:id="@+id/profile_copied"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_below="@id/profile_issuer"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/profile_issuer"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
android:text="@string/copied"
|
android:text="@string/copied"
|
||||||
android:textSize="9sp" />
|
android:textSize="9sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/profile_account_name"
|
android:id="@+id/profile_account_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
<string name="pref_account_name_position_title">Show the account name</string>
|
<string name="pref_account_name_position_title">Show the account name</string>
|
||||||
<string name="pref_shared_issuer_account_name_title">Only show account name when necessary</string>
|
<string name="pref_shared_issuer_account_name_title">Only show account name when necessary</string>
|
||||||
<string name="pref_shared_issuer_account_name_summary">Only show account names whenever they share the same issuer. Other account names will be hidden.</string>
|
<string name="pref_shared_issuer_account_name_summary">Only show account names whenever they share the same issuer. Other account names will be hidden.</string>
|
||||||
<string name="pref_account_name_position_summary_override">This setting is overridden by the tiles view mode. Account name will always be shown below the issuer.</string>
|
<string name="pref_account_name_position_summary_override">This setting is overridden by the tiles view mode. Account name will be shown below the issuer.</string>
|
||||||
<string name="pref_import_file_title">Import from file</string>
|
<string name="pref_import_file_title">Import from file</string>
|
||||||
<string name="pref_import_file_summary">Import tokens from a file</string>
|
<string name="pref_import_file_summary">Import tokens from a file</string>
|
||||||
<string name="pref_android_backups_title">Android cloud backups</string>
|
<string name="pref_android_backups_title">Android cloud backups</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue