2015-08-03 23:09:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.model;
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2017-02-26 22:46:49 +01:00
|
|
|
import android.support.annotation.DrawableRes;
|
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* For every supported device, a device type constant must exist.
|
2016-08-17 00:34:19 +02:00
|
|
|
*
|
|
|
|
* Note: they key of every constant is stored in the DB, so it is fixed forever,
|
|
|
|
* and may not be changed.
|
2015-10-26 23:32:03 +01:00
|
|
|
*/
|
2015-05-05 00:48:02 +02:00
|
|
|
public enum DeviceType {
|
2017-02-26 22:46:49 +01:00
|
|
|
UNKNOWN(-1, R.drawable.ic_launcher, R.drawable.ic_device_default_disabled),
|
|
|
|
PEBBLE(1, R.drawable.ic_device_pebble, R.drawable.ic_device_pebble_disabled),
|
|
|
|
MIBAND(10, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled),
|
|
|
|
MIBAND2(11, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled),
|
|
|
|
VIBRATISSIMO(20, R.drawable.ic_device_lovetoy, R.drawable.ic_device_lovetoy_disabled),
|
|
|
|
LIVEVIEW(30, R.drawable.ic_launcher, R.drawable.ic_device_default_disabled),
|
|
|
|
HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled),
|
|
|
|
MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled),
|
|
|
|
TEST(1000, R.drawable.ic_launcher, R.drawable.ic_device_default_disabled);
|
2016-08-17 00:34:19 +02:00
|
|
|
|
|
|
|
private final int key;
|
2017-02-26 22:46:49 +01:00
|
|
|
@DrawableRes
|
|
|
|
private final int defaultIcon;
|
|
|
|
@DrawableRes
|
|
|
|
private final int disabledIcon;
|
2016-08-17 00:34:19 +02:00
|
|
|
|
2017-02-26 22:46:49 +01:00
|
|
|
DeviceType(int key, int defaultIcon, int disabledIcon) {
|
2016-08-17 00:34:19 +02:00
|
|
|
this.key = key;
|
2017-02-26 22:46:49 +01:00
|
|
|
this.defaultIcon = defaultIcon;
|
|
|
|
this.disabledIcon = disabledIcon;
|
2016-08-17 00:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getKey() {
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2016-11-27 01:09:20 +01:00
|
|
|
public boolean isSupported() {
|
|
|
|
return this != UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2016-08-17 00:34:19 +02:00
|
|
|
public static DeviceType fromKey(int key) {
|
|
|
|
for (DeviceType type : values()) {
|
|
|
|
if (type.key == key) {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DeviceType.UNKNOWN;
|
|
|
|
}
|
2017-02-26 22:46:49 +01:00
|
|
|
|
|
|
|
@DrawableRes
|
|
|
|
public int getIcon() {
|
|
|
|
return defaultIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
@DrawableRes
|
|
|
|
public int getDisabledIcon() {
|
|
|
|
return disabledIcon;
|
|
|
|
}
|
2015-05-05 00:48:02 +02:00
|
|
|
}
|