Add support for LED Color, FM Frequency

This commit is contained in:
José Rebelo 2018-07-28 16:23:58 +01:00
parent 3e989cd89a
commit cc6c57bd4c
25 changed files with 469 additions and 4 deletions

View File

@ -85,7 +85,7 @@ dependencies {
implementation "org.greenrobot:greendao:2.2.1"
implementation "org.apache.commons:commons-lang3:3.5"
implementation "org.cyanogenmod:platform.sdk:6.0"
implementation 'com.jaredrummler:colorpicker:1.0.2'
// implementation project(":DaoCore")
}

View File

@ -22,16 +22,19 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.InputType;
import android.transition.TransitionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@ -40,7 +43,11 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.jaredrummler.android.colorpicker.ColorPickerDialog;
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener;
import java.util.List;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -125,16 +132,22 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
//battery
holder.batteryStatusBox.setVisibility(View.GONE);
short batteryLevel = device.getBatteryLevel();
float batteryVoltage = device.getBatteryVoltage();
BatteryState batteryState = device.getBatteryState();
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
holder.batteryStatusBox.setVisibility(View.VISIBLE);
holder.batteryStatusLabel.setText(device.getBatteryLevel() + "%");
BatteryState batteryState = device.getBatteryState();
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
holder.batteryIcon.setImageLevel(device.getBatteryLevel() + 100);
} else {
holder.batteryIcon.setImageLevel(device.getBatteryLevel());
}
} else if (BatteryState.NO_BATTERY.equals(batteryState) && batteryVoltage != GBDevice.BATTERY_UNKNOWN) {
holder.batteryStatusBox.setVisibility(View.VISIBLE);
holder.batteryStatusLabel.setText(String.format(Locale.getDefault(), "%.1fV", batteryVoltage));
holder.batteryIcon.setImageLevel(200);
}
//fetch activity data
@ -301,6 +314,101 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
}
});
holder.fmFrequencyBox.setVisibility(View.GONE);
if (device.isInitialized() && device.getExtraInfo("fm_frequency") != null) {
holder.fmFrequencyBox.setVisibility(View.VISIBLE);
holder.fmFrequencyLabel.setText(String.format(Locale.getDefault(), "%.1f", (float) device.getExtraInfo("fm_frequency")));
}
final TextView fmFrequencyLabel = holder.fmFrequencyLabel;
holder.fmFrequencyBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.preferences_fm_frequency);
final EditText input = new EditText(context);
input.setSelection(input.getText().length());
input.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
input.setText(String.format(Locale.getDefault(), "%.1f", (float) device.getExtraInfo("fm_frequency")));
builder.setView(input);
builder.setPositiveButton(context.getResources().getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
float frequency = Float.valueOf(input.getText().toString());
// Trim to 1 decimal place, discard the rest
frequency = Float.valueOf(String.format(Locale.getDefault(), "%.1f", frequency));
if (frequency < 87.5 || frequency > 108.0) {
new AlertDialog.Builder(context)
.setTitle(R.string.pref_invalid_frequency_title)
.setMessage(R.string.pref_invalid_frequency_message)
.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.show();
} else {
device.setExtraInfo("fm_frequency", frequency);
fmFrequencyLabel.setText(String.format(Locale.getDefault(), "%.1f", (float) device.getExtraInfo("fm_frequency")));
GBApplication.deviceService().onSetFmFrequency(frequency);
}
}
});
builder.setNegativeButton(context.getResources().getString(R.string.Cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
});
holder.ledColor.setVisibility(View.GONE);
if (device.isInitialized() && device.getExtraInfo("led_color") != null && coordinator.supportsLedColor()) {
holder.ledColor.setVisibility(View.VISIBLE);
final GradientDrawable ledColor = (GradientDrawable) holder.ledColor.getDrawable().mutate();
ledColor.setColor((int) device.getExtraInfo("led_color"));
holder.ledColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ColorPickerDialog.Builder builder = ColorPickerDialog.newBuilder();
builder.setDialogTitle(R.string.preferences_led_color);
builder.setColor((int) device.getExtraInfo("led_color"));
if (coordinator.supportsRgbLedColor()) {
builder.setAllowCustom(true);
builder.setShowAlphaSlider(false);
builder.setAllowPresets(true);
} else {
builder.setAllowCustom(false);
builder.setAllowPresets(true);
builder.setShowColorShades(false);
builder.setPresets(coordinator.getColorPresets());
}
ColorPickerDialog dialog = builder.create();
dialog.setColorPickerDialogListener(new ColorPickerDialogListener() {
@Override
public void onColorSelected(int dialogId, int color) {
ledColor.setColor(color);
device.setExtraInfo("led_color", color);
GBApplication.deviceService().onSetLedColor(color);
}
@Override
public void onDialogDismissed(int dialogId) {
// Nothing to do
}
});
dialog.show(((Activity) context).getFragmentManager(), "color-picker-dialog");
}
});
}
//remove device, hidden under details
holder.removeDevice.setOnClickListener(new View.OnClickListener()
@ -373,6 +481,9 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
ListView deviceInfoList;
ImageView findDevice;
ImageView removeDevice;
LinearLayout fmFrequencyBox;
TextView fmFrequencyLabel;
ImageView ledColor;
ViewHolder(View view) {
super(view);
@ -402,6 +513,9 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
deviceInfoList = view.findViewById(R.id.device_item_infos);
findDevice = view.findViewById(R.id.device_action_find);
removeDevice = view.findViewById(R.id.device_action_remove);
fmFrequencyBox = view.findViewById(R.id.device_fm_frequency_box);
fmFrequencyLabel = view.findViewById(R.id.fm_frequency);
ledColor = view.findViewById(R.id.device_led_color);
}
}

