Skip to content

Commit

Permalink
improve: predictable color patterns for installers
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Jan 2, 2025
1 parent c84218f commit a52a73d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .idea/dictionaries/Hamza.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 13 additions & 23 deletions app/src/main/java/app/simple/inure/constants/InstallerColors.kt
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
package app.simple.inure.constants

/**
* If you are developer who maintains apps that installs apps and acts as a
* source for them as well, you can add your signature colors here. Or open an
* issue for that.
*/
object InstallerColors {

const val UNKNOWN = 0xFF6D7291.toInt()

private val colors: ArrayList<Int> by lazy {
arrayListOf(
0xFFEA4335.toInt(), // Play Store
0xFFFFB401.toInt(), // Aurora Store
0xFF217AD3.toInt(), // F-Droid
0xFFFFA967.toInt(), // Inure
0xFF4CAF50.toInt(), // APKMirror
0xFF9E9E9E.toInt(), // System
0xFF673AB7.toInt(), // Aptoide
0xFF00C4F7.toInt(), // Amazon Appstore
0xFF2196F3.toInt(), // APKPure
0xFF3F51B5.toInt(), // Samsung Galaxy Store
0xFFF65C5B.toInt(), // Huawei AppGallery
0xFFE91E63.toInt(), // SlideME
)
}

private val colorMap = mapOf(
"com.android.vending" to 0xFFEA4335.toInt(),
"com.google.android.packageinstaller" to 0xFFEA4335.toInt(),
"com.aurora.store" to 0xFFFFB401.toInt(),
"org.fdroid.fdroid" to 0xFF217AD3.toInt(),
"app.simple.inure" to 0xFFFFA967.toInt(),
"app.simple.inure.debug" to 0xFFFFA967.toInt(),
"app.simple.inure.beta" to 0xFFFFA967.toInt(),
"app.simple.inure.play" to 0xFFFFA967.toInt(),
"com.apkmirror" to 0xFF4CAF50.toInt(),
"android" to 0xFF9E9E9E.toInt(),
"system" to 0xFF9E9E9E.toInt(),
"com.android.shell" to 0xFF9E9E9E.toInt(),
"com.aptoide.pt" to 0xFF673AB7.toInt(),
Expand All @@ -38,12 +28,12 @@ object InstallerColors {
"com.slideme.sam.manager" to 0xFFE91E63.toInt(),
"com.xiaomi.market" to 0xFFE173E5.toInt(),
"com.xiaomi.discover" to 0xFF3B56E5.toInt(),
"com.uptodown" to 0xFFE5E53B.toInt(),
"com.getjar.rewards" to 0xFF3BE5E5.toInt(),
"com.opera.app.discover" to 0xFF3BE53B.toInt(),
"com.opera.app.market" to 0xFFE53B3B.toInt(),
)

fun getInstallerColors(): ArrayList<Int> {
return colors
}

fun getInstallerColorMap(): Map<String, Int> {
return colorMap
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.lifecycle.viewModelScope
import app.simple.inure.R
import app.simple.inure.apk.utils.PackageUtils.getInstallerPackageName
import app.simple.inure.apk.utils.PackageUtils.safeApplicationInfo
import app.simple.inure.constants.Colors
import app.simple.inure.constants.InstallerColors
import app.simple.inure.extensions.viewmodels.PackageUtilsViewModel
import app.simple.inure.preferences.AnalyticsPreferences
Expand Down Expand Up @@ -162,7 +163,8 @@ class AnalyticsViewModel(application: Application) : PackageUtilsViewModel(appli
}

installers.keys.distinct().forEach { packageName ->
colors.add(InstallerColors.getInstallerColorMap()[packageName] ?: InstallerColors.UNKNOWN)
colors.add(InstallerColors.getInstallerColorMap()[packageName]
?: Colors.getRetroColor()[installers.keys.distinct().indexOf(packageName)])
labels[packageName] = kotlin.runCatching {
packageManager.getApplicationLabel(packageManager.getApplicationInfo(packageName)!!).toString()
}.getOrElse {
Expand Down

0 comments on commit a52a73d

Please sign in to comment.