diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java index a88f13574..bd26b7787 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java @@ -102,9 +102,14 @@ public class ControlCenter extends Activity { deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View v, int position, long id) { - if (deviceList.get(position).isConnected()) { - Intent startIntent = new Intent(ControlCenter.this, AppManagerActivity.class); - startActivity(startIntent); + GBDevice gbDevice = deviceList.get(position); + if (gbDevice.isConnected()) { + DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice); + Class primaryActivity = coordinator.getPrimaryActivity(); + if (primaryActivity != null) { + Intent startIntent = new Intent(ControlCenter.this, primaryActivity); + startActivity(startIntent); + } } else { Intent startIntent = new Intent(ControlCenter.this, BluetoothCommunicationService.class); startIntent.setAction(BluetoothCommunicationService.ACTION_CONNECT); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DeviceCoordinator.java index 05c90453b..ac4a693f5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DeviceCoordinator.java @@ -14,4 +14,6 @@ public interface DeviceCoordinator { DeviceType getDeviceType(); Class getPairingActivity(); + + Class getPrimaryActivity(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/UnknownDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/UnknownDeviceCoordinator.java index 9ba8b904b..e06982f49 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/UnknownDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/UnknownDeviceCoordinator.java @@ -24,4 +24,9 @@ public class UnknownDeviceCoordinator implements DeviceCoordinator { public Class getPairingActivity() { return ControlCenter.class; } + + @Override + public Class getPrimaryActivity() { + return null; + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandCoordinator.java index 25b092f0a..ca7ba021b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandCoordinator.java @@ -9,10 +9,12 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; +import nodomain.freeyourgadget.gadgetbridge.AppManagerActivity; import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.DeviceType; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.activities.ChartsActivity; import nodomain.freeyourgadget.gadgetbridge.discovery.DeviceCandidate; public class MiBandCoordinator implements DeviceCoordinator { @@ -38,6 +40,10 @@ public class MiBandCoordinator implements DeviceCoordinator { return MiBandPairingActivity.class; } + public Class getPrimaryActivity() { + return ChartsActivity.class; + } + public static boolean hasValidUserInfo() { String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER + ":00:00:00"; try { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleCoordinator.java index 03e5fe431..2e1f135fc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleCoordinator.java @@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.pebble; import android.app.Activity; +import nodomain.freeyourgadget.gadgetbridge.AppManagerActivity; import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.DeviceType; import nodomain.freeyourgadget.gadgetbridge.GBDevice; @@ -27,4 +28,8 @@ public class PebbleCoordinator implements DeviceCoordinator { public Class getPairingActivity() { return null; } + + public Class getPrimaryActivity() { + return AppManagerActivity.class; + } }