Skip to content

Commit

Permalink
feat: Implement history page
Browse files Browse the repository at this point in the history
Change-Id: Idf9c8ee6e0c0f263cb1427ed25350e9973c2d5f2
  • Loading branch information
XayahSuSuSu committed Oct 20, 2024
1 parent 629dec3 commit e92baf3
Show file tree
Hide file tree
Showing 31 changed files with 720 additions and 49 deletions.
1 change: 1 addition & 0 deletions source/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ dependencies {
implementation(project(":feature:main:processing"))
implementation(project(":feature:main:list"))
implementation(project(":feature:main:details"))
implementation(project(":feature:main:history"))
implementation(project(":feature:main:packages"))
implementation(project(":feature:main:medium"))
implementation(project(":feature:main:directory"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import com.xayah.feature.main.configurations.PageConfigurations
import com.xayah.feature.main.dashboard.PageDashboard
import com.xayah.feature.main.details.DetailsRoute
import com.xayah.feature.main.directory.PageDirectory
import com.xayah.feature.main.history.HistoryRoute
import com.xayah.feature.main.history.TaskDetailsRoute
import com.xayah.feature.main.list.ListRoute
import com.xayah.feature.main.medium.backup.detail.PageMediumBackupDetail
import com.xayah.feature.main.medium.backup.list.PageMediumBackupList
Expand Down Expand Up @@ -110,6 +112,12 @@ class MainActivity : AppCompatActivity() {
composable(MainRoutes.Details.route) {
DetailsRoute()
}
composable(MainRoutes.History.route) {
HistoryRoute()
}
composable(MainRoutes.TaskDetails.route) {
TaskDetailsRoute()
}
composable(MainRoutes.PackagesBackupDetail.route) {
PagePackagesBackupDetail()
}
Expand Down
5 changes: 5 additions & 0 deletions source/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,9 @@
<string name="args_apps_restored_and_failed">已恢复%1$s个应用,%2$s个应用恢复失败</string>
<string name="args_files_backed_up_and_failed">已备份%1$s个文件,%2$s个文件备份失败</string>
<string name="args_files_restored_and_failed">已恢复%1$s个文件,%2$s个文件恢复失败</string>
<string name="history">历史</string>
<string name="args_backed_up_at">备份于%1$s</string>
<string name="args_restored_at">恢复于%1$s</string>
<string name="task_details">任务详情</string>
<string name="visit_details">查看详情</string>
</resources>
5 changes: 5 additions & 0 deletions source/app/src/main/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,9 @@
<string name="args_apps_restored_and_failed">已復原%1$s個應用,%2$s個應用復原失敗</string>
<string name="args_files_backed_up_and_failed">已備份%1$s個文件,%2$s個文件備份失敗</string>
<string name="args_files_restored_and_failed">已恢復%1$s個文件,%2$s個文件恢復失敗</string>
<string name="history">歷史</string>
<string name="args_backed_up_at">備份于%1$s</string>
<string name="args_restored_at">恢復于%1$s</string>
<string name="task_details">任務詳情</string>
<string name="visit_details">查看詳情</string>
</resources>
5 changes: 5 additions & 0 deletions source/app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,9 @@
<string name="args_apps_restored_and_failed">已復原%1$s個應用,%2$s個應用復原失敗</string>
<string name="args_files_backed_up_and_failed">已備份%1$s個文件,%2$s個文件備份失敗</string>
<string name="args_files_restored_and_failed">已恢復%1$s個文件,%2$s個文件恢復失敗</string>
<string name="history">歷史</string>
<string name="args_backed_up_at">備份于%1$s</string>
<string name="args_restored_at">恢復于%1$s</string>
<string name="task_details">任務詳情</string>
<string name="visit_details">查看詳情</string>
</resources>
5 changes: 5 additions & 0 deletions source/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,9 @@
<string name="args_apps_restored_and_failed">%1$s apps restored, %2$s failed</string>
<string name="args_files_backed_up_and_failed">%1$s files backed up, %2$s failed</string>
<string name="args_files_restored_and_failed">%1$s files restored, %2$s failed</string>
<string name="history">History</string>
<string name="args_backed_up_at">Backed up at %1$s</string>
<string name="args_restored_at">Restored at %1$s</string>
<string name="task_details">Task details</string>
<string name="visit_details">Visit details</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class TaskRepository @Inject constructor(
private val taskDao: TaskDao,
) {
fun queryTaskFlow(id: Long) = taskDao.queryTaskFlow(id)
fun queryTasksFlow() = taskDao.queryTasksFlow()

fun queryProcessingInfoFlow(taskId: Long, type: ProcessingType) = taskDao.queryProcessingInfoFlow(taskId, type)
fun queryProcessingInfoFlow(taskId: Long) = taskDao.queryProcessingInfoFlow(taskId)
fun queryPackageFlow(taskId: Long) = taskDao.queryPackageFlow(taskId)
fun queryMediaFlow(taskId: Long) = taskDao.queryMediaFlow(taskId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ interface TaskDao {
@Query("SELECT * FROM TaskEntity WHERE id = :id LIMIT 1")
fun queryTaskFlow(id: Long): Flow<TaskEntity?>

@Query("SELECT * FROM TaskEntity")
fun queryTasksFlow(): Flow<List<TaskEntity>>

@Query("SELECT * FROM ProcessingInfoEntity WHERE taskId = :taskId AND type = :type")
fun queryProcessingInfoFlow(taskId: Long, type: ProcessingType): Flow<List<ProcessingInfoEntity>>

@Query("SELECT * FROM ProcessingInfoEntity WHERE taskId = :taskId")
fun queryProcessingInfoFlow(taskId: Long): Flow<List<ProcessingInfoEntity>>

@Query("SELECT * FROM TaskDetailPackageEntity WHERE taskId = :taskId")
fun queryPackageFlow(taskId: Long): Flow<List<TaskDetailPackageEntity>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,35 @@ fun Clickable(
}
}

@ExperimentalAnimationApi
@Composable
fun Clickable(
enabled: Boolean = true,
title: String, value: String? = null,
desc: String? = null,
leadingIcon: @Composable (RowScope.() -> Unit)? = null,
trailingIcon: @Composable (RowScope.() -> Unit)? = null,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
content: @Composable (ColumnScope.() -> Unit)? = null,
onClick: () -> Unit = {}
) {
Clickable(enabled = enabled, desc = desc, onClick = onClick, indication = rememberRipple(), interactionSource = interactionSource) {
Row(modifier = Modifier.height(IntrinsicSize.Min), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(SizeTokens.Level16)) {
leadingIcon?.invoke(this)
Column(modifier = Modifier.weight(1f)) {
AnimatedTextContainer(targetState = title) { text ->
TitleLargeText(enabled = enabled, text = text, color = ThemedColorSchemeKeyTokens.OnSurface.value.withState(enabled), fontWeight = FontWeight.Normal)
}
if (value != null) AnimatedTextContainer(targetState = value) { text ->
TitleSmallText(enabled = enabled, text = text, color = ThemedColorSchemeKeyTokens.Outline.value.withState(enabled), fontWeight = FontWeight.Normal)
}
content?.invoke(this)
}
trailingIcon?.invoke(this)
}
}
}


@ExperimentalAnimationApi
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ sealed class MainRoutes(val route: String) {
fun getRoute(target: Target, opType: OpType, id: Long) = "main_details/${target}/${opType}/${id}"
}

data object History : MainRoutes(route = "main_history")
data object TaskDetails : MainRoutes(route = "main_task_details/{$ARG_ID}") {
fun getRoute(id: Long) = "main_task_details/${id}"
}

data object PackagesBackupList : MainRoutes(route = "main_packages_backup_list")
data object PackagesBackupDetail : MainRoutes(route = "main_packages_backup_detail/{$ARG_PACKAGE_NAME}/{$ARG_USER_ID}") {
fun getRoute(packageName: String, userId: Int) = "main_packages_backup_detail/${packageName}/${userId}"
Expand Down
21 changes: 21 additions & 0 deletions source/core/ui/src/main/kotlin/com/xayah/core/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,24 @@ val Red40 = Color(0xFF974067)
val Red30 = Color(0xFF7A294F)
val Red20 = Color(0xFF5D1138)
val Red10 = Color(0xFF3E0021)

val Pink90 = Color(0XFFFFDADC)
val Pink80 = Color(0XFFFFB2B9)
val Pink40 = Color(0XFF8F4952)
val Pink30 = Color(0XFF72333B)
val Pink20 = Color(0XFF561D26)
val Pink10 = Color(0XFF3B0712)

val Purple90 = Color(0XFFFFD5FF)
val Purple80 = Color(0XFFEAB5ED)
val Purple40 = Color(0XFF7B4E80)
val Purple30 = Color(0XFF613767)
val Purple20 = Color(0XFF48204E)
val Purple10 = Color(0XFF310938)

val Orange90 = Color(0XFFFFDDB8)
val Orange80 = Color(0XFFF8BB71)
val Orange40 = Color(0XFF825513)
val Orange30 = Color(0XFF653E00)
val Orange20 = Color(0XFF472A00)
val Orange10 = Color(0XFF2A1700)
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class ThemedColorScheme(
val blue: ColorFamily,
val green: ColorFamily,
val red: ColorFamily,
val pink: ColorFamily,
val purple: ColorFamily,
val orange: ColorFamily,
)

@Stable
Expand Down Expand Up @@ -144,6 +147,18 @@ fun ThemedColorScheme.fromToken(value: ThemedColorSchemeKeyTokens): Color {
ThemedColorSchemeKeyTokens.RedPrimaryContainer -> red.primaryContainer
ThemedColorSchemeKeyTokens.RedOnPrimaryContainer -> red.onPrimaryContainer
ThemedColorSchemeKeyTokens.RedL80D20 -> red.l80d20
ThemedColorSchemeKeyTokens.PinkPrimary -> pink.primary
ThemedColorSchemeKeyTokens.PinkPrimaryContainer -> pink.primaryContainer
ThemedColorSchemeKeyTokens.PinkOnPrimaryContainer -> pink.onPrimaryContainer
ThemedColorSchemeKeyTokens.PinkL80D20 -> pink.l80d20
ThemedColorSchemeKeyTokens.PurplePrimary -> purple.primary
ThemedColorSchemeKeyTokens.PurplePrimaryContainer -> purple.primaryContainer
ThemedColorSchemeKeyTokens.PurpleOnPrimaryContainer -> purple.onPrimaryContainer
ThemedColorSchemeKeyTokens.PurpleL80D20 -> purple.l80d20
ThemedColorSchemeKeyTokens.OrangePrimary -> orange.primary
ThemedColorSchemeKeyTokens.OrangePrimaryContainer -> orange.primaryContainer
ThemedColorSchemeKeyTokens.OrangeOnPrimaryContainer -> orange.onPrimaryContainer
ThemedColorSchemeKeyTokens.OrangeL80D20 -> orange.l80d20

ThemedColorSchemeKeyTokens.Transparent -> Color.Transparent
ThemedColorSchemeKeyTokens.Unspecified -> Color.Unspecified
Expand Down Expand Up @@ -271,6 +286,24 @@ fun lightThemedColorScheme(
Red10,
Red80,
),
pink = ColorFamily(
Pink40,
Pink90,
Pink10,
Pink80,
),
purple = ColorFamily(
Purple40,
Purple90,
Purple10,
Purple80,
),
orange = ColorFamily(
Orange40,
Orange90,
Orange10,
Orange80,
),
)

fun darkThemedColorScheme(
Expand Down Expand Up @@ -389,6 +422,24 @@ fun darkThemedColorScheme(
Red90,
Red20,
),
pink = ColorFamily(
Pink80,
Pink30,
Pink90,
Pink20,
),
purple = ColorFamily(
Purple80,
Purple30,
Purple90,
Purple20,
),
orange = ColorFamily(
Orange80,
Orange30,
Orange90,
Orange20,
),
)

internal val LocalThemedColorScheme = staticCompositionLocalOf { lightThemedColorScheme() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ enum class ThemedColorSchemeKeyTokens {
RedPrimaryContainer,
RedOnPrimaryContainer,
RedL80D20,
PinkPrimary,
PinkPrimaryContainer,
PinkOnPrimaryContainer,
PinkL80D20,
PurplePrimary,
PurplePrimaryContainer,
PurpleOnPrimaryContainer,
PurpleL80D20,
OrangePrimary,
OrangePrimaryContainer,
OrangeOnPrimaryContainer,
OrangeL80D20,

Transparent,
Unspecified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Cloud
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.rounded.KeyboardArrowRight
import androidx.compose.material.icons.rounded.ListAlt
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
Expand Down Expand Up @@ -187,9 +189,9 @@ fun PageDashboard() {
enabled = nullBackupDir.not(),
title = stringResource(id = R.string.cloud),
icon = Icons.Outlined.Cloud,
colorContainer = ThemedColorSchemeKeyTokens.PrimaryContainer,
colorL80D20 = ThemedColorSchemeKeyTokens.PrimaryL80D20,
onColorContainer = ThemedColorSchemeKeyTokens.OnPrimaryContainer,
colorContainer = ThemedColorSchemeKeyTokens.PurplePrimaryContainer,
colorL80D20 = ThemedColorSchemeKeyTokens.PurpleL80D20,
onColorContainer = ThemedColorSchemeKeyTokens.PurpleOnPrimaryContainer,
actionIcon = Icons.Rounded.KeyboardArrowRight
) {
navController.navigateSingle(MainRoutes.Cloud.route)
Expand All @@ -199,13 +201,26 @@ fun PageDashboard() {
enabled = nullBackupDir.not(),
title = stringResource(id = R.string.restore),
icon = ImageVector.vectorResource(id = R.drawable.ic_rounded_history),
colorContainer = ThemedColorSchemeKeyTokens.SecondaryContainer,
colorL80D20 = ThemedColorSchemeKeyTokens.SecondaryL80D20,
onColorContainer = ThemedColorSchemeKeyTokens.OnSecondaryContainer,
colorContainer = ThemedColorSchemeKeyTokens.OrangePrimaryContainer,
colorL80D20 = ThemedColorSchemeKeyTokens.OrangeL80D20,
onColorContainer = ThemedColorSchemeKeyTokens.OrangeOnPrimaryContainer,
actionIcon = Icons.Rounded.KeyboardArrowRight
) {
navController.navigateSingle(MainRoutes.Restore.route)
}
QuickActionsButton(
modifier = Modifier.weight(1f),
enabled = nullBackupDir.not(),
title = stringResource(R.string.history),
icon = Icons.Rounded.ListAlt,
colorContainer = ThemedColorSchemeKeyTokens.PinkPrimaryContainer,
colorL80D20 = ThemedColorSchemeKeyTokens.PinkL80D20,
onColorContainer = ThemedColorSchemeKeyTokens.PinkOnPrimaryContainer,
actionIcon = Icons.Rounded.KeyboardArrowRight
) {
navController.navigateSingle(MainRoutes.History.route)
}
Spacer(modifier = Modifier.weight(1f))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions source/feature/main/dashboard/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<item name="download" type="string" />
<item name="changelog" type="string" />
<item name="args_update_from" type="string" />
<item name="history" type="string" />

<item name="ic_rounded_package_2" type="drawable" />
<item name="ic_rounded_folder_open" type="drawable" />
Expand Down
1 change: 1 addition & 0 deletions source/feature/main/history/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
23 changes: 23 additions & 0 deletions source/feature/main/history/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
alias(libs.plugins.library.common)
alias(libs.plugins.library.hilt)
alias(libs.plugins.library.compose)
}

android {
namespace = "com.xayah.feature.main.history"
}

dependencies {
// Core
implementation(project(":core:common"))
implementation(project(":core:ui"))
implementation(project(":core:util"))
implementation(project(":core:model"))
implementation(project(":core:data"))
implementation(project(":core:hiddenapi"))
implementation(project(":core:rootservice"))

// Hilt navigation
implementation(libs.androidx.hilt.navigation.compose)
}
2 changes: 2 additions & 0 deletions source/feature/main/history/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Loading

0 comments on commit e92baf3

Please sign in to comment.