diff --git a/LICENSE.artwork b/LICENSE.artwork index d4b56ec03..e5029951e 100644 --- a/LICENSE.artwork +++ b/LICENSE.artwork @@ -1,4 +1,8 @@ -The following artwork is licensed under the -Creative Commons Attribution-Share Alike 4.0 International license: +The following artwork is licensed under the following licenses -"GET IT ON F-Droid" button by Laura Kalbag. Source: https://ind.ie/about/blog/f-droid-button/ +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0): + ic_device_pebble.png (gadgetbridge.png from https://gitlab.com/xphnx/twelf_cm12_theme/) + ic_watchface.png (clock.png from https://gitlab.com/xphnx/twelf_cm12_theme/) + +Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0): + "GET IT ON F-Droid" button by Laura Kalbag. Source: https://ind.ie/about/blog/f-droid-button/ diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AppManagerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AppManagerActivity.java index a58cf08f3..4796ab137 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AppManagerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AppManagerActivity.java @@ -38,8 +38,9 @@ public class AppManagerActivity extends Activity { String appCreator = intent.getStringExtra("app_creator" + i.toString()); int id = intent.getIntExtra("app_id" + i.toString(), -1); int index = intent.getIntExtra("app_index" + i.toString(), -1); + GBDeviceApp.Type appType = GBDeviceApp.Type.values()[intent.getIntExtra("app_type" + i.toString(), 0)]; - appList.add(new GBDeviceApp(id, index, appName, appCreator, "")); + appList.add(new GBDeviceApp(id, index, appName, appCreator, "", appType)); } mGBDeviceAppAdapter.notifyDataSetChanged(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java index 184d569c5..1514dfb54 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java @@ -166,6 +166,7 @@ public class BluetoothCommunicationService extends Service { appInfoIntent.putExtra("app_creator" + i.toString(), appInfoCmd.apps[i].getCreator()); appInfoIntent.putExtra("app_id" + i.toString(), appInfoCmd.apps[i].getId()); appInfoIntent.putExtra("app_index" + i.toString(), appInfoCmd.apps[i].getIndex()); + appInfoIntent.putExtra("app_type" + i.toString(), appInfoCmd.apps[i].getType().ordinal()); } LocalBroadcastManager.getInstance(this).sendBroadcast(appInfoIntent); break; @@ -251,7 +252,13 @@ public class BluetoothCommunicationService extends Service { } BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(btDeviceAddress); if (btDevice != null) { - gbdevice = new GBDevice(btDeviceAddress, btDevice.getName()); + GBDevice.Type deviceType = GBDevice.Type.UNKNOWN; + if (btDevice.getName().indexOf("Pebble") == 0) { + deviceType = GBDevice.Type.PEBBLE; + } else if (btDevice.getName().equals("MI")) { + deviceType = GBDevice.Type.MIBAND; + } + gbdevice = new GBDevice(btDeviceAddress, btDevice.getName(), deviceType); gbdevice.setState(GBDevice.State.CONNECTING); sendDeviceUpdateIntent(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java index aa840bf87..d47be4c21 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java @@ -171,10 +171,16 @@ public class ControlCenter extends Activity { } else { Set pairedDevices = btAdapter.getBondedDevices(); for (BluetoothDevice device : pairedDevices) { + GBDevice.Type deviceType = GBDevice.Type.UNKNOWN; if (device.getName().indexOf("Pebble") == 0) { - // Matching device found - deviceList.add(new GBDevice(device.getAddress(), device.getName())); + deviceType = GBDevice.Type.PEBBLE; + } else if (device.getName().equals("MI")) { + deviceType = GBDevice.Type.MIBAND; } + else { + continue; + } + deviceList.add(new GBDevice(device.getAddress(), device.getName(), deviceType)); } if (!deviceList.isEmpty()) { hintTextView.setText("tap a device to connect"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDevice.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDevice.java index d33666612..fb7d22e8a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDevice.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDevice.java @@ -3,26 +3,14 @@ package nodomain.freeyourgadget.gadgetbridge; public class GBDevice { private final String name; private final String address; + private final Type type; private String firmwareVersion = null; private State state = State.NOT_CONNECTED; - public void setState(State state) { - this.state = state; - } - - public enum State { - NOT_CONNECTED, - CONNECTING, - CONNECTED - } - - public GBDevice(String address, String name) { + public GBDevice(String address, String name, Type type) { this.address = address; this.name = name; - } - - public void setFirmwareVersion(String firmwareVersion) { - this.firmwareVersion = firmwareVersion; + this.type = type; } public String getName() { @@ -37,10 +25,18 @@ public class GBDevice { return firmwareVersion; } + public void setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + } + public State getState() { return state; } + public void setState(State state) { + this.state = state; + } + String getStateString() { switch (state) { case NOT_CONNECTED: @@ -60,4 +56,21 @@ public class GBDevice { return getStateString(); } } + + public Type getType() { + return type; + } + + public enum State { + NOT_CONNECTED, + CONNECTING, + CONNECTED + } + + public enum Type { + UNKNOWN, + PEBBLE, + MIBAND + } + } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDeviceApp.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDeviceApp.java index fbf443a22..8d43642ba 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDeviceApp.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBDeviceApp.java @@ -6,13 +6,15 @@ public class GBDeviceApp { private final String version; private final int id; private final int index; + private final Type type; - public GBDeviceApp(int id, int index, String name, String creator, String version) { + public GBDeviceApp(int id, int index, String name, String creator, String version, Type type) { this.id = id; this.index = index; this.name = name; this.creator = creator; this.version = version; + this.type = type; } public String getName() { @@ -34,4 +36,15 @@ public class GBDeviceApp { public int getIndex() { return index; } + + public Type getType() { + return type; + } + + public enum Type { + UNKNOWN, + WATCHFACE, + APP_GENERIC, + APP_ACTIVITYTRACKER, + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java index 4c55695a6..ef559b7de 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapter.java @@ -5,6 +5,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.TextView; import java.util.List; @@ -36,9 +37,22 @@ public class GBDeviceAdapter extends ArrayAdapter { } TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status); TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name); + ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image); + deviceStatusLabel.setText(device.getInfoString()); deviceNameLabel.setText(device.getName()); + switch (device.getType()) { + case PEBBLE: + deviceImageView.setImageResource(R.drawable.ic_device_pebble); + break; + case MIBAND: + deviceImageView.setImageResource(R.drawable.ic_launcher); //FIXME: add icon + break; + default: + deviceImageView.setImageResource(R.drawable.ic_launcher); + } + return view; } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAppAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAppAdapter.java index dd7667079..c2b923059 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAppAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAppAdapter.java @@ -5,6 +5,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.TextView; import java.util.List; @@ -36,8 +37,17 @@ public class GBDeviceAppAdapter extends ArrayAdapter { } TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status); TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name); + ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image); + deviceStatusLabel.setText(deviceApp.getVersion() + " by " + deviceApp.getCreator()); deviceNameLabel.setText(deviceApp.getName()); + switch (deviceApp.getType()) { + case WATCHFACE: + deviceImageView.setImageResource(R.drawable.ic_watchface); + break; + default: + deviceImageView.setImageResource(R.drawable.ic_device_pebble); + } return view; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java index 7962b9382..2cec28d30 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java @@ -325,17 +325,27 @@ public class PebbleProtocol { int banks = buf.getInt(); int banksUsed = buf.getInt(); byte[] appName = new byte[32]; - byte[] creatorName = new byte[32]; + byte[] appCreator = new byte[32]; appInfoCmd.apps = new GBDeviceApp[banksUsed]; for (int i = 0; i < banksUsed; i++) { int id = buf.getInt(); int index = buf.getInt(); buf.get(appName, 0, 32); - buf.get(creatorName, 0, 32); + buf.get(appCreator, 0, 32); int flags = buf.getInt(); + + GBDeviceApp.Type appType; + switch (flags) { + case 1: + appType = GBDeviceApp.Type.WATCHFACE; + break; + default: + appType = GBDeviceApp.Type.APP_GENERIC; + break; + } Short appVersion = buf.getShort(); - appInfoCmd.apps[i] = new GBDeviceApp(id, index, new String(appName).trim(), new String(creatorName).trim(), appVersion.toString()); + appInfoCmd.apps[i] = new GBDeviceApp(id, index, new String(appName).trim(), new String(appCreator).trim(), appVersion.toString(), appType); } cmd = appInfoCmd; break; diff --git a/app/src/main/res/drawable-hdpi/ic_device_pebble.png b/app/src/main/res/drawable-hdpi/ic_device_pebble.png new file mode 100644 index 000000000..b089f42a0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_device_pebble.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_watchface.png b/app/src/main/res/drawable-hdpi/ic_watchface.png new file mode 100644 index 000000000..002f1a4e3 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_watchface.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_device_pebble.png b/app/src/main/res/drawable-mdpi/ic_device_pebble.png new file mode 100644 index 000000000..1d56ef4c4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_device_pebble.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_watchface.png b/app/src/main/res/drawable-mdpi/ic_watchface.png new file mode 100644 index 000000000..132fd6c32 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_watchface.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_device_pebble.png b/app/src/main/res/drawable-xhdpi/ic_device_pebble.png new file mode 100644 index 000000000..bdf0ecb43 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_device_pebble.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_watchface.png b/app/src/main/res/drawable-xhdpi/ic_watchface.png new file mode 100644 index 000000000..802abf3c1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_watchface.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_device_pebble.png b/app/src/main/res/drawable-xxhdpi/ic_device_pebble.png new file mode 100644 index 000000000..ed08272a5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_device_pebble.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_watchface.png b/app/src/main/res/drawable-xxhdpi/ic_watchface.png new file mode 100644 index 000000000..46b1f2466 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_watchface.png differ diff --git a/app/src/main/res/layout/device_item.xml b/app/src/main/res/layout/device_item.xml index c1de3063f..464f80f44 100644 --- a/app/src/main/res/layout/device_item.xml +++ b/app/src/main/res/layout/device_item.xml @@ -9,8 +9,7 @@ android:id="@+id/device_image" android:layout_width="48dp" android:layout_height="48dp" - android:layout_alignParentLeft="true" - android:src="@drawable/ic_launcher"/> + android:layout_alignParentLeft="true" />