Rename Device related preferences and commit them.

This commit is contained in:
Denis-Cosmin Nutiu 2020-12-12 17:24:06 +02:00
parent 3cd90abdc9
commit 588973e0ad
3 changed files with 5 additions and 3 deletions

View file

@ -2,5 +2,6 @@ package dev.nuculabs.nucuhub.domain;
public class SettingValues { public class SettingValues {
public static final String NAME = "settings"; public static final String NAME = "settings";
public static final String CURRENT_DEVICE_LIST = "current_device_list"; public static final String DEVICE_LIST = "device_list";
public static final String SELECTED_DEVICE = "selected_device";
} }

View file

@ -26,7 +26,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
private void initializeDeviceListItems() { private void initializeDeviceListItems() {
SharedPreferences sp = Objects.requireNonNull(getContext()).getSharedPreferences(SettingValues.NAME, Activity.MODE_PRIVATE); SharedPreferences sp = Objects.requireNonNull(getContext()).getSharedPreferences(SettingValues.NAME, Activity.MODE_PRIVATE);
DeviceListPreference devicesList = findPreference(DEVICE_LIST_PREFERENCE); DeviceListPreference devicesList = findPreference(DEVICE_LIST_PREFERENCE);
Set<String> savedEntries = sp.getStringSet(SettingValues.CURRENT_DEVICE_LIST, null); Set<String> savedEntries = sp.getStringSet(SettingValues.DEVICE_LIST, null);
if (savedEntries != null) { if (savedEntries != null) {
CharSequence[] items = new CharSequence[savedEntries.size()]; CharSequence[] items = new CharSequence[savedEntries.size()];
int index = 0; int index = 0;

View file

@ -96,7 +96,8 @@ public class DeviceManagementDialog extends Dialog {
preference.setEntries(entries); preference.setEntries(entries);
SharedPreferences.Editor spe = sharedPreferences.edit(); SharedPreferences.Editor spe = sharedPreferences.edit();
spe.putStringSet(SettingValues.CURRENT_DEVICE_LIST, entriesSet); spe.putStringSet(SettingValues.DEVICE_LIST, entriesSet);
spe.commit();
} }
private void setupToolbar() { private void setupToolbar() {