Skip to content

Commit 5ff57f4

Browse files
Add legal disclaimer
1 parent 5017478 commit 5ff57f4

File tree

6 files changed

+83
-10
lines changed

6 files changed

+83
-10
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
minSdk = 29
2727
targetSdk = 35
2828

29-
versionCode = 1708536374
30-
versionName = "0.29.4-beta"
29+
versionCode = 1708536375
30+
versionName = "0.29.5-beta"
3131

3232
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3333

app/src/main/java/f/cking/software/data/repo/SettingsRepository.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ class SettingsRepository(
112112
return sharedPreferences.getBoolean(KEY_ENABLE_DEEP_ANALYSIS, false)
113113
}
114114

115+
fun setDisclaimerWasAccepted(value: Boolean) {
116+
sharedPreferences.edit { putBoolean(KEY_DISCLAIMER_WAS_ACCEPTED, value) }
117+
}
118+
119+
fun getDisclaimerWasAccepted(): Boolean {
120+
return sharedPreferences.getBoolean(KEY_DISCLAIMER_WAS_ACCEPTED, false)
121+
}
122+
115123
companion object {
116124
private const val KEY_GARBAGING_TIME = "key_garbaging_time"
117125
private const val KEY_USE_GPS_ONLY = "key_use_gps_location_only"
@@ -124,6 +132,7 @@ class SettingsRepository(
124132
private const val KEY_CURRENT_BATCH_SORTING_STRATEGY_ID = "key_current_batch_sorting_strategy_id"
125133
private const val KEY_HIDE_BACKGROUND_LOCATION_WARNING = "key_hide_background_location_warning"
126134
private const val KEY_ENABLE_DEEP_ANALYSIS = "key_enable_deep_analysis"
135+
private const val KEY_DISCLAIMER_WAS_ACCEPTED = "key_disclaimer_was_accepted"
127136

128137
const val NO_APP_LAUNCH_TIME = -1L
129138
const val NO_ENJOY_THE_APP_STARTING_POINT = -1L

app/src/main/java/f/cking/software/ui/main/MainScreen.kt

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ import android.widget.Toast
66
import androidx.compose.foundation.Image
77
import androidx.compose.foundation.background
88
import androidx.compose.foundation.clickable
9-
import androidx.compose.foundation.layout.*
9+
import androidx.compose.foundation.layout.Arrangement
10+
import androidx.compose.foundation.layout.Box
11+
import androidx.compose.foundation.layout.Column
12+
import androidx.compose.foundation.layout.Row
13+
import androidx.compose.foundation.layout.Spacer
14+
import androidx.compose.foundation.layout.fillMaxSize
15+
import androidx.compose.foundation.layout.fillMaxWidth
16+
import androidx.compose.foundation.layout.height
17+
import androidx.compose.foundation.layout.padding
18+
import androidx.compose.foundation.layout.size
19+
import androidx.compose.foundation.layout.width
1020
import androidx.compose.foundation.lazy.LazyColumn
1121
import androidx.compose.foundation.shape.RoundedCornerShape
1222
import androidx.compose.material.icons.Icons
@@ -52,6 +62,7 @@ import f.cking.software.utils.graphic.DropEffectState
5262
import f.cking.software.utils.graphic.GlassBottomNavBar
5363
import f.cking.software.utils.graphic.SystemNavbarSpacer
5464
import f.cking.software.utils.graphic.ThemedDialog
65+
import f.cking.software.utils.graphic.infoDialog
5566
import f.cking.software.utils.graphic.rememberDropEffectState
5667
import f.cking.software.utils.graphic.withDropEffect
5768
import org.koin.androidx.compose.koinViewModel
@@ -195,10 +206,35 @@ object MainScreen {
195206
}
196207

197208
val context = LocalContext.current
209+
210+
var checkAndStartService: (() -> Boolean)? = null
211+
212+
val disclaimerDialog = infoDialog(
213+
title = stringResource(R.string.disclaimer),
214+
content = stringResource(R.string.unlowful_usage_disclaimer),
215+
buttons = { state ->
216+
{
217+
negativeButton(
218+
stringResource(R.string.decline),
219+
textStyle = TextStyle(color = MaterialTheme.colorScheme.onSurface)
220+
) { state.hide() }
221+
222+
positiveButton(
223+
stringResource(R.string.accept),
224+
textStyle = TextStyle(color = MaterialTheme.colorScheme.onSurface)
225+
) {
226+
viewModel.disclaimerWasAccepted()
227+
state.hide()
228+
checkAndStartService?.invoke()
229+
}
230+
}
231+
}
232+
)
233+
198234
val permissionsIntro = permissionsIntroDialog(
199235
onPassed = {
200236
viewModel.userHasPassedPermissionsIntro()
201-
viewModel.runBackgroundScanning()
237+
checkAndStartService?.invoke()
202238
},
203239
onDeclined = {
204240
Toast.makeText(context, "The scanner cannot work without these permissions", Toast.LENGTH_SHORT).show()
@@ -207,6 +243,23 @@ object MainScreen {
207243
val haptic = LocalHapticFeedback.current
208244
var observeEvent = remember { true }
209245

246+
checkAndStartService = {
247+
when {
248+
viewModel.needToShowDisclaimer() -> {
249+
disclaimerDialog.show()
250+
false
251+
}
252+
viewModel.needToShowPermissionsIntro() -> {
253+
permissionsIntro.show()
254+
false
255+
}
256+
else -> {
257+
viewModel.runBackgroundScanning()
258+
true
259+
}
260+
}
261+
}
262+
210263
ExtendedFloatingActionButton(
211264
containerColor = MaterialTheme.colorScheme.primaryContainer,
212265
modifier = Modifier
@@ -225,13 +278,12 @@ object MainScreen {
225278
}
226279

227280
observeEvent && event.action == MotionEvent.ACTION_UP -> {
228-
if (viewModel.needToShowPermissionsIntro()) {
229-
permissionsIntro.show()
230-
dropEffectState.drop(type = DropEffectState.DropEvent.Type.RELEASE_SOFT, touchX, touchY)
231-
} else {
232-
viewModel.runBackgroundScanning()
281+
val started = checkAndStartService.invoke()
282+
if (started) {
233283
dropEffectState.drop(type = DropEffectState.DropEvent.Type.RELEASE_HARD, touchX, touchY)
234284
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
285+
} else {
286+
dropEffectState.drop(type = DropEffectState.DropEvent.Type.RELEASE_SOFT, touchX, touchY)
235287
}
236288
true
237289
}

app/src/main/java/f/cking/software/ui/main/MainViewModel.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ class MainViewModel(
113113
settingsRepository.setPermissionsIntroWasShown(true)
114114
}
115115

116+
fun needToShowDisclaimer(): Boolean {
117+
return !settingsRepository.getDisclaimerWasAccepted()
118+
}
119+
120+
fun disclaimerWasAccepted() {
121+
settingsRepository.setDisclaimerWasAccepted(true)
122+
}
123+
116124
private fun observeScanInProgress() {
117125
viewModelScope.launch {
118126
BgScanService.state

app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,12 @@ fun rememberProgressDialog(
191191
fun infoDialog(
192192
title: String,
193193
content: String?,
194+
buttons: ((state: MaterialDialogState) -> (@Composable MaterialDialogButtons.() -> Unit))? = null,
194195
): MaterialDialogState {
195196
val dialogState = rememberMaterialDialogState()
196197
ThemedDialog(
197198
dialogState = dialogState,
198-
buttons = {
199+
buttons = buttons?.invoke(dialogState) ?: {
199200
positiveButton(
200201
stringResource(R.string.ok),
201202
textStyle = TextStyle(color = MaterialTheme.colorScheme.onSurface)

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<string name="ok">OK</string>
1717
<string name="turn_on">Turn on</string>
1818
<string name="report">Report</string>
19+
<string name="accept">Accept</string>
1920
<string name="shaders_test" translatable="false">Shaders test</string>
2021
<string name="preparing_database">Optimizing database, it might take a minute…</string>
2122

@@ -356,4 +357,6 @@
356357

357358
<string name="bluetooth_status_paired">paired</string>
358359
<string name="bluetooth_status_paired_description">Device is paired</string>
360+
361+
<string name="unlowful_usage_disclaimer">This project is developed solely for educational, security research, and personal investigative purposes. The author does not endorse or encourage any use of this software for unlawful or unethical activities. You are solely responsible for ensuring your use of this tool complies with all applicable laws and regulations.</string>
359362
</resources>

0 commit comments

Comments
 (0)