Skip to content

Commit

Permalink
v0.1.4 - crash fix, small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dadencukillia committed Nov 14, 2024
1 parent 2e76759 commit c285c2d
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 71 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)

id("com.google.devtools.ksp") version "2.0.21-1.0.25"
id("com.google.devtools.ksp") version "2.0.21-1.0.26"
id("kotlin-parcelize")
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.21"
}
Expand All @@ -16,8 +16,8 @@ android {
applicationId = "com.crocoby.animeplayerua"
minSdk = 28
targetSdk = 34
versionCode = 3
versionName = "0.1.3"
versionCode = 4
versionName = "0.1.4"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -26,5 +29,4 @@
</intent-filter>
</activity>
</application>

</manifest>
63 changes: 8 additions & 55 deletions app/src/main/java/com/crocoby/animeplayerua/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,15 @@ import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.navigation.NavHostController
Expand All @@ -44,13 +28,13 @@ import com.crocoby.animeplayerua.logic.AnimeDao
import com.crocoby.animeplayerua.logic.AppDatabase
import com.crocoby.animeplayerua.logic.LatestAppVersionAndDownloadUrl
import com.crocoby.animeplayerua.logic.parser
import com.crocoby.animeplayerua.widgets.UpdateAlertDialog
import kotlinx.coroutines.launch

var database: AnimeDao? = null
@SuppressLint("StaticFieldLeak")
var navController: NavHostController? = null

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun App(context: Context) {
navController = rememberNavController()
Expand Down Expand Up @@ -79,46 +63,15 @@ fun App(context: Context) {
}

MaterialTheme(colorScheme = darkScheme) {
if (updatePopupInfo != null) {
val curInfo = updatePopupInfo!!

BasicAlertDialog(
onDismissRequest = {
updatePopupInfo?.let {
UpdateAlertDialog(
version = it.version,
onClose = { updatePopupInfo = null },
onOpen = {
uriHandler.openUri(it.downloadUrl)
updatePopupInfo = null
},
) {
Surface(
modifier = Modifier.fillMaxWidth().wrapContentHeight().padding(16.dp),
shape = MaterialTheme.shapes.large,
tonalElevation = AlertDialogDefaults.TonalElevation
) {
Column(modifier = Modifier.padding(16.dp)) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = "Доступна нова версія застосунку!",
style = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 18.sp
)
)
Text(
text = "Оновіть застосунок до версії ${curInfo.version}, щоб отримати нові функції та користуватися стабільнішою версією програми.",
)
Button(
onClick = {
uriHandler.openUri(curInfo.downloadUrl)
updatePopupInfo = null
}
) {
Text("Відвідати")
}
}
}
}
}
)
}

NavHost(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.crocoby.animeplayerua.widgets

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun UpdateAlertDialog(
version: String,
onClose: () -> Unit,
onOpen: () -> Unit
) {
BasicAlertDialog(
onDismissRequest = { onClose() },
) {
Surface(
modifier = Modifier.fillMaxWidth().wrapContentHeight().padding(16.dp),
shape = MaterialTheme.shapes.large,
tonalElevation = AlertDialogDefaults.TonalElevation
) {
Column(modifier = Modifier.padding(16.dp)) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = "Доступна нова версія застосунку!",
style = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 18.sp
)
)
Text(
text = "Оновіть застосунок до версії ${version}, щоб отримати нові функції та користуватися стабільною версією програми.",
)
Button(
onClick = { onOpen() }
) {
Text("Перейти")
}
}
}
}
}
}
15 changes: 5 additions & 10 deletions app/src/main/java/com/crocoby/animeplayerua/widgets/VideoPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import androidx.compose.ui.input.key.type
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.viewinterop.AndroidView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.util.UnstableApi
Expand Down Expand Up @@ -55,7 +54,6 @@ fun VideoPlayer(modifier: Modifier, url: String) {
val systemUiController = rememberSystemUiController()
val focusRequester = remember { FocusRequester() }
var lastBarVisibleState by remember { mutableStateOf(false) }
val lifecycleOwner = LocalLifecycleOwner.current

val exoPlayer: ExoPlayer = remember {
ExoPlayer.Builder(context).build().apply {
Expand Down Expand Up @@ -149,18 +147,15 @@ fun VideoPlayer(modifier: Modifier, url: String) {
onRelease = {},
)

LifecycleEventEffect(Lifecycle.Event.ON_PAUSE) {
exoPlayer.pause()
}

DisposableEffect(Unit) {
focusRequester.requestFocus()
val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_PAUSE) {
exoPlayer.pause()
}
}
lifecycleOwner.lifecycle.addObserver(observer)

onDispose {
exoPlayer.release()
lifecycleOwner.lifecycle.removeObserver(observer)
}
}
}
4 changes: 2 additions & 2 deletions releaseVersion
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.1.3
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.3
0.1.4
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.4
Binary file modified screenshots/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c285c2d

Please sign in to comment.