Skip to content

Commit

Permalink
v0.1.2 - app update checker, player hide controller issue fix and oth…
Browse files Browse the repository at this point in the history
…er fixes
  • Loading branch information
dadencukillia committed Nov 13, 2024
1 parent 483ef34 commit 7916e16
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# AnimePlayerUA
Застосунок для зручного перегляду аніме для Android/Android TV (версії 9+).

# Скріни
<details>
<summary>1. Головний екран</summary>

![Скрін головного екрану](https://raw.github.com/dadencukillia/animeplayerua/main/screenshots/screenshot1.png)
</details>
<details>
<summary>2. Екран пошуку</summary>

![Скрін екрану пошуку](https://raw.github.com/dadencukillia/animeplayerua/main/screenshots/screenshot2.png)
</details>
<details>
<summary>3. Екран аніме</summary>

![Скрін екрану аніме](https://raw.github.com/dadencukillia/animeplayerua/main/screenshots/screenshot3.png)
</details>
<details>
<summary>4. Екран плеєру</summary>

![Скрін екрану плеєру](https://raw.github.com/dadencukillia/animeplayerua/main/screenshots/screenshot4.png)
</details>
<details>
<summary>5. Екран аніме, додатковий функціонал</summary>

![Скрін екрану аніме](https://raw.github.com/dadencukillia/animeplayerua/main/screenshots/screenshot5.png)
</details>
<details>
<summary>6. Екран особистого списку аніме</summary>

![Скрін екрану особистого списку](https://raw.github.com/dadencukillia/animeplayerua/main/screenshots/screenshot6.png)
</details>

# Завантажити
Доступне для Android/Android TV **версії 9 або більше**. Завантажити APK файл можете натиснувши тут: [Завантажити .APK](https://github.com/dadencukillia/animeplayerua/releases)

# Допомога (Contribution)
Допомога завжди вітається. Ви можете тестувати застосунок на баги і створювати [репорти](https://github.com/dadencukillia/animeplayerua/issues), [пропонувати ваші ідеї](https://github.com/dadencukillia/animeplayerua/discussions) або [допомогти оновлювати код](https://github.com/dadencukillia/animeplayerua/pulls). Застосунок розвивається і йому потрібна ваша допомога.

Застосунок розроблений на мові програмування **Kotlin** з використанням **Jetpack Compose**. Серед залежностей такі бібліотеки: **room**, **exoplayer**, **navigation compose**, **ktor**, **kamel image**.

Інформація береться (парситься) з сайту anitube у режимі реального часу.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "com.crocoby.animeplayerua"
minSdk = 28
targetSdk = 34
versionCode = 2
versionName = "0.1.1"
versionCode = 3
versionName = "0.1.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -43,6 +43,7 @@ android {
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
Expand Down
101 changes: 101 additions & 0 deletions app/src/main/java/com/crocoby/animeplayerua/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,43 @@ package com.crocoby.animeplayerua

import android.annotation.SuppressLint
import android.content.Context
import android.util.Log
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.AlertDialog
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
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.compose.ui.window.Dialog
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.whenCreated
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
Expand All @@ -18,17 +50,86 @@ import com.crocoby.animeplayerua.activities.SearchActivity
import com.crocoby.animeplayerua.activities.VideoActivity
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.logic.runParser
import kotlinx.coroutines.launch

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

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun App(context: Context) {
navController = rememberNavController()
database = remember { AppDatabase.getDatabase(context).getDao() }

val coroutine = rememberCoroutineScope()
val uriHandler = LocalUriHandler.current
val appVersion = BuildConfig.VERSION_NAME
var updatePopupInfo by remember { mutableStateOf<LatestAppVersionAndDownloadUrl?>(null) }
var firstStart by rememberSaveable { mutableStateOf(true) }

LifecycleEventEffect(Lifecycle.Event.ON_START) {
if (!firstStart) {
return@LifecycleEventEffect
}
firstStart = false

coroutine.launch {
try {
val resp = parser.getLatestAppVersionAndDownloadUrl()
if (resp.version != appVersion) {
updatePopupInfo = resp
}
} catch (_: Exception) { }
}
}

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

BasicAlertDialog(
onDismissRequest = {
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(
navController!!,
startDestination = Routes.HOME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crocoby.animeplayerua

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/crocoby/animeplayerua/logic/Parser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fun runParser(
}

data class MainPageAnime(val bestSeason: List<AnimeItem>, val new: List<AnimeItem>)
data class LatestAppVersionAndDownloadUrl(val version: String, val downloadUrl: String)

class Parser {
private val client: HttpClient = HttpClient()
Expand Down Expand Up @@ -236,4 +237,16 @@ class Parser {

return fileUrl.substringBeforeLast("\"").substringAfterLast("\"").substringAfterLast(",").substringAfterLast("]")
}

suspend fun getLatestAppVersionAndDownloadUrl(): LatestAppVersionAndDownloadUrl {
val resp = client.get("https://raw.githubusercontent.com/dadencukillia/animeplayerua/main/releaseVersion") {
expectSuccess = true

header("User-Agent", userAgent)
}
val body = resp.bodyAsText()
val split = body.split("\n")

return LatestAppVersionAndDownloadUrl(split.first(), split.last())
}
}
13 changes: 11 additions & 2 deletions app/src/main/java/com/crocoby/animeplayerua/widgets/VideoPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand Down Expand Up @@ -50,6 +53,7 @@ fun VideoPlayer(modifier: Modifier, url: String) {
val context = LocalContext.current.applicationContext
val systemUiController = rememberSystemUiController()
val focusRequester = remember { FocusRequester() }
var lastBarVisibleState by remember { mutableStateOf(false) }
val lifecycleOwner = LocalLifecycleOwner.current

val exoPlayer: ExoPlayer = remember {
Expand Down Expand Up @@ -88,7 +92,12 @@ fun VideoPlayer(modifier: Modifier, url: String) {
launch {
while (true) {
if (systemUiController.isSystemBarsVisible || systemUiController.isStatusBarVisible || systemUiController.isNavigationBarVisible) {
playerView.showController()
if (!lastBarVisibleState) {
lastBarVisibleState = true
playerView.showController()
}
} else {
lastBarVisibleState = false
}
delay(500)
}
Expand Down Expand Up @@ -140,7 +149,7 @@ fun VideoPlayer(modifier: Modifier, url: String) {

DisposableEffect(Unit) {
focusRequester.requestFocus()
val observer = LifecycleEventObserver { source, event ->
val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_PAUSE) {
exoPlayer.pause()
}
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.buildConfig=true
2 changes: 2 additions & 0 deletions releaseVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.1.2
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.2
Binary file added screenshots/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 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.
Binary file added screenshots/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot6.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 7916e16

Please sign in to comment.