mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 19:36:50 +01:00
Add Discovery setting to the Discovery Activity
This commit is contained in:
parent
71138192f0
commit
682a26e56d
@ -95,6 +95,10 @@
|
||||
android:name=".activities.charts.ChartsPreferencesActivity"
|
||||
android:label="@string/activity_prefs_charts"
|
||||
android:parentActivityName=".activities.charts.ChartsPreferencesActivity" />
|
||||
<activity
|
||||
android:name=".activities.DiscoveryPairingPreferenceActivity"
|
||||
android:label="@string/activity_prefs_discovery_pairing"
|
||||
android:parentActivityName=".activities.SettingsActivity" />
|
||||
<activity
|
||||
android:name=".devices.miband.MiBandPreferencesActivity"
|
||||
android:label="@string/preferences_miband_settings"
|
||||
|
@ -250,15 +250,7 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
ignoreBonded = prefs.getBoolean("ignore_bonded_devices", true);
|
||||
discoverUnsupported = prefs.getBoolean("discover_unsupported_devices", false);
|
||||
|
||||
oldBleScanning = prefs.getBoolean("disable_new_ble_scanning", false);
|
||||
if (oldBleScanning) {
|
||||
LOG.info("New BLE scanning disabled via settings, using old method");
|
||||
}
|
||||
|
||||
loadSettingsValues();
|
||||
setContentView(R.layout.activity_discovery);
|
||||
startButton = findViewById(R.id.discovery_start);
|
||||
startButton.setOnClickListener(new View.OnClickListener() {
|
||||
@ -268,6 +260,15 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
}
|
||||
});
|
||||
|
||||
Button settingsButton = findViewById(R.id.discovery_preferences);
|
||||
settingsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent enableIntent = new Intent(DiscoveryActivity.this, DiscoveryPairingPreferenceActivity.class);
|
||||
startActivity(enableIntent);
|
||||
}
|
||||
});
|
||||
|
||||
bluetoothProgress = findViewById(R.id.discovery_progressbar);
|
||||
bluetoothProgress.setProgress(0);
|
||||
bluetoothProgress.setIndeterminate(true);
|
||||
@ -296,6 +297,8 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
if (isScanning()) {
|
||||
stopDiscovery();
|
||||
} else {
|
||||
deviceCandidates.clear();
|
||||
deviceCandidateAdapter.notifyDataSetChanged();
|
||||
if (GB.supportsBluetoothLE()) {
|
||||
startDiscovery(Scanning.SCANNING_BT_NEXT_BLE);
|
||||
} else {
|
||||
@ -345,6 +348,7 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
loadSettingsValues();
|
||||
registerBroadcastReceivers();
|
||||
super.onResume();
|
||||
}
|
||||
@ -830,6 +834,16 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
registerReceiver(bluetoothReceiver, bluetoothIntents);
|
||||
}
|
||||
|
||||
private void loadSettingsValues() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
ignoreBonded = prefs.getBoolean("ignore_bonded_devices", true);
|
||||
discoverUnsupported = prefs.getBoolean("discover_unsupported_devices", false);
|
||||
oldBleScanning = prefs.getBoolean("disable_new_ble_scanning", false);
|
||||
if (oldBleScanning) {
|
||||
LOG.info("New BLE scanning disabled via settings, using old method");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return this;
|
||||
|
@ -0,0 +1,34 @@
|
||||
/* Copyright (C) 2015-2020 Andreas Shimokawa, Carsten Pfeiffer, Lem Dulfo,
|
||||
vanous
|
||||
|
||||
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 <http://www.gnu.org/licenses/>. */
|
||||
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);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -89,5 +89,10 @@
|
||||
android:textColor="@color/secondarytext"
|
||||
android:textIsSelectable="true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/discovery_preferences"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_prefs_discovery_pairing" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
@ -692,6 +692,7 @@
|
||||
<string name="pref_title_charts_swipe">Enable left/right swipe in the charts activity</string>
|
||||
<string name="pref_title_charts_average">Show averages in the charts</string>
|
||||
<string name="activity_prefs_charts">Chart settings</string>
|
||||
<string name="activity_prefs_discovery_pairing">Discovery and Pairing options</string>
|
||||
<string name="activity_prefs_chart_max_heart_rate">Max heart rate</string>
|
||||
<string name="activity_prefs_chart_min_heart_rate">Min heart rate</string>
|
||||
<string name="pref_title_charts_range">Charts Range</string>
|
||||
|
31
app/src/main/res/xml/discovery_pairing_preferences.xml
Normal file
31
app/src/main/res/xml/discovery_pairing_preferences.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<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="disable_new_ble_scanning"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_disable_new_ble_scanning"
|
||||
android:title="@string/pref_disable_new_ble_scanning" />
|
||||
<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" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
@ -376,29 +376,9 @@
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_check_permission_status_summary"
|
||||
android:title="@string/pref_check_permission_status" />
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="true"
|
||||
android:key="ignore_bonded_devices"
|
||||
android:summary="@string/ignore_bonded_devices_description"
|
||||
android:title="@string/ignore_bonded_devices" />
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="false"
|
||||
android:key="disable_new_ble_scanning"
|
||||
android:summary="@string/pref_summary_disable_new_ble_scanning"
|
||||
android:title="@string/pref_disable_new_ble_scanning" />
|
||||
<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" />
|
||||
<Preference
|
||||
android:key="pref_discovery_pairing"
|
||||
android:title="@string/activity_prefs_discovery_pairing" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user