diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java index 056cdd6c4..3d5c64c80 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java @@ -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; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java index 0a74095c3..e74f5a21f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java @@ -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); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java index dd4ff86a3..32b37f5aa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java @@ -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); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java index d8246355b..7ecdbbbe7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java @@ -397,7 +397,7 @@ public class GBDeviceAdapterv2 extends ListAdapter devices = GBApplication.app().getDeviceManager().getSelectedDevices(); for(GBDevice device : devices){ diff --git a/app/src/main/res/drawable/ic_bluetooth.xml b/app/src/main/res/drawable/ic_bluetooth.xml new file mode 100644 index 000000000..24105193c --- /dev/null +++ b/app/src/main/res/drawable/ic_bluetooth.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_bluetooth_searching.xml b/app/src/main/res/drawable/ic_bluetooth_searching.xml new file mode 100644 index 000000000..3550ab438 --- /dev/null +++ b/app/src/main/res/drawable/ic_bluetooth_searching.xml @@ -0,0 +1,11 @@ + + android:autoMirrored="true"> + + diff --git a/app/src/main/res/drawable/ic_open_in_browser.xml b/app/src/main/res/drawable/ic_open_in_browser.xml new file mode 100644 index 000000000..35f49b36d --- /dev/null +++ b/app/src/main/res/drawable/ic_open_in_browser.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/menu/activity_controlcenterv2_device_submenu.xml b/app/src/main/res/menu/activity_controlcenterv2_device_submenu.xml index edd7e47f0..03a251436 100644 --- a/app/src/main/res/menu/activity_controlcenterv2_device_submenu.xml +++ b/app/src/main/res/menu/activity_controlcenterv2_device_submenu.xml @@ -12,6 +12,9 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e41050a0a..be9dfc9d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -372,6 +372,8 @@ Device specific settings Auth Key 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 + Some devices require a special pairing key for the very first initialization of the device. Tap here for more details. + 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. Heart rate alarm during sports activity Low limit High limit @@ -1227,7 +1229,7 @@ Failed to start background service Starting the background service failed becauseā€¦ ALREADY BONDED - KEY REQUIRED + KEY REQUIRED, LONG PRESS TO ENTER UNSUPPORTED Starting the background service failed because of an exception. Error: Check permission status @@ -1687,6 +1689,7 @@ no devices connected %d devices connected Set parent folder + Set preferences Toggle details Connected: %d/%d Error setting parent folder: %s @@ -1695,4 +1698,10 @@ Add new folder Unset folder Set or create new folder + Auto reconnect to device + Proactively try to connect to device periodically + Connection over BLE + Connection over Bluetooth classic + Connect on connection from device + Establish a connection when connection is initiated by device, like headphones diff --git a/app/src/main/res/xml/devicesettings_miband6.xml b/app/src/main/res/xml/devicesettings_miband6.xml index 2a56241c6..9bc1050ff 100644 --- a/app/src/main/res/xml/devicesettings_miband6.xml +++ b/app/src/main/res/xml/devicesettings_miband6.xml @@ -20,9 +20,4 @@ android:persistent="true" android:summary="@string/bip_prefs_shotcuts_summary" android:title="@string/bip_prefs_shortcuts" /> - diff --git a/app/src/main/res/xml/devicesettings_miband6_new_auth_protocol_explanation.xml b/app/src/main/res/xml/devicesettings_miband6_new_auth_protocol_explanation.xml new file mode 100644 index 000000000..587f31d5b --- /dev/null +++ b/app/src/main/res/xml/devicesettings_miband6_new_auth_protocol_explanation.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/app/src/main/res/xml/devicesettings_miband6_new_protocol.xml b/app/src/main/res/xml/devicesettings_miband6_new_protocol.xml new file mode 100644 index 000000000..dce6381e7 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_miband6_new_protocol.xml @@ -0,0 +1,8 @@ + + + + diff --git a/app/src/main/res/xml/devicesettings_pairingkey_explanation.xml b/app/src/main/res/xml/devicesettings_pairingkey_explanation.xml new file mode 100644 index 000000000..27e5ee532 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_pairingkey_explanation.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/app/src/main/res/xml/devicesettings_reconnect_bl_classic.xml b/app/src/main/res/xml/devicesettings_reconnect_bl_classic.xml index 4bc3cd59d..712e1950b 100644 --- a/app/src/main/res/xml/devicesettings_reconnect_bl_classic.xml +++ b/app/src/main/res/xml/devicesettings_reconnect_bl_classic.xml @@ -1,11 +1,12 @@ + android:title="@string/connection_over_bt_classic" /> \ No newline at end of file diff --git a/app/src/main/res/xml/devicesettings_reconnect_ble.xml b/app/src/main/res/xml/devicesettings_reconnect_ble.xml index 194be53e0..f2b8f1f89 100644 --- a/app/src/main/res/xml/devicesettings_reconnect_ble.xml +++ b/app/src/main/res/xml/devicesettings_reconnect_ble.xml @@ -1,11 +1,12 @@ + android:title="@string/connection_over_ble" /> \ No newline at end of file