View File

@ -26,6 +26,7 @@ public class GBDeviceEventBatteryInfo extends GBDeviceEvent {
public BatteryState state = BatteryState.UNKNOWN;
public short level = 50;
public int numCharges = -1;
public float voltage = -1f;
public boolean extendedInfoAvailable() {
if (numCharges != -1 && lastChargeTime != null) {

View File

@ -0,0 +1,21 @@
/* Copyright (C) 2018 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
public class GBDeviceEventFmFrequency extends GBDeviceEvent {
public float frequency;
}

View File

@ -0,0 +1,21 @@
/* Copyright (C) 2018 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
public class GBDeviceEventLEDColor extends GBDeviceEvent {
public int color;
}

View File

@ -135,4 +135,18 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
public boolean supportsMusicInfo() {
return false;
}
public boolean supportsLedColor() {
return false;
}
@Override
public boolean supportsRgbLedColor() {
return false;
}
@Override
public int[] getColorPresets() {
return new int[0];
}
}

View File

@ -254,4 +254,21 @@ public interface DeviceCoordinator {
* like artist, title, album, play state etc.
*/
boolean supportsMusicInfo();
/**
* Indicates whether the device has an led which supports custom colors
*/
boolean supportsLedColor();
/**
* Indicates whether the device's led supports any RGB color,
* or only preset colors
*/
boolean supportsRgbLedColor();
/**
* Returns the preset colors supported by the device, if any, in ARGB, with alpha = 255
*/
@NonNull
int[] getColorPresets();
}

View File

@ -99,4 +99,12 @@ public interface EventHandler {
void onTestNewFunction();
void onSendWeather(WeatherSpec weatherSpec);
void onSetFmFrequency(float frequency);
/**
* Set the device's led color.
* @param color the new color, in ARGB, with alpha = 255
*/
void onSetLedColor(int color);
}

View File

@ -186,4 +186,19 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
public boolean supportsFindDevice() {
return false;
}
@Override
public boolean supportsLedColor() {
return false;
}
@Override
public boolean supportsRgbLedColor() {
return false;
}
@Override
public int[] getColorPresets() {
return new int[0];
}
}

View File

@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -73,11 +74,13 @@ public class GBDevice implements Parcelable {
private String mModel;
private State mState = State.NOT_CONNECTED;
private short mBatteryLevel = BATTERY_UNKNOWN;
private float mBatteryVoltage = BATTERY_UNKNOWN;
private short mBatteryThresholdPercent = BATTERY_THRESHOLD_PERCENT;
private BatteryState mBatteryState;
private short mRssi = RSSI_UNKNOWN;
private String mBusyTask;
private List<ItemWithDetails> mDeviceInfos;
private HashMap<String, Object> mExtraInfos;
public GBDevice(String address, String name, DeviceType deviceType) {
this(address, null, name, deviceType);
@ -106,6 +109,7 @@ public class GBDevice implements Parcelable {
mRssi = (short) in.readInt();
mBusyTask = in.readString();
mDeviceInfos = in.readArrayList(getClass().getClassLoader());
mExtraInfos = (HashMap) in.readSerializable();
validate();
}
@ -126,6 +130,7 @@ public class GBDevice implements Parcelable {
dest.writeInt(mRssi);
dest.writeString(mBusyTask);
dest.writeList(mDeviceInfos);
dest.writeSerializable(mExtraInfos);
}
private void validate() {
@ -371,6 +376,33 @@ public class GBDevice implements Parcelable {
return mAddress.hashCode() ^ 37;
}
/**
* Returns the extra info value if it is set, null otherwise
* @param key the extra info key
* @return the extra info value if set, null otherwise
*/
public Object getExtraInfo(String key) {
if (mExtraInfos == null) {
return null;
}
return mExtraInfos.get(key);
}
/**
* Sets an extra info value, overwriting the current one, if any
* @param key the extra info key
* @param info the extra info value
*/
public void setExtraInfo(String key, Object info) {
if (mExtraInfos == null) {
mExtraInfos = new HashMap<>();
}
mExtraInfos.put(key, info);
}
/**
* Ranges from 0-100 (percent), or -1 if unknown
*
@ -388,6 +420,23 @@ public class GBDevice implements Parcelable {
}
}
public void setBatteryVoltage(float batteryVoltage) {
if (batteryVoltage >= 0 || batteryVoltage == BATTERY_UNKNOWN) {
mBatteryVoltage = batteryVoltage;
} else {
LOG.error("Battery voltage must be > 0: " + batteryVoltage);
}
}
/**
* Voltage greater than zero (unit: Volt), or -1 if unknown
*
* @return the battery voltage, or -1 if unknown
*/
public float getBatteryVoltage() {
return mBatteryVoltage;
}
public BatteryState getBatteryState() {
return mBatteryState;
}

View File

@ -405,4 +405,18 @@ public class GBDeviceService implements DeviceService {
return name;
}
@Override
public void onSetFmFrequency(float frequency) {
Intent intent = createIntent().setAction(ACTION_SET_FM_FREQUENCY)
.putExtra(EXTRA_FM_FREQUENCY, frequency);
invokeService(intent);
}
@Override
public void onSetLedColor(int color) {
Intent intent = createIntent().setAction(ACTION_SET_LED_COLOR)
.putExtra(EXTRA_LED_COLOR, color);
invokeService(intent);
}
}

View File

@ -22,5 +22,6 @@ public enum BatteryState {
BATTERY_LOW,
BATTERY_CHARGING,
BATTERY_CHARGING_FULL,
BATTERY_NOT_CHARGING_FULL
BATTERY_NOT_CHARGING_FULL,
NO_BATTERY
}

View File

@ -65,6 +65,8 @@ public interface DeviceService extends EventHandler {
String ACTION_SEND_CONFIGURATION = PREFIX + ".action.send_configuration";
String ACTION_SEND_WEATHER = PREFIX + ".action.send_weather";
String ACTION_TEST_NEW_FUNCTION = PREFIX + ".action.test_new_function";
String ACTION_SET_FM_FREQUENCY = PREFIX + ".action.set_fm_frequency";
String ACTION_SET_LED_COLOR = PREFIX + ".action.set_led_color";
String EXTRA_NOTIFICATION_BODY = "notification_body";
String EXTRA_NOTIFICATION_FLAGS = "notification_flags";
String EXTRA_NOTIFICATION_ID = "notification_id";
@ -106,6 +108,8 @@ public interface DeviceService extends EventHandler {
String EXTRA_INTERVAL_SECONDS = "interval_seconds";
String EXTRA_WEATHER = "weather";
String EXTRA_RECORDED_DATA_TYPES = "data_types";
String EXTRA_FM_FREQUENCY = "fm_frequency";
String EXTRA_LED_COLOR = "led_color";
/**
* Use EXTRA_REALTIME_SAMPLE instead

View File

@ -52,7 +52,9 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFmFrequency;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventLEDColor;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventNotificationControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
@ -159,6 +161,10 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
handleGBDeviceEvent((GBDeviceEventBatteryInfo) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventFindPhone) {
handleGBDeviceEvent((GBDeviceEventFindPhone) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventLEDColor) {
handleGBDeviceEvent((GBDeviceEventLEDColor) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventFmFrequency) {
handleGBDeviceEvent((GBDeviceEventFmFrequency) deviceEvent);
}
}
@ -208,6 +214,26 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
gbDevice.sendDeviceUpdateIntent(context);
}
protected void handleGBDeviceEvent(GBDeviceEventLEDColor colorEvent) {
Context context = getContext();
LOG.info("Got event for LED Color");
if (gbDevice == null) {
return;
}
gbDevice.setExtraInfo("led_color", colorEvent.color);
gbDevice.sendDeviceUpdateIntent(context);
}
protected void handleGBDeviceEvent(GBDeviceEventFmFrequency frequencyEvent) {
Context context = getContext();
LOG.info("Got event for FM Frequency");
if (gbDevice == null) {
return;
}
gbDevice.setExtraInfo("fm_frequency", frequencyEvent.frequency);
gbDevice.sendDeviceUpdateIntent(context);
}
private void handleGBDeviceEvent(GBDeviceEventAppInfo appInfoEvent) {
Context context = getContext();
LOG.info("Got event for APP_INFO");
@ -328,6 +354,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
LOG.info("Got BATTERY_INFO device event");
gbDevice.setBatteryLevel(deviceEvent.level);
gbDevice.setBatteryState(deviceEvent.state);
gbDevice.setBatteryVoltage(deviceEvent.voltage);
//show the notification if the battery level is below threshold and only if not connected to charger
if (deviceEvent.level <= gbDevice.getBatteryThresholdPercent() &&

View File

@ -105,7 +105,9 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SE
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETTIME;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_ALARMS;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_CONSTANT_VIBRATION;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_FM_FREQUENCY;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_HEARTRATE_MEASUREMENT_INTERVAL;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_LED_COLOR;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_START;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_STARTAPP;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_TEST_NEW_FUNCTION;
@ -130,7 +132,9 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CAN
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CONFIG;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CONNECT_FIRST_TIME;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FM_FREQUENCY;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_INTERVAL_SECONDS;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_LED_COLOR;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ARTIST;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_DURATION;
@ -549,6 +553,18 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
}
break;
}
case ACTION_SET_LED_COLOR:
int color = intent.getIntExtra(EXTRA_LED_COLOR, 0);
if (color != 0) {
mDeviceSupport.onSetLedColor(color);
}
break;
case ACTION_SET_FM_FREQUENCY:
float frequency = intent.getFloatExtra(EXTRA_FM_FREQUENCY, -1);
if (frequency != -1) {
mDeviceSupport.onSetFmFrequency(frequency);
}
break;
}
return START_STICKY;

View File

@ -374,4 +374,20 @@ public class ServiceDeviceSupport implements DeviceSupport {
}
delegate.onSendWeather(weatherSpec);
}
@Override
public void onSetFmFrequency(float frequency) {
if (checkBusy("set frequency event")) {
return;
}
delegate.onSetFmFrequency(frequency);
}
@Override
public void onSetLedColor(int color) {
if (checkBusy("set led color event")) {
return;
}
delegate.onSetLedColor(color);
}
}

View File

@ -318,4 +318,14 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
profile.onReadRemoteRssi(gatt, rssi, status);
}
}
@Override
public void onSetFmFrequency(float frequency) {
}
@Override
public void onSetLedColor(int color) {
}
}

View File

@ -250,4 +250,16 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
byte[] bytes = gbDeviceProtocol.encodeSendWeather(weatherSpec);
sendToDevice(bytes);
}
@Override
public void onSetFmFrequency(float frequency) {
byte[] bytes = gbDeviceProtocol.encodeFmFrequency(frequency);
sendToDevice(bytes);
}
@Override
public void onSetLedColor(int color) {
byte[] bytes = gbDeviceProtocol.encodeLedColor(color);
sendToDevice(bytes);
}
}

View File

@ -133,4 +133,12 @@ public abstract class GBDeviceProtocol {
public byte[] encodeSendWeather(WeatherSpec weatherSpec) {
return null;
}
public byte[] encodeLedColor(int color) {
return null;
}
public byte[] encodeFmFrequency(float frequency) {
return null;
}
}

View File

@ -0,0 +1,11 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false">
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="@color/secondarytext" />
</shape>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M3.24,6.15C2.51,6.43 2,7.17 2,8v12c0,1.1 0.89,2 2,2h16c1.11,0 2,-0.9 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2L8.3,6l8.26,-3.34L15.88,1 3.24,6.15zM7,20c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM20,12h-2v-2h-2v2L4,12L4,8h16v4z"/>
</vector>

View File

@ -139,13 +139,58 @@
</LinearLayout>
<LinearLayout
android:id="@+id/device_fm_frequency_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/device_image"
android:layout_toEndOf="@id/device_battery_status_box"
android:layout_margin="4dp"
android:orientation="vertical">
<ImageView
android:id="@+id/device_fm_frequency"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="4dp"
android:scaleType="fitXY"
android:tint="@color/secondarytext"
card_view:srcCompat="@drawable/ic_radio" />
<TextView
android:id="@+id/fm_frequency"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:minWidth="36dp"
android:textColor="@color/secondarytext"
android:textStyle="bold"
tools:text="107.8" />
</LinearLayout>
<ImageView
android:id="@+id/device_led_color"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_below="@id/device_image"
android:layout_margin="4dp"
android:layout_toEndOf="@id/device_fm_frequency_box"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/controlcenter_take_screenshot"
android:padding="4dp"
android:scaleType="fitXY"
card_view:srcCompat="@drawable/ic_led_color"
android:focusable="true" />
<LinearLayout
android:id="@+id/device_action_fetch_activity_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/device_image"
android:layout_margin="4dp"
android:layout_toEndOf="@id/device_battery_status_box"
android:layout_toEndOf="@id/device_led_color"
android:gravity="center_vertical"
android:minWidth="36dp"
android:orientation="vertical">

View File

@ -9,6 +9,8 @@
<string name="controlcenter_start_sleepmonitor">Monitor de sono (ALPHA)</string>
<string name="controlcenter_find_device">Procurar dispositivo perdido</string>
<string name="controlcenter_take_screenshot">Captura de ecrã</string>
<string name="controlcenter_change_led_color">Mudar cor do LED</string>
<string name="controlcenter_change_fm_frequency">Mudar frequência FM</string>
<string name="controlcenter_disconnect">Desligar</string>
<string name="controlcenter_delete_device">Apagar dispositivo</string>
<string name="controlcenter_delete_device_name">Apagar %1$s</string>
@ -523,4 +525,14 @@
<string name="watch9_calibration_button">Calibrar</string>
<string name="title_activity_watch9_pairing">Emparelhamento do Watch 9</string>
<string name="title_activity_watch9_calibration">Calibração do Watch 9</string>
<!-- LED Color -->
<string name="preferences_led_color">Cor do LED</string>
<!-- FM transmitters -->
<string name="preferences_fm_frequency">Frequência FM</string>
<string name="pref_invalid_frequency_title">Frequência inválida</string>
<string name="pref_invalid_frequency_message">Por favor introduza uma frequência entre 87.5 e 108.0</string>
</resources>

View File

@ -10,6 +10,8 @@
<string name="controlcenter_fetch_activity_data">Synchronize</string>
<string name="controlcenter_find_device">Find lost device</string>
<string name="controlcenter_take_screenshot">Take Screenshot</string>
<string name="controlcenter_change_led_color">Change LED Color</string>
<string name="controlcenter_change_fm_frequency">Change FM Frequency</string>
<string name="controlcenter_connect">Connect</string>
<string name="controlcenter_disconnect">Disconnect</string>
<string name="controlcenter_delete_device">Delete Device</string>
@ -634,4 +636,12 @@
<string name="share_log">Share log</string>
<string name="share_log_warning">Please keep in mind Gadgetbridge log files may contain lots of personal information, including but not limited to health data, unique identifiers (such as a device MAC address), music preferences, etc. Consider editing the file and removing this information before sending the file to a public issue report.</string>
<string name="warning">Warning!</string>
<!-- LED Color -->
<string name="preferences_led_color">LED Color</string>
<!-- FM transmitters -->
<string name="preferences_fm_frequency">FM Frequency</string>
<string name="pref_invalid_frequency_title">Invalid frequency</string>
<string name="pref_invalid_frequency_message">Please enter a frequency between 87.5 and 108.0</string>
</resources>

View File

@ -188,4 +188,14 @@ class TestDeviceSupport extends AbstractDeviceSupport {
public void onSendWeather(WeatherSpec weatherSpec) {
}
@Override
public void onSetFmFrequency(float frequency) {
}
@Override
public void onSetLedColor(int color) {
}
}