From 18a7566e7dec994cf3b66d472927dd1686781685 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 3 Nov 2022 22:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4compose,compose=E5=9C=A8?= =?UTF-8?q?=E5=8D=8E=E4=B8=BA=E6=89=8B=E6=9C=BA=E6=8A=A5=E9=94=99=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 16 ------- .../app/ui/book/audio/AudioPlayActivity.kt | 14 +----- .../legado/app/ui/book/audio/ComposeView.kt | 41 ---------------- .../java/io/legado/app/ui/theme/AppTheme.kt | 41 ---------------- .../ui/widget/checkbox/LabelledCheckBox.kt | 48 ------------------- .../main/res/layout/activity_arrange_book.xml | 6 --- .../main/res/layout/activity_audio_play.xml | 6 --- 7 files changed, 2 insertions(+), 170 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt delete mode 100644 app/src/main/java/io/legado/app/ui/theme/AppTheme.kt delete mode 100644 app/src/main/java/io/legado/app/ui/widget/checkbox/LabelledCheckBox.kt diff --git a/app/build.gradle b/app/build.gradle index b77a0996f..4b5ebe974 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,7 +61,6 @@ android { buildFeatures { buildConfig true viewBinding true - compose true } buildTypes { release { @@ -112,9 +111,6 @@ android { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } - composeOptions { - kotlinCompilerExtensionVersion "$compose_compiler_version" - } sourceSets { // Adds exported schema location as test app assets. @@ -171,18 +167,6 @@ dependencies { implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version") implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version") - //compose - // Integration with activities - implementation 'androidx.activity:activity-compose:1.6.1' - // Compose Material Design - implementation "androidx.compose.material:material:$compose_version" - // Animations - implementation "androidx.compose.animation:animation:$compose_version" - // Tooling support (Previews, etc.) - implementation "androidx.compose.ui:ui-tooling:$compose_version" - // UI Tests - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - //media implementation("androidx.media:media:1.6.0") implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version") diff --git a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt index 6acaffd80..5a19a7e73 100644 --- a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt @@ -9,7 +9,6 @@ import android.view.Menu import android.view.MenuItem import android.widget.SeekBar import androidx.activity.viewModels -import androidx.compose.runtime.mutableStateOf import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.EventBus @@ -32,7 +31,6 @@ import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.toc.TocActivityResult import io.legado.app.ui.login.SourceLoginActivity -import io.legado.app.ui.theme.AppTheme import io.legado.app.ui.widget.seekbar.SeekBarChangeListener import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -52,7 +50,7 @@ class AudioPlayActivity : override val binding by viewBinding(ActivityAudioPlayBinding::inflate) override val viewModel by viewModels() private var adjustProgress = false - private val timerViewState = mutableStateOf(false) + private val progressTimeFormat by lazy { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { SimpleDateFormat("mm:ss", Locale.getDefault()) @@ -166,19 +164,11 @@ class AudioPlayActivity : } binding.ivTimer.setOnClickListener { if (AudioPlayService.isRun) { - timerViewState.value = true + } else { toastOnUi(R.string.cannot_timed_non_playback) } } - binding.composeView.setContent { - AppTheme { - TimerDialog( - state = timerViewState, - binding.ivTimer - ) - } - } } private fun upCover(path: String?) { diff --git a/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt b/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt deleted file mode 100644 index ab7edd7ea..000000000 --- a/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.legado.app.ui.book.audio - -import android.view.View -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Card -import androidx.compose.material.Slider -import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog -import io.legado.app.model.AudioPlay -import io.legado.app.service.AudioPlayService - - -@Composable -fun TimerDialog(state: MutableState, parent: View) { - val intOffset = IntArray(2) - parent.getLocationInWindow(intOffset) - if (state.value) { - val timeMinute = remember { - mutableStateOf(AudioPlayService.timeMinute) - } - Dialog(onDismissRequest = { state.value = false }) { - Card(Modifier.fillMaxWidth()) { - Slider( - modifier = Modifier.padding(horizontal = 16.dp), - value = timeMinute.value.toFloat(), - onValueChange = { - timeMinute.value = it.toInt() - AudioPlay.setTimer(it.toInt()) - }, - valueRange = 0f..180f, - ) - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt b/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt deleted file mode 100644 index 6f83d03aa..000000000 --- a/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.legado.app.ui.theme - -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import io.legado.app.help.config.ThemeConfig -import io.legado.app.lib.theme.accentColor -import io.legado.app.lib.theme.primaryColor -import io.legado.app.utils.ColorUtils -import splitties.init.appCtx - -object AppTheme { - - val colors - get() = if (ThemeConfig.isDarkTheme()) { - darkColors( - primary = Color(appCtx.accentColor), - primaryVariant = Color(ColorUtils.darkenColor(appCtx.accentColor)), - secondary = Color(appCtx.primaryColor), - secondaryVariant = Color(appCtx.primaryColor) - ) - } else { - lightColors( - primary = Color(appCtx.accentColor), - primaryVariant = Color(ColorUtils.darkenColor(appCtx.accentColor)), - secondary = Color(appCtx.primaryColor), - secondaryVariant = Color(appCtx.primaryColor) - ) - } - -} - -@Composable -fun AppTheme(content: @Composable () -> Unit) { - MaterialTheme( - colors = AppTheme.colors, - content = content - ) -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/checkbox/LabelledCheckBox.kt b/app/src/main/java/io/legado/app/ui/widget/checkbox/LabelledCheckBox.kt deleted file mode 100644 index 50ed867b2..000000000 --- a/app/src/main/java/io/legado/app/ui/widget/checkbox/LabelledCheckBox.kt +++ /dev/null @@ -1,48 +0,0 @@ -package io.legado.app.ui.widget.checkbox - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.* -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Checkbox -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.ripple.rememberRipple -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.unit.dp - -@Composable -fun LabelledCheckBox( - checked: Boolean, - onCheckedChange: ((Boolean) -> Unit), - label: String, - modifier: Modifier = Modifier -) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = modifier - .clip(MaterialTheme.shapes.small) - .clickable( - indication = rememberRipple(color = MaterialTheme.colors.primary), - interactionSource = remember { MutableInteractionSource() }, - onClick = { onCheckedChange(!checked) } - ) - .requiredHeight(ButtonDefaults.MinHeight) - .padding(4.dp) - ) { - Checkbox( - checked = checked, - onCheckedChange = null - ) - - Spacer(Modifier.size(6.dp)) - - Text( - text = label, - ) - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_arrange_book.xml b/app/src/main/res/layout/activity_arrange_book.xml index b9875f283..bcc8ed9c7 100644 --- a/app/src/main/res/layout/activity_arrange_book.xml +++ b/app/src/main/res/layout/activity_arrange_book.xml @@ -25,10 +25,4 @@ android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" /> - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_audio_play.xml b/app/src/main/res/layout/activity_audio_play.xml index ad9bf920a..17b4822e2 100644 --- a/app/src/main/res/layout/activity_audio_play.xml +++ b/app/src/main/res/layout/activity_audio_play.xml @@ -228,10 +228,4 @@ - - \ No newline at end of file