Skip to content

Commit

Permalink
Updated the personalized ads preference when the user turn off ads
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai-Cristian Condrea committed Jun 17, 2024
1 parent 348e79a commit d02d414
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
applicationId = "com.d4rk.cartcalculator"
minSdk = 26
targetSdk = 34
versionCode = 43
versionCode = 44
versionName = "1.0.1"
archivesName = "${applicationId}-v${versionName}"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fun AdsSettingsComposable(activity : AdsSettingsActivity) {
item {
Box(modifier = Modifier.padding(horizontal = 8.dp)) {
PreferenceItem(title = stringResource(R.string.personalized_ads) ,
enabled = switchState.value ,
summary = stringResource(id = R.string.summary_ads_personalized_ads) ,
onClick = {
val params = ConsentRequestParameters.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults
Expand Down Expand Up @@ -118,30 +119,40 @@ fun PreferenceCategoryItem(
*/
@Composable
fun PreferenceItem(
icon: ImageVector? = null,
title: String? = null,
summary: String? = null,
onClick: () -> Unit = {}
icon : ImageVector? = null ,
title : String? = null ,
summary : String? = null ,
enabled : Boolean = true ,
onClick : () -> Unit = {}
) {
Row(
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(16.dp))
.clickable(onClick = onClick), verticalAlignment = Alignment.CenterVertically
.fillMaxWidth()
.clip(RoundedCornerShape(16.dp))
.clickable(enabled = enabled , onClick = onClick) ,
verticalAlignment = Alignment.CenterVertically
) {
icon?.let {
Spacer(modifier = Modifier.width(16.dp))
Icon(it, contentDescription = null)
Icon(it , contentDescription = null)
Spacer(modifier = Modifier.width(16.dp))
}
Column(
modifier = Modifier.padding(16.dp)
) {
title?.let {
Text(text = it, style = MaterialTheme.typography.titleLarge)
Text(
text = it ,
style = MaterialTheme.typography.titleLarge ,
color = if (! enabled) LocalContentColor.current.copy(alpha = 0.38f) else LocalContentColor.current
)
}
summary?.let {
Text(text = it, style = MaterialTheme.typography.bodyMedium)
Text(
text = it ,
style = MaterialTheme.typography.bodyMedium ,
color = if (! enabled) LocalContentColor.current.copy(alpha = 0.38f) else LocalContentColor.current
)
}
}
}
Expand Down

0 comments on commit d02d414

Please sign in to comment.