Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
597 changes: 597 additions & 0 deletions core/data/schemas/zed.rainxch.core.data.local.db.AppDatabase/9.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import zed.rainxch.core.data.local.db.migrations.MIGRATION_4_5
import zed.rainxch.core.data.local.db.migrations.MIGRATION_5_6
import zed.rainxch.core.data.local.db.migrations.MIGRATION_6_7
import zed.rainxch.core.data.local.db.migrations.MIGRATION_7_8
import zed.rainxch.core.data.local.db.migrations.MIGRATION_8_9

fun initDatabase(context: Context): AppDatabase {
val appContext = context.applicationContext
Expand All @@ -27,5 +28,6 @@ fun initDatabase(context: Context): AppDatabase {
MIGRATION_5_6,
MIGRATION_6_7,
MIGRATION_7_8,
MIGRATION_8_9,
).build()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package zed.rainxch.core.data.local.db.migrations

import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase

val MIGRATION_8_9 =
object : Migration(8, 9) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL(
"ALTER TABLE installed_apps ADD COLUMN latestReleasePublishedAt TEXT",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import zed.rainxch.core.data.local.db.entities.UpdateHistoryEntity
SeenRepoEntity::class,
SearchHistoryEntity::class,
],
version = 8,
version = 9,
exportSchema = true,
)
abstract class AppDatabase : RoomDatabase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ interface InstalledAppDao {
releaseNotes = :releaseNotes,
lastCheckedAt = :timestamp,
latestVersionName = :latestVersionName,
latestVersionCode = :latestVersionCode
latestVersionCode = :latestVersionCode,
latestReleasePublishedAt = :latestReleasePublishedAt
WHERE packageName = :packageName
""",
)
Expand All @@ -67,6 +68,7 @@ interface InstalledAppDao {
timestamp: Long,
latestVersionName: String?,
latestVersionCode: Long?,
latestReleasePublishedAt: String?,
)

@Query("UPDATE installed_apps SET includePreReleases = :enabled WHERE packageName = :packageName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ data class InstalledAppEntity(
val installedVersionCode: Long = 0L,
val latestVersionName: String? = null,
val latestVersionCode: Long? = null,
val latestReleasePublishedAt: String? = null,
val includePreReleases: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun InstalledApp.toEntity(): InstalledAppEntity =
installedVersionCode = installedVersionCode,
latestVersionName = latestVersionName,
latestVersionCode = latestVersionCode,
latestReleasePublishedAt = latestReleasePublishedAt,
signingFingerprint = signingFingerprint,
includePreReleases = includePreReleases,
)
Expand Down Expand Up @@ -71,6 +72,7 @@ fun InstalledAppEntity.toDomain(): InstalledApp =
installedVersionCode = installedVersionCode,
latestVersionName = latestVersionName,
latestVersionCode = latestVersionCode,
latestReleasePublishedAt = latestReleasePublishedAt,
signingFingerprint = signingFingerprint,
includePreReleases = includePreReleases,
)
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class InstalledAppsRepositoryImpl(
timestamp = System.currentTimeMillis(),
latestVersionName = latestRelease.tagName,
latestVersionCode = null,
latestReleasePublishedAt = latestRelease.publishedAt,
)

return isUpdateAvailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ data class InstalledApp(
val installedVersionCode: Long = 0L,
val latestVersionName: String? = null,
val latestVersionCode: Long? = null,
val latestReleasePublishedAt: String? = null,
val includePreReleases: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<!-- Apps feature - Search -->
<string name="search_your_apps">Search your apps</string>
<string name="no_apps_found">No apps found</string>
<string name="sort_apps">Sort apps</string>
<string name="sort_updates_first">Updates first</string>


<!-- Apps feature - Actions -->
<string name="update_all">Update All</string>
Expand Down Expand Up @@ -155,7 +158,7 @@

<!-- Dialog -->
<string name="warning">Warning!</string>
<string name="logout_confirmation">Are you sure you want to logout?</string>
<string name="logout_confirmation">Are you sure you want to log out?</string>

<!-- Theme names -->
<string name="theme_dynamic">Dynamic</string>
Expand Down Expand Up @@ -258,7 +261,7 @@

<!-- External installer -->
<string name="install_permission_unavailable">Install permission unavailable</string>
<string name="install_permission_blocked_message">The APK was downloaded successfully but this device doesn\'t allow direct installation. Would you like to open it with an external installer?</string>
<string name="install_permission_blocked_message">The APK was downloaded successfully but this device doesn't allow direct installation. Would you like to open it with an external installer?</string>
<string name="open_with_external_installer">Open with external installer</string>
<string name="external_installer_description">Use a third-party app to install the APK</string>

Expand Down Expand Up @@ -626,4 +629,4 @@

<!-- Per-app pre-release toggle -->
<string name="pre_releases">Pre-releases</string>
</resources>
</resources>
1 change: 1 addition & 0 deletions feature/apps/presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ kotlin {
implementation(libs.liquid)

implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.datetime)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package zed.rainxch.apps.presentation.components

import android.content.pm.PackageManager.NameNotFoundException
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.core.graphics.drawable.toBitmap
import org.jetbrains.compose.resources.painterResource
import zed.rainxch.githubstore.core.presentation.res.Res
import zed.rainxch.githubstore.core.presentation.res.app_icon

@Composable
actual fun InstalledAppIcon(
packageName: String,
appName: String,
modifier: Modifier,
) {
val packageManager = LocalContext.current.packageManager
val iconBitmap =
remember(packageName, packageManager) {
try {
packageManager
.getApplicationIcon(packageName)
.toBitmap()
.asImageBitmap()
} catch (_: NameNotFoundException) {
null
}
}

if (iconBitmap != null) {
Image(
bitmap = iconBitmap,
contentDescription = appName,
modifier = modifier,
)
} else {
Image(
painter = painterResource(Res.drawable.app_icon),
contentDescription = appName,
modifier = modifier,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zed.rainxch.apps.presentation

import zed.rainxch.apps.presentation.model.InstalledAppUi
import zed.rainxch.apps.presentation.model.AppSortRule
import zed.rainxch.apps.presentation.model.DeviceAppUi
import zed.rainxch.apps.presentation.model.GithubAssetUi

Expand All @@ -12,6 +13,10 @@ sealed interface AppsAction {
val query: String,
) : AppsAction

data class OnSortRuleSelected(
val sortRule: AppSortRule,
) : AppsAction

data class OnOpenApp(
val app: InstalledAppUi,
) : AppsAction
Expand Down
Loading