recreate settingsactivity when theme changed

This commit is contained in:
Daniel Gultsch 2017-06-05 14:57:09 +02:00
parent 10025123e9
commit 00bb527333
5 changed files with 18 additions and 5 deletions

View file

@ -250,7 +250,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
recreate(); recreate();
} else { } else {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); 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); this.showLastSeen = preferences.getBoolean("last_activity", false);
} }
} }

View file

@ -46,6 +46,8 @@ public class SettingsActivity extends XmppActivity implements
public static final String BLIND_TRUST_BEFORE_VERIFICATION = "btbv"; public static final String BLIND_TRUST_BEFORE_VERIFICATION = "btbv";
public static final String AUTOMATIC_MESSAGE_DELETION = "automatic_message_deletion"; public static final String AUTOMATIC_MESSAGE_DELETION = "automatic_message_deletion";
public static final String BROADCAST_LAST_ACTIVITY = "last_activity"; 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; public static final int REQUEST_WRITE_LOGS = 0xbf8701;
private SettingsFragment mSettingsFragment; private SettingsFragment mSettingsFragment;
@ -371,6 +373,11 @@ public class SettingsActivity extends XmppActivity implements
reconnectAccounts(); reconnectAccounts();
} else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) { } else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) {
xmppConnectionService.expireOldMessages(true); xmppConnectionService.expireOldMessages(true);
} else if (name.equals(THEME)) {
final int theme = findTheme();
if (this.mTheme != theme) {
recreate();
}
} }
} }

View file

@ -90,9 +90,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private ViewPager mViewPager; private ViewPager mViewPager;
private ListPagerAdapter mListPagerAdapter; private ListPagerAdapter mListPagerAdapter;
private List<ListItem> contacts = new ArrayList<>(); private List<ListItem> contacts = new ArrayList<>();
private ArrayAdapter<ListItem> mContactsAdapter; private ListItemAdapter mContactsAdapter;
private List<ListItem> conferences = new ArrayList<>(); private List<ListItem> conferences = new ArrayList<>();
private ArrayAdapter<ListItem> mConferenceAdapter; private ListItemAdapter mConferenceAdapter;
private List<String> mActivatedAccounts = new ArrayList<>(); private List<String> mActivatedAccounts = new ArrayList<>();
private List<String> mKnownHosts; private List<String> mKnownHosts;
private List<String> mKnownConferenceHosts; private List<String> mKnownConferenceHosts;
@ -289,6 +289,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} else { } else {
askForContactsPermissions(); askForContactsPermissions();
} }
mConferenceAdapter.refreshSettings();
mContactsAdapter.refreshSettings();
} }
@Override @Override

View file

@ -1038,7 +1038,7 @@ public abstract class XmppActivity extends Activity {
} }
protected int findTheme() { protected int findTheme() {
Boolean dark = getPreferences().getString("theme", "light").equals("dark"); Boolean dark = getPreferences().getString(SettingsActivity.THEME, "light").equals("dark");
Boolean larger = getPreferences().getBoolean("use_larger_font", false); Boolean larger = getPreferences().getBoolean("use_larger_font", false);
if(dark) { if(dark) {

View file

@ -23,6 +23,7 @@ import java.util.concurrent.RejectedExecutionException;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.ListItem; import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.ui.SettingsActivity;
import eu.siacs.conversations.ui.XmppActivity; import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
@ -45,8 +46,11 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
public ListItemAdapter(XmppActivity activity, List<ListItem> objects) { public ListItemAdapter(XmppActivity activity, List<ListItem> objects) {
super(activity, 0, objects); super(activity, 0, objects);
this.activity = activity; this.activity = activity;
}
public void refreshSettings() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
this.showDynamicTags = preferences.getBoolean("show_dynamic_tags",false); this.showDynamicTags = preferences.getBoolean(SettingsActivity.SHOW_DYNAMIC_TAGS,false);
} }
@Override @Override