Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove app_setup key config #361

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class ExodusDataStoreRepositoryTest {

// then
assert(defaults.containsValue(ExodusConfig("privacy_policy_consent", false)))
assert(defaults.containsValue(ExodusConfig("is_setup_complete", false)))
assert(defaults.containsValue(ExodusConfig("notification_requested", false)))
}

Expand All @@ -62,7 +61,6 @@ class ExodusDataStoreRepositoryTest {

val newValues = mapOf(
"privacy_policy" to ExodusConfig("privacy_policy_consent", true),
"app_setup" to ExodusConfig("is_setup_complete", true),
"notification_perm" to ExodusConfig("notification_requested", true)
)

Expand All @@ -72,33 +70,6 @@ class ExodusDataStoreRepositoryTest {

// then
assert(values.containsValue(ExodusConfig("privacy_policy_consent", true)))
assert(values.containsValue(ExodusConfig("is_setup_complete", true)))
assert(values.containsValue(ExodusConfig("notification_requested", true)))
}

@Test
fun testInsertsAppSetupCorrectly() = runTest {
// given
dataStoreRepository = ExodusDataStoreRepository(
Gson(),
stringPreferencesKey("testKey"),
object : TypeToken<Map<String, ExodusConfig>>() {},
DataStoreName("testDataStore3"),
context
)

val values = mapOf(
"privacy_policy" to ExodusConfig("privacy_policy_consent", true),
"app_setup" to ExodusConfig("is_setup_complete", true),
"notification_perm" to ExodusConfig("notification_requested", true)
)

// when
dataStoreRepository.insert(values)
dataStoreRepository.insertAppSetup(ExodusConfig("is_setup_complete", false))
val appSetup = dataStoreRepository.get("app_setup").first()

// then
assert(appSetup == ExodusConfig("is_setup_complete", false))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import org.eu.exodus_privacy.exodusprivacy.manager.network.ExodusAPIRepository
import org.eu.exodus_privacy.exodusprivacy.manager.network.NetworkManager
import org.eu.exodus_privacy.exodusprivacy.manager.network.data.AppDetails
import org.eu.exodus_privacy.exodusprivacy.manager.packageinfo.ExodusPackageRepository
import org.eu.exodus_privacy.exodusprivacy.manager.storage.ExodusConfig
import org.eu.exodus_privacy.exodusprivacy.manager.storage.ExodusDataStoreRepository
import org.eu.exodus_privacy.exodusprivacy.objects.Application
import javax.inject.Inject

Expand Down Expand Up @@ -78,9 +76,6 @@ class ExodusUpdateService : LifecycleService() {
@Inject
lateinit var exodusDatabaseRepository: ExodusDatabaseRepository

@Inject
lateinit var exodusDataStoreRepository: ExodusDataStoreRepository<ExodusConfig>

@Inject
lateinit var notificationBuilder: NotificationCompat.Builder

Expand Down Expand Up @@ -264,12 +259,6 @@ class ExodusUpdateService : LifecycleService() {
exodusDatabaseRepository.saveApp(it)
}
Log.d(TAG, "Done saving app details.")
exodusDataStoreRepository.insertAppSetup(
ExodusConfig(
"is_setup_complete",
true
)
)
// We are done, gracefully exit!
stopService()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ class MainActivity : AppCompatActivity() {

private fun startInitial() {
viewModel.config.observe(this) { config ->
if (!config["app_setup"]?.enable!! &&
config["privacy_policy"]?.enable!! &&
if (config["privacy_policy"]?.enable!! &&
!ExodusUpdateService.IS_SERVICE_RUNNING
) {
Log.d(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ExodusDialogFragment : DialogFragment() {

private fun startInitial() {
exodusDialogViewModel.config.observe(this) { config ->
if (!config["app_setup"]?.enable!! && config["privacy_policy"]?.enable!! && !ExodusUpdateService.IS_SERVICE_RUNNING) {
if (config["privacy_policy"]?.enable!! && !ExodusUpdateService.IS_SERVICE_RUNNING) {
Log.d(TAG, "Populating database for the first time.")
val intent = Intent(requireContext(), ExodusUpdateService::class.java)
intent.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ExodusPackageRepository @Inject constructor(
permissionsMap[packageInfo.packageName] ?: emptyList(),
getAppStore(packageInfo.packageName, packageManager)
)
Log.d(TAG, "Add app: $app")
Log.d(TAG, "Add app: ${app.name}, ${app.versionName}")
applicationList.add(app)
}
applicationList.sortBy { it.name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject
Expand All @@ -34,7 +33,6 @@ class ExodusDataStoreRepository<ExodusConfig> @Inject constructor(
return gson.toJson(
mapOf(
"privacy_policy" to ExodusConfig("privacy_policy_consent", false),
"app_setup" to ExodusConfig("is_setup_complete", false),
"notification_perm" to ExodusConfig("notification_requested", false)
)
)
Expand All @@ -61,15 +59,6 @@ class ExodusDataStoreRepository<ExodusConfig> @Inject constructor(
}
}

override suspend fun insertAppSetup(data: ExodusConfig) {
val currentData = getAll().first() as MutableMap
currentData["app_setup"] = data
dataStore.edit {
val jsonString = gson.toJson(currentData, typeToken.type)
it[preferenceKey] = jsonString
}
}

override fun clearAll(): Flow<Int> {
return flow {
dataStore.edit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import kotlinx.coroutines.flow.Flow
interface ExodusStorage<T> {
suspend fun insert(data: Map<String, T>)

suspend fun insertAppSetup(data: T)

fun get(key: String): Flow<T>

fun getAll(): Flow<Map<String, T>>
Expand Down