1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 04:46:51 +01:00

Pebble: remove last global settings

In order to add an emulated device it is sufficient to use the "Add test device" functionality choosing pebble as device and entering IP:PORT in the mac address field.

The pebble setting to force BLE is moved to discovery_pairing_preferences.xml

Also delete the pebble_preferences file and update general preferences.
This commit is contained in:
Daniele Gobbetti 2024-08-23 12:03:18 +02:00 committed by José Rebelo
parent 8e876c8a92
commit 13be343392
7 changed files with 11 additions and 145 deletions

View File

@ -186,10 +186,6 @@
android:name=".devices.garmin.GarminRealtimeSettingsActivity"
android:label="@string/loading"
android:parentActivityName=".activities.devicesettings.DeviceSettingsActivity" />
<activity
android:name=".devices.pebble.PebbleSettingsActivity"
android:label="@string/pref_title_pebble_settings"
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.ActivitySummariesActivity"
android:label="@string/activity_summaries"

View File

@ -66,7 +66,6 @@ import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsPreferencesActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.discovery.DiscoveryPairingPreferenceActivity;
import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver;
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
@ -126,15 +125,6 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
});
}
pref = findPreference("pref_key_pebble");
if (pref != null) {
pref.setOnPreferenceClickListener(preference -> {
Intent enableIntent = new Intent(requireContext(), PebbleSettingsActivity.class);
startActivity(enableIntent);
return true;
});
}
pref = findPreference("datetime_synconconnect");
if (pref != null) {
pref.setOnPreferenceChangeListener((preference, newVal) -> {

View File

@ -1,72 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
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 <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.pebble;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractPreferenceFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
public class PebbleSettingsActivity extends AbstractSettingsActivityV2 {
@Override
protected String fragmentTag() {
return PebbleSettingsFragment.FRAGMENT_TAG;
}
@Override
protected PreferenceFragmentCompat newFragment() {
return new PebbleSettingsFragment();
}
public static class PebbleSettingsFragment extends AbstractPreferenceFragment {
static final String FRAGMENT_TAG = "PEBBLE_SETTINGS_FRAGMENT";
@Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.pebble_preferences, rootKey);
setInputTypeFor("pebble_mtu_limit", InputType.TYPE_CLASS_NUMBER);
setInputTypeFor("pebble_emu_port", InputType.TYPE_CLASS_NUMBER);
final Preference pebbleEmuAddrPref = findPreference("pebble_emu_addr");
if (pebbleEmuAddrPref != null) {
pebbleEmuAddrPref.setOnPreferenceChangeListener((preference, newVal) -> {
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
LocalBroadcastManager.getInstance(requireContext().getApplicationContext()).sendBroadcast(refreshIntent);
return true;
});
}
final Preference pebbleEmuPort = findPreference("pebble_emu_port");
if (pebbleEmuPort != null) {
pebbleEmuPort.setOnPreferenceChangeListener((preference, newVal) -> {
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
LocalBroadcastManager.getInstance(requireContext().getApplicationContext()).sendBroadcast(refreshIntent);
return true;
});
}
}
}
}

View File

@ -101,13 +101,6 @@ public class DeviceHelper {
Set<GBDevice> availableDevices = new LinkedHashSet<>(getDatabaseDevices());
Prefs prefs = GBApplication.getPrefs();
String pebbleEmuAddr = prefs.getString("pebble_emu_addr", "");
String pebbleEmuPort = prefs.getString("pebble_emu_port", "");
if (pebbleEmuAddr.length() >= 7 && !pebbleEmuPort.isEmpty()) {
GBDevice pebbleEmuDevice = new GBDevice(pebbleEmuAddr + ":" + pebbleEmuPort, "Pebble qemu", "", null, DeviceType.PEBBLE);
availableDevices.add(pebbleEmuDevice);
}
return availableDevices;
}

View File

@ -141,21 +141,5 @@
android:summary="@string/pref_summary_pebble_enable_bgjs"
android:title="@string/pref_title_pebble_enable_bgjs"
app:iconSpaceReserved="false" />
<!--
<EditTextPreference
android:digits="0123456789."
android:key="pebble_emu_addr"
android:maxLength="15"
android:title="Emulator IP"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:inputType="number"
android:key="pebble_emu_port"
android:maxLength="5"
android:title="Emulator Port"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
-->
</PreferenceCategory>
</androidx.preference.PreferenceScreen>

View File

@ -16,4 +16,15 @@
android:summary="@string/auto_reconnect_ble_scan_summary"
android:layout="@layout/preference_checkbox"
app:iconSpaceReserved="false" />
<PreferenceCategory
android:title="@string/pref_title_pebble_settings"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pebble_force_le"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_pebble_forcele"
android:title="@string/pref_title_pebble_forcele"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:title="@string/pref_header_development"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pebble_force_untested"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_pebble_forceuntested"
android:title="@string/pref_title_pebble_forceuntested"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pebble_force_le"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_pebble_forcele"
android:title="@string/pref_title_pebble_forcele"
app:iconSpaceReserved="false" />
<EditTextPreference
android:digits="0123456789."
android:key="pebble_emu_addr"
android:maxLength="15"
android:title="Emulator IP"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:inputType="number"
android:key="pebble_emu_port"
android:maxLength="5"
android:title="Emulator Port"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>