mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Pebble: In AppManager allow moving apps on the device to the top (context menu)
This commit is contained in:
parent
f20b659b86
commit
98999993e5
@ -193,6 +193,9 @@ public class AppManagerActivity extends GBActivity {
|
||||
if (!selectedApp.isConfigurable()) {
|
||||
menu.removeItem(R.id.appmanager_app_configure);
|
||||
}
|
||||
if (mGBDevice != null && !mGBDevice.getFirmwareVersion().startsWith("v3")) {
|
||||
menu.removeItem(R.id.appmanager_app_move_to_top);
|
||||
}
|
||||
menu.setHeaderTitle(selectedApp.getName());
|
||||
}
|
||||
|
||||
@ -256,6 +259,9 @@ public class AppManagerActivity extends GBActivity {
|
||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
|
||||
startActivity(startIntent);
|
||||
return true;
|
||||
case R.id.appmanager_app_move_to_top:
|
||||
GBApplication.deviceService().onAppReorder(new UUID[]{selectedApp.getUUID()});
|
||||
return true;
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ public interface EventHandler {
|
||||
|
||||
void onAppConfiguration(UUID appUuid, String config);
|
||||
|
||||
void onAppReorder(UUID uuids[]);
|
||||
|
||||
void onFetchActivityData();
|
||||
|
||||
void onReboot();
|
||||
|
@ -18,6 +18,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
|
||||
|
||||
//import java.util.UUID;
|
||||
|
||||
public class GBDeviceService implements DeviceService {
|
||||
protected final Context mContext;
|
||||
protected final Class<? extends Service> mServiceClass;
|
||||
@ -185,6 +187,13 @@ public class GBDeviceService implements DeviceService {
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppReorder(UUID[] uuids) {
|
||||
Intent intent = createIntent().setAction(ACTION_APP_REORDER)
|
||||
.putExtra(EXTRA_APP_UUID, uuids);
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
Intent intent = createIntent().setAction(ACTION_FETCH_ACTIVITY_DATA);
|
||||
|
@ -25,6 +25,7 @@ public interface DeviceService extends EventHandler {
|
||||
String ACTION_STARTAPP = PREFIX + ".action.startapp";
|
||||
String ACTION_DELETEAPP = PREFIX + ".action.deleteapp";
|
||||
String ACTION_APP_CONFIGURE = PREFIX + ".action.app_configure";
|
||||
String ACTION_APP_REORDER = PREFIX + ".action.app_reorder";
|
||||
String ACTION_INSTALL = PREFIX + ".action.install";
|
||||
String ACTION_REBOOT = PREFIX + ".action.reboot";
|
||||
String ACTION_HEARTRATE_TEST = PREFIX + ".action.heartrate_test";
|
||||
|
@ -48,6 +48,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_ADD_CALENDAREVENT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_APP_CONFIGURE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_APP_REORDER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CALLSTATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CONNECT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_DELETEAPP;
|
||||
@ -388,6 +389,12 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID);
|
||||
String config = intent.getStringExtra(EXTRA_APP_CONFIG);
|
||||
mDeviceSupport.onAppConfiguration(uuid, config);
|
||||
break;
|
||||
}
|
||||
case ACTION_APP_REORDER: {
|
||||
UUID[] uuids = (UUID[]) intent.getSerializableExtra(EXTRA_APP_UUID);
|
||||
mDeviceSupport.onAppReorder(uuids);
|
||||
break;
|
||||
}
|
||||
case ACTION_INSTALL:
|
||||
Uri uri = intent.getParcelableExtra(EXTRA_URI);
|
||||
|
@ -207,6 +207,14 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||
delegate.onAppConfiguration(uuid, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppReorder(UUID[] uuids) {
|
||||
if (checkBusy("app reorder")) {
|
||||
return;
|
||||
}
|
||||
delegate.onAppReorder(uuids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
if (checkBusy("fetch activity data")) {
|
||||
|
@ -767,6 +767,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
// not supported
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppReorder(UUID[] uuids) {
|
||||
// not supported
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScreenshotReq() {
|
||||
// not supported
|
||||
|
@ -1293,7 +1293,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
return encodeSimpleMessage(ENDPOINT_SCREENSHOT, SCREENSHOT_TAKE);
|
||||
}
|
||||
|
||||
public byte[] encodeAppReoder(UUID[] uuids) {
|
||||
@Override
|
||||
public byte[] encodeAppReorder(UUID[] uuids) {
|
||||
int length = 2 + uuids.length * LENGTH_UUID;
|
||||
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + length);
|
||||
buf.order(ByteOrder.BIG_ENDIAN);
|
||||
|
@ -154,6 +154,12 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
|
||||
sendToDevice(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppReorder(UUID[] uuids) {
|
||||
byte[] bytes = gbDeviceProtocol.encodeAppReorder(uuids);
|
||||
sendToDevice(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
byte[] bytes = gbDeviceProtocol.encodeSynchronizeActivityData();
|
||||
|
@ -48,6 +48,10 @@ public abstract class GBDeviceProtocol {
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] encodeAppReorder(UUID[] uuids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] encodeSynchronizeActivityData() {
|
||||
return null;
|
||||
}
|
||||
|
@ -18,4 +18,8 @@
|
||||
<item
|
||||
android:id="@+id/appmanager_app_configure"
|
||||
android:title="@string/app_configure"/>
|
||||
<item
|
||||
android:id="@+id/appmanager_app_move_to_top"
|
||||
android:title="@string/app_move_to_top"/>
|
||||
|
||||
</menu>
|
@ -257,9 +257,11 @@
|
||||
<string name="activity_prefs_weight_kg">Weight in kg</string>
|
||||
<string name="appmanager_health_activate">Activate</string>
|
||||
<string name="appmanager_health_deactivate">Deactivate</string>
|
||||
<string name="app_configure">Configure</string>
|
||||
<string name="app_move_to_top">Move to top</string>
|
||||
|
||||
<string name="authenticating">authenticating</string>
|
||||
<string name="authentication_required">authentication required</string>
|
||||
<string name="app_configure">Configure</string>
|
||||
|
||||
<string name="appwidget_text">Zzz</string>
|
||||
<string name="add_widget">Add widget</string>
|
||||
|
@ -102,6 +102,11 @@ public class TestDeviceSupport extends AbstractDeviceSupport {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppReorder(UUID[] uuids) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user