1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-09-01 03:55:47 +02:00

Refactor preferences screen

This commit is contained in:
José Rebelo 2024-08-30 21:25:47 +01:00 committed by José Rebelo
parent 64887a5adf
commit b59ba76803
12 changed files with 374 additions and 456 deletions

View File

@ -1,250 +0,0 @@
/* Copyright (C) 2015-2024 Andreas Shimokawa, Carsten Pfeiffer, Christian
Fischer, Daniele Gobbetti, José Rebelo, Lem Dulfo, Petr Vaněk, Taavi Eomäe
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.activities;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.view.MenuItem;
import androidx.core.app.NavUtils;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
/**
* A settings activity with support for preferences directly displaying their value.
* If you combine such preferences with a custom OnPreferenceChangeListener, you have
* to set that listener in #onCreate, *not* in #onPostCreate, otherwise the value will
* not be displayed.
*
* @deprecated use AbstractSettingsActivityV2
*/
@Deprecated
public abstract class AbstractSettingsActivity extends AppCompatPreferenceActivity implements GBActivity {
private static final Logger LOG = LoggerFactory.getLogger(AbstractSettingsActivity.class);
private boolean isLanguageInvalid = false;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch (action) {
case GBApplication.ACTION_LANGUAGE_CHANGE:
setLanguage(GBApplication.getLanguage(), true);
break;
case GBApplication.ACTION_QUIT:
finish();
break;
}
}
};
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static class SimpleSetSummaryOnChangeListener implements Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
if (preference instanceof EditTextPreference) {
if ((((EditTextPreference) preference).getEditText().getKeyListener().getInputType() & InputType.TYPE_CLASS_NUMBER) != 0) {
if ("".equals(String.valueOf(value))) {
// reject empty numeric input
return false;
}
}
}
updateSummary(preference, value);
return true;
}
public void updateSummary(Preference preference, Object value) {
String stringValue = String.valueOf(value);
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
}
}
private static class ExtraSetSummaryOnChangeListener extends SimpleSetSummaryOnChangeListener {
private final Preference.OnPreferenceChangeListener prefChangeListener;
public ExtraSetSummaryOnChangeListener(Preference.OnPreferenceChangeListener prefChangeListener) {
this.prefChangeListener = prefChangeListener;
}
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
boolean result = prefChangeListener.onPreferenceChange(preference, value);
if (result) {
return super.onPreferenceChange(preference, value);
}
return false;
}
}
private static final SimpleSetSummaryOnChangeListener sBindPreferenceSummaryToValueListener = new SimpleSetSummaryOnChangeListener();
@Override
protected void onCreate(Bundle savedInstanceState) {
AbstractGBActivity.init(this);
IntentFilter filterLocal = new IntentFilter();
filterLocal.addAction(GBApplication.ACTION_QUIT);
filterLocal.addAction(GBApplication.ACTION_LANGUAGE_CHANGE);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
super.onCreate(savedInstanceState);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
for (String prefKey : getPreferenceKeysWithSummary()) {
final Preference pref = findPreference(prefKey);
if (pref != null) {
bindPreferenceSummaryToValue(pref);
} else {
LOG.error("Unknown preference key: " + prefKey + ", unable to display value.");
}
}
}
@Override
protected void onResume() {
super.onResume();
if (isLanguageInvalid) {
isLanguageInvalid = false;
recreate();
}
}
@Override
protected void onDestroy() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
super.onDestroy();
}
/**
* Subclasses should reimplement this to return the keys of those
* preferences which should print its values as a summary below the
* preference name.
*/
protected String[] getPreferenceKeysWithSummary() {
return new String[0];
}
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
*
* @see #sBindPreferenceSummaryToValueListener
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
SimpleSetSummaryOnChangeListener listener;
Preference.OnPreferenceChangeListener existingListener = preference.getOnPreferenceChangeListener();
if (existingListener != null) {
listener = new ExtraSetSummaryOnChangeListener(existingListener);
} else {
listener = sBindPreferenceSummaryToValueListener;
}
preference.setOnPreferenceChangeListener(listener);
// Trigger the listener immediately with the preference's current value.
try {
listener.updateSummary(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
} catch (ClassCastException cce) {
//the preference is not a string, use the provided summary
//TODO: it shows true/false instead of the xml summary
listener.updateSummary(preference, preference.getSummary());
}
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
final int itemId = item.getItemId();
if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
public void setLanguage(Locale language, boolean invalidateLanguage) {
if (invalidateLanguage) {
isLanguageInvalid = true;
}
AndroidUtils.setLanguage(this, language);
}
protected void addPreferenceHandlerFor(final String preferenceKey) {
Preference pref = findPreference(preferenceKey);
if (pref != null) {
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newVal) {
GBApplication.deviceService().onSendConfiguration(preferenceKey);
return true;
}
});
} else {
LOG.warn("Could not find preference " + preferenceKey);
}
}
}

