Added preference to show / hide issuers

This commit is contained in:
Michael Schättgen 2016-11-01 23:43:46 +01:00
parent 54e5fba7c0
commit 03713c303c
4 changed files with 26 additions and 2 deletions

View file

@ -2,7 +2,9 @@ package me.impy.aegis;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.content.ClipData; import android.content.ClipData;
import android.content.SharedPreferences;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -110,9 +112,11 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
ImageView profileDrawable; ImageView profileDrawable;
KeyProfile keyProfile; KeyProfile keyProfile;
ProgressBar progressBar; ProgressBar progressBar;
View _itemView;
KeyProfileHolder(final View itemView) { KeyProfileHolder(final View itemView) {
super(itemView); super(itemView);
_itemView = itemView;
profileName = (TextView) itemView.findViewById(R.id.profile_name); profileName = (TextView) itemView.findViewById(R.id.profile_name);
profileCode = (TextView) itemView.findViewById(R.id.profile_code); profileCode = (TextView) itemView.findViewById(R.id.profile_code);
profileIssuer = (TextView) itemView.findViewById(R.id.profile_issuer); profileIssuer = (TextView) itemView.findViewById(R.id.profile_issuer);
@ -127,7 +131,16 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
this.keyProfile = profile; this.keyProfile = profile;
profileName.setText(profile.Name); profileName.setText(profile.Name);
profileCode.setText(profile.Code); profileCode.setText(profile.Code);
// So that we can have text in the designer without showing it to our user
profileIssuer.setText("");
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(_itemView.getContext());
if(sharedPreferences.getBoolean("pref_issuer", false))
{
profileIssuer.setText(" - " + profile.Info.getIssuer()); profileIssuer.setText(" - " + profile.Info.getIssuer());
}
profileDrawable.setImageDrawable(generateTextDrawable(profile)); profileDrawable.setImageDrawable(generateTextDrawable(profile));
} }

View file

@ -172,6 +172,7 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
mKeyProfileAdapter.notifyDataSetChanged();
setPreferredTheme(); setPreferredTheme();
} }

View file

@ -4,4 +4,7 @@
<string name="title_activity_intro">IntroActivity</string> <string name="title_activity_intro">IntroActivity</string>
<string name="settings">Preferences</string> <string name="settings">Preferences</string>
<string name="pref_night_mode">Night mode</string> <string name="pref_night_mode">Night mode</string>
<string name="pref_night_mode_description">Enable this to use darker colors</string>
<string name="pref_issuers">Show the issuer</string>
<string name="pref_issuers_description">Enable this to show the issuer next to the profile name</string>
</resources> </resources>

View file

@ -5,5 +5,12 @@
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="pref_night_mode" android:key="pref_night_mode"
android:title="@string/pref_night_mode" /> android:title="@string/pref_night_mode"
android:summary="@string/pref_night_mode_description"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_issuer"
android:title="@string/pref_issuers"
android:summary="@string/pref_issuers_description"/>
</PreferenceScreen> </PreferenceScreen>