forked from cliuff/boundo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add market scheme AppInfoOwners, fix rect icons
- Market scheme includes Xiaomi and Huawei app stores - Change splash screen icon from adaptive shape to static circle to work around rect mask on MIUI and EMUI/HarmonyOS
- Loading branch information
Showing
9 changed files
with
213 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/kotlin/com/madness/collision/chief/ChiefContext.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2023 Clifford Liu | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.madness.collision.chief | ||
|
||
import android.content.Context | ||
import android.content.pm.ApplicationInfo | ||
import android.content.pm.PackageManager | ||
import com.madness.collision.main.MainApplication | ||
|
||
val chiefContext: Context get() = MainApplication.INSTANCE | ||
val chiefAppInfo: ApplicationInfo get() = chiefContext.applicationInfo | ||
val chiefPkgMan: PackageManager get() = chiefContext.packageManager |
81 changes: 81 additions & 0 deletions
81
app/src/main/kotlin/com/madness/collision/chief/graphics/AdaptiveIcon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2023 Clifford Liu | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.madness.collision.chief.graphics | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.res.Resources | ||
import android.graphics.Path | ||
import android.graphics.Rect | ||
import android.graphics.Region | ||
import android.graphics.RegionIterator | ||
import android.graphics.drawable.AdaptiveIconDrawable | ||
import android.graphics.drawable.Drawable | ||
import android.os.Build | ||
import android.util.Log | ||
import androidx.annotation.RequiresApi | ||
import androidx.compose.ui.graphics.asAndroidPath | ||
import androidx.compose.ui.graphics.vector.PathParser | ||
import com.madness.collision.chief.chiefContext | ||
import com.madness.collision.util.os.OsUtils | ||
|
||
object AdaptiveIcon { | ||
fun hasRectIconMask(drawable: Drawable): Boolean { | ||
val systemRect = when { | ||
OsUtils.satisfy(OsUtils.O) -> getSystemIconMask()?.let(::isFullRect) | ||
else -> null | ||
} | ||
val isRect = when { | ||
OsUtils.satisfy(OsUtils.O) && drawable is AdaptiveIconDrawable -> | ||
drawable.iconMask.let(::isFullRect) | ||
else -> null | ||
} | ||
Log.d("AdaptiveIcon", "hasRectIconMask/sysRect:$systemRect/hasRect:$isRect") | ||
return isRect == true | ||
} | ||
|
||
@SuppressLint("PrivateApi", "DiscouragedApi") | ||
@RequiresApi(Build.VERSION_CODES.O) | ||
private fun getSystemIconMask(): Path? { | ||
val maskId = Resources.getSystem() | ||
.getIdentifier("config_icon_mask", "string", "android") | ||
if (maskId <= 0) return null | ||
try { | ||
val pathData = chiefContext.getString(maskId) | ||
Log.d("AdaptiveIcon", "getIconMask/config_icon_mask[$pathData]") | ||
return PathParser().parsePathString(pathData).toPath().asAndroidPath() | ||
} catch (e: Resources.NotFoundException) { | ||
e.printStackTrace() | ||
} catch (e: UnsupportedOperationException) { | ||
e.printStackTrace() | ||
} | ||
return null | ||
} | ||
|
||
/** Whether the [path] is a rectangle covering 100% area */ | ||
private fun isFullRect(path: Path): Boolean { | ||
if (path.isEmpty || !path.isRect(null)) return false | ||
val clip = Region(0, 0, 100, 100) | ||
val region = Region().apply { setPath(path, clip) } | ||
val iterator = RegionIterator(region) | ||
val rect = Rect() | ||
var area = 0 | ||
while (iterator.next(rect)) { | ||
area += rect.width() * rect.height() | ||
} | ||
return area == 10000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters