From d494a6d3908c04d9be140a79af91619b87ce3add Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 11 Jun 2017 19:14:55 +0200 Subject: recreate settingsactivity when theme changed --- src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java | 2 +- src/main/java/de/pixart/messenger/ui/SettingsActivity.java | 8 +++++++- .../java/de/pixart/messenger/ui/StartConversationActivity.java | 6 ++++-- src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java | 6 +++++- 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/main/java/de/pixart/messenger/ui') diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index a38ae7e59..81967bfa7 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -322,7 +322,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp recreate(); } else { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - this.showDynamicTags = preferences.getBoolean("show_dynamic_tags", false); + this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS, false); this.showLastSeen = preferences.getBoolean("last_activity", false); } } diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 13cb9bb99..feeec7c1c 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -43,6 +43,8 @@ public class SettingsActivity extends XmppActivity implements public static final String BLIND_TRUST_BEFORE_VERIFICATION = "btbv"; public static final String AUTOMATIC_MESSAGE_DELETION = "automatic_message_deletion"; public static final String BROADCAST_LAST_ACTIVITY = "last_activity"; + public static final String THEME = "theme"; + public static final String SHOW_DYNAMIC_TAGS = "show_dynamic_tags"; public static final int REQUEST_WRITE_LOGS = 0xbf8701; private SettingsFragment mSettingsFragment; @@ -276,8 +278,12 @@ public class SettingsActivity extends XmppActivity implements reconnectAccounts(); } else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) { xmppConnectionService.expireOldMessages(true); + } else if (name.equals(THEME)) { + final int theme = findTheme(); + if (this.mTheme != theme) { + recreate(); + } } - } @Override diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 73400dde3..784e511ef 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -92,9 +92,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU private ViewPager mViewPager; private ListPagerAdapter mListPagerAdapter; private List contacts = new ArrayList<>(); - private ArrayAdapter mContactsAdapter; + private ListItemAdapter mContactsAdapter; private List conferences = new ArrayList<>(); - private ArrayAdapter mConferenceAdapter; + private ListItemAdapter mConferenceAdapter; private List mActivatedAccounts = new ArrayList<>(); private List mKnownHosts; private List mKnownConferenceHosts; @@ -304,6 +304,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } else { askForContactsPermissions(); } + mConferenceAdapter.refreshSettings(); + mContactsAdapter.refreshSettings(); } @Override diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java index 00c612e20..ce0649c56 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java @@ -24,6 +24,7 @@ import java.util.concurrent.RejectedExecutionException; import de.pixart.messenger.R; import de.pixart.messenger.entities.ListItem; +import de.pixart.messenger.ui.SettingsActivity; import de.pixart.messenger.ui.XmppActivity; import de.pixart.messenger.utils.UIHelper; @@ -50,8 +51,11 @@ public class ListItemAdapter extends ArrayAdapter { public ListItemAdapter(XmppActivity activity, List objects) { super(activity, 0, objects); this.activity = activity; + } + + public void refreshSettings() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); - this.showDynamicTags = preferences.getBoolean("show_dynamic_tags", false); + this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS, false); } @Override -- cgit v1.2.3