mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 19:36:50 +01:00
Upgrade discovery and pairing preferences to androidx
This commit is contained in:
parent
1b281c7c62
commit
cac92fdc26
@ -1,5 +1,5 @@
|
||||
/* Copyright (C) 2015-2020 Andreas Shimokawa, Carsten Pfeiffer, Lem Dulfo,
|
||||
vanous
|
||||
/* Copyright (C) 2015-2023 Andreas Shimokawa, Carsten Pfeiffer, Lem Dulfo,
|
||||
vanous, José Rebelo
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
@ -18,36 +18,36 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.charts.AbstractPreferenceFragment;
|
||||
|
||||
public class DiscoveryPairingPreferenceActivity extends AbstractSettingsActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractSettingsActivity.class);
|
||||
public class DiscoveryPairingPreferenceActivity extends AbstractGBActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.discovery_pairing_preferences);
|
||||
setContentView(R.layout.activity_device_settings);
|
||||
|
||||
final Prefs prefs = GBApplication.getPrefs();
|
||||
final Preference pref = findPreference("scanning_intensity");
|
||||
pref.setSummary(String.valueOf(prefs.getInt("scanning_intensity", 1)));
|
||||
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
preference.setSummary(newVal.toString());
|
||||
return true;
|
||||
if (savedInstanceState == null) {
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentByTag(DiscoveryPairingPreferenceFragment.FRAGMENT_TAG);
|
||||
if (fragment == null) {
|
||||
fragment = new DiscoveryPairingPreferenceFragment();
|
||||
}
|
||||
});
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.settings_container, fragment, DiscoveryPairingPreferenceFragment.FRAGMENT_TAG)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
public static class DiscoveryPairingPreferenceFragment extends AbstractPreferenceFragment {
|
||||
static final String FRAGMENT_TAG = "DISCOVERY_PAIRING_PREFERENCES_FRAGMENT";
|
||||
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.discovery_pairing_preferences);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="pref_discovery_pairing"
|
||||
android:title="@string/activity_prefs_discovery_pairing">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="ignore_bonded_devices"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/ignore_bonded_devices_description"
|
||||
android:title="@string/ignore_bonded_devices" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="enable_companiondevice_pairing"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/companiondevice_pairing_details"
|
||||
android:title="@string/companiondevice_pairing" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="discover_unsupported_devices"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/discover_unsupported_devices_description"
|
||||
android:title="@string/discover_unsupported_devices" />
|
||||
<SeekBarPreference
|
||||
android:key="scanning_intensity"
|
||||
android:max="3"
|
||||
android:min="0"
|
||||
android:title="@string/discovery_scanning_intensity"
|
||||
android:defaultValue="1"
|
||||
app:showSeekBarValue="true" />
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:persistent="false"
|
||||
android:summary="@string/discovery_scanning_intensity_warning" />
|
||||
|
||||
</PreferenceCategory>
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="ignore_bonded_devices"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/ignore_bonded_devices_description"
|
||||
android:title="@string/ignore_bonded_devices"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="enable_companiondevice_pairing"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/companiondevice_pairing_details"
|
||||
android:title="@string/companiondevice_pairing"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="discover_unsupported_devices"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/discover_unsupported_devices_description"
|
||||
android:title="@string/discover_unsupported_devices"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SeekBarPreference
|
||||
android:defaultValue="1"
|
||||
android:key="scanning_intensity"
|
||||
android:max="3"
|
||||
android:min="0"
|
||||
android:title="@string/discovery_scanning_intensity"
|
||||
app:iconSpaceReserved="false"
|
||||
app:showSeekBarValue="true" />
|
||||
<Preference
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:summary="@string/discovery_scanning_intensity_warning"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user