Changelog Updated and Dialog Fixes

This commit is contained in:
shabinder 2021-05-16 23:40:02 +05:30
parent a780d03d5a
commit 6461603bd8
9 changed files with 122 additions and 42 deletions

View File

@ -63,6 +63,7 @@ import com.shabinder.common.root.SpotiFlyerRoot
import com.shabinder.common.root.SpotiFlyerRoot.Analytics import com.shabinder.common.root.SpotiFlyerRoot.Analytics
import com.shabinder.common.root.callbacks.SpotiFlyerRootCallBacks import com.shabinder.common.root.callbacks.SpotiFlyerRootCallBacks
import com.shabinder.common.uikit.* import com.shabinder.common.uikit.*
import com.shabinder.spotiflyer.ui.AnalyticsDialog
import com.shabinder.spotiflyer.ui.NetworkDialog import com.shabinder.spotiflyer.ui.NetworkDialog
import com.shabinder.spotiflyer.ui.PermissionDialog import com.shabinder.spotiflyer.ui.PermissionDialog
import com.shabinder.spotiflyer.utils.* import com.shabinder.spotiflyer.utils.*
@ -112,16 +113,32 @@ class MainActivity : ComponentActivity() {
) )
} }
LaunchedEffect(view) {
permissionGranted.value = checkPermissions()
}
NetworkDialog(isInternetAvailableState()) NetworkDialog(isInternetAvailableState())
PermissionDialog( PermissionDialog(
permissionGranted.value, permissionGranted.value,
{ requestStoragePermission() }, { requestStoragePermission() },
{ disableDozeMode(disableDozeCode) }, { disableDozeMode(disableDozeCode) },
dir::enableAnalytics
) )
var askForAnalyticsPermission by remember { mutableStateOf(false) }
AnalyticsDialog(
askForAnalyticsPermission,
dir::enableAnalytics,
dismissDialog = {
askForAnalyticsPermission = false
}
)
LaunchedEffect(view) {
permissionGranted.value = checkPermissions()
if(dir.isFirstLaunch) {
delay(2500)
// Ask For Analytics Permission on first Dialog
askForAnalyticsPermission = true
dir.firstLaunchDone()
}
}
} }
} }
} }

View File

@ -0,0 +1,67 @@
package com.shabinder.spotiflyer.ui
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.AlertDialog
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Insights
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.DialogProperties
import com.shabinder.common.uikit.SpotiFlyerShapes
import com.shabinder.common.uikit.SpotiFlyerTypography
import com.shabinder.common.uikit.colorPrimary
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun AnalyticsDialog(
isVisible:Boolean,
enableAnalytics: ()->Unit,
dismissDialog: () -> Unit,
) {
// Analytics Permission Dialog
AnimatedVisibility(isVisible) {
AlertDialog(
onDismissRequest = dismissDialog,
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(Icons.Rounded.Insights,"Analytics", Modifier.size(52.dp))
Spacer(Modifier.padding(horizontal = 4.dp))
Text("Grant Analytics Access",style = SpotiFlyerTypography.h5,textAlign = TextAlign.Center)
}
},
backgroundColor = Color.DarkGray,
buttons = {
TextButton(
{
dismissDialog()
enableAnalytics()
},
Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp).fillMaxWidth()
.background(colorPrimary, shape = SpotiFlyerShapes.medium)
.padding(horizontal = 8.dp),
) {
Text("Sure!",color = Color.Black,fontSize = 18.sp,textAlign = TextAlign.Center)
}
},
text = {
Text("Your Data is Anonymized and will never be shared with any 3rd party service",style = SpotiFlyerTypography.body2,textAlign = TextAlign.Center)
},
properties = DialogProperties(dismissOnBackPress = true,dismissOnClickOutside = false)
)
}
}

View File

