Skip to content

Commit

Permalink
[fix|build] Fix Add screen bugs; update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Oct 4, 2024
1 parent 9afd8c9 commit 2d56000
Show file tree
Hide file tree
Showing 14 changed files with 567 additions and 406 deletions.
22 changes: 11 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 67
versionName = "2.3-alpha06"
versionName = "2.3-alpha07"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -147,27 +147,27 @@ tasks.withType(KotlinCompile::class.java).configureEach {

dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.compose.ui:ui:1.7.0")
implementation("androidx.compose.ui:ui:1.7.3")
implementation("androidx.compose.material3:material3:1.3.0")
implementation("androidx.compose.material3:material3-window-size-class:1.3.0")
implementation("androidx.compose.material:material:1.7.0")
implementation("androidx.compose.material:material-icons-extended:1.7.0")
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0")
implementation("androidx.compose.material:material:1.7.3")
implementation("androidx.compose.material:material-icons-extended:1.7.3")
implementation("androidx.compose.ui:ui-tooling-preview:1.7.3")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.5")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.5")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.6")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
implementation("androidx.activity:activity-compose:1.9.2")
implementation("androidx.palette:palette-ktx:1.0.0")
implementation("com.google.dagger:hilt-android:2.52")
ksp("com.google.dagger:hilt-android-compiler:2.52")
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
implementation("androidx.navigation:navigation-compose:2.8.0")
implementation("androidx.navigation:navigation-compose:2.8.2")
implementation("androidx.security:security-crypto:1.1.0-alpha06")
implementation("com.google.accompanist:accompanist-drawablepainter:0.36.0")
implementation("io.coil-kt:coil-compose:2.7.0")
implementation("io.coil-kt:coil-gif:2.7.0")
implementation("io.coil-kt:coil-svg:2.7.0")
implementation("androidx.profileinstaller:profileinstaller:1.3.1")
implementation("androidx.profileinstaller:profileinstaller:1.4.1")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.room:room-runtime:2.6.1")
implementation("androidx.room:room-ktx:2.6.1")
Expand Down Expand Up @@ -195,6 +195,6 @@ dependencies {

implementation("com.github.penfeizhou.android.animation:apng:3.0.1")

debugImplementation("androidx.compose.ui:ui-tooling:1.7.0")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0")
debugImplementation("androidx.compose.ui:ui-tooling:1.7.3")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.3")
}
30 changes: 30 additions & 0 deletions app/src/main/java/com/skyd/rays/base/BaseComposeActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.skyd.rays.base

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import com.skyd.rays.model.preference.SettingsProvider
import com.skyd.rays.ui.local.LocalDarkMode
import com.skyd.rays.ui.local.LocalWindowSizeClass
import com.skyd.rays.ui.theme.RaysTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
open class BaseComposeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
}

fun setContentBase(content: @Composable () -> Unit) = setContent {
CompositionLocalProvider(
LocalWindowSizeClass provides calculateWindowSizeClass(this@BaseComposeActivity)
) {
SettingsProvider { RaysTheme(darkTheme = LocalDarkMode.current, content) }
}
}
}
23 changes: 3 additions & 20 deletions app/src/main/java/com/skyd/rays/ext/NavExt.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.skyd.rays.ext

import android.os.Bundle
import androidx.core.net.toUri
import androidx.lifecycle.Lifecycle
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import androidx.navigation.NavDeepLinkRequest
import androidx.navigation.NavDestination
import androidx.navigation.NavOptions
import androidx.navigation.Navigator

