Skip to content

Commit

Permalink
Android Studio suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Oct 9, 2024
1 parent 45c2204 commit 52c6dd7
Show file tree
Hide file tree
Showing 7 changed files with 507 additions and 702 deletions.

This file was deleted.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
applicationId = "com.d4rk.cleaner"
minSdk = 23
targetSdk = 35
versionCode = 133
versionCode = 134
versionName = "3.0.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += listOf(
Expand Down
35 changes: 17 additions & 18 deletions app/src/main/kotlin/com/d4rk/cleaner/data/datastore/DataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DataStore(context: Context) {
private val startupKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_STARTUP)
val startup: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[startupKey] ?: true
preferences[startupKey] != false
}

suspend fun saveStartup(isFirstTime: Boolean) {
Expand All @@ -72,7 +72,7 @@ class DataStore(context: Context) {
private val amoledModeKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_AMOLED_MODE)
val amoledMode: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[amoledModeKey] ?: false
preferences[amoledModeKey] == true
}

suspend fun saveAmoledMode(isChecked: Boolean) {
Expand All @@ -84,7 +84,7 @@ class DataStore(context: Context) {
private val dynamicColorsKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DYNAMIC_COLORS)
val dynamicColors: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[dynamicColorsKey] ?: true
preferences[dynamicColorsKey] != false
}

suspend fun saveDynamicColors(isChecked: Boolean) {
Expand All @@ -96,7 +96,7 @@ class DataStore(context: Context) {
private val bouncyButtonsKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_BOUNCY_BUTTONS)
val bouncyButtons: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[bouncyButtonsKey] ?: true
preferences[bouncyButtonsKey] != false
}

suspend fun saveBouncyButtons(isChecked: Boolean) {
Expand All @@ -121,8 +121,7 @@ class DataStore(context: Context) {

fun getShowBottomBarLabels(): Flow<Boolean> {
return dataStore.data.map { preferences ->
preferences[booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_SHOW_BOTTOM_BAR_LABELS)]
?: true
preferences[booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_SHOW_BOTTOM_BAR_LABELS)] != false
}
}

Expand Down Expand Up @@ -169,7 +168,7 @@ class DataStore(context: Context) {
private val genericFilterKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_GENERIC_FILTER)
val genericFilter: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[genericFilterKey] ?: false
preferences[genericFilterKey] == true
}

suspend fun saveGenericFilter(isChecked: Boolean) {
Expand All @@ -181,7 +180,7 @@ class DataStore(context: Context) {
private val deleteEmptyFoldersKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_EMPTY_FOLDERS)
val deleteEmptyFolders: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteEmptyFoldersKey] ?: true
preferences[deleteEmptyFoldersKey] != false
}

suspend fun saveDeleteEmptyFolders(isChecked: Boolean) {
Expand All @@ -193,7 +192,7 @@ class DataStore(context: Context) {
private val deleteArchivesKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_ARCHIVES)
val deleteArchives: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteArchivesKey] ?: false
preferences[deleteArchivesKey] == true
}

suspend fun saveDeleteArchives(isChecked: Boolean) {
Expand All @@ -205,7 +204,7 @@ class DataStore(context: Context) {
private val deleteInvalidMediaKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_INVALID_MEDIA)
val deleteInvalidMedia: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteInvalidMediaKey] ?: false
preferences[deleteInvalidMediaKey] == true
}

suspend fun saveDeleteInvalidMedia(isChecked: Boolean) {
Expand All @@ -217,7 +216,7 @@ class DataStore(context: Context) {
private val deleteCorpseFilesKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_CORPSE_FILES)
val deleteCorpseFiles: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteCorpseFilesKey] ?: false
preferences[deleteCorpseFilesKey] == true
}

suspend fun saveDeleteCorpseFiles(isChecked: Boolean) {
Expand All @@ -229,7 +228,7 @@ class DataStore(context: Context) {
private val deleteApkFilesKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_APK_FILES)
val deleteApkFiles: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteApkFilesKey] ?: true
preferences[deleteApkFilesKey] != false
}

suspend fun saveDeleteApkFiles(isChecked: Boolean) {
Expand All @@ -241,7 +240,7 @@ class DataStore(context: Context) {
private val deleteAudioFilesKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_AUDIO_FILES)
val deleteAudioFiles: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteAudioFilesKey] ?: true
preferences[deleteAudioFilesKey] != false
}

suspend fun saveDeleteAudioFiles(isChecked: Boolean) {
Expand All @@ -253,7 +252,7 @@ class DataStore(context: Context) {
private val deleteVideoFilesKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_VIDEO_FILES)
val deleteVideoFiles: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteVideoFilesKey] ?: true
preferences[deleteVideoFilesKey] != false
}

suspend fun saveDeleteVideoFiles(isChecked: Boolean) {
Expand All @@ -265,7 +264,7 @@ class DataStore(context: Context) {
private val deleteImageFilesKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_DELETE_IMAGE_FILES)
val deleteImageFiles: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[deleteImageFilesKey] ?: true
preferences[deleteImageFilesKey] != false
}

suspend fun saveDeleteImageFiles(isChecked: Boolean) {
Expand All @@ -277,7 +276,7 @@ class DataStore(context: Context) {
private val clipboardCleanKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_CLIPBOARD_CLEAN)
val clipboardClean: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[clipboardCleanKey] ?: false
preferences[clipboardCleanKey] == true
}

suspend fun saveClipboardClean(isChecked: Boolean) {
Expand All @@ -290,7 +289,7 @@ class DataStore(context: Context) {
private val usageAndDiagnosticsKey =
booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_USAGE_AND_DIAGNOSTICS)
val usageAndDiagnostics: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[usageAndDiagnosticsKey] ?: true
preferences[usageAndDiagnosticsKey] != false
}

suspend fun saveUsageAndDiagnostics(isChecked: Boolean) {
Expand All @@ -302,7 +301,7 @@ class DataStore(context: Context) {
// Ads
private val adsKey = booleanPreferencesKey(name = DataStoreNamesConstants.DATA_STORE_ADS)
val ads: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[adsKey] ?: true
preferences[adsKey] != false
}

suspend fun saveAds(isChecked: Boolean) {
Expand Down
Loading

0 comments on commit 52c6dd7

Please sign in to comment.