@ -42,49 +42,13 @@ fun PermissionDialog(
permissionGranted: Boolean, permissionGranted: Boolean,
requestStoragePermission:() -> Unit, requestStoragePermission:() -> Unit,
disableDozeMode:() -> Unit, disableDozeMode:() -> Unit,
enableAnalytics:() -> Unit
){ ){
var askForPermission by remember { mutableStateOf(false) } var askForPermission by remember { mutableStateOf(false) }
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
delay(2000) delay(2600)
askForPermission = true askForPermission = true
} }
// Analytics Permission Dialog
var askForAnalyticsPermission by remember { mutableStateOf(false) }
AnimatedVisibility(askForAnalyticsPermission) {
AlertDialog(
onDismissRequest = {
askForAnalyticsPermission = false
},
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(Icons.Rounded.Insights,"Analytics",Modifier.size(52.dp))
Spacer(Modifier.padding(horizontal = 4.dp))
Text("Grant Analytics Access",style = SpotiFlyerTypography.h5,textAlign = TextAlign.Center)
}
},
backgroundColor = Color.DarkGray,
buttons = {
TextButton(
{
askForAnalyticsPermission = false
enableAnalytics()
},
Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp).fillMaxWidth()
.background(colorPrimary, shape = SpotiFlyerShapes.medium)
.padding(horizontal = 8.dp),
) {
Text("Sure!",color = Color.Black,fontSize = 18.sp,textAlign = TextAlign.Center)
}
},
text = {
Text("Your Data is Anonymized and will never be shared with any 3rd party service",style = SpotiFlyerTypography.body2,textAlign = TextAlign.Center)
},
properties = DialogProperties(dismissOnBackPress = true,dismissOnClickOutside = false)
)
}
AnimatedVisibility( AnimatedVisibility(
askForPermission && !permissionGranted askForPermission && !permissionGranted
) { ) {
@ -95,7 +59,6 @@ fun PermissionDialog(
{ {
requestStoragePermission() requestStoragePermission()
disableDozeMode() disableDozeMode()
askForAnalyticsPermission = true
}, },
Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp).fillMaxWidth() Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp).fillMaxWidth()
.background(colorPrimary, shape = SpotiFlyerShapes.medium) .background(colorPrimary, shape = SpotiFlyerShapes.medium)

View File

@ -51,7 +51,15 @@ actual class Dir actual constructor(
companion object { companion object {
const val DirKey = "downloadDir" const val DirKey = "downloadDir"
const val AnalyticsKey = "analytics" const val AnalyticsKey = "analytics"
const val firstLaunch = "firstLaunch"
} }
actual val isFirstLaunch get() = settings.getBooleanOrNull(firstLaunch) ?: true
actual fun firstLaunchDone(){
settings.putBoolean(firstLaunch,false)
}
/* /*
* Do we have Analytics Permission? * Do we have Analytics Permission?
* - Defaults to `False` * - Defaults to `False`

View File

@ -38,7 +38,9 @@ expect class Dir (
) { ) {
val db: Database? val db: Database?
val isAnalyticsEnabled:Boolean val isAnalyticsEnabled:Boolean
val isFirstLaunch:Boolean
fun enableAnalytics() fun enableAnalytics()
fun firstLaunchDone()
fun isPresent(path: String): Boolean fun isPresent(path: String): Boolean
fun fileSeparator(): String fun fileSeparator(): String
fun defaultDir(): String fun defaultDir(): String

View File

@ -43,9 +43,17 @@ actual class Dir actual constructor(
private val settings: Settings, private val settings: Settings,
private val spotiFlyerDatabase: SpotiFlyerDatabase, private val spotiFlyerDatabase: SpotiFlyerDatabase,
) { ) {
companion object { companion object {
const val DirKey = "downloadDir" const val DirKey = "downloadDir"
const val AnalyticsKey = "analytics" const val AnalyticsKey = "analytics"
const val firstLaunch = "firstLaunch"
}
actual val isFirstLaunch get() = settings.getBooleanOrNull(firstLaunch) ?: true
actual fun firstLaunchDone(){
settings.putBoolean(firstLaunch,false)
} }
actual val isAnalyticsEnabled get() = settings.getBooleanOrNull(AnalyticsKey) ?: false actual val isAnalyticsEnabled get() = settings.getBooleanOrNull(AnalyticsKey) ?: false

View File

@ -30,6 +30,13 @@ actual class Dir actual constructor(
companion object { companion object {
const val DirKey = "downloadDir" const val DirKey = "downloadDir"
const val AnalyticsKey = "analytics" const val AnalyticsKey = "analytics"
const val firstLaunch = "firstLaunch"
}
actual val isFirstLaunch get() = settings.getBooleanOrNull(firstLaunch) ?: true
actual fun firstLaunchDone() {
settings.putBoolean(firstLaunch,false)
} }
actual val isAnalyticsEnabled get() = settings.getBooleanOrNull(AnalyticsKey) ?: false actual val isAnalyticsEnabled get() = settings.getBooleanOrNull(AnalyticsKey) ?: false

View File

@ -40,6 +40,13 @@ actual class Dir actual constructor(
companion object { companion object {
const val DirKey = "downloadDir" const val DirKey = "downloadDir"
const val AnalyticsKey = "analytics" const val AnalyticsKey = "analytics"
const val firstLaunch = "firstLaunch"
}
actual val isFirstLaunch get() = settings.getBooleanOrNull(firstLaunch) ?: true
actual fun firstLaunchDone() {
settings.putBoolean(firstLaunch,false)
} }
actual val isAnalyticsEnabled get() = settings.getBooleanOrNull(AnalyticsKey) ?: false actual val isAnalyticsEnabled get() = settings.getBooleanOrNull(AnalyticsKey) ?: false

View File

@ -1,3 +1,4 @@
- F-Droid Initial Release. - F-Droid Initial Release.
- Size Reduced to 4.9 MB (14% smalled than previous apk).
- Firebase Analytics/Crashlytics Removed, Self-Hosted Alternatives Used (100% Open Source). - Firebase Analytics/Crashlytics Removed, Self-Hosted Alternatives Used (100% Open Source).
- Dependencies Updated. - Dependencies Updated.