mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 14:32:54 +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,
|
/* Copyright (C) 2015-2023 Andreas Shimokawa, Carsten Pfeiffer, Lem Dulfo,
|
||||||
vanous
|
vanous, José Rebelo
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
This file is part of Gadgetbridge.
|
||||||
|
|
||||||
@ -18,36 +18,36 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.activities.charts.AbstractPreferenceFragment;
|
||||||
|
|
||||||
public class DiscoveryPairingPreferenceActivity extends AbstractSettingsActivity {
|
public class DiscoveryPairingPreferenceActivity extends AbstractGBActivity {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractSettingsActivity.class);
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_device_settings);
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
addPreferencesFromResource(R.xml.discovery_pairing_preferences);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
|
||||||
super.onPostCreate(savedInstanceState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,39 @@
|
|||||||
<?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">
|
||||||
<PreferenceCategory
|
|
||||||
android:key="pref_discovery_pairing"
|
<SwitchPreference
|
||||||
android:title="@string/activity_prefs_discovery_pairing">
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="ignore_bonded_devices"
|
android:key="ignore_bonded_devices"
|
||||||
android:layout="@layout/preference_checkbox"
|
android:layout="@layout/preference_checkbox"
|
||||||
android:summary="@string/ignore_bonded_devices_description"
|
android:summary="@string/ignore_bonded_devices_description"
|
||||||
android:title="@string/ignore_bonded_devices" />
|
android:title="@string/ignore_bonded_devices"
|
||||||
<CheckBoxPreference
|
app:iconSpaceReserved="false" />
|
||||||
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="enable_companiondevice_pairing"
|
android:key="enable_companiondevice_pairing"
|
||||||
android:layout="@layout/preference_checkbox"
|
android:layout="@layout/preference_checkbox"
|
||||||
android:summary="@string/companiondevice_pairing_details"
|
android:summary="@string/companiondevice_pairing_details"
|
||||||
android:title="@string/companiondevice_pairing" />
|
android:title="@string/companiondevice_pairing"
|
||||||
<CheckBoxPreference
|
app:iconSpaceReserved="false" />
|
||||||
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="discover_unsupported_devices"
|
android:key="discover_unsupported_devices"
|
||||||
android:layout="@layout/preference_checkbox"
|
android:layout="@layout/preference_checkbox"
|
||||||
android:summary="@string/discover_unsupported_devices_description"
|
android:summary="@string/discover_unsupported_devices_description"
|
||||||
android:title="@string/discover_unsupported_devices" />
|
android:title="@string/discover_unsupported_devices"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
<SeekBarPreference
|
<SeekBarPreference
|
||||||
|
android:defaultValue="1"
|
||||||
android:key="scanning_intensity"
|
android:key="scanning_intensity"
|
||||||
android:max="3"
|
android:max="3"
|
||||||
android:min="0"
|
android:min="0"
|
||||||
android:title="@string/discovery_scanning_intensity"
|
android:title="@string/discovery_scanning_intensity"
|
||||||
android:defaultValue="1"
|
app:iconSpaceReserved="false"
|
||||||
app:showSeekBarValue="true" />
|
app:showSeekBarValue="true" />
|
||||||
<Preference
|
<Preference
|
||||||
android:selectable="false"
|
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:summary="@string/discovery_scanning_intensity_warning" />
|
android:selectable="false"
|
||||||
|
android:summary="@string/discovery_scanning_intensity_warning"
|
||||||
</PreferenceCategory>
|
app:iconSpaceReserved="false" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user