ToS consent not needed for F-Droid

Unless user has a Tasks.org account
main
Alex Baker 1 day ago
parent 71450aa782
commit 346d970c0e

@ -53,6 +53,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.tasks.BuildConfig
import org.tasks.R
import org.tasks.TasksApplication.Companion.IS_GOOGLE_PLAY
import org.tasks.analytics.Firebase
import org.tasks.auth.SignInActivity
import org.tasks.billing.Inventory
@ -154,7 +155,8 @@ class MainActivity : AppCompatActivity() {
val acceptedTosVersion by tasksPreferences
.flow(TasksPreferences.acceptedTosVersion, 0)
.collectAsStateWithLifecycle(0)
val needsTosAcceptance = acceptedTosVersion < currentTosVersion
val needsTosAcceptance = acceptedTosVersion < currentTosVersion &&
(IS_GOOGLE_PLAY || inventory.hasTasksAccount)
suspend fun setAcceptedTosVersion(version: Int) {
tasksPreferences.set(TasksPreferences.acceptedTosVersion, version)
}
@ -224,27 +226,33 @@ class MainActivity : AppCompatActivity() {
onBack = { finish() },
onSignIn = {
lifecycleScope.launch {
firebase.logEvent(R.string.event_accept_tos)
setAcceptedTosVersion(currentTosVersion)
if (IS_GOOGLE_PLAY) {
firebase.logEvent(R.string.event_accept_tos)
setAcceptedTosVersion(currentTosVersion)
}
navController.navigate(AddAccountDestination)
}
},
onContinueWithoutSync = {
lifecycleScope.launch {
firebase.logEvent(R.string.event_accept_tos)
if (IS_GOOGLE_PLAY) {
firebase.logEvent(R.string.event_accept_tos)
setAcceptedTosVersion(currentTosVersion)
}
firebase.logEvent(R.string.event_onboarding_sync, R.string.param_selection to "local")
setAcceptedTosVersion(currentTosVersion)
addAccountViewModel.createLocalAccount()
}
},
onImportBackup = {
lifecycleScope.launch {
firebase.logEvent(R.string.event_accept_tos)
if (IS_GOOGLE_PLAY) {
firebase.logEvent(R.string.event_accept_tos)
setAcceptedTosVersion(currentTosVersion)
}
firebase.logEvent(
R.string.event_onboarding_sync,
R.string.param_selection to "import_backup"
)
setAcceptedTosVersion(currentTosVersion)
importBackupLauncher.launch(
FileHelper.newFilePickerIntent(
this@MainActivity,
@ -276,6 +284,7 @@ class MainActivity : AppCompatActivity() {
AddAccountScreen(
hasTasksAccount = inventory.hasTasksAccount,
hasPro = inventory.hasPro,
needsConsent = acceptedTosVersion < currentTosVersion,
onBack = { navController.popBackStack() },
signIn = { platform ->
firebase.logEvent(R.string.event_onboarding_sync, R.string.param_selection to platform)
@ -313,6 +322,8 @@ class MainActivity : AppCompatActivity() {
firebase.logEvent(R.string.event_onboarding_sync, R.string.param_selection to platform.name)
addAccountViewModel.openUrl(this@MainActivity, platform)
},
openLegalUrl = { openUri(it) },
onConsent = { setAcceptedTosVersion(currentTosVersion) },
onNameYourPriceInfo = {
firebase.logEvent(R.string.event_onboarding_name_your_price)
},

@ -39,6 +39,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.tooling.preview.PreviewScreenSizes
import androidx.compose.ui.unit.dp
import org.tasks.R
import org.tasks.TasksApplication.Companion.IS_GOOGLE_PLAY
import org.tasks.themes.TasksTheme
@Composable
@ -131,13 +132,15 @@ private fun WelcomeContent(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally,
) {
LegalDisclosure(
prefixRes = R.string.legal_disclosure_prefix_continuing,
openLegalUrl = openLegalUrl,
modifier = Modifier.widthIn(max = 400.dp),
)
if (IS_GOOGLE_PLAY) {
LegalDisclosure(
prefixRes = R.string.legal_disclosure_prefix_continuing,
openLegalUrl = openLegalUrl,
modifier = Modifier.widthIn(max = 400.dp),
)
Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(16.dp))
}
Button(
onClick = onSignIn,

@ -22,6 +22,8 @@ import org.tasks.billing.Inventory
import org.tasks.caldav.CaldavAccountSettingsActivity
import org.tasks.data.dao.CaldavDao
import org.tasks.etebase.EtebaseAccountSettingsActivity
import org.tasks.extensions.Context.openUri
import org.tasks.preferences.TasksPreferences
import org.tasks.sync.microsoft.MicrosoftSignInViewModel
import org.tasks.themes.TasksTheme
import org.tasks.themes.Theme
@ -33,6 +35,7 @@ class AddAccountActivity : ComponentActivity() {
@Inject lateinit var inventory: Inventory
@Inject lateinit var firebase: Firebase
@Inject lateinit var caldavDao: CaldavDao
@Inject lateinit var tasksPreferences: TasksPreferences
private val viewModel: AddAccountViewModel by viewModels()
private val microsoftVM: MicrosoftSignInViewModel by viewModels()
@ -60,6 +63,10 @@ class AddAccountActivity : ComponentActivity() {
.collectAsStateWithLifecycle(initialValue = emptyList())
var initialAccountCount by remember { mutableStateOf<Int?>(null) }
var hasTasksAccount by remember { mutableStateOf(inventory.hasTasksAccount) }
val currentTosVersion = firebase.getTosVersion()
val acceptedTosVersion by tasksPreferences
.flow(TasksPreferences.acceptedTosVersion, 0)
.collectAsStateWithLifecycle(0)
LaunchedEffect(Unit) {
inventory.updateTasksAccount()
hasTasksAccount = inventory.hasTasksAccount
@ -78,6 +85,7 @@ class AddAccountActivity : ComponentActivity() {
AddAccountScreen(
hasTasksAccount = hasTasksAccount,
hasPro = inventory.hasPro,
needsConsent = acceptedTosVersion < currentTosVersion,
onBack = { finish() },
signIn = { platform ->
firebase.logEvent(
@ -115,6 +123,10 @@ class AddAccountActivity : ComponentActivity() {
)
viewModel.openUrl(this, platform)
},
openLegalUrl = { openUri(it) },
onConsent = {
tasksPreferences.set(TasksPreferences.acceptedTosVersion, currentTosVersion)
},
onNameYourPriceInfo = {
firebase.logEvent(R.string.event_onboarding_name_your_price)
},

@ -32,6 +32,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
@ -40,18 +41,22 @@ 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.setValue
import kotlinx.coroutines.launch
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewFontScale
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.tooling.preview.PreviewScreenSizes
import androidx.compose.ui.unit.dp
import org.tasks.R
import org.tasks.TasksApplication.Companion.IS_GOOGLE_PLAY
import org.tasks.compose.LegalDisclosure
import org.tasks.themes.TasksTheme
@OptIn(ExperimentalMaterial3Api::class)
@ -59,12 +64,17 @@ import org.tasks.themes.TasksTheme
fun AddAccountScreen(
hasTasksAccount: Boolean,
hasPro: Boolean,
needsConsent: Boolean,
onBack: () -> Unit,
signIn: (Platform) -> Unit,
openUrl: (Platform) -> Unit,
openLegalUrl: (String) -> Unit,
onConsent: suspend () -> Unit = {},
onNameYourPriceInfo: () -> Unit = {},
) {
val scope = rememberCoroutineScope()
var showNameYourPriceInfo by remember { mutableStateOf(false) }
var showTasksOrgConsent by remember { mutableStateOf(false) }
if (showNameYourPriceInfo) {
AlertDialog(
@ -79,6 +89,36 @@ fun AddAccountScreen(
)
}
if (showTasksOrgConsent) {
AlertDialog(
onDismissRequest = { showTasksOrgConsent = false },
title = { Text(stringResource(R.string.terms_of_service_proper)) },
text = {
LegalDisclosure(
prefixRes = R.string.legal_disclosure_prefix_using,
openLegalUrl = openLegalUrl,
textAlign = TextAlign.Start,
)
},
dismissButton = {
TextButton(onClick = { showTasksOrgConsent = false }) {
Text(stringResource(R.string.cancel))
}
},
confirmButton = {
Button(onClick = {
showTasksOrgConsent = false
scope.launch {
onConsent()
signIn(Platform.TASKS_ORG)
}
}) {
Text(stringResource(R.string.accept))
}
},
)
}
BackHandler(onBack = onBack)
Scaffold(
topBar = {
@ -119,7 +159,13 @@ fun AddAccountScreen(
title = R.string.tasks_org,
icon = R.drawable.ic_round_icon,
description = R.string.tasks_org_description,
onClick = { signIn(Platform.TASKS_ORG) }
onClick = {
if (needsConsent) {
showTasksOrgConsent = true
} else {
signIn(Platform.TASKS_ORG)
}
}
)
if (hasPro) {
HorizontalDivider(modifier = Modifier.padding(vertical = 16.dp))
@ -332,9 +378,11 @@ fun AddAccountPreview() {
AddAccountScreen(
hasTasksAccount = false,
hasPro = false,
needsConsent = false,
onBack = {},
signIn = {},
openUrl = {},
openLegalUrl = {},
)
}
}

@ -11,7 +11,9 @@ import kotlinx.coroutines.launch
import org.tasks.BuildConfig
import org.tasks.R
import org.tasks.TasksApplication.Companion.IS_GENERIC
import org.tasks.TasksApplication.Companion.IS_GOOGLE_PLAY
import org.tasks.analytics.Firebase
import org.tasks.billing.Inventory
import org.tasks.injection.InjectingPreferenceFragment
import org.tasks.logging.FileLogger
import javax.inject.Inject
@ -21,6 +23,7 @@ class HelpAndFeedback : InjectingPreferenceFragment() {
@Inject lateinit var firebase: Firebase
@Inject lateinit var fileLogger: FileLogger
@Inject lateinit var inventory: Inventory
override fun getPreferenceXml() = R.xml.help_and_feedback
@ -84,7 +87,11 @@ class HelpAndFeedback : InjectingPreferenceFragment() {
openUrl(R.string.follow_reddit, R.string.url_reddit)
openUrl(R.string.follow_twitter, R.string.url_twitter)
openUrl(R.string.source_code, R.string.url_source_code)
openUrl(R.string.terms_of_service, R.string.url_tos)
if (IS_GOOGLE_PLAY || inventory.hasTasksAccount) {
openUrl(R.string.terms_of_service, R.string.url_tos)
} else {
remove(R.string.terms_of_service)
}
openUrl(R.string.privacy_policy, R.string.url_privacy_policy)
}

Loading…
Cancel
Save