Skip to content

Commit

Permalink
Fixes for Play Protect alarm (#79)
Browse files Browse the repository at this point in the history
* Hide crash report setting & disable ACRA for Google Play
* Link to the Privacy Policy in Settings screen
* Explanation of pair alerts
  • Loading branch information
mdrlzy authored Jan 18, 2024
1 parent e2fd0ef commit 32002fc
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ android {
buildConfigField "String", "ACRA_LOGIN", "\"$login\""
buildConfigField "String", "ACRA_PASS", "\"$password\""
buildConfigField "String", "ACRA_URI", "\"$uri\""
buildConfigField "boolean", "GOOGLE_PLAY_BUILD", "false"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/dev/arkbuilders/rate/presentation/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class App : Application() {
super.onCreate()
Timber.plant(Timber.DebugTree())
DIManager.init(this)
initAcra()

if (!BuildConfig.GOOGLE_PLAY_BUILD)
initAcra()

initWorker()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Button
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
Expand All @@ -31,16 +33,23 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import dev.arkbuilders.rate.R
import dev.arkbuilders.rate.data.model.PairAlertCondition
import dev.arkbuilders.rate.presentation.destinations.AddCurrencyScreenDestination
import dev.arkbuilders.rate.presentation.destinations.PairAlertConditionScreenDestination
import dev.arkbuilders.rate.presentation.shared.SharedViewModel
import dev.arkbuilders.rate.presentation.theme.Purple500
import dev.arkbuilders.rate.presentation.utils.activityViewModel
import dev.arkbuilders.rate.utils.removeFractionalPartIfEmpty

Expand All @@ -50,8 +59,27 @@ fun PairAlertConditionScreen(
navigator: DestinationsNavigator,
viewModel: SharedViewModel = activityViewModel()
) {
var descDialog by remember { mutableStateOf(false) }

Box(modifier = Modifier.fillMaxSize()) {
LazyColumn(modifier = Modifier.fillMaxSize()) {
item {
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.CenterEnd
) {
IconButton(
modifier = Modifier.padding(top = 16.dp, end = 8.dp),
onClick = { descDialog = true }
) {
Icon(
painter = painterResource(R.drawable.ic_question_mark),
contentDescription = "",
tint = Purple500
)
}
}
}
items(
viewModel.pairAlertConditions,
key = { it.id }
Expand All @@ -63,6 +91,11 @@ fun PairAlertConditionScreen(
}
}
}

if (descDialog)
DescDialog {
descDialog = false
}
}

@Composable
Expand Down Expand Up @@ -205,4 +238,31 @@ private fun AddOrDeleteBtn(
Icon(Icons.Filled.Delete, "Delete")
}
}
}

@Composable
private fun DescDialog(onDismiss: () -> Unit) {
Dialog(onDismissRequest = { onDismiss() }) {
Surface(
shape = RoundedCornerShape(20.dp),
color = Color.White
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = stringResource(R.string.pair_alerts_desc),
textAlign = TextAlign.Center
)
Button(
modifier = Modifier.padding(top = 10.dp),
onClick = { onDismiss() }) {
Text(text = stringResource(R.string.ok))
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

package dev.arkbuilders.rate.presentation.settings

import android.content.Intent
import android.net.Uri
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -41,14 +44,18 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.core.content.ContextCompat
import androidx.lifecycle.viewmodel.compose.viewModel
import com.ramcosta.composedestinations.annotation.Destination
import dev.arkbuilders.rate.BuildConfig
import dev.arkbuilders.rate.R
import dev.arkbuilders.rate.data.preferences.PreferenceKey
import dev.arkbuilders.rate.di.DIManager
Expand All @@ -68,12 +75,39 @@ fun SettingsScreen() {
}
}

@Composable
private fun PrivacyPolicy() {
val ctx = LocalContext.current
val url = stringResource(id = R.string.privacy_policy_url)
Surface(
color = Color.Transparent,
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
onClick = {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
ctx.startActivity(intent)
},
) {
Column {
Text(
modifier = Modifier.padding(16.dp),
text = stringResource(id = R.string.privacy_policy),
style = MaterialTheme.typography.body1,
)
Divider()
}

}
}

@Composable
private fun Settings(vm: SettingsViewModel) {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(16.dp)
.verticalScroll(rememberScrollState())
) {
SettingsGroup(name = R.string.currencies) {
SettingsNumberComp(
Expand Down Expand Up @@ -117,14 +151,17 @@ private fun Settings(vm: SettingsViewModel) {
)
}
SettingsGroup(name = R.string.privacy) {
SettingsSwitchComp(
name = R.string.crash_reports,
state = vm.boolPrefs[PreferenceKey.CrashReport]!!
) { state ->
vm.onToggle(
PreferenceKey.CrashReport,
state
)
PrivacyPolicy()
if (!BuildConfig.GOOGLE_PLAY_BUILD) {
SettingsSwitchComp(
name = R.string.crash_reports,
state = vm.boolPrefs[PreferenceKey.CrashReport]!!
) { state ->
vm.onToggle(
PreferenceKey.CrashReport,
state
)
}
}
}
}
Expand Down Expand Up @@ -245,7 +282,7 @@ fun SettingsNumberComp(
modifier = Modifier.size(24.dp)
)
}
Spacer(modifier = Modifier.width(16.dp))
Spacer(modifier = Modifier.width(8.dp))
Column(modifier = Modifier.padding(8.dp)) {
Text(
text = stringResource(id = name),
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_question_mark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M11.07,12.85c0.77,-1.39 2.25,-2.21 3.11,-3.44c0.91,-1.29 0.4,-3.7 -2.18,-3.7c-1.69,0 -2.52,1.28 -2.87,2.34L6.54,6.96C7.25,4.83 9.18,3 11.99,3c2.35,0 3.96,1.07 4.78,2.41c0.7,1.15 1.11,3.3 0.03,4.9c-1.2,1.77 -2.35,2.31 -2.97,3.45c-0.25,0.46 -0.35,0.76 -0.35,2.24h-2.89C10.58,15.22 10.46,13.95 11.07,12.85zM14,20c0,1.1 -0.9,2 -2,2s-2,-0.9 -2,-2c0,-1.1 0.9,-2 2,-2S14,18.9 14,20z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
<string name="show_as_list">List</string>
<string name="sorted_by_used_count">Used count</string>
<string name="sorted_by_used_time">Used time</string>
<string name="pair_alerts_desc">App in the background checks the specified exchange rates once a day and if the condition matches, then displays a notification.</string>
<string name="ok">OK</string>
<string name="privacy_policy_url" translatable="false">https://www.ark-builders.dev/apps/rate/privacy-policy</string>
<string name="privacy_policy">Privacy policy</string>
</resources>

0 comments on commit 32002fc

Please sign in to comment.