From 682a26e56d0432e25eb2f9ccff16456729fe6ec6 Mon Sep 17 00:00:00 2001 From: vanous Date: Thu, 23 Dec 2021 18:56:36 +0100 Subject: [PATCH] Add Discovery setting to the Discovery Activity --- app/src/main/AndroidManifest.xml | 4 +++ .../activities/DiscoveryActivity.java | 32 ++++++++++++----- .../DiscoveryPairingPreferenceActivity.java | 34 +++++++++++++++++++ .../activities/SettingsActivity.java | 9 +++++ .../main/res/layout/activity_discovery.xml | 5 +++ app/src/main/res/values/strings.xml | 1 + .../res/xml/discovery_pairing_preferences.xml | 31 +++++++++++++++++ app/src/main/res/xml/preferences.xml | 28 +++------------ 8 files changed, 111 insertions(+), 33 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryPairingPreferenceActivity.java create mode 100644 app/src/main/res/xml/discovery_pairing_preferences.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4e7b3156d..a68761b1e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -95,6 +95,10 @@ android:name=".activities.charts.ChartsPreferencesActivity" android:label="@string/activity_prefs_charts" android:parentActivityName=".activities.charts.ChartsPreferencesActivity" /> + . */ +package nodomain.freeyourgadget.gadgetbridge.activities; + +import android.os.Bundle; + +import nodomain.freeyourgadget.gadgetbridge.R; + +public class DiscoveryPairingPreferenceActivity extends AbstractSettingsActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.discovery_pairing_preferences); + } + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index 4c249c9ec..b8a590671 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -394,6 +394,15 @@ public class SettingsActivity extends AbstractSettingsActivity { return true; } }); + pref = findPreference("pref_discovery_pairing"); + pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + public boolean onPreferenceClick(Preference preference) { + Intent enableIntent = new Intent(SettingsActivity.this, DiscoveryPairingPreferenceActivity.class); + startActivity(enableIntent); + return true; + } + }); + } @Override diff --git a/app/src/main/res/layout/activity_discovery.xml b/app/src/main/res/layout/activity_discovery.xml index 331bc9e2e..58d4cabdd 100644 --- a/app/src/main/res/layout/activity_discovery.xml +++ b/app/src/main/res/layout/activity_discovery.xml @@ -89,5 +89,10 @@ android:textColor="@color/secondarytext" android:textIsSelectable="true" /> +