Make the main activity listen to preference changes
This commit is contained in:
parent
09126ee1c0
commit
d39c3fecb4
2 changed files with 12 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
||||||
* New feature: make the font size of the labels configurable (Issue #18)
|
* New feature: make the font size of the labels configurable (Issue #18)
|
||||||
* Bug fix: make the backup activity scrollable (Issue #15)
|
* Bug fix: make the backup activity scrollable (Issue #15)
|
||||||
* Bug fix: use the whole card for tap-to-reveal, not just the token (Issue #10)
|
* Bug fix: use the whole card for tap-to-reveal, not just the token (Issue #10)
|
||||||
|
* Code: internal changes (as always)
|
||||||
|
|
||||||
#### v0.2.3
|
#### v0.2.3
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,9 @@ import com.google.zxing.integration.android.IntentResult;
|
||||||
|
|
||||||
import org.shadowice.flocke.andotp.ItemTouchHelper.SimpleItemTouchHelperCallback;
|
import org.shadowice.flocke.andotp.ItemTouchHelper.SimpleItemTouchHelperCallback;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity
|
||||||
|
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private EntriesCardAdapter adapter;
|
private EntriesCardAdapter adapter;
|
||||||
private FloatingActionMenu floatingActionMenu;
|
private FloatingActionMenu floatingActionMenu;
|
||||||
private SimpleItemTouchHelperCallback touchHelperCallback;
|
private SimpleItemTouchHelperCallback touchHelperCallback;
|
||||||
|
@ -151,6 +153,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||||
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
sharedPref.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
@ -272,6 +275,13 @@ public class MainActivity extends AppCompatActivity {
|
||||||
stopUpdater();
|
stopUpdater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
|
if (key.equals(getString(R.string.settings_key_label_size)) ||
|
||||||
|
key.equals(getString(R.string.settings_key_tap_to_reveal))) {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Activity results
|
// Activity results
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
|
@ -289,9 +299,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Toast.makeText(this, R.string.toast_invalid_qr_code, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.toast_invalid_qr_code, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (requestCode == INTENT_INTERNAL_SETTINGS && resultCode == RESULT_OK) {
|
|
||||||
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
} else if (requestCode == INTENT_INTERNAL_BACKUP && resultCode == RESULT_OK) {
|
} else if (requestCode == INTENT_INTERNAL_BACKUP && resultCode == RESULT_OK) {
|
||||||
if (intent.getBooleanExtra("reload", false))
|
if (intent.getBooleanExtra("reload", false))
|
||||||
adapter.loadEntries();
|
adapter.loadEntries();
|
||||||
|
|
Loading…
Reference in a new issue