View File

@ -412,10 +412,6 @@ public class ControlCenterv2 extends AppCompatActivity
final Intent dbIntent = new Intent(this, DataManagementActivity.class); final Intent dbIntent = new Intent(this, DataManagementActivity.class);
startActivity(dbIntent); startActivity(dbIntent);
return false; return false;
} else if (itemId == R.id.action_notification_management) {
final Intent blIntent = new Intent(this, NotificationManagementActivity.class);
startActivity(blIntent);
return false;
} else if (itemId == R.id.device_action_discover) { } else if (itemId == R.id.device_action_discover) {
launchDiscoveryActivity(); launchDiscoveryActivity();
return false; return false;

View File

@ -22,7 +22,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -36,7 +35,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class NotificationManagementActivity extends AbstractSettingsActivityV2 { public class NotificationManagementActivity extends AbstractSettingsActivityV2 {
private static final Logger LOG = LoggerFactory.getLogger(NotificationManagementActivity.class);
private static final int RINGTONE_REQUEST_CODE = 4712; private static final int RINGTONE_REQUEST_CODE = 4712;
private static final String DEFAULT_RINGTONE_URI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE).toString(); private static final String DEFAULT_RINGTONE_URI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE).toString();
@ -51,6 +49,8 @@ public class NotificationManagementActivity extends AbstractSettingsActivityV2 {
} }
public static class NotificationPreferencesFragment extends AbstractPreferenceFragment { public static class NotificationPreferencesFragment extends AbstractPreferenceFragment {
private static final Logger LOG = LoggerFactory.getLogger(NotificationPreferencesFragment.class);
static final String FRAGMENT_TAG = "NOTIFICATION_PREFERENCES_FRAGMENT"; static final String FRAGMENT_TAG = "NOTIFICATION_PREFERENCES_FRAGMENT";
@Override @Override

View File

@ -381,6 +381,15 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
}); });
} }
pref = findPreference("pref_category_notifications");
if (pref != null) {
pref.setOnPreferenceClickListener(preference -> {
Intent enableIntent = new Intent(requireContext(), NotificationManagementActivity.class);
startActivity(enableIntent);
return true;
});
}
final Preference theme = findPreference("pref_key_theme"); final Preference theme = findPreference("pref_key_theme");
final Preference amoled_black = findPreference("pref_key_theme_amoled_black"); final Preference amoled_black = findPreference("pref_key_theme_amoled_black");
@ -558,7 +567,7 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
private void setLocationPreferences(Location location) { private void setLocationPreferences(Location location) {
String latitude = String.format(Locale.US, "%.6g", location.getLatitude()); String latitude = String.format(Locale.US, "%.6g", location.getLatitude());
String longitude = String.format(Locale.US, "%.6g", location.getLongitude()); String longitude = String.format(Locale.US, "%.6g", location.getLongitude());
LOG.info("got location. Lat: " + latitude + " Lng: " + longitude); LOG.info("got location. Lat: {} Lng: {}", latitude, longitude);
GB.toast(requireContext(), getString(R.string.toast_aqurired_networklocation), 2000, 0); GB.toast(requireContext(), getString(R.string.toast_aqurired_networklocation), 2000, 0);
GBApplication.getPrefs().getPreferences() GBApplication.getPrefs().getPreferences()
.edit() .edit()

View File

@ -20,16 +20,25 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
import androidx.annotation.NonNull;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import com.mobeta.android.dslv.DragSortListPreference;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AboutUserPreferencesActivity; import nodomain.freeyourgadget.gadgetbridge.activities.AboutUserPreferencesActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragment; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs; import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
public class ChartsPreferencesActivity extends AbstractSettingsActivityV2 { public class ChartsPreferencesActivity extends AbstractSettingsActivityV2 {
private GBDevice device;
@Override @Override
protected String fragmentTag() { protected String fragmentTag() {
return ChartsPreferencesFragment.FRAGMENT_TAG; return ChartsPreferencesFragment.FRAGMENT_TAG;
@ -37,16 +46,63 @@ public class ChartsPreferencesActivity extends AbstractSettingsActivityV2 {
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new ChartsPreferencesFragment(); return ChartsPreferencesFragment.newInstance(device);
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
super.onCreate(savedInstanceState);
} }
public static class ChartsPreferencesFragment extends AbstractPreferenceFragment { public static class ChartsPreferencesFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "CHARTS_PREFERENCES_FRAGMENT"; static final String FRAGMENT_TAG = "CHARTS_PREFERENCES_FRAGMENT";
private GBDevice device;
static ChartsPreferencesFragment newInstance(final GBDevice device) {
final ChartsPreferencesFragment fragment = new ChartsPreferencesFragment();
fragment.setDevice(device);
return fragment;
}
private void setDevice(final GBDevice device) {
final Bundle args = getArguments() != null ? getArguments() : new Bundle();
args.putParcelable("device", device);
setArguments(args);
}
@Override @Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
final Bundle arguments = getArguments();
if (arguments != null) {
this.device = arguments.getParcelable(GBDevice.EXTRA_DEVICE);
}
setPreferencesFromResource(R.xml.charts_preferences, rootKey); setPreferencesFromResource(R.xml.charts_preferences, rootKey);
// If a device was provided, show the charts tabs preference, since that's the only one
// that is device-specific for now. We also sync changes to the device-specific preference.
//final DragSortListPreference prefChartsTabs = findPreference(DeviceSettingsPreferenceConst.PREFS_DEVICE_CHARTS_TABS);
//if (prefChartsTabs != null) {
// if (device != null) {
// final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device.getAddress());
// final String myTabs = devicePrefs.getString(DeviceSettingsPreferenceConst.PREFS_DEVICE_CHARTS_TABS, null);
// if (myTabs != null) {
// prefChartsTabs.setValue(myTabs);
// }
// prefChartsTabs.setOnPreferenceChangeListener((preference, newValue) -> {
// devicePrefs.getPreferences().edit()
// .putString(DeviceSettingsPreferenceConst.PREFS_DEVICE_CHARTS_TABS, String.valueOf(newValue))
// .apply();
// return true;
// });
// } else {
// prefChartsTabs.setVisible(false);
// }
//}
setInputTypeFor(GBPrefs.CHART_MAX_HEART_RATE, InputType.TYPE_CLASS_NUMBER); setInputTypeFor(GBPrefs.CHART_MAX_HEART_RATE, InputType.TYPE_CLASS_NUMBER);
setInputTypeFor(GBPrefs.CHART_MIN_HEART_RATE, InputType.TYPE_CLASS_NUMBER); setInputTypeFor(GBPrefs.CHART_MIN_HEART_RATE, InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("chart_sleep_lines_limit", InputType.TYPE_CLASS_NUMBER); setInputTypeFor("chart_sleep_lines_limit", InputType.TYPE_CLASS_NUMBER);
@ -57,11 +113,18 @@ public class ChartsPreferencesActivity extends AbstractSettingsActivityV2 {
final Preference aboutUserPref = findPreference("pref_category_activity_personal"); final Preference aboutUserPref = findPreference("pref_category_activity_personal");
if (aboutUserPref != null) { if (aboutUserPref != null) {
aboutUserPref.setOnPreferenceClickListener(preference -> { if (device != null) {
final Intent enableIntent = new Intent(getActivity(), AboutUserPreferencesActivity.class); aboutUserPref.setOnPreferenceClickListener(preference -> {
startActivity(enableIntent); final Intent enableIntent = new Intent(getActivity(), AboutUserPreferencesActivity.class);
return true; startActivity(enableIntent);
}); return true;
});
} else {
final Preference aboutUserHeader = findPreference("pref_category_activity_personal_title");
if (aboutUserHeader != null) {
aboutUserHeader.setVisible(false);
}
}
} }
} }
} }

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#7E7E7E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z" />
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#7E7E7E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M18,4V3c0,-0.55 -0.45,-1 -1,-1H5c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1V6h1v4H9v11c0,0.55 0.45,1 1,1h2c0.55,0 1,-0.45 1,-1v-9h8V4h-3z" />
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#7E7E7E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M15.73,3L8.27,3L3,8.27v7.46L8.27,21h7.46L21,15.73L21,8.27L15.73,3zM12,17.3c-0.72,0 -1.3,-0.58 -1.3,-1.3 0,-0.72 0.58,-1.3 1.3,-1.3 0.72,0 1.3,0.58 1.3,1.3 0,0.72 -0.58,1.3 -1.3,1.3zM13,13h-2L11,7h2v6z" />
</vector>

View File

@ -13,9 +13,6 @@
<item android:id="@+id/action_data_management" <item android:id="@+id/action_data_management"
android:title="@string/action_db_management" android:title="@string/action_db_management"
android:icon="@drawable/ic_pageview" /> android:icon="@drawable/ic_pageview" />
<item android:id="@+id/action_notification_management"
android:title="@string/title_activity_notification_management"
android:icon="@drawable/ic_notifications" />
<item android:id="@+id/device_action_discover" <item android:id="@+id/device_action_discover"
android:title="@string/action_discover" android:title="@string/action_discover"
android:iconTint="#7E7E7E" android:iconTint="#7E7E7E"

View File

@ -217,10 +217,22 @@
<string name="pref_title_mb_intents">Broadcast Media Button Intents Directly</string> <string name="pref_title_mb_intents">Broadcast Media Button Intents Directly</string>
<string name="pref_summary_mb_intents">Enable if device media control is not working for certain applications</string> <string name="pref_summary_mb_intents">Enable if device media control is not working for certain applications</string>
<string name="pref_title_audio_player">Preferred Audioplayer</string> <string name="pref_title_audio_player">Preferred Audioplayer</string>
<string name="pref_title_nagivation_apps">Navigation apps</string>
<string name="pref_header_external_integrations">External Integrations</string>
<string name="pref_header_automations">Automations</string>
<string name="pref_description_general">Startup, language, region, location</string>
<string name="pref_description_about_you">Date of birth, gender, height, weight, goals</string>
<string name="pref_description_notifications">App notifications, whitelist/blacklist</string>
<string name="pref_description_user_interface">Theme, main screen</string>
<string name="pref_description_dashboard">Widgets, devices to include</string>
<string name="pref_description_automations">Auto export, auto fetch</string>
<string name="pref_description_developer_options">Logs, Intent API</string>
<string name="pref_description_deprecated_functionalities">Settings that will be removed in a future version</string>
<string name="pref_default">Default</string> <string name="pref_default">Default</string>
<string name="pref_header_datetime">Date and Time</string> <string name="pref_header_datetime">Date and Time</string>
<string name="pref_title_datetime_syctimeonconnect">Sync time</string> <string name="pref_title_datetime_syctimeonconnect">Sync time</string>
<string name="pref_summary_datetime_syctimeonconnect">Sync time to Gadgetbridge device(s) when connecting, when time or time zone changes on Android device, and periodically</string> <string name="pref_summary_datetime_syctimeonconnect">Sync time to Gadgetbridge device(s) when connecting, when time or time zone changes on Android device, and periodically</string>
<string name="pref_header_main_screen">Main screen</string>
<string name="pref_title_theme">Theme</string> <string name="pref_title_theme">Theme</string>
<string name="pref_theme_light">Light</string> <string name="pref_theme_light">Light</string>
<string name="pref_theme_dark">Dark</string> <string name="pref_theme_dark">Dark</string>
@ -232,6 +244,7 @@
<string name="pref_summary_minimize_priority_off">The icon in the status bar and the notification in the lockscreen are shown</string> <string name="pref_summary_minimize_priority_off">The icon in the status bar and the notification in the lockscreen are shown</string>
<string name="pref_summary_minimize_priority_on">The icon in the status bar and the notification in the lockscreen are hidden</string> <string name="pref_summary_minimize_priority_on">The icon in the status bar and the notification in the lockscreen are hidden</string>
<string name="pref_header_notifications">Notifications</string> <string name="pref_header_notifications">Notifications</string>
<string name="pref_title_user_interface">User interface</string>
<string name="pref_title_notifications_repetitions">Repetitions</string> <string name="pref_title_notifications_repetitions">Repetitions</string>
<string name="pref_title_notifications_call">Phone Calls</string> <string name="pref_title_notifications_call">Phone Calls</string>
<string name="pref_title_notification_delay_calls">Call notification delay</string> <string name="pref_title_notification_delay_calls">Call notification delay</string>

View File

@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- this only shows up when a device is set
<com.mobeta.android.dslv.DragSortListPreference
android:icon="@drawable/ic_tabs"
android:defaultValue="@array/pref_charts_tabs_items_default"
android:dialogTitle="@string/prefs_charts_tabs"
android:entries="@array/pref_charts_tabs_items"
android:entryValues="@array/pref_charts_tabs_values"
android:key="charts_tabs"
android:persistent="false"
android:summary="@string/prefs_charts_tabs_summary"
android:title="@string/prefs_charts_tabs" />-->
<PreferenceCategory <PreferenceCategory
android:key="pref_charts" android:key="pref_charts"
android:title="@string/activity_prefs_charts" android:title="@string/activity_prefs_charts"

View File

@ -2,83 +2,44 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<PreferenceCategory
android:key="pref_key_general" <PreferenceScreen
android:title="@string/pref_header_general" android:icon="@drawable/ic_settings"
app:iconSpaceReserved="false"> android:key="pref_screen_general"
android:summary="@string/pref_description_general"
android:title="@string/pref_header_general">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="general_autostartonboot" android:key="general_autostartonboot"
android:layout="@layout/preference_checkbox" android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_general_autostartonboot" android:title="@string/pref_title_general_autostartonboot"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="show_changelog"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_show_changelog_summary"
android:title="@string/pref_show_changelog"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
android:key="general_autoconnectonbluetooth" android:key="general_autoconnectonbluetooth"
android:layout="@layout/preference_checkbox" android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_general_autoconnectonbluetooth" android:title="@string/pref_title_general_autoconnectonbluetooth"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="general_reconnectonlytoconnected" android:key="general_reconnectonlytoconnected"
android:layout="@layout/preference_checkbox" android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_general_reconnectonlytoconnected"
android:summary="@string/pref_summary_general_reconnectonlytoconnected" android:summary="@string/pref_summary_general_reconnectonlytoconnected"
app:iconSpaceReserved="false" /> android:title="@string/pref_title_general_reconnectonlytoconnected"
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="display_add_device_fab"
android:layout="@layout/preference_checkbox"
android:summaryOff="@string/pref_display_add_device_fab_off"
android:summaryOn="@string/pref_display_add_device_fab_on"
android:title="@string/pref_display_add_device_fab"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="display_bottom_navigation_bar"
android:layout="@layout/preference_checkbox"
android:summaryOff="@string/pref_summary_bottom_navigation_bar_off"
android:summaryOn="@string/pref_summary_bottom_navigation_bar_on"
android:title="@string/pref_title_bottom_navigation_bar"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<Preference <PreferenceCategory
android:key="pref_category_dashboard"
android:title="@string/bottom_nav_dashboard"
app:iconSpaceReserved="false" />
<Preference
android:key="pref_category_sleepasandroid"
android:title="@string/sleepasandroid_settings"
app:iconSpaceReserved="false" />
<PreferenceScreen
android:key="pref_screen_theme"
android:title="@string/pref_title_theme"
app:iconSpaceReserved="false">
<ListPreference
android:defaultValue="@string/pref_theme_value_light"
android:entries="@array/pref_theme_options"
android:entryValues="@array/pref_theme_values"
android:key="pref_key_theme"
android:summary="%s"
android:title="@string/pref_title_theme"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_key_theme_amoled_black"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_theme_black_background"
app:iconSpaceReserved="false" />
<Preference
android:enabled="false"
android:selectable="false"
android:singleLineTitle="false"
android:title="@string/pref_theme_dynamic_colors_explanation"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<PreferenceScreen
android:key="language_category" android:key="language_category"
android:title="@string/language_and_region_prefs" android:title="@string/language_and_region_prefs"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
@ -125,90 +86,199 @@
android:title="@string/pref_rtl_max_line_length" android:title="@string/pref_rtl_max_line_length"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
</PreferenceScreen> </PreferenceScreen>
</PreferenceScreen> </PreferenceCategory>
<PreferenceScreen <PreferenceCategory
android:key="pref_screen_weather" android:key="pref_key_datetime"
android:summary="@string/pref_title_weather_summary" android:title="@string/pref_header_datetime"
android:title="@string/pref_title_weather"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="datetime_synconconnect"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_datetime_syctimeonconnect"
android:title="@string/pref_title_datetime_syctimeonconnect"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_header_location"
app:iconSpaceReserved="false">
<Preference
android:key="location_aquire"
android:title="@string/pref_title_location_aquire"
app:iconSpaceReserved="false" />
<EditTextPreference <EditTextPreference
android:inputType="text" android:defaultValue="0"
android:key="weather_city" android:inputType="numberDecimal|numberSigned"
android:title="@string/pref_title_weather_location" android:key="location_latitude"
android:maxLength="7"
android:title="@string/pref_title_location_latitude"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
</PreferenceScreen> <EditTextPreference
android:defaultValue="0"
</PreferenceCategory> android:inputType="numberDecimal|numberSigned"
android:key="location_longitude"
android:maxLength="7"
android:title="@string/pref_title_location_longitude"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:dependency="location_aquire"
android:key="use_updated_location_if_available"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_location_keep_uptodate"
android:title="@string/pref_title_location_keep_uptodate"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
<Preference <Preference
android:icon="@drawable/ic_person"
android:key="pref_category_activity_personal" android:key="pref_category_activity_personal"
android:summary="@string/pref_description_about_you"
android:title="@string/activity_prefs_about_you" android:title="@string/activity_prefs_about_you"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<Preference <Preference
android:icon="@drawable/ic_notifications"
android:key="pref_category_notifications"
android:summary="@string/pref_description_notifications"
android:title="@string/pref_header_notifications"
app:iconSpaceReserved="false" />
<PreferenceScreen
android:icon="@drawable/ic_paint"
android:key="pref_screen_user_interface"
android:summary="@string/pref_description_user_interface"
android:title="@string/pref_title_user_interface">
<PreferenceCategory
android:key="pref_theme_dynamic_colors_explanation"
android:title="@string/pref_theme_dynamic_colors_explanation"
app:iconSpaceReserved="false"
app:singleLineTitle="false" />
<ListPreference
android:defaultValue="@string/pref_theme_value_light"
android:entries="@array/pref_theme_options"
android:entryValues="@array/pref_theme_values"
android:key="pref_key_theme"
android:summary="%s"
android:title="@string/pref_title_theme"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_key_theme_amoled_black"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_theme_black_background"
app:iconSpaceReserved="false" />
<PreferenceCategory
android:key="pref_screen_theme"
android:title="@string/pref_header_main_screen"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="display_add_device_fab"
android:layout="@layout/preference_checkbox"
android:summaryOff="@string/pref_display_add_device_fab_off"
android:summaryOn="@string/pref_display_add_device_fab_on"
android:title="@string/pref_display_add_device_fab"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="display_bottom_navigation_bar"
android:layout="@layout/preference_checkbox"
android:summaryOff="@string/pref_summary_bottom_navigation_bar_off"
android:summaryOn="@string/pref_summary_bottom_navigation_bar_on"
android:title="@string/pref_title_bottom_navigation_bar"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
<Preference
android:icon="@drawable/ic_dashboard"
android:key="pref_category_dashboard"
android:summary="@string/pref_description_dashboard"
android:title="@string/bottom_nav_dashboard"
app:iconSpaceReserved="false" />
<Preference
android:icon="@drawable/ic_show_chart"
android:key="pref_charts" android:key="pref_charts"
android:title="@string/activity_prefs_charts" android:title="@string/activity_prefs_charts"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<PreferenceCategory <PreferenceScreen
android:key="pref_key_datetime" android:icon="@drawable/ic_auto_awesome"
android:title="@string/pref_header_datetime" android:key="pref_screen_automations"
app:iconSpaceReserved="false"> android:summary="@string/pref_description_automations"
<SwitchPreferenceCompat android:title="@string/pref_header_automations">
android:defaultValue="true"
android:key="datetime_synconconnect" <PreferenceCategory
android:layout="@layout/preference_checkbox" android:title="@string/pref_header_auto_export"
android:summary="@string/pref_summary_datetime_syctimeonconnect"
android:title="@string/pref_title_datetime_syctimeonconnect"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_header_location"
app:iconSpaceReserved="false">
<Preference
android:key="location_aquire"
android:title="@string/pref_title_location_aquire"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="0"
android:inputType="numberDecimal|numberSigned"
android:key="location_latitude"
android:maxLength="7"
android:title="@string/pref_title_location_latitude"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:defaultValue="0"
android:inputType="numberDecimal|numberSigned"
android:key="location_longitude"
android:maxLength="7"
android:title="@string/pref_title_location_longitude"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:dependency="location_aquire"
android:key="use_updated_location_if_available"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_location_keep_uptodate"
android:title="@string/pref_title_location_keep_uptodate"
app:iconSpaceReserved="false" />
<Preference
android:key="pref_key_opentracks_packagename"
android:summary="@string/pref_summary_opentracks_packagename"
android:title="@string/pref_title_opentracks_packagename"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_header_navigation"
app:iconSpaceReserved="false">
<PreferenceScreen
android:key="navigation_settings"
android:title="@string/pref_title_navigation_prefs"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<Preference
android:key="auto_export_location"
android:summary="%s"
android:title="@string/pref_title_auto_export_location"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="auto_export_enabled"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_auto_export_enabled"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="3"
android:dependency="auto_export_enabled"
android:inputType="number"
android:key="auto_export_interval"
android:maxLength="3"
android:summary="@string/pref_summary_auto_export_interval"
android:title="@string/pref_title_auto_export_interval"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_header_auto_fetch"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="auto_fetch_enabled"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_auto_fetch_summary"
android:title="@string/pref_auto_fetch"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="0"
android:dependency="auto_fetch_enabled"
android:inputType="number"
android:key="auto_fetch_interval_limit"
android:maxLength="3"
android:summary="@string/pref_auto_fetch_limit_fetches_summary"
android:title="@string/pref_auto_fetch_limit_fetches"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_extension"
android:key="pref_screen_external_integrations"
android:title="@string/pref_header_external_integrations">
<PreferenceScreen
android:icon="@drawable/ic_navigation"
android:key="navigation_settings"
android:summary="@string/pref_title_navigation_forward"
android:title="@string/pref_title_nagivation_apps"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="navigation_forward" android:key="navigation_forward"
@ -249,58 +319,45 @@
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_header_auto_export"
app:iconSpaceReserved="false">
<Preference <Preference
android:key="auto_export_location" android:icon="@drawable/ic_navigation"
android:summary="%s" android:key="pref_key_opentracks_packagename"
android:title="@string/pref_title_auto_export_location" android:summary="@string/pref_summary_opentracks_packagename"
app:iconSpaceReserved="false" /> android:title="@string/pref_title_opentracks_packagename" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="auto_export_enabled"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_auto_export_enabled"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="3"
android:dependency="auto_export_enabled"
android:inputType="number"
android:key="auto_export_interval"
android:maxLength="3"
android:summary="@string/pref_summary_auto_export_interval"
android:title="@string/pref_title_auto_export_interval"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory <Preference
android:title="@string/pref_header_auto_fetch" android:icon="@drawable/ic_activity_sleep"
app:iconSpaceReserved="false"> android:key="pref_category_sleepasandroid"
<SwitchPreferenceCompat android:title="@string/sleepasandroid_settings" />
android:defaultValue="false"
android:key="auto_fetch_enabled"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_auto_fetch_summary"
android:title="@string/pref_auto_fetch"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue="0"
android:dependency="auto_fetch_enabled"
android:inputType="number"
android:key="auto_fetch_interval_limit"
android:maxLength="3"
android:summary="@string/pref_auto_fetch_limit_fetches_summary"
android:title="@string/pref_auto_fetch_limit_fetches"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory <PreferenceScreen
android:icon="@drawable/ic_wb_sunny"
android:key="pref_screen_weather"
android:summary="@string/pref_title_weather_summary"
android:title="@string/pref_title_weather">
<EditTextPreference
android:inputType="text"
android:key="weather_city"
android:title="@string/pref_title_weather_location"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
</PreferenceScreen>
<Preference
android:icon="@drawable/ic_bluetooth_searching"
android:key="pref_discovery_pairing"
android:title="@string/activity_prefs_discovery_pairing"
app:iconSpaceReserved="false" />
<PreferenceScreen
android:icon="@drawable/ic_developer_mode"
android:key="pref_key_development" android:key="pref_key_development"
android:title="@string/pref_header_development" android:summary="@string/pref_description_developer_options"
app:iconSpaceReserved="false"> android:title="@string/pref_header_development">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
android:key="log_to_file" android:key="log_to_file"
@ -314,13 +371,6 @@
android:summary="@string/pref_check_permission_status_summary" android:summary="@string/pref_check_permission_status_summary"
android:title="@string/pref_check_permission_status" android:title="@string/pref_check_permission_status"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="show_changelog"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_show_changelog_summary"
android:title="@string/pref_show_changelog"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="cache_weather" android:key="cache_weather"
@ -328,19 +378,9 @@
android:summary="@string/pref_cache_weather_summary" android:summary="@string/pref_cache_weather_summary"
android:title="@string/pref_cache_weather" android:title="@string/pref_cache_weather"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<Preference
android:key="pref_discovery_pairing"
android:title="@string/activity_prefs_discovery_pairing"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceScreen
android:key="pref_screen_intent_api"
android:title="@string/pref_header_intent_api"
app:iconSpaceReserved="false">
<PreferenceCategory <PreferenceCategory
android:key="pref_key_intent_api" android:key="pref_screen_intent_api"
android:title="@string/pref_header_intent_api" android:title="@string/pref_header_intent_api"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
@ -388,9 +428,10 @@
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_report"
android:key="pref_screen_deprecated_functionalities" android:key="pref_screen_deprecated_functionalities"
android:summary="@string/pref_description_deprecated_functionalities"
android:title="@string/pref_header_deprecated_functionalities" android:title="@string/pref_header_deprecated_functionalities"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">