Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
*.jks
*.aab
*.base64
*.json
.gradle
/local.properties
.idea
.kotlin
/build
/captures
.externalNativeBuild
Expand Down
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
*.json
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ android {
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
Expand All @@ -20,11 +24,11 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.google.android.gms.ads.MobileAds
import com.infbyte.amuze.ads.GoogleMobileAdsConsentManager
import com.infbyte.amuze.ui.screens.AboutScreen
import com.infbyte.amuze.ui.screens.LoadingScreen
import com.infbyte.amuze.ui.screens.NoMediaAvailableScreen
import com.infbyte.amuze.ui.screens.NoMediaPermissionScreen
import com.infbyte.amuze.utils.GoogleMobileAdsConsentManager
import com.infbyte.amuzeo.BuildConfig
import com.infbyte.amuzeo.R
import com.infbyte.amuzeo.presentation.theme.AmuzeoTheme
Expand Down Expand Up @@ -90,25 +94,7 @@ class MainActivity : ComponentActivity() {
color = MaterialTheme.colorScheme.background,
) {
val navController = rememberNavController()
if (!videosViewModel.state.isReadPermGranted) {
NoMediaPermissionScreen(
appIcon = R.drawable.amuzeo_intro,
action = R.string.amuzeo_watch,
onStartAction = { launchPermRequest() },
onExit = { onExit() },
aboutApp = { navigateBack ->
AboutScreen(
appName = stringResource(R.string.app_name),
appVersion = BuildConfig.VERSION_NAME,
appIconRes = R.drawable.amuzeo_foreground,
privacyPolicyLinkRes = R.string.amuzeo_privacy_policy,
adsConsentManager = googleMobileAdsConsentManager,
onNavigateBack = { navigateBack() },
)
},
)
return@Surface
}
var initialScreen by rememberSaveable { mutableStateOf(Screens.MAIN) }

if (
(videosViewModel.state.isReadPermGranted && !videosViewModel.state.isLoaded) ||
Expand All @@ -118,33 +104,18 @@ class MainActivity : ComponentActivity() {
return@Surface
}

if (!videosViewModel.state.hasVideos) {
NoMediaAvailableScreen(
R.string.amuzeo_no_videos,
onRefresh = {
if (!videosViewModel.state.isReadPermGranted) {
launchPermRequest()
} else {
videosViewModel.setIsRefreshing(true)
videosViewModel.init(this)
}
},
onExit = { onExit() },
aboutApp = { navigateBack ->
AboutScreen(
stringResource(R.string.app_name),
BuildConfig.VERSION_NAME,
R.drawable.amuzeo_foreground,
R.string.amuzeo_privacy_policy_link,
adsConsentManager = googleMobileAdsConsentManager,
onNavigateBack = { navigateBack() },
)
},
)
return@Surface
}
initialScreen =
when {
!videosViewModel.state.isReadPermGranted -> {
Screens.NO_PERMISSION
}
!videosViewModel.state.hasVideos -> {
Screens.NO_MEDIA
}
else -> Screens.MAIN
}

NavHost(navController, Screens.MAIN) {
NavHost(navController, initialScreen) {
composable(Screens.MAIN) {
MainScreen(
videosViewModel,
Expand All @@ -168,14 +139,40 @@ class MainActivity : ComponentActivity() {
)
}

composable(Screens.NO_PERMISSION) {
NoMediaPermissionScreen(
appIcon = R.drawable.amuzeo_intro,
action = R.string.amuzeo_watch,
onStartAction = { launchPermRequest() },
onExit = { onExit() },
aboutApp = { navController.navigate(Screens.ABOUT) },
)
}

composable(Screens.NO_MEDIA) {
NoMediaAvailableScreen(
R.string.amuzeo_no_videos,
onRefresh = {
if (!videosViewModel.state.isReadPermGranted) {
launchPermRequest()
} else {
videosViewModel.setIsRefreshing(true)
videosViewModel.init(this@MainActivity)
}
},
onExit = { onExit() },
aboutApp = { navController.navigate(Screens.ABOUT) },
)
}

composable(Screens.ABOUT) {
AboutScreen(
stringResource(R.string.app_name),
BuildConfig.VERSION_NAME,
R.drawable.ic_amuzeo_splash,
R.string.amuzeo_privacy_policy_link,
adsConsentManager = googleMobileAdsConsentManager,
) { navController.popBackStack() }
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ object Screens {
const val VIDEOS: String = "videos-screen"
const val VIDEO_PLAYBACK = "video-playback-screen"
const val ABOUT = "about"
const val NO_PERMISSION = "no-permission"
const val NO_MEDIA = "no-media"
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ navigation = "2.5.3"
koin = "3.5.6"
material3 = "1.3.2"
ktlintGradle = "12.1.1"
amuze = "0.2.4-a"
amuze = "0.2.6"
mobileAds = "24.2.0"

[libraries]
Expand Down