mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-03-13 09:40:15 +01:00
SuperCars: Adopt device card custom action
This commit is contained in:
parent
071f0296c9
commit
0f2d240402
@ -17,38 +17,28 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.supercars;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCardAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.supercars.SuperCarsSupport;
|
||||
|
||||
public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SuperCarsCoordinator.class);
|
||||
|
||||
@Override
|
||||
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,90 +51,22 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
|
||||
return BONDING_STYLE_NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Class<? extends DeviceSupport> getDeviceSupportClass() {
|
||||
return SuperCarsSupport.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getAppsManagementActivity() {
|
||||
return ControlActivity.class;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<? extends Activity> getPairingActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsActivityDataFetching() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsActivityTracking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsScreenshots(final GBDevice device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturer() {
|
||||
return "Brand Base";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAppsManagement(final GBDevice device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCalendarEvents() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRealtimeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsFindDevice() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getDeviceNameResource() {
|
||||
return R.string.devicetype_super_cars;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getDefaultIconResource() {
|
||||
return R.drawable.ic_device_supercars;
|
||||
@ -154,4 +76,28 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
|
||||
public int getDisabledIconResource() {
|
||||
return R.drawable.ic_device_supercars_disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceCardAction> getCustomActions() {
|
||||
return Collections.singletonList(new ControlDeviceCardAction());
|
||||
}
|
||||
|
||||
private static final class ControlDeviceCardAction implements DeviceCardAction {
|
||||
@Override
|
||||
public int getIcon(GBDevice device) {
|
||||
return R.drawable.ic_steering_wheel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(final GBDevice device, final Context context) {
|
||||
return context.getString(R.string.remote_control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final GBDevice device, final Context context) {
|
||||
final Intent startIntent = new Intent(context, ControlActivity.class);
|
||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
|
||||
context.startActivity(startIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
app/src/main/res/drawable/ic_steering_wheel.xml
Normal file
16
app/src/main/res/drawable/ic_steering_wheel.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<!--
|
||||
Licensed under public domain
|
||||
https://www.svgrepo.com/svg/466333/steering-wheel
|
||||
-->
|
||||
|
||||
<path
|
||||
android:fillColor="#7E7E7E"
|
||||
android:pathData="M12,2A10,10 0,1 0,22 12,10 10,0 0,0 12,2ZM12,4a8,8 0,0 1,7.38 4.92A29.93,29.93 0,0 0,12 8a29.63,29.63 0,0 0,-7.4 0.94A8,8 0,0 1,12 4ZM4,12.67l1.11,-0.13A4.38,4.38 0,0 1,10 16.89v2.85A8,8 0,0 1,4 12.67ZM14,19.74L14,16.89a4.38,4.38 0,0 1,4.86 -4.35l1.11,0.13A8,8 0,0 1,14 19.74Z" />
|
||||
|
||||
</vector>
|
@ -565,6 +565,7 @@
|
||||
<string name="agps_status_pending">Pending</string>
|
||||
<string name="agps_status_current">Current</string>
|
||||
<string name="agps_status_error">Error</string>
|
||||
<string name="remote_control">Remote control</string>
|
||||
<string name="pref_camera_remote_title">Camera Remote</string>
|
||||
<string name="pref_camera_remote_summary">Allows the watch to trigger the phone\'s camera</string>
|
||||
<string name="pref_morning_updates_title">Morning Updates</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user