Skip to content

Commit 3b435cc

Browse files
fix notification icon scaling?
1 parent d45d0c2 commit 3b435cc

File tree

8 files changed

+105
-60
lines changed

8 files changed

+105
-60
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/patches/CustomBrandingPatch.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,27 @@ public enum BrandingTheme {
4242
*/
4343
CUSTOM;
4444

45+
private final String alias;
46+
47+
BrandingTheme() {
48+
alias = name().toLowerCase(Locale.US);
49+
}
50+
4551
private String packageAndNameIndexToClassAlias(String packageName, int appIndex) {
4652
if (appIndex <= 0) {
4753
throw new IllegalArgumentException("App index starts at index 1");
4854
}
49-
return packageName + ".revanced_" + name().toLowerCase(Locale.US) + '_' + appIndex;
55+
return packageName + ".revanced_" + alias + '_' + appIndex;
56+
}
57+
58+
private int getNotificationIcon() {
59+
// Original icon is quantum_ic_video_youtube_white_24
60+
final int iconResource = Utils.getResourceIdentifier(
61+
"revanced_notification_icon_" + alias, "drawable");
62+
if (iconResource == 0) {
63+
Logger.printException(() -> "Could not load notification small icon");
64+
}
65+
return iconResource;
5066
}
5167
}
5268

@@ -57,16 +73,7 @@ private String packageAndNameIndexToClassAlias(String packageName, int appIndex)
5773
if (branding == BrandingTheme.ORIGINAL) {
5874
notificationSmallIcon = 0;
5975
} else {
60-
String fileName = "revanced_notification_icon_small";
61-
if (branding == BrandingTheme.CUSTOM) {
62-
fileName += "_custom";
63-
}
64-
65-
// Original icon is quantum_ic_video_youtube_white_24
66-
notificationSmallIcon = Utils.getResourceIdentifier(fileName, "mipmap");
67-
if (notificationSmallIcon == 0) {
68-
Logger.printException(() -> "Could not load notification small icon");
69-
}
76+
notificationSmallIcon = branding.getNotificationIcon();
7077
}
7178
}
7279

patches/src/main/kotlin/app/revanced/patches/shared/layout/branding/BaseCustomBrandingPatch.kt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ private const val LAUNCHER_RESOURCE_NAME_PREFIX = "revanced_launcher_"
5858
private const val LAUNCHER_ADAPTIVE_BACKGROUND_PREFIX = "revanced_adaptive_background_"
5959
private const val LAUNCHER_ADAPTIVE_FOREGROUND_PREFIX = "revanced_adaptive_foreground_"
6060
private const val LAUNCHER_ADAPTIVE_MONOCHROME_PREFIX = "revanced_adaptive_monochrome_"
61-
private const val NOTIFICATION_ICON_SMALL = "revanced_notification_icon_small"
61+
private const val NOTIFICATION_ICON_PREFIX = "revanced_notification_icon_"
6262

6363
private val USER_CUSTOM_ADAPTIVE_FILE_NAMES = arrayOf(
6464
"$LAUNCHER_ADAPTIVE_BACKGROUND_PREFIX$CUSTOM_USER_ICON_STYLE_NAME.png",
6565
"$LAUNCHER_ADAPTIVE_FOREGROUND_PREFIX$CUSTOM_USER_ICON_STYLE_NAME.png"
6666
)
6767

6868
private const val USER_CUSTOM_MONOCHROME_FILE_NAME = "$LAUNCHER_ADAPTIVE_MONOCHROME_PREFIX$CUSTOM_USER_ICON_STYLE_NAME.xml"
69-
private const val USER_CUSTOM_NOTIFICATION_ICON_FILE_NAME = "${NOTIFICATION_ICON_SMALL}_$CUSTOM_USER_ICON_STYLE_NAME.xml"
69+
private const val USER_CUSTOM_NOTIFICATION_ICON_FILE_NAME = "$NOTIFICATION_ICON_PREFIX$CUSTOM_USER_ICON_STYLE_NAME.xml"
7070

7171
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/shared/patches/CustomBrandingPatch;"
7272

@@ -209,7 +209,8 @@ internal fun baseCustomBrandingPatch(
209209
"drawable",
210210
"$LAUNCHER_ADAPTIVE_BACKGROUND_PREFIX$style.xml",
211211
"$LAUNCHER_ADAPTIVE_FOREGROUND_PREFIX$style.xml",
212-
"$LAUNCHER_ADAPTIVE_MONOCHROME_PREFIX$style.xml"
212+
"$LAUNCHER_ADAPTIVE_MONOCHROME_PREFIX$style.xml",
213+
"$NOTIFICATION_ICON_PREFIX$style.xml"
213214
),
214215
ResourceGroup(
215216
"mipmap-anydpi",
@@ -218,24 +219,17 @@ internal fun baseCustomBrandingPatch(
218219
)
219220
}
220221

