1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-18 06:37:47 +01:00

Allow Settings splitting into device, app and auth screens

- open app preferences screen from device card menu
- open auth preferences screen from DiscoveryActivity
- add explanation about Auth key, make it open wiki link, fix #2240
- add New protocol checkbox and explanation when first pairing Miband 6
This commit is contained in:
vanous 2022-06-19 16:03:37 +02:00
parent 49dcb04b62
commit fe73e9fec1
41 changed files with 306 additions and 60 deletions

View File

@ -858,6 +858,11 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
Intent startIntent;
startIntent = new Intent(this, DeviceSettingsActivity.class);
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_REQUIRE_KEY) {
startIntent.putExtra(DeviceSettingsActivity.MENU_ENTRY_POINT, DeviceSettingsActivity.MENU_ENTRY_POINTS.AUTH_SETTINGS);
} else {
startIntent.putExtra(DeviceSettingsActivity.MENU_ENTRY_POINT, DeviceSettingsActivity.MENU_ENTRY_POINTS.DEVICE_SETTINGS);
}
startActivity(startIntent);
return true;
}

View File

@ -23,33 +23,39 @@ import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
public class DeviceSettingsActivity extends AbstractGBActivity implements
PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
private static final Logger LOG = LoggerFactory.getLogger(DeviceSettingsActivity.class);
public static final String MENU_ENTRY_POINT = "MENU_ENTRY_POINT";
GBDevice device;
MENU_ENTRY_POINTS menu_entry;
public enum MENU_ENTRY_POINTS {
DEVICE_SETTINGS,
AUTH_SETTINGS,
APPLICATION_SETTINGS
}
@Override
protected void onCreate(Bundle savedInstanceState) {
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
menu_entry = (MENU_ENTRY_POINTS) getIntent().getSerializableExtra(MENU_ENTRY_POINT);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_settings);
if (savedInstanceState == null) {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(DeviceSpecificSettingsFragment.FRAGMENT_TAG);
if (fragment == null) {
fragment = DeviceSpecificSettingsFragment.newInstance(device);
fragment = DeviceSpecificSettingsFragment.newInstance(device, menu_entry);
}
getSupportFragmentManager()
.beginTransaction()
@ -61,7 +67,7 @@ public class DeviceSettingsActivity extends AbstractGBActivity implements
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen preferenceScreen) {
final PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device);
final PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device, menu_entry);
Bundle args = fragment.getArguments();
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
fragment.setArguments(args);

View File

@ -59,6 +59,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreference;
@ -825,26 +826,36 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
}
}
static DeviceSpecificSettingsFragment newInstance(GBDevice device) {
static DeviceSpecificSettingsFragment newInstance(GBDevice device, DeviceSettingsActivity.MENU_ENTRY_POINTS applicationSpecificSettings) {
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
int[] supportedSettings = coordinator.getSupportedDeviceSpecificSettings(device);
String[] supportedLanguages = coordinator.getSupportedLanguageSettings(device);
int[] supportedSettings = new int[0];
String[] supportedLanguages = null;
supportedSettings = ArrayUtils.insert(0, supportedSettings, coordinator.getSupportedDeviceSpecificConnectionSettings());
if (supportedLanguages != null) {
supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_language_generic);
}
if (coordinator.supportsActivityTracking()) {
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_chartstabs);
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_device_card_activity_card_preferences);
if (applicationSpecificSettings.equals(DeviceSettingsActivity.MENU_ENTRY_POINTS.APPLICATION_SETTINGS)) { //assemble device settings specific to the application
supportedSettings = ArrayUtils.insert(0, supportedSettings, coordinator.getSupportedDeviceSpecificConnectionSettings());
supportedSettings = ArrayUtils.addAll(supportedSettings, coordinator.getSupportedDeviceSpecificApplicationSettings());
if (coordinator.supportsActivityTracking()) {
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_chartstabs);
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_device_card_activity_card_preferences);
}
} else if (applicationSpecificSettings.equals(DeviceSettingsActivity.MENU_ENTRY_POINTS.AUTH_SETTINGS)) { //auth settings screen
supportedSettings = ArrayUtils.insert(0, supportedSettings, coordinator.getSupportedDeviceSpecificAuthenticationSettings());
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_pairingkey_explanation);
if (coordinator.getDeviceType() == DeviceType.MIBAND6) { // miband6 might require new protocol and people do not know what to do, hint them:
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_miband6_new_protocol);
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_miband6_new_auth_protocol_explanation);
}
} else { //device settings
supportedSettings = ArrayUtils.insert(0, supportedSettings, coordinator.getSupportedDeviceSpecificSettings(device));
supportedLanguages = coordinator.getSupportedLanguageSettings(device);
if (supportedLanguages != null) {
supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_language_generic);
}
supportedSettings = ArrayUtils.addAll(supportedSettings, coordinator.getSupportedDeviceSpecificAuthenticationSettings());
}
final DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer = coordinator.getDeviceSpecificSettingsCustomizer(device);
final String settingsFileSuffix = device.getAddress();
final DeviceSpecificSettingsFragment fragment = new DeviceSpecificSettingsFragment();
fragment.setSettingsFileSuffix(settingsFileSuffix, supportedSettings, supportedLanguages);
fragment.setDeviceSpecificSettingsCustomizer(deviceSpecificSettingsCustomizer);

View File

@ -397,7 +397,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
);
//device specific settings
holder.deviceSpecificSettingsView.setVisibility(coordinator.getSupportedDeviceSpecificConnectionSettings() != null ? View.VISIBLE : View.GONE);
holder.deviceSpecificSettingsView.setVisibility(coordinator.getSupportedDeviceSpecificSettings(device) != null ? View.VISIBLE : View.GONE);
holder.deviceSpecificSettingsView.setOnClickListener(new View.OnClickListener()
{
@ -406,6 +406,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
Intent startIntent;
startIntent = new Intent(context, DeviceSettingsActivity.class);
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
startIntent.putExtra(DeviceSettingsActivity.MENU_ENTRY_POINT, DeviceSettingsActivity.MENU_ENTRY_POINTS.DEVICE_SETTINGS);
context.startActivity(startIntent);
}
}
@ -842,6 +843,9 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
case R.id.controlcenter_device_submenu_set_alias:
showSetAliasDialog(device);
return true;
case R.id.controlcenter_device_submenu_set_preferences:
setAppPreferences(device);
return true;
case R.id.controlcenter_device_submenu_remove:
showRemoveDeviceDialog(device);
return true;
@ -1036,6 +1040,13 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
return false;
}
private void setAppPreferences(GBDevice device) {
Intent startIntent;
startIntent = new Intent(context, DeviceSettingsActivity.class);
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
startIntent.putExtra(DeviceSettingsActivity.MENU_ENTRY_POINT, DeviceSettingsActivity.MENU_ENTRY_POINTS.APPLICATION_SETTINGS);
context.startActivity(startIntent);
}
private void showSetAliasDialog(final GBDevice device) {
final EditText input = new EditText(context);
input.setInputType(InputType.TYPE_CLASS_TEXT);

View File

@ -280,12 +280,21 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
return settings;
}
@Override
public int[] getSupportedDeviceSpecificApplicationSettings() {
return new int[0];
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[0];
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[0];
}
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(GBDevice device) {
return null;

View File

@ -399,6 +399,19 @@ public interface DeviceCoordinator {
*/
int[] getSupportedDeviceSpecificConnectionSettings();
/**
* Returns device specific settings related to the application itself
* charts settings and so on
* @return int[]
*/
int[] getSupportedDeviceSpecificApplicationSettings();
/**
* Returns device specific settings related to the Auth key
* @return int[]
*/
int[] getSupportedDeviceSpecificAuthenticationSettings();
/**
* Indicates which device specific settings the device supports (not per device type or family, but unique per device).
*/

View File

@ -127,7 +127,7 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{R.xml.devicesettings_pairingkey};
}

View File

@ -118,12 +118,18 @@ public class AmazfitBand5Coordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{

View File

@ -82,9 +82,16 @@ public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator {
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_buttonactions_with_longpress,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_relax_firmware_checks,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -110,10 +110,15 @@ public class AmazfitBipSCoordinator extends HuamiCoordinator {
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public int getBondingStyle() {

View File

@ -123,11 +123,15 @@ public class AmazfitBipUCoordinator extends HuamiCoordinator {
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{

View File

@ -122,11 +122,15 @@ public class AmazfitBipUProCoordinator extends HuamiCoordinator {
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{

View File

@ -101,9 +101,14 @@ public class AmazfitGTRCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -101,8 +101,13 @@ public class AmazfitGTRLiteCoordinator extends HuamiCoordinator {
R.xml.devicesettings_reserve_reminders_calendar,
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -107,9 +107,14 @@ public class AmazfitGTR2Coordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -107,9 +107,14 @@ public class AmazfitGTR2eCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -101,9 +101,14 @@ public class AmazfitGTSCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -107,9 +107,14 @@ public class AmazfitGTS2Coordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -107,9 +107,14 @@ public class AmazfitGTS2eCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -93,11 +93,16 @@ public class AmazfitNeoCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{

View File

@ -101,9 +101,14 @@ public class AmazfitTRexCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -101,9 +101,14 @@ public class AmazfitTRexProCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -102,8 +102,13 @@ public class AmazfitVergeLCoordinator extends HuamiCoordinator {
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_buttonactions_with_longpress,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -107,12 +107,18 @@ public class AmazfitXCoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{
"auto",

View File

@ -107,11 +107,16 @@ public class MiBand4Coordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {

View File

@ -123,12 +123,18 @@ public class MiBand5Coordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{

View File

@ -85,6 +85,7 @@ public class MiBand6Coordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_miband6,
R.xml.devicesettings_miband6_new_protocol,
R.xml.devicesettings_vibrationpatterns,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_heartrate_sleep_alert_activity_stress,
@ -101,11 +102,16 @@ public class MiBand6Coordinator extends HuamiCoordinator {
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {

View File

@ -100,9 +100,14 @@ public class ZeppECoordinator extends HuamiCoordinator {
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_transliteration
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -83,7 +83,7 @@ public class MiBandPairingActivity extends AbstractGBActivity implements Bonding
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(deviceCandidate);
GBDevice device = DeviceHelper.getInstance().toSupportedDevice(deviceCandidate);
if (coordinator.getSupportedDeviceSpecificSettings(device) != null) { // FIXME: this will no longer be sane in the future
if (coordinator.getSupportedDeviceSpecificAuthenticationSettings() != null) { // FIXME: this will no longer be sane in the future
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(device.getAddress());
String authKey = sharedPrefs.getString("authkey", null);
if (authKey == null || authKey.isEmpty()) {

View File

@ -257,7 +257,6 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
R.xml.devicesettings_fossilhybridhr,
R.xml.devicesettings_autoremove_notifications,
R.xml.devicesettings_canned_dismisscall_16,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_custom_deviceicon,
R.xml.devicesettings_transliteration
};
@ -267,16 +266,21 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
R.xml.devicesettings_fossilhybridhr,
R.xml.devicesettings_autoremove_notifications,
R.xml.devicesettings_canned_dismisscall_16,
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_custom_deviceicon
};
}
return new int[]{
R.xml.devicesettings_pairingkey,
R.xml.devicesettings_custom_deviceicon
};
}
@Override
public int[] getSupportedDeviceSpecificAuthenticationSettings() {
return new int[]{
R.xml.devicesettings_pairingkey
};
}
private boolean isHybridHR() {
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
for(GBDevice device : devices){

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#7E7E7E">
<path
android:fillColor="@android:color/white"
android:pathData="M17.71,7.71L12,2h-1v7.59L6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 11,14.41L11,22h1l5.71,-5.71 -4.3,-4.29 4.3,-4.29zM13,5.83l1.88,1.88L13,9.59L13,5.83zM14.88,16.29L13,18.17v-3.76l1.88,1.88z"/>
</vector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#7E7E7E">
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M14.24,12.01l2.32,2.32c0.28,-0.72 0.44,-1.51 0.44,-2.33s-0.16,-1.59 -0.43,-2.31l-2.33,2.32zM19.53,6.71l-1.26,1.26c0.63,1.21 0.98,2.57 0.98,4.02s-0.36,2.82 -0.98,4.02l1.2,1.2c0.97,-1.54 1.54,-3.36 1.54,-5.31 -0.01,-1.89 -0.55,-3.67 -1.48,-5.19zM15.71,7.71L10,2L9,2v7.59L4.41,5 3,6.41 8.59,12 3,17.59 4.41,19 9,14.41L9,22h1l5.71,-5.71 -4.3,-4.29 4.3,-4.29zM11,5.83l1.88,1.88L11,9.59L11,5.83zM12.88,16.29L11,18.17v-3.76l1.88,1.88z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#7E7E7E">
<path
android:fillColor="@android:color/white"
android:pathData="M19,4L5,4c-1.11,0 -2,0.9 -2,2v12c0,1.1 0.89,2 2,2h4v-2L5,18L5,8h14v10h-4v2h4c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.89,-2 -2,-2zM12,10l-4,4h3v6h2v-6h3l-4,-4z"/>
</vector>

View File

@ -12,6 +12,9 @@
<item
android:id="@+id/controlcenter_device_submenu_set_alias"
android:title="@string/controlcenter_set_alias" />
<item
android:id="@+id/controlcenter_device_submenu_set_preferences"
android:title="@string/controlcenter_set_preferences" />
<item
android:id="@+id/controlcenter_device_submenu_show_details"
android:title="@string/controlcenter_toggle_details" />

View File

@ -372,6 +372,8 @@
<string name="title_activity_device_specific_settings">Device specific settings</string>
<string name="pref_title_authkey">Auth Key</string>
<string name="pref_summary_authkey">Change the auth key to a common key on all your Android devices from which you would like to connect from. The previous default key for all devices is 0123456789@ABCDE</string>
<string name="pref_explanation_authkey">Some devices require a special pairing key for the very first initialization of the device. Tap here for more details.</string>
<string name="pref_explanation_authkey_new_protocol">If you get \"Update the app to latest version\" message on the band, make sure to check the \"New Auth Protocol\" above. You here for info in wiki.</string>
<string name="prefs_hr_alarm_activity">Heart rate alarm during sports activity</string>
<string name="prefs_hr_alarm_low">Low limit</string>
<string name="prefs_hr_alarm_high">High limit</string>
@ -1227,7 +1229,7 @@
<string name="error_background_service">Failed to start background service</string>
<string name="error_background_service_reason_truncated">Starting the background service failed because…</string>
<string name="device_is_currently_bonded">ALREADY BONDED</string>
<string name="device_requires_key">KEY REQUIRED</string>
<string name="device_requires_key">KEY REQUIRED, LONG PRESS TO ENTER</string>
<string name="device_unsupported">UNSUPPORTED</string>
<string name="error_background_service_reason">Starting the background service failed because of an exception. Error: </string>
<string name="pref_check_permission_status">Check permission status</string>
@ -1687,6 +1689,7 @@
<string name="info_no_devices_connected">no devices connected</string>
<string name="info_connected_count">%d devices connected</string>
<string name="controlcenter_set_parent_folder">Set parent folder</string>
<string name="controlcenter_set_preferences">Set preferences</string>
<string name="controlcenter_toggle_details">Toggle details</string>
<string name="controlcenter_connected_fraction">Connected: %d/%d</string>
<string name="error_setting_parent_folder">Error setting parent folder: %s</string>
@ -1695,4 +1698,10 @@
<string name="controlcenter_add_new_folder">Add new folder</string>
<string name="controlcenter_unset_folder">Unset folder</string>
<string name="controlcenter_set_folder_title">Set or create new folder</string>
<string name="auto_reconnect_ble_title">Auto reconnect to device</string>
<string name="auto_reconnect_ble_summary">Proactively try to connect to device periodically</string>
<string name="connection_over_ble">Connection over BLE</string>
<string name="connection_over_bt_classic">Connection over Bluetooth classic</string>
<string name="autoconnect_from_device_title">Connect on connection from device</string>
<string name="autoconnect_from_device_summary">Establish a connection when connection is initiated by device, like headphones</string>
</resources>

View File

@ -20,9 +20,4 @@
android:persistent="true"
android:summary="@string/bip_prefs_shotcuts_summary"
android:title="@string/bip_prefs_shortcuts" />
<SwitchPreference
android:defaultValue="false"
android:key="force_new_protocol"
android:summary="@string/pref_summary_huami_force_new_protocol"
android:title="@string/pref_title_huami_force_new_protocol" />
</androidx.preference.PreferenceScreen>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:icon="@drawable/ic_open_in_browser"
android:persistent="false"
android:key="authkey_explanation_new_auth_protocol"
android:summary="@string/pref_explanation_authkey_new_protocol" >
<intent
android:action="android.intent.action.VIEW"
android:data="https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Mi-Band-6#new-auth-protocol"
/>
</Preference>
</androidx.preference.PreferenceScreen>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="false"
android:key="force_new_protocol"
android:summary="@string/pref_summary_huami_force_new_protocol"
android:title="@string/pref_title_huami_force_new_protocol" />
</androidx.preference.PreferenceScreen>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:icon="@drawable/ic_open_in_browser"
android:persistent="false"
android:key="authkey_explanation"
android:summary="@string/pref_explanation_authkey" >
<intent
android:action="android.intent.action.VIEW"
android:data="https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Pairing"
/>
</Preference>
</androidx.preference.PreferenceScreen>

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Connection over Bluetooth classic" />
android:title="@string/connection_over_bt_classic" />
<CheckBoxPreference
android:icon="@drawable/ic_bluetooth"
android:key="prefs_key_device_reconnect_on_acl"
android:title="connect on connection from device"
android:summary="establish a connection when connection is initiated by device, like headphones"
android:title="@string/autoconnect_from_device_title"
android:summary="@string/autoconnect_from_device_summary"
android:layout="@layout/preference_checkbox" />
</PreferenceScreen>

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Connection over BLE" />
android:title="@string/connection_over_ble" />
<CheckBoxPreference
android:icon="@drawable/ic_bluetooth"
android:key="prefs_key_device_auto_reconnect"
android:title="auto-reconnect to device"
android:summary="proactively try to connect to device periodically"
android:title="@string/auto_reconnect_ble_title"
android:summary="@string/auto_reconnect_ble_summary"
android:layout="@layout/preference_checkbox" />
</PreferenceScreen>