Settings: Add search

This commit is contained in:
José Rebelo
2025-08-03 20:33:11 +01:00
parent b322f0ac61
commit 3e036929cc
35 changed files with 412 additions and 139 deletions
+1
View File
@@ -27,6 +27,7 @@ vendor's servers.
* Files in app/src/main/java/com/android/nQuant are taken from the [nQuant.android](https://github.com/mcychan/nQuant.android/) project, licensed under the Apache license by Miller Cy Chan * Files in app/src/main/java/com/android/nQuant are taken from the [nQuant.android](https://github.com/mcychan/nQuant.android/) project, licensed under the Apache license by Miller Cy Chan
* Files in app/src/main/java/org/concentus are taken from the [Concentus](https://github.com/lostromb/concentus) project, licensed under the BSD-3 license by various holding parties * Files in app/src/main/java/org/concentus are taken from the [Concentus](https://github.com/lostromb/concentus) project, licensed under the BSD-3 license by various holding parties
* Files in GBDaoGenerator/src/de/greenrobot are taken from the [greenDAO](https://codeberg.org/Freeyourgadget/greenDAO) project (Gadgetbridge's fork), licensed under the GPLv3 by Markus Junginger, greenrobot * Files in GBDaoGenerator/src/de/greenrobot are taken from the [greenDAO](https://codeberg.org/Freeyourgadget/greenDAO) project (Gadgetbridge's fork), licensed under the GPLv3 by Markus Junginger, greenrobot
* File app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/SearchPreferenceHighlighter.java is licensed under the MIT license by ByteHamster
## Download ## Download
+1
View File
@@ -270,6 +270,7 @@ dependencies {
implementation 'com.google.protobuf:protobuf-javalite:4.31.1' implementation 'com.google.protobuf:protobuf-javalite:4.31.1'
implementation 'com.android.volley:volley:1.2.1' implementation 'com.android.volley:volley:1.2.1'
implementation 'org.msgpack:msgpack-core:0.9.10' implementation 'org.msgpack:msgpack-core:0.9.10'
implementation 'com.github.ByteHamster:SearchPreference:2.7.3'
implementation 'com.github.mapsforge.mapsforge:mapsforge-core:0.25.0' implementation 'com.github.mapsforge.mapsforge:mapsforge-core:0.25.0'
implementation 'com.github.mapsforge.mapsforge:mapsforge-map:0.25.0' implementation 'com.github.mapsforge.mapsforge:mapsforge-map:0.25.0'
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 ByteHamster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -235,5 +235,12 @@
"type": "MIT", "type": "MIT",
"url": "https://github.com/jhy/jsoup", "url": "https://github.com/jhy/jsoup",
"path": "licenses/jsoup.txt" "path": "licenses/jsoup.txt"
},
{
"name": "SearchPreference",
"owner": "ByteHamster",
"type": "MIT",
"url": "https://github.com/ByteHamster/SearchPreference",
"path": "licenses/bytehamster.txt"
} }
] ]
@@ -44,19 +44,12 @@ import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
public class AboutUserPreferencesActivity extends AbstractSettingsActivityV2 { public class AboutUserPreferencesActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return AboutUserPreferencesFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new AboutUserPreferencesFragment(); return new AboutUserPreferencesFragment();
} }
public static class AboutUserPreferencesFragment extends AbstractPreferenceFragment { public static class AboutUserPreferencesFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "ABOUT_USER_PREFERENCES_FRAGMENT";
@Override @Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.about_user, rootKey); setPreferencesFromResource(R.xml.about_user, rootKey);
@@ -20,9 +20,18 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.XmlRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.MenuProvider;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import androidx.lifecycle.Lifecycle;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.MultiSelectListPreference; import androidx.preference.MultiSelectListPreference;
@@ -34,6 +43,8 @@ import androidx.preference.PreferenceScreen;
import androidx.preference.SeekBarPreference; import androidx.preference.SeekBarPreference;
import androidx.preference.SwitchPreferenceCompat; import androidx.preference.SwitchPreferenceCompat;
import com.bytehamster.lib.preferencesearch.SearchConfiguration;
import com.bytehamster.lib.preferencesearch.SearchPreference;
import com.mobeta.android.dslv.DragSortListPreference; import com.mobeta.android.dslv.DragSortListPreference;
import com.mobeta.android.dslv.DragSortListPreferenceFragment; import com.mobeta.android.dslv.DragSortListPreferenceFragment;
@@ -56,11 +67,56 @@ import nodomain.freeyourgadget.gadgetbridge.util.dialogs.MaterialListPreferenceD
import nodomain.freeyourgadget.gadgetbridge.util.dialogs.MaterialMultiSelectListPreferenceDialogFragment; import nodomain.freeyourgadget.gadgetbridge.util.dialogs.MaterialMultiSelectListPreferenceDialogFragment;
import nodomain.freeyourgadget.gadgetbridge.util.preferences.MinMaxTextWatcher; import nodomain.freeyourgadget.gadgetbridge.util.preferences.MinMaxTextWatcher;
public abstract class AbstractPreferenceFragment extends PreferenceFragmentCompat { public abstract class AbstractPreferenceFragment extends PreferenceFragmentCompat implements MenuProvider {
protected static final Logger LOG = LoggerFactory.getLogger(AbstractPreferenceFragment.class); protected static final Logger LOG = LoggerFactory.getLogger(AbstractPreferenceFragment.class);
private final SharedPreferencesChangeHandler sharedPreferencesChangeHandler = new SharedPreferencesChangeHandler(); private final SharedPreferencesChangeHandler sharedPreferencesChangeHandler = new SharedPreferencesChangeHandler();
public static final String FRAGMENT_TAG = "preference_fragment";
private SearchConfiguration mSearchConfiguration;
@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SearchPreference searchPreference = findPreference("searchPreference");
if (searchPreference != null) {
mSearchConfiguration = searchPreference.getSearchConfiguration();
mSearchConfiguration.setActivity((AppCompatActivity) requireActivity());
mSearchConfiguration.setHistoryId(requireActivity().getClass().getName());
}
}
@Override
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
requireActivity().addMenuProvider(this, getViewLifecycleOwner(), Lifecycle.State.RESUMED);
}
@Override
public void onCreateMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) {
menu.clear();
if (mSearchConfiguration != null) {
inflater.inflate(R.menu.menu_preferences, menu);
}
}
@Override
public boolean onMenuItemSelected(@NonNull final MenuItem item) {
final int itemId = item.getItemId();
if (itemId == R.id.preferences_search) {
final SearchPreference searchPreference = findPreference("searchPreference");
if (searchPreference != null) {
//searchPreference.setVisible(true);
mSearchConfiguration.showSearchFragment();
return true;
}
}
return false;
}
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
@@ -155,6 +211,29 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragmentCompa
} }
} }
protected void index(@XmlRes final int preferencesResId) {
index(preferencesResId, 0);
}
protected void index(@XmlRes final int preferencesResId, final int breadcrumb) {
if (mSearchConfiguration == null) {
final SearchPreference searchPreference = findPreference("searchPreference");
if (searchPreference != null) {
mSearchConfiguration = searchPreference.getSearchConfiguration();
mSearchConfiguration.setActivity((AppCompatActivity) requireActivity());
mSearchConfiguration.setHistoryId(requireActivity().getClass().getName());
mSearchConfiguration.setBreadcrumbsEnabled(true);
}
}
if (mSearchConfiguration != null) {
final SearchConfiguration.SearchIndexItem indexItem = mSearchConfiguration.index(preferencesResId);
if (breadcrumb != 0) {
indexItem.addBreadcrumb(breadcrumb);
}
}
}
/** /**
* Reload the preferences in the current screen. This is needed when the user enters or exists a PreferenceScreen, * Reload the preferences in the current screen. This is needed when the user enters or exists a PreferenceScreen,
* otherwise the settings won't be reloaded by the {@link SharedPreferencesChangeHandler}, as the preferences return * otherwise the settings won't be reloaded by the {@link SharedPreferencesChangeHandler}, as the preferences return
@@ -16,41 +16,67 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.activities; package nodomain.freeyourgadget.gadgetbridge.activities;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.bytehamster.lib.preferencesearch.SearchPreferenceFragment;
import com.bytehamster.lib.preferencesearch.SearchPreferenceResult;
import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.SearchPreferenceHighlighter;
public abstract class AbstractSettingsActivityV2 extends AbstractGBActivity implements public abstract class AbstractSettingsActivityV2 extends AbstractGBActivity implements
PreferenceFragmentCompat.OnPreferenceStartScreenCallback { PreferenceFragmentCompat.OnPreferenceStartScreenCallback,
SearchPreferenceResultListener {
public static final String EXTRA_PREF_SCREEN = "preferenceScreen";
public static final String EXTRA_PREF_HIGHLIGHT = "preferenceToHighlight";
protected abstract String fragmentTag();
protected abstract PreferenceFragmentCompat newFragment(); protected abstract PreferenceFragmentCompat newFragment();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_settings); setContentView(R.layout.activity_settings);
if (savedInstanceState == null) { if (savedInstanceState == null) {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(fragmentTag()); PreferenceFragmentCompat fragment = (PreferenceFragmentCompat) getSupportFragmentManager().findFragmentByTag(AbstractPreferenceFragment.FRAGMENT_TAG);
if (fragment == null) { if (fragment == null) {
fragment = newFragment(); fragment = newFragment();
} }
final String prefScreen = getIntent().getStringExtra(EXTRA_PREF_SCREEN);
if (prefScreen != null) {
final Bundle args;
if (fragment.getArguments() != null) {
args = fragment.getArguments();
} else {
args = new Bundle();
fragment.setArguments(args);
}
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, prefScreen);
}
getSupportFragmentManager() getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.settings_container, fragment, fragmentTag()) .replace(R.id.settings_container, fragment, AbstractPreferenceFragment.FRAGMENT_TAG)
.commit(); .commit();
final String highlightKey = getIntent().getStringExtra(EXTRA_PREF_HIGHLIGHT);
if (highlightKey != null) {
SearchPreferenceHighlighter.highlight(fragment, highlightKey);
}
} }
} }
@Override @Override
public boolean onPreferenceStartScreen(final PreferenceFragmentCompat caller, final PreferenceScreen preferenceScreen) { public boolean onPreferenceStartScreen(@NonNull final PreferenceFragmentCompat caller,
@NonNull final PreferenceScreen preferenceScreen) {
final PreferenceFragmentCompat fragment = newFragment(); final PreferenceFragmentCompat fragment = newFragment();
final Bundle args; final Bundle args;
if (fragment.getArguments() != null) { if (fragment.getArguments() != null) {
@@ -83,6 +109,57 @@ public abstract class AbstractSettingsActivityV2 extends AbstractGBActivity impl
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@Override
public void onSearchResultClicked(final SearchPreferenceResult result) {
final FragmentManager fragmentManager = getSupportFragmentManager();
result.closeSearchPage(this);
// FIXME: Not sure why we need this, but otherwise we need to go back twice when switching preference screens
fragmentManager.popBackStack(SearchPreferenceFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
final Fragment currentFragment = fragmentManager.findFragmentByTag(AbstractPreferenceFragment.FRAGMENT_TAG);
if (currentFragment == null) {
return;
}
if (!(currentFragment instanceof PreferenceFragmentCompat currentPreferenceFragment)) {
return;
}
final String currentScreen = currentPreferenceFragment.getPreferenceScreen().getKey();
if (result.getScreen() != null && !result.getScreen().equals(currentScreen)) {
final PreferenceFragmentCompat newFragmentForScreen = newFragment();
final Bundle args;
if (newFragmentForScreen.getArguments() != null) {
args = newFragmentForScreen.getArguments();
} else {
args = new Bundle();
}
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, result.getScreen());
newFragmentForScreen.setArguments(args);
fragmentManager.beginTransaction()
.replace(R.id.settings_container, newFragmentForScreen)
.addToBackStack("search_goto_" + result.getScreen())
.commit();
result.highlight(newFragmentForScreen);
} else {
final Preference preference = currentPreferenceFragment.findPreference(result.getKey());
if (preference != null) {
result.highlight(currentPreferenceFragment);
}
}
}
protected void open(final Class<? extends AbstractSettingsActivityV2> clazz,
final SearchPreferenceResult result) {
final Intent intent = new Intent(this, clazz);
intent.putExtra(EXTRA_PREF_SCREEN, result.getScreen());
intent.putExtra(EXTRA_PREF_HIGHLIGHT, result.getKey());
startActivity(intent);
}
public void setActionBarTitle(final CharSequence title) { public void setActionBarTitle(final CharSequence title) {
final ActionBar actionBar = getSupportActionBar(); final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
@@ -34,19 +34,17 @@ import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class DashboardPreferencesActivity extends AbstractSettingsActivityV2 { public class DashboardPreferencesActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return DashboardPreferencesFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new DashboardPreferencesFragment(); return new DashboardPreferencesFragment();
} }
public static class DashboardPreferencesFragment extends AbstractPreferenceFragment { @Override
static final String FRAGMENT_TAG = "DASHBOARD_PREFERENCES_FRAGMENT"; protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public static class DashboardPreferencesFragment extends AbstractPreferenceFragment {
@Override @Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.dashboard_preferences, rootKey); setPreferencesFromResource(R.xml.dashboard_preferences, rootKey);
@@ -38,11 +38,6 @@ public class NotificationManagementActivity extends AbstractSettingsActivityV2 {
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();
@Override
protected String fragmentTag() {
return NotificationPreferencesFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new NotificationPreferencesFragment(); return new NotificationPreferencesFragment();
@@ -51,8 +46,6 @@ 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); private static final Logger LOG = LoggerFactory.getLogger(NotificationPreferencesFragment.class);
static final String FRAGMENT_TAG = "NOTIFICATION_PREFERENCES_FRAGMENT";
@Override @Override
protected void onSharedPreferenceChanged(final Preference preference) { protected void onSharedPreferenceChanged(final Preference preference) {
if (GBPrefs.PING_TONE.equals(preference.getKey())) { if (GBPrefs.PING_TONE.equals(preference.getKey())) {
@@ -48,6 +48,7 @@ import androidx.preference.ListPreference;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import com.bytehamster.lib.preferencesearch.SearchPreferenceResult;
import com.google.android.material.color.DynamicColors; import com.google.android.material.color.DynamicColors;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@@ -79,21 +80,35 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class SettingsActivity extends AbstractSettingsActivityV2 { public class SettingsActivity extends AbstractSettingsActivityV2 {
public static final String PREF_MEASUREMENT_SYSTEM = "measurement_system"; public static final String PREF_MEASUREMENT_SYSTEM = "measurement_system";
@Override
protected String fragmentTag() {
return SettingsFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new SettingsFragment(); return new SettingsFragment();
} }
@Override
public void onSearchResultClicked(final SearchPreferenceResult result) {
if (result.getResourceFile() == R.xml.dashboard_preferences) {
open(DashboardPreferencesActivity.class, result);
} else if (result.getResourceFile() == R.xml.about_user) {
open(AboutUserPreferencesActivity.class, result);
} else if (result.getResourceFile() == R.xml.charts_preferences) {
open(ChartsPreferencesActivity.class, result);
} else if (result.getResourceFile() == R.xml.sleepasandroid_preferences) {
open(SleepAsAndroidPreferencesActivity.class, result);
} else if (result.getResourceFile() == R.xml.discovery_pairing_preferences) {
open(DiscoveryPairingPreferenceActivity.class, result);
} else if (result.getResourceFile() == R.xml.notifications_preferences) {
open(NotificationManagementActivity.class, result);
} else if (result.getResourceFile() == R.xml.map_settings) {
open(MapsSettingsActivity.class, result);
} else {
super.onSearchResultClicked(result);
}
}
public static class SettingsFragment extends AbstractPreferenceFragment { public static class SettingsFragment extends AbstractPreferenceFragment {
private static final Logger LOG = LoggerFactory.getLogger(SettingsActivity.class); private static final Logger LOG = LoggerFactory.getLogger(SettingsActivity.class);
static final String FRAGMENT_TAG = "SETTINGS_FRAGMENT";
private static final int EXPORT_LOCATION_FILE_REQUEST_CODE = 4711; private static final int EXPORT_LOCATION_FILE_REQUEST_CODE = 4711;
private EditText fitnessAppEditText = null; private EditText fitnessAppEditText = null;
private int fitnessAppSelectionListSpinnerFirstRun = 0; private int fitnessAppSelectionListSpinnerFirstRun = 0;
@@ -101,6 +116,14 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
@Override @Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey); setPreferencesFromResource(R.xml.preferences, rootKey);
index(R.xml.preferences);
index(R.xml.dashboard_preferences, R.string.bottom_nav_dashboard);
index(R.xml.about_user, R.string.activity_prefs_about_you);
index(R.xml.charts_preferences, R.string.activity_prefs_charts);
index(R.xml.sleepasandroid_preferences, R.string.sleepasandroid_settings);
index(R.xml.discovery_pairing_preferences, R.string.activity_prefs_discovery_pairing);
index(R.xml.notifications_preferences, R.string.pref_header_notifications);
index(R.xml.map_settings, R.string.maps_settings);
setInputTypeFor("rtl_max_line_length", InputType.TYPE_CLASS_NUMBER); setInputTypeFor("rtl_max_line_length", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("location_latitude", InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); setInputTypeFor("location_latitude", InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
@@ -22,19 +22,12 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.devices.SleepAsAndroidFeature; import nodomain.freeyourgadget.gadgetbridge.devices.SleepAsAndroidFeature;
public class SleepAsAndroidPreferencesActivity extends AbstractSettingsActivityV2 { public class SleepAsAndroidPreferencesActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return SleepAsAndroidPreferencesFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new SleepAsAndroidPreferencesFragment(); return new SleepAsAndroidPreferencesFragment();
} }
public static class SleepAsAndroidPreferencesFragment extends AbstractPreferenceFragment { public static class SleepAsAndroidPreferencesFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "SLEEPASANDROID_PREFERENCES_FRAGMENT";
@Override @Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
setPreferencesFromResource(R.xml.sleepasandroid_preferences, rootKey); setPreferencesFromResource(R.xml.sleepasandroid_preferences, rootKey);
@@ -20,30 +20,19 @@ 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.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; private GBDevice device;
@Override
protected String fragmentTag() {
return ChartsPreferencesFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return ChartsPreferencesFragment.newInstance(device); return ChartsPreferencesFragment.newInstance(device);
@@ -57,8 +46,6 @@ public class ChartsPreferencesActivity extends AbstractSettingsActivityV2 {
} }
public static class ChartsPreferencesFragment extends AbstractPreferenceFragment { public static class ChartsPreferencesFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "CHARTS_PREFERENCES_FRAGMENT";
private GBDevice device; private GBDevice device;
static ChartsPreferencesFragment newInstance(final GBDevice device) { static ChartsPreferencesFragment newInstance(final GBDevice device) {
@@ -16,9 +16,14 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings; package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
import android.content.Intent;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import com.bytehamster.lib.preferencesearch.SearchPreferenceResult;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class DeviceSettingsActivity extends AbstractSettingsActivityV2 { public class DeviceSettingsActivity extends AbstractSettingsActivityV2 {
@@ -30,11 +35,6 @@ public class DeviceSettingsActivity extends AbstractSettingsActivityV2 {
APPLICATION_SETTINGS APPLICATION_SETTINGS
} }
@Override
protected String fragmentTag() {
return DeviceSpecificSettingsFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
final GBDevice device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE); final GBDevice device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
@@ -42,4 +42,20 @@ public class DeviceSettingsActivity extends AbstractSettingsActivityV2 {
return DeviceSpecificSettingsFragment.newInstance(device, menu_entry); return DeviceSpecificSettingsFragment.newInstance(device, menu_entry);
} }
@Override
public void onSearchResultClicked(final SearchPreferenceResult result) {
final GBDevice device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
DeviceCoordinator coordinator = device.getDeviceCoordinator();
DeviceSpecificSettings deviceSpecificSettings = coordinator.getDeviceSpecificSettings(device);
String rootScreenForSubScreen = deviceSpecificSettings.getRootScreenForSubScreen(result.getResourceFile());
if (rootScreenForSubScreen != null) {
final Intent intent = getIntent(); // FIXME new Intent(this, DeviceSettingsActivity.class);
intent.putExtra(EXTRA_PREF_SCREEN, rootScreenForSubScreen);
intent.putExtra(EXTRA_PREF_HIGHLIGHT, result.getKey());
startActivity(intent);
}
}
} }
@@ -122,6 +122,18 @@ public class DeviceSpecificSettings implements Parcelable {
connectedPreferences.addAll(deviceSpecificSettings.connectedPreferences); connectedPreferences.addAll(deviceSpecificSettings.connectedPreferences);
} }
public String getRootScreenForSubScreen(final int subScreen) {
for (final Map.Entry<String, List<Integer>> e : subScreens.entrySet()) {
for (final Integer ss : e.getValue()) {
if (ss == subScreen) {
return e.getKey();
}
}
}
return null;
}
public List<Integer> getRootScreens() { public List<Integer> getRootScreens() {
return rootScreens; return rootScreens;
} }
@@ -101,8 +101,6 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
private static final Logger LOG = LoggerFactory.getLogger(DeviceSpecificSettingsFragment.class); private static final Logger LOG = LoggerFactory.getLogger(DeviceSpecificSettingsFragment.class);
static final String FRAGMENT_TAG = "DEVICE_SPECIFIC_SETTINGS_FRAGMENT";
private DeviceSpecificSettings deviceSpecificSettings; private DeviceSpecificSettings deviceSpecificSettings;
private DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer; private DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer;
@@ -59,4 +59,14 @@ public enum DeviceSpecificSettingsScreen {
public int getXml() { public int getXml() {
return xml; return xml;
} }
public static DeviceSpecificSettingsScreen fromXml(final int xml) {
for (final DeviceSpecificSettingsScreen screen : DeviceSpecificSettingsScreen.values()) {
if (screen.xml == xml) {
return screen;
}
}
return null;
}
} }
@@ -28,19 +28,12 @@ import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV
import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class DiscoveryPairingPreferenceActivity extends AbstractSettingsActivityV2 { public class DiscoveryPairingPreferenceActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return DiscoveryPairingPreferenceFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new DiscoveryPairingPreferenceFragment(); return new DiscoveryPairingPreferenceFragment();
} }
public static class DiscoveryPairingPreferenceFragment extends AbstractPreferenceFragment { public static class DiscoveryPairingPreferenceFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "DISCOVERY_PAIRING_PREFERENCES_FRAGMENT";
@Override @Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.discovery_pairing_preferences, rootKey); setPreferencesFromResource(R.xml.discovery_pairing_preferences, rootKey);
@@ -18,17 +18,13 @@ package nodomain.freeyourgadget.gadgetbridge.activities.loyaltycards;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@@ -41,11 +37,6 @@ public class LoyaltyCardsSettingsActivity extends AbstractSettingsActivityV2 imp
private GBDevice device; private GBDevice device;
@Override
protected String fragmentTag() {
return LoyaltyCardsSettingsFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return LoyaltyCardsSettingsFragment.newInstance(device); return LoyaltyCardsSettingsFragment.newInstance(device);
@@ -61,8 +61,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
public class LoyaltyCardsSettingsFragment extends AbstractPreferenceFragment { public class LoyaltyCardsSettingsFragment extends AbstractPreferenceFragment {
private static final Logger LOG = LoggerFactory.getLogger(LoyaltyCardsSettingsFragment.class); private static final Logger LOG = LoggerFactory.getLogger(LoyaltyCardsSettingsFragment.class);
static final String FRAGMENT_TAG = "LOYALTY_CARDS_SETTINGS_FRAGMENT";
private GBDevice device; private GBDevice device;
private void setSettingsFileSuffix(final String settingsFileSuffix) { private void setSettingsFileSuffix(final String settingsFileSuffix) {
@@ -21,11 +21,6 @@ import androidx.preference.PreferenceFragmentCompat;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
public class MapsSettingsActivity extends AbstractSettingsActivityV2 { public class MapsSettingsActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return MapsSettingsFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new MapsSettingsFragment(); return new MapsSettingsFragment();
@@ -34,8 +34,6 @@ import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragmen
import nodomain.freeyourgadget.gadgetbridge.util.maps.MapsManager; import nodomain.freeyourgadget.gadgetbridge.util.maps.MapsManager;
public class MapsSettingsFragment extends AbstractPreferenceFragment { public class MapsSettingsFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "MAP_SETTINGS_FRAGMENT";
public static final String ACTION_SETTING_CHANGE = "nodomain.freeyourgadget.gadgetbridge.maps.setting_change"; public static final String ACTION_SETTING_CHANGE = "nodomain.freeyourgadget.gadgetbridge.maps.setting_change";
public static final String EXTRA_SETTING_KEY = "nodomain.freeyourgadget.gadgetbridge.maps_setting_key"; public static final String EXTRA_SETTING_KEY = "nodomain.freeyourgadget.gadgetbridge.maps_setting_key";
@@ -26,11 +26,6 @@ public class GarminRealtimeSettingsActivity extends AbstractSettingsActivityV2 {
public static final String EXTRA_SCREEN_ID = "screenId"; public static final String EXTRA_SCREEN_ID = "screenId";
@Override
protected String fragmentTag() {
return GarminRealtimeSettingsFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return GarminRealtimeSettingsFragment.newInstance(device, screenId); return GarminRealtimeSettingsFragment.newInstance(device, screenId);
@@ -75,8 +75,6 @@ public class GarminRealtimeSettingsFragment extends AbstractPreferenceFragment {
public static final int ROOT_SCREEN_ID = 36352; public static final int ROOT_SCREEN_ID = 36352;
static final String FRAGMENT_TAG = "GARMIN_REALTIME_SETTINGS_FRAGMENT";
private GBDevice device; private GBDevice device;
private int screenId = ROOT_SCREEN_ID; private int screenId = ROOT_SCREEN_ID;
@@ -47,7 +47,7 @@ public class HuaweiStressCalibrationActivity extends AbstractGBActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE); device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
setContentView(R.layout.activity_device_settings); setContentView(R.layout.activity_settings);
if (device == null || !device.isInitialized()) { if (device == null || !device.isInitialized()) {
GB.toast(getString(R.string.watch_not_connected), Toast.LENGTH_SHORT, GB.INFO); GB.toast(getString(R.string.watch_not_connected), Toast.LENGTH_SHORT, GB.INFO);
@@ -35,11 +35,6 @@ import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV
public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivityV2 { public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivityV2 {
static HybridHRWatchfaceSettings settings; static HybridHRWatchfaceSettings settings;
@Override
protected String fragmentTag() {
return HybridHRWatchfaceSettingsFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new HybridHRWatchfaceSettingsFragment(); return new HybridHRWatchfaceSettingsFragment();
@@ -49,11 +49,6 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
private static final Boolean WIDGET_CUSTOM_DEFAULT_HIDE_TEXT = true; private static final Boolean WIDGET_CUSTOM_DEFAULT_HIDE_TEXT = true;
private static final Boolean WIDGET_CUSTOM_DEFAULT_SHOW_CIRCLE = true; private static final Boolean WIDGET_CUSTOM_DEFAULT_SHOW_CIRCLE = true;
@Override
protected String fragmentTag() {
return HybridHRWatchfaceWidgetFragment.FRAGMENT_TAG;
}
@Override @Override
protected PreferenceFragmentCompat newFragment() { protected PreferenceFragmentCompat newFragment() {
return new HybridHRWatchfaceWidgetFragment(); return new HybridHRWatchfaceWidgetFragment();
@@ -99,8 +94,6 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
} }
public static class HybridHRWatchfaceWidgetFragment extends AbstractPreferenceFragment implements Preference.OnPreferenceChangeListener { public static class HybridHRWatchfaceWidgetFragment extends AbstractPreferenceFragment implements Preference.OnPreferenceChangeListener {
static final String FRAGMENT_TAG = "HYBRID_HR_WATCHFACE_WIDGET_FRAGMENT";
@Override @Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.fossil_hr_widget_settings, rootKey); setPreferencesFromResource(R.xml.fossil_hr_widget_settings, rootKey);
@@ -0,0 +1,85 @@
package nodomain.freeyourgadget.gadgetbridge.util;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.Log;
import android.util.TypedValue;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceGroup;
import androidx.recyclerview.widget.RecyclerView;
/**
* Copied as-is from <a href="https://github.com/ByteHamster/SearchPreference/blob/0c5669a6423292f1653abd9259a4040dad96f84e/lib/src/main/java/com/bytehamster/lib/preferencesearch/SearchPreferenceResult.java">SearchPreferenceResult</a>, since the constructor is protected, and
* we need a way to highlight preferences in a different activity due to the way Gadgetbridge is built.
*/
public class SearchPreferenceHighlighter {
public static void highlight(final PreferenceFragmentCompat prefsFragment, final String key) {
new Handler().post(() -> doHighlight(prefsFragment, key));
}
private static void doHighlight(final PreferenceFragmentCompat prefsFragment, final String key) {
final Preference prefResult = prefsFragment.findPreference(key);
if (prefResult == null) {
Log.e("doHighlight", "Preference not found on given screen");
return;
}
final RecyclerView recyclerView = prefsFragment.getListView();
final RecyclerView.Adapter<?> adapter = recyclerView.getAdapter();
if (adapter instanceof PreferenceGroup.PreferencePositionCallback) {
PreferenceGroup.PreferencePositionCallback callback = (PreferenceGroup.PreferencePositionCallback) adapter;
final int position = callback.getPreferenceAdapterPosition(prefResult);
if (position != RecyclerView.NO_POSITION) {
recyclerView.scrollToPosition(position);
recyclerView.postDelayed(() -> {
RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
if (holder != null) {
Drawable oldBackground = holder.itemView.getBackground();
int color = getColorFromAttr(prefsFragment.getContext(), android.R.attr.textColorPrimary);
holder.itemView.setBackgroundColor(color & 0xffffff | 0x33000000);
new Handler().postDelayed(() -> holder.itemView.setBackgroundDrawable(oldBackground), 1000);
return;
}
highlightFallback(prefsFragment, prefResult);
}, 200);
return;
}
}
highlightFallback(prefsFragment, prefResult);
}
/**
* Alternative highlight method if accessing the view did not work
*/
private static void highlightFallback(PreferenceFragmentCompat prefsFragment, final Preference prefResult) {
final Drawable oldIcon = prefResult.getIcon();
final boolean oldSpaceReserved = prefResult.isIconSpaceReserved();
Drawable arrow = AppCompatResources.getDrawable(prefsFragment.getContext(), com.bytehamster.lib.preferencesearch.R.drawable.searchpreference_ic_arrow_right);
int color = getColorFromAttr(prefsFragment.getContext(), android.R.attr.textColorPrimary);
arrow.setColorFilter(color, PorterDuff.Mode.SRC_IN);
prefResult.setIcon(arrow);
prefsFragment.scrollToPreference(prefResult);
new Handler().postDelayed(() -> {
prefResult.setIcon(oldIcon);
prefResult.setIconSpaceReserved(oldSpaceReserved);
}, 1000);
}
private static int getColorFromAttr(Context context, int attr) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(attr, typedValue, true);
TypedArray arr = context.obtainStyledAttributes(typedValue.data, new int[]{
android.R.attr.textColorPrimary});
int color = arr.getColor(0, 0xff3F51B5);
arr.recycle();
return color;
}
}
@@ -4,8 +4,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="10dp"> android:layout_margin="10dp">
<FrameLayout <FrameLayout
android:id="@+id/settings_container" android:id="@+id/settings_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
@@ -0,0 +1,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activities.DashboardFragment">
<item
android:id="@+id/preferences_search"
android:icon="@drawable/searchpreference_ic_search"
android:title="@string/menuitem_calendar"
app:iconTint="?attr/actionmenu_icon_color"
app:showAsAction="always" />
</menu>
+2 -2
View File
@@ -24,8 +24,8 @@
android:entries="@array/gender" android:entries="@array/gender"
android:entryValues="@array/gender_values" android:entryValues="@array/gender_values"
android:key="activity_user_gender" android:key="activity_user_gender"
android:summary="%s" android:title="@string/activity_prefs_gender"
android:title="@string/activity_prefs_gender" /> app:useSimpleSummaryProvider="true" />
<!--TODO: support localized heights and weights --> <!--TODO: support localized heights and weights -->
<EditTextPreference <EditTextPreference
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ListPreference <ListPreference
android:defaultValue="0" android:defaultValue="0"
android:entries="@array/lefun_interface_language_names" android:entries="@array/lefun_interface_language_names"
android:entryValues="@array/lefun_interface_language_values" android:entryValues="@array/lefun_interface_language_values"
android:icon="@drawable/ic_language" android:icon="@drawable/ic_language"
android:key="language" android:key="language"
android:summary="%s" android:title="@string/lefun_prefs_interface_language_title"
android:title="@string/lefun_prefs_interface_language_title" /> app:useSimpleSummaryProvider="true" />
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<com.bytehamster.lib.preferencesearch.SearchPreference
android:key="searchPreference" />
</androidx.preference.PreferenceScreen>
+4 -3
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory <PreferenceCategory
android:key="pref_key_header_loyalty_cards_catima" android:key="pref_key_header_loyalty_cards_catima"
android:title="@string/loyalty_cards_catima"> android:title="@string/loyalty_cards_catima">
@@ -9,8 +10,8 @@
android:entries="@array/pref_huami2021_empty_array" android:entries="@array/pref_huami2021_empty_array"
android:entryValues="@array/pref_huami2021_empty_array" android:entryValues="@array/pref_huami2021_empty_array"
android:key="loyalty_cards_catima_package" android:key="loyalty_cards_catima_package"
android:summary="%s" android:title="@string/loyalty_cards_catima_package"
android:title="@string/loyalty_cards_catima_package" /> app:useSimpleSummaryProvider="true" />
<Preference <Preference
android:icon="@drawable/ic_loyalty" android:icon="@drawable/ic_loyalty"
@@ -67,17 +67,16 @@
android:id="@+id/preference" android:id="@+id/preference"
android:key="ping_tone" android:key="ping_tone"
android:title="@string/pref_title_ping_tone" android:title="@string/pref_title_ping_tone"
app:iconSpaceReserved="false" app:iconSpaceReserved="false" />
app:summary="%s" />
<ListPreference <ListPreference
android:defaultValue="always" android:defaultValue="always"
android:entries="@array/notification_mode_toggle" android:entries="@array/notification_mode_toggle"
android:entryValues="@array/notification_mode_values_toggle" android:entryValues="@array/notification_mode_values_toggle"
android:key="notification_mode_calls" android:key="notification_mode_calls"
android:summary="%s"
android:title="@string/pref_title_notifications_call" android:title="@string/pref_title_notifications_call"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
@@ -101,9 +100,9 @@
android:entries="@array/notification_mode" android:entries="@array/notification_mode"
android:entryValues="@array/notification_mode_values" android:entryValues="@array/notification_mode_values"
android:key="notification_mode_sms" android:key="notification_mode_sms"
android:summary="%s"
android:title="@string/pref_title_notifications_sms" android:title="@string/pref_title_notifications_sms"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference <ListPreference
android:defaultValue="when_screen_off" android:defaultValue="when_screen_off"
@@ -119,9 +118,9 @@
android:entries="@array/notifications_timeout" android:entries="@array/notifications_timeout"
android:entryValues="@array/notifications_timeout_values" android:entryValues="@array/notifications_timeout_values"
android:key="notifications_timeout" android:key="notifications_timeout"
android:summary="%s"
android:title="@string/pref_title_notifications_timeout" android:title="@string/pref_title_notifications_timeout"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
@@ -169,9 +168,9 @@
android:entries="@array/notification_list_is_blacklist_names" android:entries="@array/notification_list_is_blacklist_names"
android:entryValues="@array/notification_list_is_blacklist_values" android:entryValues="@array/notification_list_is_blacklist_values"
android:key="notification_list_is_blacklist" android:key="notification_list_is_blacklist"
android:summary="%s"
android:title="@string/pref_title_notification_use_as" android:title="@string/pref_title_notification_use_as"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
@@ -196,18 +195,18 @@
android:entries="@array/pref_call_privacy_mode" android:entries="@array/pref_call_privacy_mode"
android:entryValues="@array/pref_call_privacy_mode_values" android:entryValues="@array/pref_call_privacy_mode_values"
android:key="pref_call_privacy_mode" android:key="pref_call_privacy_mode"
android:summary="%s"
android:title="@string/pref_title_call_privacy_mode" android:title="@string/pref_title_call_privacy_mode"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<ListPreference <ListPreference
android:defaultValue="off" android:defaultValue="off"
android:entries="@array/pref_message_privacy_mode" android:entries="@array/pref_message_privacy_mode"
android:entryValues="@array/pref_message_privacy_mode_values" android:entryValues="@array/pref_message_privacy_mode_values"
android:key="pref_message_privacy_mode" android:key="pref_message_privacy_mode"
android:summary="%s"
android:title="@string/pref_title_message_privacy_mode" android:title="@string/pref_title_message_privacy_mode"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
+12 -9
View File
@@ -3,6 +3,10 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<com.bytehamster.lib.preferencesearch.SearchPreference
android:key="searchPreference"
app:isPreferenceVisible="false" />
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_settings" android:icon="@drawable/ic_settings"
android:key="pref_screen_general" android:key="pref_screen_general"
@@ -47,17 +51,17 @@
android:entries="@array/pref_language_options" android:entries="@array/pref_language_options"
android:entryValues="@array/pref_language_values" android:entryValues="@array/pref_language_values"
android:key="language" android:key="language"
android:summary="%s"
android:title="@string/pref_title_language" android:title="@string/pref_title_language"
android:icon="@drawable/ic_translate" /> android:icon="@drawable/ic_translate"
app:useSimpleSummaryProvider="true" />
<ListPreference <ListPreference
android:defaultValue="metric" android:defaultValue="metric"
android:entries="@array/pref_entries_unit_system" android:entries="@array/pref_entries_unit_system"
android:entryValues="@array/pref_values_unit_system" android:entryValues="@array/pref_values_unit_system"
android:key="measurement_system" android:key="measurement_system"
android:summary="%s"
android:title="@string/pref_title_unit_system" android:title="@string/pref_title_unit_system"
android:icon="@drawable/ic_straighten" /> android:icon="@drawable/ic_straighten"
app:useSimpleSummaryProvider="true" />
<PreferenceScreen <PreferenceScreen
android:key="pref_screen_rtl" android:key="pref_screen_rtl"
android:title="@string/preferences_rtl_settings" android:title="@string/preferences_rtl_settings"
@@ -164,8 +168,8 @@
android:entryValues="@array/pref_theme_values" android:entryValues="@array/pref_theme_values"
android:icon="@drawable/ic_contrast" android:icon="@drawable/ic_contrast"
android:key="pref_key_theme" android:key="pref_key_theme"
android:summary="%s" android:title="@string/pref_title_theme"
android:title="@string/pref_title_theme" /> app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
android:icon="@drawable/ic_dark_mode" android:icon="@drawable/ic_dark_mode"
@@ -236,7 +240,6 @@
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<Preference <Preference
android:key="auto_export_location" android:key="auto_export_location"
android:summary="%s"
android:title="@string/pref_title_auto_export_location" android:title="@string/pref_title_auto_export_location"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
@@ -493,9 +496,9 @@
android:defaultValue="default" android:defaultValue="default"
android:dependency="mb_intents" android:dependency="mb_intents"
android:key="audio_player" android:key="audio_player"
android:summary="%s"
android:title="@string/pref_title_audio_player" android:title="@string/pref_title_audio_player"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
</PreferenceScreen> </PreferenceScreen>