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
Binary file modified composeApp/release/baselineProfiles/0/composeApp-release.dm
Binary file not shown.
Binary file modified composeApp/release/baselineProfiles/1/composeApp-release.dm
Binary file not shown.
592 changes: 592 additions & 0 deletions core/data/schemas/zed.rainxch.core.data.local.db.AppDatabase/8.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import zed.rainxch.core.data.local.db.migrations.MIGRATION_2_3
import zed.rainxch.core.data.local.db.migrations.MIGRATION_3_4
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_7_8

fun initDatabase(context: Context): AppDatabase {
val appContext = context.applicationContext
Expand All @@ -23,5 +24,6 @@ fun initDatabase(context: Context): AppDatabase {
MIGRATION_3_4,
MIGRATION_4_5,
MIGRATION_5_6,
MIGRATION_7_8,
).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_7_8 =
object : Migration(7, 8) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL(
"ALTER TABLE installed_apps ADD COLUMN includePreReleases INTEGER NOT NULL DEFAULT 0",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ val coreModule =
historyDao = get(),
installer = get(),
httpClient = get(),
tweaksRepository = get(),
)
}

Expand Down
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 = 7,
version = 8,
exportSchema = true,
)
abstract class AppDatabase : RoomDatabase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ interface InstalledAppDao {
latestVersionCode: Long?,
)

@Query("UPDATE installed_apps SET includePreReleases = :enabled WHERE packageName = :packageName")
suspend fun updateIncludePreReleases(packageName: String, enabled: Boolean)

