Răsfoiți Sursa

navigation improvements

Milan Jurkulak 2 ani în urmă
părinte
comite
28b71d09be

+ 22 - 21
app/build.gradle.kts

@@ -15,6 +15,7 @@ import org.mjdev.gradle.plugin.MainAppPlugin.Companion.projectCompileSdk
 import org.mjdev.gradle.plugin.MainAppPlugin.Companion.projectMinSdk
 import org.mjdev.gradle.plugin.MainAppPlugin.Companion.versionCode
 import org.mjdev.gradle.plugin.MainAppPlugin.Companion.versionName
+import org.mjdev.gradle.plugin.MainAppPlugin.Companion.suffixToString
 
 @Suppress("PropertyName")
 val CONFIG_KEYSTORE_PROPERTIES_FILE = "config/keystore.properties"
@@ -102,7 +103,7 @@ android {
             resValue(
                 "string",
                 "app_name",
-                "TV App  ${applicationIdSuffix.toString().replace(".", "").capitalize()}"
+                "TV App  ${applicationIdSuffix.suffixToString()}"
             )
         }
 
@@ -130,7 +131,7 @@ android {
             resValue(
                 "string",
                 "app_name",
-                "TV App  ${applicationIdSuffix.toString().replace(".", "").capitalize()}"
+                "TV App  ${applicationIdSuffix.suffixToString()}"
             )
         }
     }
