mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-26 09:11:37 +02: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() {
|
deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView parent, View v, int position, long id) {
|
public void onItemClick(AdapterView parent, View v, int position, long id) {
|
||||||
if (deviceList.get(position).isConnected()) {
|
GBDevice gbDevice = deviceList.get(position);
|
||||||
Intent startIntent = new Intent(ControlCenter.this, AppManagerActivity.class);
|
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);
|
startActivity(startIntent);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent startIntent = new Intent(ControlCenter.this, BluetoothCommunicationService.class);
|
Intent startIntent = new Intent(ControlCenter.this, BluetoothCommunicationService.class);
|
||||||
startIntent.setAction(BluetoothCommunicationService.ACTION_CONNECT);
|
startIntent.setAction(BluetoothCommunicationService.ACTION_CONNECT);
|
||||||
|
@ -14,4 +14,6 @@ public interface DeviceCoordinator {
|
|||||||
DeviceType getDeviceType();
|
DeviceType getDeviceType();
|
||||||
|
|
||||||
Class<? extends Activity> getPairingActivity();
|
Class<? extends Activity> getPairingActivity();
|
||||||
|
|
||||||
|
Class<? extends Activity> getPrimaryActivity();
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,9 @@ public class UnknownDeviceCoordinator implements DeviceCoordinator {
|
|||||||
public Class<? extends Activity> getPairingActivity() {
|
public Class<? extends Activity> getPairingActivity() {
|
||||||
return ControlCenter.class;
|
return ControlCenter.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Activity> getPrimaryActivity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,12 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.AppManagerActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.activities.ChartsActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.discovery.DeviceCandidate;
|
import nodomain.freeyourgadget.gadgetbridge.discovery.DeviceCandidate;
|
||||||
|
|
||||||
public class MiBandCoordinator implements DeviceCoordinator {
|
public class MiBandCoordinator implements DeviceCoordinator {
|
||||||
@ -38,6 +40,10 @@ public class MiBandCoordinator implements DeviceCoordinator {
|
|||||||
return MiBandPairingActivity.class;
|
return MiBandPairingActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<? extends Activity> getPrimaryActivity() {
|
||||||
|
return ChartsActivity.class;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hasValidUserInfo() {
|
public static boolean hasValidUserInfo() {
|
||||||
String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER + ":00:00:00";
|
String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER + ":00:00:00";
|
||||||
try {
|
try {
|
||||||
|
@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.pebble;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.AppManagerActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||||
@ -27,4 +28,8 @@ public class PebbleCoordinator implements DeviceCoordinator {
|
|||||||
public Class<? extends Activity> getPairingActivity() {
|
public Class<? extends Activity> getPairingActivity() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<? extends Activity> getPrimaryActivity() {
|
||||||
|
return AppManagerActivity.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user