Skip to content

Commit

Permalink
refactor: compose ui (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
aistra0528 authored Dec 13, 2024
1 parent 959b325 commit 1edf05d
Show file tree
Hide file tree
Showing 59 changed files with 1,062 additions and 1,380 deletions.
11 changes: 10 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
}

android {
Expand Down Expand Up @@ -30,6 +31,7 @@ android {
release {
isMinifyEnabled = true
isShrinkResources = true
versionNameSuffix = ".$commitShort"
signingConfig = if (signingProps.exists()) {
val props = `java.util`.Properties().apply { load(signingProps.reader()) }
signingConfigs.create("release") {
Expand Down Expand Up @@ -66,6 +68,7 @@ android {
buildFeatures {
viewBinding = true
buildConfig = true
compose = true
}
dependenciesInfo {
includeInApk = false
Expand All @@ -74,6 +77,12 @@ android {
}

dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.material3)
implementation(libs.androidx.material.icons.extended)
implementation(libs.androidx.ui.tooling.preview)
debugImplementation(libs.androidx.ui.tooling)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.biometric.ktx)
implementation(libs.androidx.constraintlayout)
Expand All @@ -87,11 +96,11 @@ dependencies {
implementation(libs.pinyin4j)
implementation(libs.material)
implementation(libs.insetter)
implementation(libs.simplemenu.preference)
implementation(libs.shizuku.api)
implementation(libs.shizuku.provider)
implementation(libs.dhizuku.api)
implementation(libs.appiconloader)
implementation(libs.compose.preference)
implementation(libs.commons.text)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.hiddenapibypass)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleInstance"
android:theme="@style/Theme.Hail.Dialog">
android:theme="@style/Theme.Hail.Translucent">
<intent-filter>
<action android:name="android.intent.action.SHOW_APP_INFO"/>
<action android:name="${applicationId}.action.LAUNCH"/>
Expand Down
132 changes: 78 additions & 54 deletions app/src/main/kotlin/com/aistra/hail/app/HailData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,103 +23,127 @@ object HailData {
const val URL_PAYPAL = "https://www.paypal.me/aistra0528"
const val URL_TRANSLATE = "https://hosted.weblate.org/engage/hail/"
const val VERSION = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
private const val KEY_ID = "id"
const val KEY_TAG = "tag"
private const val KEY_PINNED = "pinned"
private const val KEY_WHITELISTED = "whitelisted"
const val KEY_PACKAGE = "package"
const val KEY_FROZEN = "frozen"
const val WORKING_MODE = "working_mode"
const val MODE_DEFAULT = "default"

private const val SORT_BY = "sort_by"
const val SORT_NAME = "name"
const val SORT_INSTALL = "install"
const val SORT_UPDATE = "update"
const val FILTER_USER_APPS = "filter_user_apps"
const val FILTER_SYSTEM_APPS = "filter_system_apps"
const val FILTER_FROZEN_APPS = "filter_frozen_apps"
const val FILTER_UNFROZEN_APPS = "filter_unfrozen_apps"
const val OWNER = "owner_"
const val DHIZUKU = "dhizuku_"
const val SU = "su_"
const val SHIZUKU = "shizuku_"
const val ISLAND = "island_"
const val PRIVAPP = "privapp_"

const val STOP = "stop"
const val DISABLE = "disable"
const val HIDE = "hide"
const val SUSPEND = "suspend"

const val MODE_OWNER_HIDE = OWNER + HIDE
const val MODE_OWNER_SUSPEND = OWNER + SUSPEND
const val MODE_DHIZUKU_HIDE = DHIZUKU + HIDE
const val MODE_DHIZUKU_SUSPEND = DHIZUKU + SUSPEND
const val MODE_SU_STOP = SU + STOP
const val MODE_SU_DISABLE = SU + DISABLE
const val MODE_SU_HIDE = SU + HIDE
const val MODE_SU_SUSPEND = SU + SUSPEND
const val WORKING_MODE = "working_mode"
const val MODE_DEFAULT = "default"
const val MODE_SHIZUKU_STOP = SHIZUKU + STOP
const val MODE_SHIZUKU_DISABLE = SHIZUKU + DISABLE
const val MODE_SHIZUKU_HIDE = SHIZUKU + HIDE
const val MODE_SHIZUKU_SUSPEND = SHIZUKU + SUSPEND
const val MODE_SU_STOP = SU + STOP
const val MODE_SU_DISABLE = SU + DISABLE
const val MODE_SU_HIDE = SU + HIDE
const val MODE_SU_SUSPEND = SU + SUSPEND
const val MODE_DHIZUKU_HIDE = DHIZUKU + HIDE
const val MODE_DHIZUKU_SUSPEND = DHIZUKU + SUSPEND
const val MODE_OWNER_HIDE = OWNER + HIDE
const val MODE_OWNER_SUSPEND = OWNER + SUSPEND
const val MODE_ISLAND_HIDE = ISLAND + HIDE
const val MODE_ISLAND_SUSPEND = ISLAND + SUSPEND
const val MODE_PRIVAPP_STOP = PRIVAPP + STOP
const val MODE_PRIVAPP_DISABLE = PRIVAPP + DISABLE

private const val TILE_ACTION = "tile_action"
private const val HOME_FONT_SIZE = "home_font_size"
const val DYNAMIC_SHORTCUT_ACTION = "dynamic_shortcut_action"
val WORKING_MODE_VALUES = listOf(
MODE_DEFAULT,
MODE_SHIZUKU_STOP,
MODE_SHIZUKU_DISABLE,
MODE_SHIZUKU_HIDE,
MODE_SHIZUKU_SUSPEND,
MODE_SU_STOP,
MODE_SU_DISABLE,
MODE_SU_HIDE,
MODE_SU_SUSPEND,
MODE_DHIZUKU_HIDE,
MODE_DHIZUKU_SUSPEND,
MODE_OWNER_HIDE,
MODE_OWNER_SUSPEND,
MODE_ISLAND_HIDE,
MODE_ISLAND_SUSPEND,
MODE_PRIVAPP_STOP,
MODE_PRIVAPP_DISABLE
)
const val BIOMETRIC_LOGIN = "biometric_login"
const val APP_THEME = "app_theme"
const val FOLLOW_SYSTEM = "follow_system"
const val THEME_LIGHT = "theme_light"
const val THEME_DARK = "theme_dark"
val APP_THEME_VALUES = listOf(FOLLOW_SYSTEM, THEME_LIGHT, THEME_DARK)
const val ICON_PACK = "icon_pack"
const val GRAYSCALE_ICON = "grayscale_icon"
const val COMPACT_ICON = "compact_icon"
const val SYNTHESIZE_ADAPTIVE_ICONS = "synthesize_adaptive_icons"
const val HOME_FONT_SIZE = "home_font_size_f"
const val FUZZY_SEARCH = "fuzzy_search"
const val NINE_KEY_SEARCH = "nine_key"
const val TILE_ACTION = "tile_action"
const val ACTION_NONE = "none"
const val ACTION_FREEZE_ALL = "freeze_all"
const val ACTION_UNFREEZE_ALL = "unfreeze_all"
const val ACTION_FREEZE_NON_WHITELISTED = "freeze_non_whitelisted"
const val ACTION_LOCK = "lock"
const val ACTION_LOCK_FREEZE = "lock_freeze"
private const val SORT_BY = "sort_by"
const val SORT_NAME = "name"
const val SORT_INSTALL = "install"
const val SORT_UPDATE = "update"
private const val KEY_ID = "id"
const val KEY_TAG = "tag"
private const val KEY_PINNED = "pinned"
private const val KEY_WHITELISTED = "whitelisted"
const val FILTER_USER_APPS = "filter_user_apps"
const val FILTER_SYSTEM_APPS = "filter_system_apps"
const val FILTER_FROZEN_APPS = "filter_frozen_apps"
const val FILTER_UNFROZEN_APPS = "filter_unfrozen_apps"
private const val BIOMETRIC_LOGIN = "biometric_login"
private const val FUZZY_SEARCH = "fuzzy_search"
private const val NINE_KEY_SEARCH = "nine_key"
const val APP_THEME = "app_theme"
private const val FOLLOW_SYSTEM = "follow_system"
const val THEME_LIGHT = "theme_light"
const val THEME_DARK = "theme_dark"
const val ICON_PACK = "icon_pack"
private const val GRAYSCALE_ICON = "grayscale_icon"
private const val COMPACT_ICON = "compact_icon"
private const val SYNTHESIZE_ADAPTIVE_ICONS = "synthesize_adaptive_icons"
val TILE_ACTION_VALUES =
listOf(ACTION_FREEZE_ALL, ACTION_UNFREEZE_ALL, ACTION_FREEZE_NON_WHITELISTED, ACTION_LOCK, ACTION_LOCK_FREEZE)
const val AUTO_FREEZE_AFTER_LOCK = "auto_freeze_after_lock"
private const val SKIP_WHILE_CHARGING = "skip_while_charging"
const val AUTO_FREEZE_DELAY = "auto_freeze_delay_f"
const val SKIP_WHILE_CHARGING = "skip_while_charging"
const val SKIP_FOREGROUND_APP = "skip_foreground_app"
const val SKIP_NOTIFYING_APP = "skip_notifying_app"
private const val AUTO_FREEZE_DELAY = "auto_freeze_delay"
const val DYNAMIC_SHORTCUT_ACTION = "dynamic_shortcut_action"
val DYNAMIC_SHORTCUT_ACTIONS = listOf(
ACTION_NONE,
ACTION_FREEZE_ALL,
ACTION_UNFREEZE_ALL,
ACTION_FREEZE_NON_WHITELISTED,
ACTION_LOCK,
ACTION_LOCK_FREEZE
)

private val sp = PreferenceManager.getDefaultSharedPreferences(app)
val workingMode get() = sp.getString(WORKING_MODE, MODE_DEFAULT)!!
val sortBy get() = sp.getString(SORT_BY, SORT_NAME)
val filterUserApps get() = sp.getBoolean(FILTER_USER_APPS, true)
val filterSystemApps get() = sp.getBoolean(FILTER_SYSTEM_APPS, false)
val filterFrozenApps get() = sp.getBoolean(FILTER_FROZEN_APPS, true)
val filterUnfrozenApps get() = sp.getBoolean(FILTER_UNFROZEN_APPS, true)
val workingMode get() = sp.getString(WORKING_MODE, MODE_DEFAULT)!!
val biometricLogin get() = sp.getBoolean(BIOMETRIC_LOGIN, false)
val appTheme get() = sp.getString(APP_THEME, FOLLOW_SYSTEM)!!
val iconPack get() = sp.getString(ICON_PACK, ACTION_NONE)!!
val grayscaleIcon get() = sp.getBoolean(GRAYSCALE_ICON, true)
val compactIcon get() = sp.getBoolean(COMPACT_ICON, false)
val tileAction get() = sp.getString(TILE_ACTION, ACTION_FREEZE_ALL)
val homeFontSize get() = sp.getInt(HOME_FONT_SIZE, 14)
val dynamicShortcutAction get() = sp.getString(DYNAMIC_SHORTCUT_ACTION, ACTION_NONE)!!
val synthesizeAdaptiveIcons get() = sp.getBoolean(SYNTHESIZE_ADAPTIVE_ICONS, false)
val homeFontSize get() = sp.getFloat(HOME_FONT_SIZE, 14f)
val fuzzySearch get() = sp.getBoolean(FUZZY_SEARCH, false)
val nineKeySearch get() = sp.getBoolean(NINE_KEY_SEARCH, false)
val tileAction get() = sp.getString(TILE_ACTION, ACTION_FREEZE_ALL)
val autoFreezeAfterLock get() = sp.getBoolean(AUTO_FREEZE_AFTER_LOCK, false)
val autoFreezeDelay get() = sp.getFloat(AUTO_FREEZE_DELAY, 0f).toLong()
val skipWhileCharging get() = sp.getBoolean(SKIP_WHILE_CHARGING, false)
val skipForegroundApp get() = sp.getBoolean(SKIP_FOREGROUND_APP, false)
val skipNotifyingApp get() = sp.getBoolean(SKIP_NOTIFYING_APP, false)
val autoFreezeDelay get() = sp.getInt(AUTO_FREEZE_DELAY, 0).toLong()

val fuzzySearch get() = sp.getBoolean(FUZZY_SEARCH, false)
val nineKeySearch get() = sp.getBoolean(NINE_KEY_SEARCH, false)

val appTheme get() = sp.getString(APP_THEME, FOLLOW_SYSTEM)!!
val iconPack get() = sp.getString(ICON_PACK, ACTION_NONE)!!
fun setIconPack(packageName: String) = sp.edit().putString(ICON_PACK, packageName).apply()
val dynamicShortcutAction get() = sp.getString(DYNAMIC_SHORTCUT_ACTION, ACTION_NONE)!!

private val dir = "${app.filesDir.path}/v1"
private val appsPath = "$dir/apps.json"
Expand Down
Loading

0 comments on commit 1edf05d

Please sign in to comment.