@@ -183,7 +184,7 @@ dependencies {
     implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.21")
     // startups
 //    implementation("androidx.startup:startup-runtime:1.1.1")
-    // tv library by mjde milan jurkulak
+    // tv library by mjdev milan jurkulak
     implementation(project(mapOf("path" to ":tvlib")))
     // base libs
     implementation("androidx.core:core-ktx:1.12.0")
@@ -191,44 +192,44 @@ dependencies {
     // compose base libs
     implementation(platform("androidx.compose:compose-bom:2023.10.01"))
     implementation("androidx.compose.ui:ui-tooling")
-    implementation("androidx.activity:activity-compose:1.8.1")
+    implementation("androidx.activity:activity-compose:1.8.2")
     // more icons
     implementation("androidx.compose.material:material-icons-extended:1.5.4")
     // tv compose
     implementation("androidx.tv:tv-foundation:1.0.0-alpha10")
     implementation("androidx.tv:tv-material:1.0.0-alpha10")
     // dagger - hilt
-    implementation("com.google.dagger:dagger-android:2.49")
-    implementation("com.google.dagger:dagger-android-support:2.49")
-    implementation("com.google.dagger:dagger:2.49")
-    implementation("com.google.dagger:hilt-android:2.49")
+    implementation("com.google.dagger:dagger-android:2.50")
+    implementation("com.google.dagger:dagger-android-support:2.50")
+    implementation("com.google.dagger:dagger:2.50")
+    implementation("com.google.dagger:hilt-android:2.50")
     implementation("androidx.hilt:hilt-navigation-compose:1.1.0")
     // moshi json
     implementation("com.squareup.moshi:moshi:1.15.0")
     implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
     // okhttp
-    implementation(platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.11"))
+    implementation(platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.12"))
     implementation("com.squareup.okhttp3:okhttp")
-    implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11")
+    implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12")
     // debug
     implementation("com.jakewharton.timber:timber:5.0.1")
     implementation("com.android.volley:volley:1.2.1")
     // kapt
-    kapt("com.google.dagger:dagger-compiler:2.49")
-    kapt("com.google.dagger:dagger-android-processor:2.49")
-    kapt("com.google.dagger:hilt-compiler:2.49")
+    kapt("com.google.dagger:dagger-compiler:2.50")
+    kapt("com.google.dagger:dagger-android-processor:2.50")
+    kapt("com.google.dagger:hilt-compiler:2.50")
     ksp("com.squareup.moshi:moshi-kotlin-codegen:1.15.0")
     // view model
     implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")
     // navigation
-    implementation("androidx.navigation:navigation-compose:2.7.5")
+    implementation("androidx.navigation:navigation-compose:2.7.6")
     // retrofit
     implementation("com.squareup.retrofit2:retrofit:2.9.0")
     implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
     implementation("com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2")
     // sandwich
-    implementation("com.github.skydoves:sandwich:2.0.4")
-    implementation("com.github.skydoves:sandwich-retrofit:2.0.4")
+    implementation("com.github.skydoves:sandwich:2.0.5")
+    implementation("com.github.skydoves:sandwich-retrofit:2.0.5")
     // encrypt data
     implementation("com.scottyab:aescrypt:0.0.1")
     // permission
@@ -246,11 +247,11 @@ dependencies {
     // image loading
     implementation("com.github.bumptech.glide:okhttp3-integration:4.16.0")
     implementation("com.github.bumptech.glide:compose:1.0.0-beta01")
-    implementation("com.github.skydoves:landscapist-glide:2.2.12")
-    implementation("com.github.skydoves:landscapist-transformation:2.2.12")
-    implementation("com.github.skydoves:landscapist-palette:2.2.12")
-    implementation("com.github.skydoves:landscapist-placeholder:2.2.12")
-    ksp("com.github.bumptech.glide:ksp:4.15.1")
+    implementation("com.github.skydoves:landscapist-glide:2.2.13")
+    implementation("com.github.skydoves:landscapist-transformation:2.2.13")
+    implementation("com.github.skydoves:landscapist-palette:2.2.13")
+    implementation("com.github.skydoves:landscapist-placeholder:2.2.13")
+    ksp("com.github.bumptech.glide:ksp:4.16.0")
     // exoplayer
     implementation("androidx.media3:media3-exoplayer:1.2.0")
     implementation("androidx.media3:media3-exoplayer-dash:1.2.0")

+ 0 - 4
app/src/main/kotlin/org/mjdev/tvapp/sync/SyncAdapter.kt

@@ -8,7 +8,6 @@ import android.content.SyncResult
 import android.os.Bundle
 import androidx.annotation.Keep
 import io.objectbox.Box
-import kotlinx.coroutines.delay
 import org.mjdev.tvapp.data.local.Movie
 import org.mjdev.tvapp.database.DAO
 import org.mjdev.tvapp.database.DAO.Companion.tx
@@ -43,12 +42,9 @@ class SyncAdapter(
         syncResult: SyncResult?
     ) {
         launch(IO) {
-            delay(4000L)
             try {
-
                 val streams = apiService.streams().safeGet()
                 val channels = apiService.channels().safeGet()
-
                 val oldMovies = movieDao.all
                 val newMovies = mutableListOf<Movie>()
 

+ 8 - 1
buildSrc/src/main/kotlin/org/mjdev/gradle/plugin/MainAppPlugin.kt

@@ -20,10 +20,11 @@ import org.gradle.kotlin.dsl.extra
 import org.mjdev.gradle.helper.CustomEventLogger
 import java.io.File
 import java.io.FileInputStream
+import java.util.Locale
 import java.util.Properties
 
 // todo
-@Suppress("UsePropertyAccessSyntax")
+@Suppress("UsePropertyAccessSyntax", "MemberVisibilityCanBePrivate")
 abstract class MainAppPlugin : Plugin<Project> {
 
     companion object {
@@ -60,6 +61,12 @@ abstract class MainAppPlugin : Plugin<Project> {
                 return "${major}.${minor}.${patch}"
             }
 
+        fun String.capitalize() = replaceFirstChar {
+            if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
+        }
+
+        fun String?.suffixToString() = (this ?: "").replace(".", "").capitalize()
+
         val javaVersion: JavaVersion = JavaVersion.VERSION_17
 
         const val projectCompileSdk: Int = 34

+ 20 - 20
tvlib/build.gradle.kts

@@ -102,7 +102,7 @@ dependencies {
     // compose base libs
     implementation(platform("androidx.compose:compose-bom:2023.10.01"))
     implementation("androidx.compose.ui:ui-tooling")
-    implementation("androidx.activity:activity-compose:1.8.1")
+    implementation("androidx.activity:activity-compose:1.8.2")
     // more icons
     implementation("androidx.compose.material:material-icons-extended:1.5.4")
     // tv compose
@@ -111,11 +111,11 @@ dependencies {
     // view model
     implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")
     // navigation
-    implementation("androidx.navigation:navigation-compose:2.7.5")
+    implementation("androidx.navigation:navigation-compose:2.7.6")
     // okhttp
-    implementation(platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.11"))
+    implementation(platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.12"))
     implementation("com.squareup.okhttp3:okhttp")
-    implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11")
+    implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12")
     // retrofit
     implementation("com.squareup.retrofit2:retrofit:2.9.0")
     implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
@@ -126,16 +126,16 @@ dependencies {
     implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
     ksp("com.squareup.moshi:moshi-kotlin-codegen:1.15.0")
     // sandwich
-    implementation("com.github.skydoves:sandwich:2.0.4")
-    implementation("com.github.skydoves:sandwich-retrofit:2.0.4")
+    implementation("com.github.skydoves:sandwich:2.0.5")
+    implementation("com.github.skydoves:sandwich-retrofit:2.0.5")
     // image loading
     implementation("com.github.bumptech.glide:okhttp3-integration:4.16.0")
     implementation("com.github.bumptech.glide:compose:1.0.0-beta01")
-    implementation("com.github.skydoves:landscapist-glide:2.2.12")
-    implementation("com.github.skydoves:landscapist-transformation:2.2.12")
-    implementation("com.github.skydoves:landscapist-palette:2.2.12")
-    implementation("com.github.skydoves:landscapist-placeholder:2.2.12")
-    ksp("com.github.bumptech.glide:ksp:4.15.1")
+    implementation("com.github.skydoves:landscapist-glide:2.2.13")
+    implementation("com.github.skydoves:landscapist-transformation:2.2.13")
+    implementation("com.github.skydoves:landscapist-palette:2.2.13")
+    implementation("com.github.skydoves:landscapist-placeholder:2.2.13")
+    ksp("com.github.bumptech.glide:ksp:4.16.0")
     // zxing
     implementation("com.google.zxing:core:3.5.2")
     // svg
@@ -146,17 +146,17 @@ dependencies {
     // debug
     implementation("com.jakewharton.timber:timber:5.0.1")
     // dagger core
-    implementation("com.google.dagger:dagger:2.49")
+    implementation("com.google.dagger:dagger:2.50")
     implementation("androidx.compose.material3:material3:1.1.2")
-    kapt("com.google.dagger:dagger-compiler:2.49")
+    kapt("com.google.dagger:dagger-compiler:2.50")
     // dagger android
-    implementation("com.google.dagger:dagger-android:2.49")
-    implementation("com.google.dagger:dagger-android-support:2.49")
-    kapt("com.google.dagger:dagger-android-processor:2.49")
+    implementation("com.google.dagger:dagger-android:2.50")
+    implementation("com.google.dagger:dagger-android-support:2.50")
+    kapt("com.google.dagger:dagger-android-processor:2.50")
     // dagger - hilt
-    implementation("com.google.dagger:hilt-android:2.49")
+    implementation("com.google.dagger:hilt-android:2.50")
     implementation("androidx.hilt:hilt-navigation-compose:1.1.0")
-    kapt("com.google.dagger:hilt-compiler:2.49")
+    kapt("com.google.dagger:hilt-compiler:2.50")
     // encrypt data
     implementation("com.scottyab:aescrypt:0.0.1")
     // exoplayer
@@ -188,7 +188,7 @@ dependencies {
     // lottie
     implementation("com.airbnb.android:lottie-compose:6.2.0")
     // exif info
-    implementation("androidx.exifinterface:exifinterface:1.3.6")
+    implementation("androidx.exifinterface:exifinterface:1.3.7")
     // anr
     implementation("com.github.anrwatchdog:anrwatchdog:1.4.0")
     // jsoup
@@ -196,7 +196,7 @@ dependencies {
     // dm
     implementation("com.dailymotion.dailymotion-sdk-android:sdk:0.2.12")
     // dynamic theme
-    implementation("com.google.android.material:material:1.10.0")
+    implementation("com.google.android.material:material:1.11.0")
     // stripe payments
 //    implementation("com.stripe:stripe-android:20.33.0")
 //    implementation("com.stripe:stripecardscan:20.33.0")

+ 3 - 15
tvlib/src/main/kotlin/org/mjdev/tvlib/ui/components/navigation/NavigationRow.kt

@@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.width
 import androidx.compose.foundation.shape.CircleShape
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.clip
@@ -49,11 +48,9 @@ import org.mjdev.tvlib.extensions.NavControllerExt.open
 import org.mjdev.tvlib.extensions.NavExt.rememberNavControllerEx
 import org.mjdev.tvlib.navigation.MenuItem
 import org.mjdev.tvlib.navigation.NavHostControllerEx
-import org.mjdev.tvlib.ui.components.card.FocusHelper
 import org.mjdev.tvlib.ui.components.complex.FocusableBox
 import org.mjdev.tvlib.ui.components.icon.IconAny
 import org.mjdev.tvlib.ui.components.text.TextAny
-import timber.log.Timber
 
 @OptIn(ExperimentalTvMaterial3Api::class)
 @Previews
@@ -88,8 +85,8 @@ fun NavigationRow(
         onDrawerItemFocus()
     }
     val drawerState = navController.menuDrawerState
-    val focused = (navController.selectedMenuItem.intValue == id)
-    val focusState = rememberFocusState(FocusHelper(focused))
+    val selected = (navController.selectedMenuItem.intValue == id)
+    val focusState = rememberFocusState()
     val isEdit = isEditMode()
     val isShown = isLandscapeMode() || drawerState.isOpen
     val isPortrait = isPortraitMode()
@@ -117,7 +114,7 @@ fun NavigationRow(
                 .border(
                     BorderStroke(
                         strokeWidth,
-                        if (isEdit || focused) focusedColor else unFocusedColor
+                        if (isEdit || selected) focusedColor else unFocusedColor
                     ),
                     shape
                 )
@@ -170,14 +167,5 @@ fun NavigationRow(
                 }
             }
         }
-        LaunchedEffect(focused) {
-            try {
-                if (focused) {
-                    focusRequester.requestFocus()
-                }
-            } catch (e: Exception) {
-                Timber.e(e)
-            }
-        }
     }
 }