@Query("UPDATE installed_apps SET lastCheckedAt = :timestamp WHERE packageName = :packageName")
suspend fun updateLastChecked(
packageName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ data class InstalledAppEntity(
val installedVersionCode: Long = 0L,
val latestVersionName: String? = null,
val latestVersionCode: Long? = null,
val includePreReleases: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fun InstalledApp.toEntity(): InstalledAppEntity =
latestVersionName = latestVersionName,
latestVersionCode = latestVersionCode,
signingFingerprint = signingFingerprint,
includePreReleases = includePreReleases,
)

fun InstalledAppEntity.toDomain(): InstalledApp =
Expand Down Expand Up @@ -71,4 +72,5 @@ fun InstalledAppEntity.toDomain(): InstalledApp =
latestVersionName = latestVersionName,
latestVersionCode = latestVersionCode,
signingFingerprint = signingFingerprint,
includePreReleases = includePreReleases,
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import zed.rainxch.core.domain.model.GithubRelease
import zed.rainxch.core.domain.model.InstallSource
import zed.rainxch.core.domain.model.InstalledApp
import zed.rainxch.core.domain.repository.InstalledAppsRepository
import zed.rainxch.core.domain.repository.TweaksRepository
import zed.rainxch.core.domain.system.Installer

class InstalledAppsRepositoryImpl(
Expand All @@ -32,7 +31,6 @@ class InstalledAppsRepositoryImpl(
private val historyDao: UpdateHistoryDao,
private val installer: Installer,
private val httpClient: HttpClient,
private val tweaksRepository: TweaksRepository,
) : InstalledAppsRepository {
override suspend fun <R> executeInTransaction(block: suspend () -> R): R =
database.useWriterConnection { transactor ->
Expand Down Expand Up @@ -76,10 +74,9 @@ class InstalledAppsRepositoryImpl(
private suspend fun fetchLatestPublishedRelease(
owner: String,
repo: String,
includePreReleases: Boolean,
): GithubRelease? {
return try {
val includePreReleases = tweaksRepository.getIncludePreReleases().first()

val releases =
httpClient
.executeRequest<List<ReleaseNetwork>> {
Expand Down Expand Up @@ -112,6 +109,7 @@ class InstalledAppsRepositoryImpl(
fetchLatestPublishedRelease(
owner = app.repoOwner,
repo = app.repoName,
includePreReleases = app.includePreReleases,
)

if (latestRelease != null) {
Expand Down Expand Up @@ -241,6 +239,13 @@ class InstalledAppsRepositoryImpl(
installedAppsDao.updateApp(app.copy(isPendingInstall = isPending))
}

override suspend fun setIncludePreReleases(
packageName: String,
enabled: Boolean,
) {
installedAppsDao.updateIncludePreReleases(packageName, enabled)
}

private fun normalizeVersion(version: String): String = version.removePrefix("v").removePrefix("V").trim()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ data class InstalledApp(
val installedVersionCode: Long = 0L,
val latestVersionName: String? = null,
val latestVersionCode: Long? = null,
val includePreReleases: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ interface InstalledAppsRepository {
isPending: Boolean,
)

suspend fun setIncludePreReleases(
packageName: String,
enabled: Boolean,
)

suspend fun <R> executeInTransaction(block: suspend () -> R): R
}
Original file line number Diff line number Diff line change
Expand Up @@ -618,4 +618,8 @@
<string name="recent_searches">عمليات البحث الأخيرة</string>
<string name="clear_all_history">مسح الكل</string>
<string name="remove_search_history_item">إزالة</string>

<string name="bottom_nav_profile_tweaks">تعديلات</string>
<string name="tweaks_title">تعديلات</string>
<string name="pre_releases">إصدارات تجريبية</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -617,4 +617,8 @@
<string name="recent_searches">সাম্প্রতিক অনুসন্ধান</string>
<string name="clear_all_history">সব মুছুন</string>
<string name="remove_search_history_item">সরান</string>

<string name="bottom_nav_profile_tweaks">টুইকস</string>
<string name="tweaks_title">টুইকস</string>
<string name="pre_releases">প্রি-রিলিজ</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,8 @@
<string name="recent_searches">Búsquedas recientes</string>
<string name="clear_all_history">Borrar todo</string>
<string name="remove_search_history_item">Eliminar</string>

<string name="bottom_nav_profile_tweaks">Ajustes</string>
<string name="tweaks_title">Ajustes</string>
<string name="pre_releases">Pre-lanzamientos</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,8 @@
<string name="recent_searches">Recherches récentes</string>
<string name="clear_all_history">Tout effacer</string>
<string name="remove_search_history_item">Supprimer</string>

<string name="bottom_nav_profile_tweaks">Réglages</string>
<string name="tweaks_title">Réglages</string>
<string name="pre_releases">Pré-versions</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,8 @@
<string name="recent_searches">हाल की खोजें</string>
<string name="clear_all_history">सभी साफ करें</string>
<string name="remove_search_history_item">हटाएँ</string>

<string name="bottom_nav_profile_tweaks">ट्वीक्स</string>
<string name="tweaks_title">ट्वीक्स</string>
<string name="pre_releases">प्री-रिलीज़</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -617,4 +617,8 @@
<string name="recent_searches">Ricerche recenti</string>
<string name="clear_all_history">Cancella tutto</string>
<string name="remove_search_history_item">Rimuovi</string>

<string name="bottom_nav_profile_tweaks">Modifiche</string>
<string name="tweaks_title">Modifiche</string>
<string name="pre_releases">Pre-release</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,8 @@
<string name="recent_searches">最近の検索</string>
<string name="clear_all_history">すべてクリア</string>
<string name="remove_search_history_item">削除</string>

<string name="bottom_nav_profile_tweaks">調整</string>
<string name="tweaks_title">調整</string>
<string name="pre_releases">プレリリース</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,8 @@
<string name="recent_searches">최근 검색</string>
<string name="clear_all_history">모두 지우기</string>
<string name="remove_search_history_item">삭제</string>

<string name="bottom_nav_profile_tweaks">조정</string>
<string name="tweaks_title">조정</string>
<string name="pre_releases">프리릴리스</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,8 @@
<string name="recent_searches">Ostatnie wyszukiwania</string>
<string name="clear_all_history">Wyczyść wszystko</string>
<string name="remove_search_history_item">Usuń</string>

<string name="bottom_nav_profile_tweaks">Ustawienia</string>
<string name="tweaks_title">Ustawienia</string>
<string name="pre_releases">Wersje wstępne</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,8 @@
<string name="recent_searches">Недавние поиски</string>
<string name="clear_all_history">Очистить всё</string>
<string name="remove_search_history_item">Удалить</string>

<string name="bottom_nav_profile_tweaks">Настройки</string>
<string name="tweaks_title">Настройки</string>
<string name="pre_releases">Пре-релизы</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,8 @@
<string name="recent_searches">Son aramalar</string>
<string name="clear_all_history">Tümünü temizle</string>
<string name="remove_search_history_item">Kaldır</string>

<string name="bottom_nav_profile_tweaks">İnce Ayarlar</string>
<string name="tweaks_title">İnce Ayarlar</string>
<string name="pre_releases">Ön sürümler</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,8 @@
<string name="recent_searches">最近搜索</string>
<string name="clear_all_history">清除全部</string>
<string name="remove_search_history_item">移除</string>

<string name="bottom_nav_profile_tweaks">调整</string>
<string name="tweaks_title">调整</string>
<string name="pre_releases">预发布版本</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -623,4 +623,7 @@
<string name="remove_search_history_item">Remove</string>

<string name="tweaks_title">Tweaks</string>

<!-- Per-app pre-release toggle -->
<string name="pre_releases">Pre-releases</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ class AppsRepositoryImpl(
override suspend fun getLatestRelease(
owner: String,
repo: String,
includePreReleases: Boolean,
): GithubRelease? =
try {
val includePreReleases = tweaksRepository.getIncludePreReleases().first()

val releases =
httpClient
.executeRequest<List<ReleaseNetwork>> {
Expand Down Expand Up @@ -154,6 +153,7 @@ class AppsRepositoryImpl(
repoInfo: GithubRepoInfo,
) {
val now = Clock.System.now().toEpochMilliseconds()
val globalPreRelease = tweaksRepository.getIncludePreReleases().first()

val installedApp =
InstalledApp(
Expand Down Expand Up @@ -186,6 +186,7 @@ class AppsRepositoryImpl(
installedVersionName = deviceApp.versionName,
installedVersionCode = deviceApp.versionCode,
signingFingerprint = deviceApp.signingFingerprint,
includePreReleases = globalPreRelease,
)

appsRepository.saveInstalledApp(installedApp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface AppsRepository {
suspend fun getLatestRelease(
owner: String,
repo: String,
includePreReleases: Boolean = false,
): GithubRelease?

suspend fun getDeviceApps(): List<DeviceApp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ sealed interface AppsAction {
data class OnLinkAssetSelected(val asset: GithubAssetUi) : AppsAction
data object OnBackToEnterUrl : AppsAction

// Per-app pre-release toggle
data class OnTogglePreReleases(val packageName: String, val enabled: Boolean) : AppsAction

// Export/Import
data object OnExportApps : AppsAction
data object OnImportApps : AppsAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
Expand Down Expand Up @@ -108,6 +109,7 @@ import zed.rainxch.githubstore.core.presentation.res.last_checked_minutes_ago
import zed.rainxch.githubstore.core.presentation.res.no_apps_found
import zed.rainxch.githubstore.core.presentation.res.open
import zed.rainxch.githubstore.core.presentation.res.pending_install
import zed.rainxch.githubstore.core.presentation.res.pre_release_badge
import zed.rainxch.githubstore.core.presentation.res.search_your_apps
import zed.rainxch.githubstore.core.presentation.res.uninstall
import zed.rainxch.githubstore.core.presentation.res.update
Expand Down Expand Up @@ -448,6 +450,9 @@ fun AppsScreen(
onCancelClick = { onAction(AppsAction.OnCancelUpdate(appItem.installedApp.packageName)) },
onUninstallClick = { onAction(AppsAction.OnUninstallApp(appItem.installedApp)) },
onRepoClick = { onAction(AppsAction.OnNavigateToRepo(appItem.installedApp.repoId)) },
onTogglePreReleases = { enabled ->
onAction(AppsAction.OnTogglePreReleases(appItem.installedApp.packageName, enabled))
},
modifier =
Modifier
.then(
Expand Down Expand Up @@ -538,6 +543,7 @@ fun AppItemCard(
onCancelClick: () -> Unit,
onUninstallClick: () -> Unit,
onRepoClick: () -> Unit,
onTogglePreReleases: (Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
val app = appItem.installedApp
Expand Down Expand Up @@ -625,7 +631,25 @@ fun AppItemCard(
)
}

Spacer(Modifier.height(12.dp))
Spacer(Modifier.height(8.dp))

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = stringResource(Res.string.pre_release_badge),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Switch(
checked = app.includePreReleases,
onCheckedChange = onTogglePreReleases,
)
}

Spacer(Modifier.height(4.dp))

when (val state = appItem.updateState) {
is UpdateState.Downloading -> {
Expand Down
Loading