Dynamically generate shortcut icon (#1628)
This commit is contained in:
parent
d6dfc3ac0e
commit
e70a9fddaa
|
|
@ -113,6 +113,14 @@ android {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
named("main") {
|
||||
res {
|
||||
srcDirs("src/common/res")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
||||
|
|
|
|||
|
|
@ -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="@android:color/white"
|
||||
android:pathData="M10.5,4.5c0.28,0 0.5,0.22 0.5,0.5v2h6v6h2c0.28,0 0.5,0.22 0.5,0.5s-0.22,0.5 -0.5,0.5h-2v6h-2.12c-0.68,-1.75 -2.39,-3 -4.38,-3s-3.7,1.25 -4.38,3H4v-2.12c1.75,-0.68 3,-2.39 3,-4.38 0,-1.99 -1.24,-3.7 -2.99,-4.38L4,7h6V5c0,-0.28 0.22,-0.5 0.5,-0.5m0,-2C9.12,2.5 8,3.62 8,5H4c-1.1,0 -1.99,0.9 -1.99,2v3.8h0.29c1.49,0 2.7,1.21 2.7,2.7s-1.21,2.7 -2.7,2.7H2V20c0,1.1 0.9,2 2,2h3.8v-0.3c0,-1.49 1.21,-2.7 2.7,-2.7s2.7,1.21 2.7,2.7v0.3H17c1.1,0 2,-0.9 2,-2v-4c1.38,0 2.5,-1.12 2.5,-2.5S20.38,11 19,11V7c0,-1.1 -0.9,-2 -2,-2h-4c0,-1.38 -1.12,-2.5 -2.5,-2.5z" />
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<resources>
|
||||
<color name="ic_launcher_foreground">#F06292</color>
|
||||
<color name="ic_launcher_background">#E1F5FE</color>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<resources>
|
||||
<color name="ic_launcher_foreground">#FFFFFF</color>
|
||||
<color name="ic_launcher_background">#F48FB1</color>
|
||||
</resources>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 81 KiB |
|
|
@ -1,10 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M10.5,4.5c0.28,0 0.5,0.22 0.5,0.5v2h6v6h2c0.28,0 0.5,0.22 0.5,0.5s-0.22,0.5 -0.5,0.5h-2v6h-2.12c-0.68,-1.75 -2.39,-3 -4.38,-3s-3.7,1.25 -4.38,3H4v-2.12c1.75,-0.68 3,-2.39 3,-4.38 0,-1.99 -1.24,-3.7 -2.99,-4.38L4,7h6V5c0,-0.28 0.22,-0.5 0.5,-0.5m0,-2C9.12,2.5 8,3.62 8,5H4c-1.1,0 -1.99,0.9 -1.99,2v3.8h0.29c1.49,0 2.7,1.21 2.7,2.7s-1.21,2.7 -2.7,2.7H2V20c0,1.1 0.9,2 2,2h3.8v-0.3c0,-1.49 1.21,-2.7 2.7,-2.7s2.7,1.21 2.7,2.7v0.3H17c1.1,0 2,-0.9 2,-2v-4c1.38,0 2.5,-1.12 2.5,-2.5S20.38,11 19,11V7c0,-1.1 -0.9,-2 -2,-2h-4c0,-1.38 -1.12,-2.5 -2.5,-2.5z"/>
|
||||
</vector>
|
||||
|
|
@ -18,9 +18,6 @@
|
|||
-->
|
||||
|
||||
<resources>
|
||||
<color name="ic_launcher_foreground">@color/material_pink_300</color>
|
||||
<color name="ic_launcher_background">@color/material_light_blue_50</color>
|
||||
|
||||
<color name="home_secondary_outline_ambient_shadow_color">@color/material_grey_700</color>
|
||||
<color name="home_secondary_outline_spot_shadow_color">@color/material_grey_600</color>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@
|
|||
-->
|
||||
|
||||
<resources>
|
||||
<color name="ic_launcher_foreground">@android:color/white</color>
|
||||
<color name="ic_launcher_background">@color/material_pink_200</color>
|
||||
|
||||
<color name="home_secondary_outline_ambient_shadow_color">@color/material_grey_500</color>
|
||||
<color name="home_secondary_outline_spot_shadow_color">@color/material_grey_300</color>
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,14 @@ android {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
named("main") {
|
||||
res {
|
||||
srcDir(project(":app").file("src/common/res"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||
|
|
@ -155,7 +163,6 @@ afterEvaluate {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation("dev.rikka.ndk.thirdparty:cxx:1.2.0")
|
||||
implementation("com.android.tools.build:apksig:$agpVersion")
|
||||
implementation("org.apache.commons:commons-lang3:3.12.0")
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ import android.content.pm.ResolveInfo;
|
|||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.content.pm.VersionedPackage;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.Uri;
|
||||
|
|
@ -76,10 +77,8 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import hidden.HiddenApiBridge;
|
||||
import io.github.xposed.xposedservice.utils.ParceledListSlice;
|
||||
|
|
@ -161,16 +160,24 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
|||
LSPManagerService() {
|
||||
}
|
||||
|
||||
private static Icon getIcon(int res) {
|
||||
var icon = ConfigFileManager.getResources().getDrawable(res, ConfigFileManager.getResources().newTheme());
|
||||
var bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
|
||||
icon.draw(new Canvas(bitmap));
|
||||
return Icon.createWithBitmap(bitmap);
|
||||
}
|
||||
|
||||
private static Icon getManagerIcon() {
|
||||
try (var zip = new ZipFile(ConfigFileManager.managerApkPath.toString())) {
|
||||
var entry = zip.getEntry("assets/ic_launcher-playstore.png");
|
||||
try (var is = zip.getInputStream(entry)) {
|
||||
return Icon.createWithAdaptiveBitmap(BitmapFactory.decodeStream(is));
|
||||
}
|
||||
try {
|
||||
return getIcon(R.mipmap.ic_launcher);
|
||||
} catch (Throwable e) {
|
||||
Log.e(TAG, "load icon", e);
|
||||
return getIcon(R.drawable.ic_launcher);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Icon getNotificationIcon() {
|
||||
return getIcon(R.drawable.ic_outline_extension_24);
|
||||
}
|
||||
|
||||
static Intent getManagerIntent() {
|
||||
|
|
@ -236,7 +243,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
|||
var notification = new Notification.Builder(context, CHANNEL_ID)
|
||||
.setContentTitle(title)
|
||||
.setContentText(content)
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setColor(Color.BLUE)
|
||||
.setContentIntent(getNotificationIntent(modulePackageName, moduleUserId))
|
||||
.setAutoCancel(true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue