Only use filled paths for SVG app icon, add icon for bridge loading.

This commit is contained in:
Sergio Martínez Portela 2020-05-28 23:42:48 +02:00
parent 1cbb712eee
commit 6c2ced0685
8 changed files with 432 additions and 95 deletions

View file

@ -21,6 +21,12 @@ import com.codigoparallevar.minicards.types.functional.Tuple2;
import com.codigoparallevar.minicards.ui_helpers.DoAsync;
import com.programaker.api.ProgramakerApi;
enum ServiceState {
LOADING,
RUNNING,
STOPPED,
}
public class ProgramakerBridgeService extends Service {
public static final String BridgeUserNotificationChannel = "PROGRAMAKER_BRIDGE_USER_NOTIFICATION";
public static final CharSequence BridgeUserNotificationChannelName = "User notifications";
@ -41,10 +47,10 @@ public class ProgramakerBridgeService extends Service {
@Override
public void onCreate() {
setBridgeStatusNotification(getString(R.string.bridge_service_not_started), true);
setBridgeStatusNotification(getString(R.string.bridge_service_not_started), ServiceState.LOADING);
}
private void setBridgeStatusNotification(String title, boolean stopped) {
private void setBridgeStatusNotification(String title, ServiceState state) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
assert notificationManager != null;
@ -72,13 +78,19 @@ public class ProgramakerBridgeService extends Service {
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
if (stopped) {
if (state == ServiceState.STOPPED) {
builder.addAction(R.drawable.ic_start, getString(R.string.start_bridge), startPendingIntent)
.setSmallIcon(R.drawable.ic_vector_stopped_icon);
}
else {
builder.addAction(R.drawable.ic_cancel, getString(R.string.stop_bridge), stopPendingIntent)
.setSmallIcon(R.drawable.ic_vector_icon);
builder.addAction(R.drawable.ic_cancel, getString(R.string.stop_bridge), stopPendingIntent);
if (state == ServiceState.RUNNING) {
builder.setSmallIcon(R.drawable.ic_vector_icon);
}
else {
builder.setSmallIcon(R.drawable.ic_vector_icon_loading);
}
}
Notification notification = builder.build();
@ -148,7 +160,7 @@ public class ProgramakerBridgeService extends Service {
bridgeId);
ProgramakerBridgeService.this.bridge.start(
() -> { // On ready
setBridgeStatusNotification(getString(R.string.bridge_service_online), false);
setBridgeStatusNotification(getString(R.string.bridge_service_online), ServiceState.RUNNING);
if (config.getBridgeConnectionId() == null) {
new DoAsync().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
new Tuple2<>(
@ -178,14 +190,14 @@ public class ProgramakerBridgeService extends Service {
}, "ServiceStartArguments");
thread.setPriority(Process.THREAD_PRIORITY_BACKGROUND);
setBridgeStatusNotification(getString(R.string.bridge_service_starting), false);
setBridgeStatusNotification(getString(R.string.bridge_service_starting), ServiceState.LOADING);
thread.start();
}
private void onBridgeFailedAfterConnected() {
if (!stopped) {
Log.e(LogTag, "Bridge stopped after connected. Waiting 10s then restarting");
setBridgeStatusNotification(getString(R.string.bridge_service_failed_restarting), false);
setBridgeStatusNotification(getString(R.string.bridge_service_failed_restarting), ServiceState.LOADING);
try {
Thread.sleep(WAIT_TIME_BEFORE_RESTART_MILLIS);
} catch (InterruptedException e) {
@ -208,6 +220,6 @@ public class ProgramakerBridgeService extends Service {
if (bridge != null) {
bridge.stop();
}
setBridgeStatusNotification(getString(R.string.bridge_service_failed_stopping), true);
setBridgeStatusNotification(getString(R.string.bridge_service_failed_stopping), ServiceState.STOPPED);
}
}

View file

@ -1,12 +1,32 @@
<vector android:alpha="0.99" android:autoMirrored="true"
android:height="328.6dp" android:viewportHeight="328.6"
android:viewportWidth="322" android:width="322dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00000000"
android:pathData="M90.79,152.763 L287.19,286.563 173.29,25.493c0,0 -12.3,-23.91 -26,0.37 -13.6,24.3 -56.5,126.9 -56.5,126.9z"
android:strokeAlpha="1" android:strokeColor="#000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="30.2362"/>
<path android:fillColor="#00000000"
android:pathData="M32.25,290.863 L132.09,230.763 74.8,191.163Z"
android:strokeAlpha="1" android:strokeColor="#000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="30.2362"/>
android:height="328.9dp" android:viewportHeight="328.9"
android:viewportWidth="321.8" android:width="321.8dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="m160.24,33.827 l27.3,-12.96c0,0 -10.7,-20.629 -26.8,-20.865C144.54,-0.233 132.84,20.867 132.84,20.867Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M187.54,20.867 L160.24,33.827 252.34,244.877 109.44,147.877 71.93,158.577 321.84,328.877Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M71.93,158.577 L109.44,147.877 160.24,33.827 252.34,244.877 321.84,328.877 187.54,20.867h-54.7z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M321.84,328.877 L252.34,244.877 109.44,147.877 160.24,33.827 297.94,273.877 187.54,20.867L132.84,20.867L71.93,158.577Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="m68.01,168.477 l13.26,45.9 -16.92,39.7 39.79,-23.9 55.6,1.7 -159.74,96.2z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M0,328.077 L64.35,254.077 104.14,230.177 81.27,214.377 68.01,168.477 159.74,231.877Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M159.74,231.877 L104.14,230.177 81.27,214.377 64.35,254.077 0,328.077 68.01,168.477Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
</vector>

View file

@ -0,0 +1,41 @@
<vector android:alpha="0.99" android:autoMirrored="true"
android:height="328.9dp" android:viewportHeight="328.9"
android:viewportWidth="321.8" android:width="321.8dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M187.5,20.87L160.2,33.83L243.2,224.2A48.11,48.11 0,0 1,265.3 218.8A48.11,48.11 0,0 1,274.1 219.6L187.5,20.87zM109.4,147.9L71.93,158.6L160.3,218.8A48.11,48.11 0,0 1,204.3 248.8L218,258.2A48.11,48.11 0,0 1,232.7 231.6L109.4,147.9zM306,292.6A48.11,48.11 0,0 1,290.7 307.7L321.8,328.9L306,292.6z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M132.8,20.87L71.93,158.6L109.4,147.9L160.2,33.83L243.3,224.1A48.11,48.11 0,0 1,265.3 218.8A48.11,48.11 0,0 1,274.2 219.6L187.5,20.87L132.8,20.87zM306,292.6A48.11,48.11 0,0 1,299 301.2L321.8,328.9L306,292.6z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M132.8,20.87L71.93,158.6L160.3,218.8A48.11,48.11 0,0 1,204.3 248.8L218,258.2A48.11,48.11 0,0 1,232.7 231.6L109.4,147.9L160.2,33.83L266.3,218.8A48.11,48.11 0,0 1,274.2 219.6L187.5,20.87L132.8,20.87zM298.9,301.3A48.11,48.11 0,0 1,290.7 307.7L321.8,328.9L298.9,301.3z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M54.33,266.877m-29.26,0a29.26,29.26 0,1 1,58.52 0a29.26,29.26 0,1 1,-58.52 0"
android:strokeLineCap="square" android:strokeWidth="0"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M68.01,168.5L46.29,219.5A48.11,48.11 0,0 1,54.33 218.8A48.11,48.11 0,0 1,76.98 224.4L81.27,214.4L68.01,168.5zM104.1,230.2L92.27,237.3A48.11,48.11 0,0 1,102.4 266.4L112.1,260.6A48.11,48.11 0,0 1,127.8 230.9L104.1,230.2zM14.55,293.9L0,328.1L31.41,309.2A48.11,48.11 0,0 1,14.55 293.9z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M68.01,168.5L46.29,219.5A48.11,48.11 0,0 1,54.33 218.8A48.11,48.11 0,0 1,76.98 224.4L81.27,214.4L104.1,230.2L127.8,230.9A48.11,48.11 0,0 1,144.4 221.3L68.01,168.5zM14.55,293.9L0,328.1L22.14,302.6A48.11,48.11 0,0 1,14.55 293.9z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M68.01,168.5L81.27,214.4L104.1,230.2L92.27,237.3A48.11,48.11 0,0 1,102.4 266.4L112.1,260.6A48.11,48.11 0,0 1,144.4 221.3L68.01,168.5zM22.14,302.6L0,328.1L31.41,309.2A48.11,48.11 0,0 1,22.14 302.6z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M265.34,266.877m-29.26,0a29.26,29.26 0,1 1,58.52 0a29.26,29.26 0,1 1,-58.52 0"
android:strokeLineCap="square" android:strokeWidth="0"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M159.74,266.877m-29.26,0a29.26,29.26 0,1 1,58.52 0a29.26,29.26 0,1 1,-58.52 0"
android:strokeLineCap="square" android:strokeWidth="0"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="m160.24,33.827 l27.3,-12.96c0,0 -10.7,-20.629 -26.8,-20.865C144.54,-0.233 132.84,20.867 132.84,20.867Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
</vector>

View file

@ -1,16 +1,35 @@
<vector android:alpha="0.99" android:autoMirrored="true"
android:height="328.6dp" android:viewportHeight="328.6"
android:viewportWidth="322" android:width="322dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00000000"
android:pathData="M90.79,152.763 L287.19,286.563 173.29,25.493c0,0 -12.3,-23.91 -26,0.37 -13.6,24.3 -56.5,126.9 -56.5,126.9z"
android:strokeAlpha="1" android:strokeColor="#000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="30.2362"/>
<path android:fillColor="#00000000"
android:pathData="M32.25,290.863 L132.09,230.763 74.8,191.163Z"
android:strokeAlpha="1" android:strokeColor="#000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="30.2362"/>
<path android:fillColor="#000000"
android:pathData="M-14.73,211.691l338.429,-119.798l12.181,33.237l-338.429,119.798z"
android:strokeColor="#ff00ff" android:strokeLineCap="square"
android:strokeLineJoin="miter" android:strokeWidth="0"/>
android:height="328.9dp" android:viewportHeight="328.9"
android:viewportWidth="321.8" android:width="321.8dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M132.8,20.87L98.26,99.06L127.2,108L160.2,33.83L202.8,131.3L240.8,143L187.5,20.87L132.8,20.87zM238.5,213.2L252.3,244.9L321.8,328.9L276.5,224.9L238.5,213.2z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M132.8,20.87L98.26,99.06L127.2,108L160.2,33.83L219,136.3L240.9,143.1L187.5,20.87L132.8,20.87zM80.45,164.4L321.8,328.9L252.3,244.9L178.2,194.5L80.45,164.4zM268.4,222.4L297.9,273.9L276.6,224.9L268.4,222.4z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M46.593,103.207l254.65,78.584l-8.625,27.949l-254.65,-78.584z"
android:strokeLineCap="square" android:strokeWidth="0"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="m160.24,33.827 l27.3,-12.96c0,0 -10.7,-20.629 -26.8,-20.865C144.54,-0.233 132.84,20.867 132.84,20.867Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M187.5,20.87L160.2,33.83L202.8,131.3L240.8,143L187.5,20.87zM80.45,164.4L321.8,328.9L276.5,224.9L238.5,213.2L252.3,244.9L178.2,194.5L80.45,164.4z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="m68.01,168.477 l13.26,45.9 -16.92,39.7 39.79,-23.9 55.6,1.7 -159.74,96.2z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M0,328.077 L64.35,254.077 104.14,230.177 81.27,214.377 68.01,168.477 159.74,231.877Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
<path android:fillAlpha="1" android:fillColor="#000000"
android:pathData="M159.74,231.877 L104.14,230.177 81.27,214.377 64.35,254.077 0,328.077 68.01,168.477Z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
</vector>