mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Let DeviceCoordinator decide which activity to launch on click
This commit is contained in:
parent
184e0f2dea
commit
13d2c2166c
@ -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<? extends Activity> 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);
|
||||
|
@ -14,4 +14,6 @@ public interface DeviceCoordinator {
|
||||
DeviceType getDeviceType();
|
||||
|
||||
Class<? extends Activity> getPairingActivity();
|
||||
|
||||
Class<? extends Activity> getPrimaryActivity();
|
||||
}
|
||||
|
@ -24,4 +24,9 @@ public class UnknownDeviceCoordinator implements DeviceCoordinator {
|
||||
public Class<? extends Activity> getPairingActivity() {
|
||||
return ControlCenter.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getPrimaryActivity() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -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<? extends Activity> getPrimaryActivity() {
|
||||
return ChartsActivity.class;
|
||||
}
|
||||
|
||||
public static boolean hasValidUserInfo() {
|
||||
String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER + ":00:00:00";
|
||||
try {
|
||||
|
@ -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<? extends Activity> getPairingActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class<? extends Activity> getPrimaryActivity() {
|
||||
return AppManagerActivity.class;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user