Skip to content

Commit

Permalink
Added privacy links
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai-Cristian Condrea committed May 29, 2024
1 parent e4a08f0 commit 1eee2fd
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class AppCoreManager : MultiDexApplication(), Application.ActivityLifecycleCallb

override fun onCreate() {
super.onCreate()
database = Room.databaseBuilder(this, AppDatabase::class.java, "my_database").build()
database = Room.databaseBuilder(this, AppDatabase::class.java, "Cart Calculator")
.fallbackToDestructiveMigration()
.fallbackToDestructiveMigrationOnDowngrade()
.build()
registerActivityLifecycleCallbacks(this)
MobileAds.initialize(this)
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.d4rk.cartcalculator.data.db.table.ShoppingCartItemsTable
import com.d4rk.cartcalculator.data.db.table.ShoppingCartTable
import com.d4rk.cartcalculator.data.repository.DateConverter

@Database(entities = [ShoppingCartTable::class, ShoppingCartItemsTable::class], version = 1)
@Database(entities = [ShoppingCartTable::class, ShoppingCartItemsTable::class], version = 2)
@TypeConverters(DateConverter::class)
abstract class AppDatabase : RoomDatabase() {
abstract fun newCartDao(): NewCartDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,32 @@ import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AdsSettingsComposable(activity: AdsSettingsActivity) {
fun AdsSettingsComposable(activity : AdsSettingsActivity) {
val context = LocalContext.current
val dataStore = DataStore.getInstance(context)
val switchState = dataStore.ads.collectAsState(initial = true)
val scope = rememberCoroutineScope()
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = {
LargeTopAppBar(title = { Text(stringResource(R.string.ads)) }, navigationIcon = {
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection) , topBar = {
LargeTopAppBar(title = { Text(stringResource(R.string.ads)) } , navigationIcon = {
IconButton(onClick = {
activity.finish()
}) {
Icon(
Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null
Icons.AutoMirrored.Filled.ArrowBack , contentDescription = null
)
}
}, scrollBehavior = scrollBehavior)
} , scrollBehavior = scrollBehavior)
}) { innerPadding ->
Box(modifier = Modifier.fillMaxSize()) {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding),
.padding(innerPadding) ,
) {
item {
SwitchCardComposable(
title = stringResource(R.string.display_ads), switchState = switchState
title = stringResource(R.string.display_ads) , switchState = switchState
) { isChecked ->
scope.launch(Dispatchers.IO) {
dataStore.saveAds(isChecked)
Expand All @@ -79,22 +79,22 @@ fun AdsSettingsComposable(activity: AdsSettingsActivity) {
}
item {
Box(modifier = Modifier.padding(horizontal = 8.dp)) {
PreferenceItem(title = stringResource(R.string.personalized_ads),
summary = stringResource(id = R.string.summary_ads_personalized_ads),
onClick = {
val params = ConsentRequestParameters.Builder()
.setTagForUnderAgeOfConsent(false).build()
val consentInformation =
UserMessagingPlatform.getConsentInformation(
context
)
consentInformation.requestConsentInfoUpdate(activity,
params,
{
activity.loadForm()
},
{})
})
PreferenceItem(title = stringResource(R.string.personalized_ads) ,
summary = stringResource(id = R.string.summary_ads_personalized_ads) ,
onClick = {
val params = ConsentRequestParameters.Builder()
.setTagForUnderAgeOfConsent(false).build()
val consentInformation =
UserMessagingPlatform.getConsentInformation(
context
)
consentInformation.requestConsentInfoUpdate(activity ,
params ,
{
activity.loadForm()
} ,
{})
})
}
}
item {
Expand All @@ -103,30 +103,30 @@ fun AdsSettingsComposable(activity: AdsSettingsActivity) {
.fillMaxWidth()
.padding(24.dp)
) {
Icon(imageVector = Icons.Outlined.Info, contentDescription = null)
Icon(imageVector = Icons.Outlined.Info , contentDescription = null)
Spacer(modifier = Modifier.height(24.dp))
Text(stringResource(R.string.summary_ads))
val annotatedString = buildAnnotatedString {
withStyle(
style = SpanStyle(
color = MaterialTheme.colorScheme.primary,
color = MaterialTheme.colorScheme.primary ,
textDecoration = TextDecoration.Underline
)
) {
append(stringResource(R.string.learn_more))
}
addStringAnnotation(
tag = "URL",
annotation = "https://www.example.com",
start = 0,
tag = "URL" ,
annotation = "https://sites.google.com/view/d4rk7355608/more/apps/ads-help-center" ,
start = 0 ,
end = stringResource(R.string.learn_more).length
)
}
ClickableText(text = annotatedString, onClick = { offset ->
annotatedString.getStringAnnotations("URL", offset, offset)
.firstOrNull()?.let { annotation ->
Utils.openUrl(context, annotation.item)
}
ClickableText(text = annotatedString , onClick = { offset ->
annotatedString.getStringAnnotations("URL" , offset , offset)
.firstOrNull()?.let { annotation ->
Utils.openUrl(context , annotation.item)
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun UsageAndDiagnosticsComposable(activity: UsageAndDiagnosticsActivity) {
fun UsageAndDiagnosticsComposable(activity : UsageAndDiagnosticsActivity) {
val context = LocalContext.current
val dataStore = DataStore.getInstance(context)
val switchState = dataStore.usageAndDiagnostics.collectAsState(initial = true)
val scope = rememberCoroutineScope()
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = {
LargeTopAppBar(title = { Text(stringResource(R.string.usage_and_diagnostics)) },
navigationIcon = {
IconButton(onClick = {
activity.finish()
}) {
Icon(
Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null
)
}
},
scrollBehavior = scrollBehavior
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection) , topBar = {
LargeTopAppBar(title = { Text(stringResource(R.string.usage_and_diagnostics)) } ,
navigationIcon = {
IconButton(onClick = {
activity.finish()
}) {
Icon(
Icons.AutoMirrored.Filled.ArrowBack , contentDescription = null
)
}
} ,
scrollBehavior = scrollBehavior
)
}) { innerPadding ->
Box(modifier = Modifier.fillMaxSize()) {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding),
.fillMaxSize()
.padding(innerPadding) ,
) {
item {
SwitchCardComposable(
title = stringResource(R.string.usage_and_diagnostics),
title = stringResource(R.string.usage_and_diagnostics) ,
switchState = switchState
) { isChecked ->
scope.launch(Dispatchers.IO) {
Expand All @@ -81,33 +81,33 @@ fun UsageAndDiagnosticsComposable(activity: UsageAndDiagnosticsActivity) {
item {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(24.dp)
.fillMaxWidth()
.padding(24.dp)
) {
Icon(imageVector = Icons.Outlined.Info, contentDescription = null)
Icon(imageVector = Icons.Outlined.Info , contentDescription = null)
Spacer(modifier = Modifier.height(24.dp))
Text(stringResource(R.string.summary_usage_and_diagnostics))
val annotatedString = buildAnnotatedString {
withStyle(
style = SpanStyle(
color = MaterialTheme.colorScheme.primary,
color = MaterialTheme.colorScheme.primary ,
textDecoration = TextDecoration.Underline
)
) {
append(stringResource(R.string.learn_more))
}
addStringAnnotation(
tag = "URL",
annotation = "https://www.example.com",
start = 0,
tag = "URL" ,
annotation = "https://sites.google.com/view/d4rk7355608/more/apps/privacy-policy" ,
start = 0 ,
end = stringResource(R.string.learn_more).length
)
}
ClickableText(text = annotatedString, onClick = { offset ->
annotatedString.getStringAnnotations("URL", offset, offset)
.firstOrNull()?.let { annotation ->
Utils.openUrl(context, annotation.item)
}
ClickableText(text = annotatedString , onClick = { offset ->
annotatedString.getStringAnnotations("URL" , offset , offset)
.firstOrNull()?.let { annotation ->
Utils.openUrl(context , annotation.item)
}
})
}
}
Expand Down

0 comments on commit 1eee2fd

Please sign in to comment.