Skip to content

Commit 2d687d6

Browse files
Merge pull request #1175 from session-foundation/fix/huawei-app-disguise
fixed builds that don't support adaptive icons
2 parents 2227076 + 86ff5e6 commit 2d687d6

File tree

10 files changed

+22
-15
lines changed

10 files changed

+22
-15
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
<activity-alias
226226
android:name=".RoutingActivity"
227227
android:exported="true"
228+
android:icon="@mipmap/ic_launcher"
228229
android:targetActivity="org.thoughtcrime.securesms.home.HomeActivity">
229230
<intent-filter>
230231
<action android:name="android.intent.action.MAIN" />
15.6 KB
Loading

app/src/main/java/org/thoughtcrime/securesms/preferences/appearance/AppDisguiseSettings.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import androidx.compose.ui.Alignment
2525
import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.draw.drawWithContent
2727
import androidx.compose.ui.geometry.Offset
28+
import androidx.compose.ui.geometry.Rect
29+
import androidx.compose.ui.graphics.Path
2830
import androidx.compose.ui.graphics.asComposePath
2931
import androidx.compose.ui.graphics.asImageBitmap
3032
import androidx.compose.ui.graphics.drawscope.Stroke
@@ -196,10 +198,16 @@ private fun IconItem(
196198
val resources = LocalContext.current.resources
197199
val theme = LocalContext.current.theme
198200

199-
val (path, bitmap) = remember(icon, resources, theme) {
200-
val drawable =
201-
ResourcesCompat.getDrawable(resources, icon, theme) as AdaptiveIconDrawable
202-
drawable.iconMask.asComposePath() to drawable.toBitmap().asImageBitmap()
201+
val (path: Path, bitmap) = remember(icon, resources, theme) {
202+
val drawable = ResourcesCompat.getDrawable(resources, icon, theme)
203+
204+
when(drawable){
205+
is AdaptiveIconDrawable -> drawable.iconMask.asComposePath() to drawable.toBitmap().asImageBitmap()
206+
else -> { // if the system does not support adaptive icons (like Huawei phones) default to a rectangle shape
207+
val bmp = drawable!!.toBitmap()
208+
Path().apply { addRect(Rect(0f, 0f, bmp.width.toFloat(), bmp.height.toFloat())) } to bmp.asImageBitmap()
209+
}
210+
}
203211
}
204212

205213
val textColor = LocalColors.current.text
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<vector xmlns:android="http://schemas.android.com/apk/res/android"
22
android:width="108dp"
33
android:height="108dp"
4-
android:viewportWidth="1018.39685"
5-
android:viewportHeight="1019.1061">
6-
<group android:translateX="307.15576"
7-
android:translateY="285.3497">
8-
<group>
9-
<clip-path android:pathData="M0,0L404.085,0L404.085,448.407L0,448.407Z M 0,0"/>
10-
<path android:fillAlpha="1" android:fillColor="#00f782"
11-
android:fillType="nonZero"
12-
android:pathData="m288.607,420.376l-196.335,-0c-33.576,-0 -62.508,-25.748 -64.164,-59.281 -1.771,-35.847 26.883,-65.576 62.353,-65.576l113.072,-0c6.919,-0 12.527,-5.608 12.527,-12.525l0,-92.305L327.307,252.333C356.723,268.633 375.241,299.335 376.027,332.848 377.161,380.975 336.746,420.376 288.607,420.376m-211.829,-224.303c-29.416,-16.3 -47.933,-47.001 -48.721,-80.515 -1.132,-48.127 39.283,-87.528 87.42,-87.528L311.811,28.031c33.576,-0 62.508,25.748 64.165,59.283 1.771,35.845 -26.883,65.575 -62.352,65.575 0,-0 -81.316,0.013 -113.077,0.019 -6.915,0.001 -12.499,5.608 -12.501,12.523l-0.021,92.289zM340.891,227.816 L256.254,180.919l57.371,-0c49.877,-0 90.46,-40.579 90.46,-90.457 0,-49.877 -40.583,-90.461 -90.46,-90.461l-200.299,-0c-62.485,-0 -113.327,50.841 -113.327,113.327 0,44.567 24.216,85.664 63.195,107.265l84.636,46.896l-57.368,-0c-49.88,-0 -90.463,40.58 -90.463,90.457 0,49.877 40.583,90.461 90.463,90.461L290.758,448.407c62.488,-0 113.327,-50.84 113.327,-113.327 0,-44.567 -24.216,-85.664 -63.193,-107.264" android:strokeColor="#00000000"/>
13-
</group>
4+
android:viewportWidth="68"
5+
android:viewportHeight="69">
6+
<group android:scaleX="0.49275362"
7+
android:scaleY="0.5"
8+
android:translateX="17.246376"
9+
android:translateY="17.25">
10+
<path
11+
android:pathData="M50.375,34.804L40.432,29.115H47.172C49.99,29.115 52.694,27.959 54.687,25.901C56.68,23.843 57.8,21.052 57.8,18.141C57.8,15.23 56.68,12.439 54.687,10.381C52.694,8.323 49.99,7.166 47.172,7.166H23.638C20.108,7.171 16.724,8.62 14.228,11.198C11.732,13.775 10.328,17.27 10.324,20.915C10.325,23.571 11.015,26.179 12.322,28.467C13.629,30.755 15.505,32.641 17.755,33.928L27.701,39.618H20.952C19.546,39.601 18.151,39.872 16.847,40.416C15.543,40.96 14.357,41.766 13.357,42.786C12.357,43.807 11.563,45.023 11.021,46.362C10.479,47.702 10.2,49.14 10.2,50.592C10.2,52.044 10.479,53.481 11.021,54.821C11.563,56.161 12.357,57.376 13.357,58.397C14.357,59.418 15.543,60.223 16.847,60.767C18.151,61.311 19.546,61.582 20.952,61.565H44.485C48.015,61.562 51.4,60.112 53.896,57.534C56.392,54.957 57.796,51.462 57.8,47.817C57.799,45.161 57.111,42.554 55.805,40.266C54.5,37.978 52.625,36.092 50.375,34.804ZM19.344,30.954C17.648,29.982 16.227,28.57 15.223,26.856C14.219,25.142 13.667,23.187 13.621,21.185C13.487,15.346 18.236,10.567 23.891,10.567H46.959C50.905,10.567 54.303,13.685 54.498,17.759C54.547,18.784 54.394,19.809 54.048,20.771C53.702,21.734 53.17,22.613 52.485,23.357C51.8,24.101 50.976,24.693 50.063,25.098C49.149,25.503 48.166,25.713 47.172,25.714H33.887C33.498,25.716 33.125,25.877 32.85,26.162C32.576,26.448 32.422,26.833 32.423,27.236V38.431L19.344,30.954ZM44.232,58.165H21.165C17.22,58.165 13.821,55.047 13.627,50.974C13.578,49.949 13.731,48.924 14.077,47.962C14.422,47 14.954,46.12 15.639,45.376C16.324,44.632 17.148,44.039 18.061,43.634C18.975,43.229 19.958,43.019 20.952,43.018H34.238C34.431,43.018 34.623,42.979 34.801,42.902C34.98,42.826 35.142,42.714 35.279,42.573C35.415,42.431 35.524,42.264 35.597,42.079C35.671,41.895 35.709,41.697 35.709,41.498V30.3L48.779,37.778C50.477,38.75 51.899,40.164 52.903,41.879C53.907,43.594 54.459,45.551 54.504,47.554C54.638,53.385 49.889,58.165 44.232,58.165Z"
12+
android:fillColor="#31F196"/>
1413
</group>
1514
</vector>

app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
33
<background android:drawable="@color/ic_launcher_background"/>
44
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5-
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
65
</adaptive-icon>
-1.76 KB
Binary file not shown.
-1.27 KB
Binary file not shown.
-2.5 KB
Binary file not shown.
-3.79 KB
Binary file not shown.
-5.32 KB
Binary file not shown.

0 commit comments

Comments
 (0)