移除compose,compose在华为手机报错崩溃

pull/2533/head
kunfei 2 years ago
parent 8d5211c67e
commit 18a7566e7d
  1. 16
      app/build.gradle
  2. 14
      app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt
  3. 41
      app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt
  4. 41
      app/src/main/java/io/legado/app/ui/theme/AppTheme.kt
  5. 48
      app/src/main/java/io/legado/app/ui/widget/checkbox/LabelledCheckBox.kt
  6. 6
      app/src/main/res/layout/activity_arrange_book.xml
  7. 6
      app/src/main/res/layout/activity_audio_play.xml

@ -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")

@ -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<AudioPlayViewModel>()
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?) {

@ -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<Boolean>, 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,
)
}
}
}
}

@ -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
)
}

@ -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,
)
}
}

@ -25,10 +25,4 @@
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" />
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -228,10 +228,4 @@
</LinearLayout>
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save