222+
// Copy template user icon, because the aliases must be added even if no user icon is provided.
221223
copyResources(
222224
"custom-branding",
223-
// ReVanced notification icon (all preset styles use the same icon).
224-
ResourceGroup(
225-
"mipmap-anydpi",
226-
"$NOTIFICATION_ICON_SMALL.xml"
227-
),
228-
229-
// Copy template user icon, because the aliases must be added even if no user icon is provided.
230225
ResourceGroup(
231226
"drawable",
232227
USER_CUSTOM_MONOCHROME_FILE_NAME,
233-
228+
USER_CUSTOM_NOTIFICATION_ICON_FILE_NAME
234229
),
235230
ResourceGroup(
236231
"mipmap-anydpi",
237-
"$LAUNCHER_RESOURCE_NAME_PREFIX$CUSTOM_USER_ICON_STYLE_NAME.xml",
238-
USER_CUSTOM_NOTIFICATION_ICON_FILE_NAME
232+
"$LAUNCHER_RESOURCE_NAME_PREFIX$CUSTOM_USER_ICON_STYLE_NAME.xml"
239233
)
240234
)
241235

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Copyright 2024 ReVanced. Not licensed under GPL. See https://github.com/ReVanced/revanced-branding -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="256"
6+
android:viewportHeight="256">
7+
<group
8+
android:scaleX="0.95"
9+
android:scaleY="0.95"
10+
android:translateX="12"
11+
android:translateY="12">
12+
<path
13+
android:fillColor="#FF000000"
14+
android:pathData="M250.09,13.49C251.39,10.51 251.11,7.08 249.33,4.36C247.55,1.64 244.52,0 241.27,0L228.81,0C226.08,0 223.61,1.62 222.51,4.11C211.54,29.1 153.63,160.99 134.29,205.04C133.2,207.54 130.73,209.15 128,209.15C125.27,209.15 122.8,207.54 121.7,205.04C102.36,160.99 44.46,29.1 33.49,4.11C32.39,1.62 29.92,0 27.19,0L14.73,0C11.48,0 8.45,1.64 6.67,4.36C4.89,7.08 4.61,10.51 5.91,13.49C26.64,60.8 95.56,218.1 109.63,250.24C111.17,253.74 114.63,256 118.45,256L137.55,256C141.37,256 144.83,253.74 146.36,250.24C160.44,218.1 229.36,60.8 250.09,13.49Z" />
15+
<path
16+
android:fillColor="#FF000000"
17+
android:pathData="M135.14,123.87C133.67,126.43 130.94,128 128,128C125.05,128 122.33,126.43 120.85,123.87C105.89,97.97 71.44,38.28 56.48,12.37C55,9.82 55,6.68 56.48,4.12C57.95,1.57 60.68,-0 63.62,-0L192.37,-0C195.32,-0 198.04,1.57 199.52,4.12C200.99,6.68 200.99,9.82 199.52,12.37C184.56,38.28 150.1,97.97 135.14,123.87Z" />
18+
</group>
19+
</vector>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Copyright 2024 ReVanced. Not licensed under GPL. See https://github.com/ReVanced/revanced-branding -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="256"
6+
android:viewportHeight="256">
7+
<group
8+
android:scaleX="0.95"
9+
android:scaleY="0.95"
10+
android:translateX="12"
11+
android:translateY="12">
12+
<path
13+
android:fillColor="#FF000000"
14+
android:pathData="M250.09,13.49C251.39,10.51 251.11,7.08 249.33,4.36C247.55,1.64 244.52,0 241.27,0L228.81,0C226.08,0 223.61,1.62 222.51,4.11C211.54,29.1 153.63,160.99 134.29,205.04C133.2,207.54 130.73,209.15 128,209.15C125.27,209.15 122.8,207.54 121.7,205.04C102.36,160.99 44.46,29.1 33.49,4.11C32.39,1.62 29.92,0 27.19,0L14.73,0C11.48,0 8.45,1.64 6.67,4.36C4.89,7.08 4.61,10.51 5.91,13.49C26.64,60.8 95.56,218.1 109.63,250.24C111.17,253.74 114.63,256 118.45,256L137.55,256C141.37,256 144.83,253.74 146.36,250.24C160.44,218.1 229.36,60.8 250.09,13.49Z" />
15+
<path
16+
android:fillColor="#FF000000"
17+
android:pathData="M135.14,123.87C133.67,126.43 130.94,128 128,128C125.05,128 122.33,126.43 120.85,123.87C105.89,97.97 71.44,38.28 56.48,12.37C55,9.82 55,6.68 56.48,4.12C57.95,1.57 60.68,-0 63.62,-0L192.37,-0C195.32,-0 198.04,1.57 199.52,4.12C200.99,6.68 200.99,9.82 199.52,12.37C184.56,38.28 150.1,97.97 135.14,123.87Z" />
18+
</group>
19+
</vector>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Copyright 2024 ReVanced. Not licensed under GPL. See https://github.com/ReVanced/revanced-branding -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="800"
6+
android:viewportHeight="800">
7+
<group
8+
android:scaleX="0.95"
9+
android:scaleY="0.95"
10+
android:translateX="40"
11+
android:translateY="40">
12+
<path
13+
android:fillColor="#000000"
14+
android:fillType="evenOdd"
15+
android:pathData="M400,0c220.77,0 400,179.23 400,400c-0,220.77 -179.23,400 -400,400c-220.77,-0 -400,-179.23 -400,-400c0,-220.77 179.23,-400 400,-400ZM400,36c200.9,-0 364,163.1 364,364c0,200.9 -163.1,364 -364,364c-200.9,0 -364,-163.1 -364,-364c-0,-200.9 163.1,-364 364,-364Z" />
16+
<path
17+
android:fillColor="#000000"
18+
android:pathData="M538.74,269.87c1.48,-3.38 1.16,-7.28 -0.86,-10.37c-2.02,-3.09 -5.46,-4.95 -9.16,-4.95c-5.15,0 -10.44,0 -14.16,0c-3.1,0 -5.91,1.83 -7.15,4.67c-12.47,28.4 -78.27,178.27 -100.25,228.33c-1.25,2.84 -4.05,4.67 -7.15,4.67c-3.1,0 -5.91,-1.83 -7.15,-4.67c-21.98,-50.06 -87.78,-199.93 -100.25,-228.33c-1.25,-2.84 -4.05,-4.67 -7.15,-4.67c-3.73,0 -9.02,0 -14.16,0c-3.69,0 -7.14,1.86 -9.16,4.95c-2.02,3.09 -2.34,6.99 -0.86,10.37c23.56,53.77 101.87,232.52 117.87,269.03c1.74,3.98 5.67,6.55 10.02,6.55c6.29,-0 15.41,-0 21.7,-0c4.34,-0 8.27,-2.57 10.02,-6.55c16,-36.51 94.32,-215.27 117.87,-269.03Z" />
19+
<path
20+
android:fillColor="#000000"
21+
android:pathData="M408.12,395.31c-1.67,2.9 -4.77,4.69 -8.12,4.69c-3.35,-0 -6.44,-1.79 -8.12,-4.69c-17,-29.44 -56.16,-97.26 -73.15,-126.7c-1.67,-2.9 -1.67,-6.47 0,-9.38c1.67,-2.9 4.77,-4.69 8.12,-4.69c33.99,0 112.31,0 146.31,0c3.35,0 6.44,1.79 8.12,4.69c1.67,2.9 1.67,6.47 -0,9.38c-17,29.44 -56.16,97.26 -73.15,126.7Z" />
22+
</group>
23+
</vector>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Copyright 2024 ReVanced. Not licensed under GPL. See https://github.com/ReVanced/revanced-branding -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="256"
6+
android:viewportHeight="256">
7+
<group
8+
android:scaleX="0.95"
9+
android:scaleY="0.95"
10+
android:translateX="12"
11+
android:translateY="12">
12+
<path
13+
android:fillColor="#FF000000"
14+
android:pathData="M250.09,13.49C251.39,10.51 251.11,7.08 249.33,4.36C247.55,1.64 244.52,0 241.27,0L228.81,0C226.08,0 223.61,1.62 222.51,4.11C211.54,29.1 153.63,160.99 134.29,205.04C133.2,207.54 130.73,209.15 128,209.15C125.27,209.15 122.8,207.54 121.7,205.04C102.36,160.99 44.46,29.1 33.49,4.11C32.39,1.62 29.92,0 27.19,0L14.73,0C11.48,0 8.45,1.64 6.67,4.36C4.89,7.08 4.61,10.51 5.91,13.49C26.64,60.8 95.56,218.1 109.63,250.24C111.17,253.74 114.63,256 118.45,256L137.55,256C141.37,256 144.83,253.74 146.36,250.24C160.44,218.1 229.36,60.8 250.09,13.49Z" />
15+
<path
16+
android:fillColor="#FF000000"
17+
android:pathData="M135.14,123.87C133.67,126.43 130.94,128 128,128C125.05,128 122.33,126.43 120.85,123.87C105.89,97.97 71.44,38.28 56.48,12.37C55,9.82 55,6.68 56.48,4.12C57.95,1.57 60.68,-0 63.62,-0L192.37,-0C195.32,-0 198.04,1.57 199.52,4.12C200.99,6.68 200.99,9.82 199.52,12.37C184.56,38.28 150.1,97.97 135.14,123.87Z" />
18+
</group>
19+
</vector>

patches/src/main/resources/custom-branding/mipmap-anydpi/revanced_notification_icon_small.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

patches/src/main/resources/custom-branding/mipmap-anydpi/revanced_notification_icon_small_custom.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)