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

Unfollow google's recommended app architecture. #224

Merged
merged 7 commits into from
Nov 12, 2024
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
4 changes: 2 additions & 2 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Apply custom settings to your apps
About The Project
==================

The architecture and modularization of this project are inspired
from [Now in Android](https://github.com/android/nowinandroid) and my goal is to apply the modern
architectures and principles of programming to this project.

The only reason I created this app is to turn off that damn Developer Options when using a banking
app. The only annoying thing about it is you have to go to the Settings app. When you turn off that
switch button, your Developer Options configurations will be reset to default. The good thing is
Expand Down
10 changes: 9 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ android {
dependencies {
implementation(projects.core.data)
implementation(projects.core.designSystem)
implementation(projects.core.model)
implementation(projects.core.domain)

implementation(projects.feature.apps)
implementation(projects.feature.appSettings)
Expand All @@ -73,6 +73,14 @@ dependencies {
implementation(projects.feature.settings)

implementation(projects.broadcastReceiver)
implementation(projects.foregroundService)
implementation(projects.framework.assetManager)
implementation(projects.framework.clipboardManager)
implementation(projects.framework.notificationManager)
implementation(projects.framework.packageManager)
implementation(projects.framework.secureSettings)
implementation(projects.framework.shortcutManager)
implementation(projects.framework.usageStatsManager)

implementation(libs.accompanist.permissions)
implementation(libs.androidx.activity.ktx)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/com/android/geto/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.compose.rememberNavController
import com.android.geto.core.designsystem.theme.GetoTheme
import com.android.geto.core.model.DarkThemeConfig
import com.android.geto.core.model.ThemeBrand
import com.android.geto.core.domain.model.DarkThemeConfig
import com.android.geto.core.domain.model.ThemeBrand
import com.android.geto.navigation.GetoNavHost
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package com.android.geto

import com.android.geto.core.model.UserData
import com.android.geto.core.domain.model.UserData

sealed interface MainActivityUiState {
data object Loading : MainActivityUiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.android.geto

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.android.geto.core.data.repository.UserDataRepository
import com.android.geto.core.domain.repository.UserDataRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand Down
7 changes: 0 additions & 7 deletions broadcast-receiver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,10 @@ plugins {

android {
namespace = "com.android.geto.broadcastreceiver"

defaultConfig {
consumerProguardFiles("consumer-proguard-rules.pro")
}
}

dependencies {
implementation(libs.androidx.core.ktx)
implementation(projects.core.common)
implementation(projects.core.domain)
implementation(projects.core.model)

implementation(projects.framework.notificationManager)
}
Empty file.
2 changes: 1 addition & 1 deletion broadcast-receiver/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<application>
<receiver
android:name=".RevertSettingsBroadcastReceiver"
android:name=".DefaultRevertSettingsBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="ACTION_REVERT_SETTINGS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package com.android.geto.broadcastreceiver

import com.android.geto.core.domain.broadcastreceiver.BroadcastReceiverController
import com.android.geto.core.domain.broadcastreceiver.RevertSettingsBroadcastReceiver
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -30,4 +32,8 @@ internal interface BroadcastReceiverModule {
@Binds
@Singleton
fun broadcastReceiverController(impl: DefaultBroadcastReceiverController): BroadcastReceiverController

@Binds
@Singleton
fun revertSettingsBroadcastReceiver(impl: DefaultRevertSettingsBroadcastReceiver): RevertSettingsBroadcastReceiver
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package com.android.geto.broadcastreceiver

import com.android.geto.core.common.Dispatcher
import com.android.geto.core.common.GetoDispatchers.IO
import com.android.geto.core.domain.RevertAppSettingsUseCase
import com.android.geto.core.model.AppSettingsResult
import com.android.geto.framework.notificationmanager.NotificationManagerWrapper
import com.android.geto.core.domain.broadcastreceiver.BroadcastReceiverController
import com.android.geto.core.domain.framework.NotificationManagerWrapper
import com.android.geto.core.domain.model.AppSettingsResult
import com.android.geto.core.domain.usecase.RevertAppSettingsUseCase
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ package com.android.geto.broadcastreceiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.android.geto.framework.notificationmanager.NotificationManagerWrapper.Companion.EXTRA_NOTIFICATION_ID
import com.android.geto.framework.notificationmanager.NotificationManagerWrapper.Companion.EXTRA_PACKAGE_NAME
import com.android.geto.core.domain.broadcastreceiver.BroadcastReceiverController
import com.android.geto.core.domain.broadcastreceiver.RevertSettingsBroadcastReceiver
import com.android.geto.core.domain.broadcastreceiver.RevertSettingsBroadcastReceiver.Companion.EXTRA_NOTIFICATION_ID
import com.android.geto.core.domain.broadcastreceiver.RevertSettingsBroadcastReceiver.Companion.EXTRA_PACKAGE_NAME
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class RevertSettingsBroadcastReceiver : BroadcastReceiver() {
class DefaultRevertSettingsBroadcastReceiver @Inject constructor() :
BroadcastReceiver(),
RevertSettingsBroadcastReceiver {
@Inject
lateinit var broadcastReceiverController: BroadcastReceiverController

Expand Down
2 changes: 1 addition & 1 deletion core/data-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {

dependencies {
implementation(projects.core.data)
implementation(projects.core.model)
implementation(projects.core.domain)

implementation(libs.hilt.android.testing)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
package com.android.geto.core.data.test

import com.android.geto.core.data.di.DataModule
import com.android.geto.core.data.repository.AppSettingsRepository
import com.android.geto.core.data.repository.PackageRepository
import com.android.geto.core.data.repository.SecureSettingsRepository
import com.android.geto.core.data.repository.ShortcutRepository
import com.android.geto.core.data.repository.UserDataRepository
import com.android.geto.core.data.test.repository.FakeAppSettingsRepository
import com.android.geto.core.data.test.repository.FakePackageRepository
import com.android.geto.core.data.test.repository.FakeSecureSettingsRepository
import com.android.geto.core.data.test.repository.FakeShortcutRepository
import com.android.geto.core.data.test.repository.FakeUserDataRepository
import com.android.geto.core.domain.repository.AppSettingsRepository
import com.android.geto.core.domain.repository.PackageRepository
import com.android.geto.core.domain.repository.SecureSettingsRepository
import com.android.geto.core.domain.repository.ShortcutRepository
import com.android.geto.core.domain.repository.UserDataRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.components.SingletonComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
*/
package com.android.geto.core.data.test.repository

import com.android.geto.core.data.repository.AppSettingsRepository
import com.android.geto.core.model.AppSetting
import com.android.geto.core.model.SettingType
import com.android.geto.core.domain.model.AppSetting
import com.android.geto.core.domain.model.SettingType
import com.android.geto.core.domain.repository.AppSettingsRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flowOf
import javax.inject.Inject

class FakeAppSettingsRepository @Inject constructor() : AppSettingsRepository {
class FakeAppSettingsRepository @Inject constructor() :
AppSettingsRepository {
override val appSettings: Flow<List<AppSetting>> = emptyFlow()

override suspend fun upsertAppSetting(appSetting: AppSetting) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
package com.android.geto.core.data.test.repository

import android.graphics.drawable.Drawable
import com.android.geto.core.data.repository.PackageRepository
import com.android.geto.core.model.GetoApplicationInfo
import com.android.geto.core.domain.model.GetoApplicationInfo
import com.android.geto.core.domain.repository.PackageRepository
import javax.inject.Inject

class FakePackageRepository @Inject constructor() : PackageRepository {
class FakePackageRepository @Inject constructor() :
PackageRepository {
override suspend fun queryIntentActivities(): List<GetoApplicationInfo> {
return List(20) { index ->
GetoApplicationInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
*/
package com.android.geto.core.data.test.repository

import com.android.geto.core.data.repository.SecureSettingsRepository
import com.android.geto.core.model.AppSetting
import com.android.geto.core.model.SecureSetting
import com.android.geto.core.model.SettingType
import com.android.geto.core.domain.model.AppSetting
import com.android.geto.core.domain.model.SecureSetting
import com.android.geto.core.domain.model.SettingType
import com.android.geto.core.domain.repository.SecureSettingsRepository
import javax.inject.Inject

class FakeSecureSettingsRepository @Inject constructor() : SecureSettingsRepository {
class FakeSecureSettingsRepository @Inject constructor() :
SecureSettingsRepository {
override suspend fun applySecureSettings(appSettings: List<AppSetting>): Boolean {
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
*/
package com.android.geto.core.data.test.repository

import com.android.geto.core.data.repository.ShortcutRepository
import com.android.geto.core.model.GetoShortcutInfoCompat
import com.android.geto.core.domain.model.GetoShortcutInfoCompat
import com.android.geto.core.domain.repository.ShortcutRepository
import javax.inject.Inject

class FakeShortcutRepository @Inject constructor() : ShortcutRepository {
class FakeShortcutRepository @Inject constructor() :
ShortcutRepository {

override fun isRequestPinShortcutSupported(): Boolean {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
*/
package com.android.geto.core.data.test.repository

import com.android.geto.core.data.repository.UserDataRepository
import com.android.geto.core.model.DarkThemeConfig
import com.android.geto.core.model.ThemeBrand
import com.android.geto.core.model.UserData
import com.android.geto.core.domain.model.DarkThemeConfig
import com.android.geto.core.domain.model.ThemeBrand
import com.android.geto.core.domain.model.UserData
import com.android.geto.core.domain.repository.UserDataRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import javax.inject.Inject

class FakeUserDataRepository @Inject constructor() : UserDataRepository {
class FakeUserDataRepository @Inject constructor() :
UserDataRepository {

override val userData: Flow<UserData> = flowOf(
UserData(
Expand Down
7 changes: 1 addition & 6 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ dependencies {
implementation(projects.core.common)
implementation(projects.core.database)
implementation(projects.core.datastore)
implementation(projects.core.model)

implementation(projects.framework.clipboardManager)
implementation(projects.framework.packageManager)
implementation(projects.framework.secureSettings)
implementation(projects.framework.shortcutManager)
implementation(projects.core.domain)

testImplementation(libs.kotlinx.coroutines.test)
testImplementation(projects.core.datastoreTest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
*/
package com.android.geto.core.data.di

import com.android.geto.core.data.repository.AppSettingsRepository
import com.android.geto.core.data.repository.DefaultAppSettingsRepository
import com.android.geto.core.data.repository.DefaultPackageRepository
import com.android.geto.core.data.repository.DefaultSecureSettingsRepository
import com.android.geto.core.data.repository.DefaultShortcutRepository
import com.android.geto.core.data.repository.DefaultUserDataRepository
import com.android.geto.core.data.repository.PackageRepository
import com.android.geto.core.data.repository.SecureSettingsRepository
import com.android.geto.core.data.repository.ShortcutRepository
import com.android.geto.core.data.repository.UserDataRepository
import com.android.geto.core.domain.repository.AppSettingsRepository
import com.android.geto.core.domain.repository.PackageRepository
import com.android.geto.core.domain.repository.SecureSettingsRepository
import com.android.geto.core.domain.repository.ShortcutRepository
import com.android.geto.core.domain.repository.UserDataRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import com.android.geto.core.database.dao.AppSettingsDao
import com.android.geto.core.database.model.AppSettingEntity
import com.android.geto.core.database.model.asEntity
import com.android.geto.core.database.model.asExternalModel
import com.android.geto.core.model.AppSetting
import com.android.geto.core.domain.model.AppSetting
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import javax.inject.Inject

internal class DefaultAppSettingsRepository @Inject constructor(
private val appSettingsDao: AppSettingsDao,
) : AppSettingsRepository {
) : com.android.geto.core.domain.repository.AppSettingsRepository {

override val appSettings: Flow<List<AppSetting>> =
appSettingsDao.getAppSettingEntities().distinctUntilChanged().map { entities ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
package com.android.geto.core.data.repository

import android.graphics.drawable.Drawable
import com.android.geto.core.model.GetoApplicationInfo
import com.android.geto.framework.packagemanager.PackageManagerWrapper
import com.android.geto.core.domain.framework.PackageManagerWrapper
import com.android.geto.core.domain.model.GetoApplicationInfo
import javax.inject.Inject

internal class DefaultPackageRepository @Inject constructor(
private val packageManagerWrapper: PackageManagerWrapper,
) : PackageRepository {
) : com.android.geto.core.domain.repository.PackageRepository {

override suspend fun queryIntentActivities(): List<GetoApplicationInfo> {
return packageManagerWrapper.queryIntentActivities()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ package com.android.geto.core.data.repository

import com.android.geto.core.common.Dispatcher
import com.android.geto.core.common.GetoDispatchers.Default
import com.android.geto.core.model.AppSetting
import com.android.geto.core.model.SecureSetting
import com.android.geto.core.model.SettingType
import com.android.geto.framework.securesettings.SecureSettingsWrapper
import com.android.geto.core.domain.framework.SecureSettingsWrapper
import com.android.geto.core.domain.model.AppSetting
import com.android.geto.core.domain.model.SecureSetting
import com.android.geto.core.domain.model.SettingType
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject

internal class DefaultSecureSettingsRepository @Inject constructor(
@Dispatcher(Default) private val defaultDispatcher: CoroutineDispatcher,
private val secureSettingsWrapper: SecureSettingsWrapper,
) : SecureSettingsRepository {
) : com.android.geto.core.domain.repository.SecureSettingsRepository {
override suspend fun applySecureSettings(appSettings: List<AppSetting>): Boolean {
return appSettings.all { appSetting ->
secureSettingsWrapper.canWriteSecureSettings(
Expand Down
Loading
Loading