Expand All @@ -16,23 +13,9 @@ fun NavController.navigate(
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
) {
val routeLink = NavDeepLinkRequest
.Builder
.fromUri(NavDestination.createRoute(route).toUri())
.build()

val deepLinkMatch = graph.matchDeepLink(routeLink)
if (deepLinkMatch != null) {
val destination = deepLinkMatch.destination
val id = destination.id
navigate(
id,
args.apply { putAll(deepLinkMatch.matchingArgs ?: Bundle()) },
navOptions,
navigatorExtras
)
} else {
navigate(route, navOptions, navigatorExtras)
val nodeId = graph.findNode(route = route)?.id
if (nodeId != null) {
navigate(nodeId, args, navOptions, navigatorExtras)
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/skyd/rays/model/bean/StickerBean.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ data class StickerBean(
constructor(
title: String,
createTime: Long = System.currentTimeMillis(),
uuid: String = UUID.randomUUID().toString(),
) : this(
uuid = UUID.randomUUID().toString(),
uuid = uuid,
title = title,
stickerMd5 = "",
clickCount = 0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class AddRepository @Inject constructor(
emit(stickerDao.getStickerWithTags(uuidGotByMd5)!!)
} else {
stickerWithTags.sticker.stickerMd5 = stickerMd5
if (stickerWithTags.sticker.createTime == 0L) {
stickerWithTags.sticker.createTime = System.currentTimeMillis()
}
val uuid = stickerDao.addStickerWithTags(stickerWithTags)
if (!tempFile.renameTo(File(appContext.STICKER_DIR, uuid))) {
tempFile.deleteRecursively()
Expand Down
31 changes: 7 additions & 24 deletions app/src/main/java/com/skyd/rays/ui/activity/CrashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -29,9 +26,7 @@ import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
Expand All @@ -42,20 +37,17 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import com.skyd.rays.R
import com.skyd.rays.base.BaseComposeActivity
import com.skyd.rays.config.GITHUB_NEW_ISSUE_URL
import com.skyd.rays.ext.showSnackbar
import com.skyd.rays.model.preference.SettingsProvider
import com.skyd.rays.ui.local.LocalDarkMode
import com.skyd.rays.ui.local.LocalWindowSizeClass
import com.skyd.rays.ui.theme.RaysTheme
import com.skyd.rays.util.CommonUtil.getAppVersionCode
import com.skyd.rays.util.CommonUtil.getAppVersionName
import com.skyd.rays.util.CommonUtil.openBrowser

/**
* CrashActivity
*/
class CrashActivity : ComponentActivity() {
class CrashActivity : BaseComposeActivity() {
companion object {
const val CRASH_INFO = "crashInfo"

Expand All @@ -68,7 +60,6 @@ class CrashActivity : ComponentActivity() {
}

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)

val crashInfo = intent.getStringExtra(CRASH_INFO)
Expand All @@ -83,19 +74,11 @@ class CrashActivity : ComponentActivity() {
append(crashInfo)
}

setContent {
CompositionLocalProvider(
LocalWindowSizeClass provides calculateWindowSizeClass(this)
) {
SettingsProvider {
RaysTheme(darkTheme = LocalDarkMode.current) {
CrashScreen(
message = message,
onReport = { openBrowser(GITHUB_NEW_ISSUE_URL) }
)
}
}
}
setContentBase {
CrashScreen(
message = message,
onReport = { openBrowser(GITHUB_NEW_ISSUE_URL) }
)
}
}
}
Expand Down
115 changes: 115 additions & 0 deletions app/src/main/java/com/skyd/rays/ui/activity/ImagePickerActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//package com.skyd.rays.ui.activity
//
//import android.os.Bundle
//import androidx.compose.animation.AnimatedVisibility
//import androidx.compose.foundation.layout.WindowInsets
//import androidx.compose.foundation.layout.WindowInsetsSides
//import androidx.compose.foundation.layout.imePadding
//import androidx.compose.foundation.layout.only
//import androidx.compose.foundation.layout.systemBars
//import androidx.compose.foundation.layout.windowInsetsPadding
//import androidx.compose.foundation.lazy.staggeredgrid.rememberLazyStaggeredGridState
//import androidx.compose.material.icons.Icons
//import androidx.compose.material.icons.outlined.ArrowUpward
//import androidx.compose.material3.Icon
//import androidx.compose.material3.Scaffold
//import androidx.compose.material3.SnackbarHost
//import androidx.compose.material3.SnackbarHostState
//import androidx.compose.material3.Text
//import androidx.compose.runtime.Composable
//import androidx.compose.runtime.LaunchedEffect
//import androidx.compose.runtime.derivedStateOf
//import androidx.compose.runtime.getValue
//import androidx.compose.runtime.mutableStateOf
//import androidx.compose.runtime.remember
//import androidx.compose.runtime.rememberCoroutineScope
//import androidx.compose.runtime.setValue
//import androidx.compose.ui.Modifier
//import androidx.compose.ui.platform.LocalContext
//import androidx.compose.ui.platform.LocalSoftwareKeyboardController
//import androidx.compose.ui.res.stringResource
//import androidx.compose.ui.text.TextRange
//import androidx.compose.ui.text.input.TextFieldValue
//import androidx.compose.ui.unit.dp
//import com.skyd.rays.R
//import com.skyd.rays.base.BaseComposeActivity
//import com.skyd.rays.model.preference.search.QueryPreference
//import com.skyd.rays.ui.component.BackIcon
//import com.skyd.rays.ui.component.RaysFloatingActionButton
//import com.skyd.rays.ui.local.LocalWindowSizeClass
//import com.skyd.rays.ui.screen.search.SearchBarInputField
//import com.skyd.rays.ui.screen.search.TrailingIcon
//import kotlinx.coroutines.delay
//import kotlinx.coroutines.launch
//
//class ImagePickerActivity : BaseComposeActivity() {
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
//
// setContentBase {
// ImagePicker()
// }
// }
//}
//
//@Composable
//private fun ImagePicker() {
// val context = LocalContext.current
// val snackbarHostState = remember { SnackbarHostState() }
// val scope = rememberCoroutineScope()
// val searchResultListState = rememberLazyStaggeredGridState()
// val windowSizeClass = LocalWindowSizeClass.current
// val keyboardController = LocalSoftwareKeyboardController.current
// var fabHeight by remember { mutableStateOf(0.dp) }
// Scaffold(
// modifier = Modifier.imePadding(),
// snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
// floatingActionButton = {
// AnimatedVisibility(
// visible = remember {
// derivedStateOf { searchResultListState.firstVisibleItemIndex > 2 }
// }.value
// ) {
// RaysFloatingActionButton(
// onClick = { scope.launch { searchResultListState.animateScrollToItem(0) } },
// onSizeWithSinglePaddingChanged = { _, height -> fabHeight = height },
// contentDescription = stringResource(R.string.home_screen_search_result_list_to_top),
// ) {
// Icon(
// imageVector = Icons.Outlined.ArrowUpward,
// contentDescription = null
// )
// }
// }
// },
// topBar = {
// LaunchedEffect(searchFieldValueState.text) {
// delay(60)
// QueryPreference.put(context, scope, searchFieldValueState.text)
// }
// SearchBarInputField(
// modifier = Modifier.windowInsetsPadding(
// WindowInsets.systemBars
// .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top)
// ),
// onQueryChange = { searchFieldValueState = it },
// query = searchFieldValueState,
// onSearch = { state ->
// keyboardController?.hide()
// searchFieldValueState = state
// },
// placeholder = { Text(text = stringResource(R.string.home_screen_search_hint)) },
// leadingIcon = { BackIcon() },
// trailingIcon = {
// TrailingIcon(showClearButton = searchFieldValueState.text.isNotEmpty()) {
// searchFieldValueState = TextFieldValue(
// text = QueryPreference.default,
// selection = TextRange(QueryPreference.default.length)
// )
// }
// }
// )
// }
// ) { innerPaddings ->
// }
//}
Loading

0 comments on commit 2d56000

Please sign in to comment.