Skip to content

Commit 956751a

Browse files
committed
refactor: [WIP] updated domain layer
1 parent 1ccb8bb commit 956751a

43 files changed

Lines changed: 758 additions & 280 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

domain/consumer-rules.pro

Whitespace-only changes.

domain/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.androidvip.sysctlgui.domain
2+
3+
import androidx.annotation.StringRes
4+
5+
/**
6+
* Provides access to string resources.
7+
* This interface allows for fetching localized strings, potentially with formatting arguments.
8+
*/
9+
interface StringProvider {
10+
fun getString(@StringRes resId: Int): String
11+
fun getString(@StringRes resId: Int, vararg formatArgs: Any): String
12+
}

domain/src/main/java/com/androidvip/sysctlgui/domain/datasource/LocalDataSourceContract.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

domain/src/main/java/com/androidvip/sysctlgui/domain/datasource/RuntimeDataSourceContract.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
package com.androidvip.sysctlgui.domain.di
22

3-
import com.androidvip.sysctlgui.domain.usecase.AddUserParamUseCase
43
import com.androidvip.sysctlgui.domain.usecase.AddUserParamsUseCase
5-
import com.androidvip.sysctlgui.domain.usecase.ApplyParamsUseCase
4+
import com.androidvip.sysctlgui.domain.usecase.ApplyParamUseCase
65
import com.androidvip.sysctlgui.domain.usecase.BackupParamsUseCase
76
import com.androidvip.sysctlgui.domain.usecase.ClearUserParamUseCase
87
import com.androidvip.sysctlgui.domain.usecase.ExportParamsUseCase
9-
import com.androidvip.sysctlgui.domain.usecase.GetJsonParamsUseCase
8+
import com.androidvip.sysctlgui.domain.usecase.GetAppSettingsUseCase
9+
import com.androidvip.sysctlgui.domain.usecase.GetParamDocumentationUseCase
1010
import com.androidvip.sysctlgui.domain.usecase.GetParamsFromFilesUseCase
11+
import com.androidvip.sysctlgui.domain.usecase.GetRuntimeParamUseCase
1112
import com.androidvip.sysctlgui.domain.usecase.GetRuntimeParamsUseCase
13+
import com.androidvip.sysctlgui.domain.usecase.GetUserParamByNameUseCase
1214
import com.androidvip.sysctlgui.domain.usecase.GetUserParamsUseCase
13-
import com.androidvip.sysctlgui.domain.usecase.ImportParamsUseCase
14-
import com.androidvip.sysctlgui.domain.usecase.PerformDatabaseMigrationUseCase
15+
import com.androidvip.sysctlgui.domain.usecase.IsTaskerInstalledUseCase
1516
import com.androidvip.sysctlgui.domain.usecase.RemoveUserParamUseCase
16-
import com.androidvip.sysctlgui.domain.usecase.UpdateUserParamUseCase
17+
import com.androidvip.sysctlgui.domain.usecase.UpsertUserParamUseCase
18+
import org.koin.android.ext.koin.androidContext
19+
import org.koin.core.module.dsl.factoryOf
1720
import org.koin.dsl.module
1821

1922
val domainModule = module {
20-
factory { AddUserParamsUseCase(get(), get()) }
21-
factory { AddUserParamUseCase(get(), get()) }
22-
factory { ApplyParamsUseCase(get(), get()) }
23-
factory { ClearUserParamUseCase(get()) }
24-
factory { GetJsonParamsUseCase(get()) }
25-
factory { GetParamsFromFilesUseCase(get()) }
26-
factory { GetUserParamsUseCase(get()) }
27-
factory { GetRuntimeParamsUseCase(get(), get()) }
28-
factory { PerformDatabaseMigrationUseCase(get()) }
29-
factory { RemoveUserParamUseCase(get()) }
30-
factory { UpdateUserParamUseCase(get(), get()) }
31-
factory { ImportParamsUseCase(get(), get(), get(), get()) }
32-
factory { BackupParamsUseCase(get(), get()) }
33-
factory { ExportParamsUseCase(get(), get()) }
23+
factoryOf(::AddUserParamsUseCase)
24+
factoryOf(::ApplyParamUseCase)
25+
factoryOf(::ClearUserParamUseCase)
26+
factoryOf(::GetParamsFromFilesUseCase)
27+
factoryOf(::GetUserParamsUseCase)
28+
factoryOf(::GetRuntimeParamsUseCase)
29+
factoryOf(::GetRuntimeParamUseCase)
30+
factoryOf(::GetUserParamByNameUseCase)
31+
factoryOf(::RemoveUserParamUseCase)
32+
factoryOf(::UpsertUserParamUseCase)
33+
factoryOf(::BackupParamsUseCase)
34+
factoryOf(::ExportParamsUseCase)
35+
factoryOf(::GetAppSettingsUseCase)
36+
factoryOf(::GetParamDocumentationUseCase)
37+
factory { IsTaskerInstalledUseCase(androidContext()) }
3438
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.androidvip.sysctlgui.domain.enums
2+
3+
/**
4+
* Defines the method used to commit kernel parameter changes.
5+
*/
6+
enum class CommitMode {
7+
/**
8+
* Commits the value using the `sysctl -w` command.
9+
* This is the default mode.
10+
*/
11+
SYSCTL,
12+
/**
13+
* Commits the value to the file using `echo` command.
14+
* This method is generally safer and more reliable.
15+
*/
16+
ECHO;
17+
18+
companion object {
19+
fun parse(value: String): CommitMode {
20+
return when (value) {
21+
"sysctl" -> SYSCTL
22+
"echo" -> ECHO
23+
else -> SYSCTL
24+
}
25+
}
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.androidvip.sysctlgui.domain.enums
2+
3+
/**
4+
* Represents the different types of settings component that can be displayed in the UI.
5+
* Each type corresponds to a specific UI element used to interact with the setting.
6+
*/
7+
enum class SettingItemType {
8+
/**
9+
* Simple setting header with no behavior
10+
*/
11+
Text,
12+
13+
/**
14+
* Represents a switch setting component that can be toggled on or off.
15+
*/
16+
Switch,
17+
18+
/**
19+
* Represents a list of options that can be selected from.
20+
*/
21+
List,
22+
23+
/**
24+
* Represents a slider component that allows the user to select a value within a range.
25+
*/
26+
Slider
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
package com.androidvip.sysctlgui.domain.exceptions
22

3+
// TODO: Use sealed classes instead of exceptions
4+
/**
5+
* Exception thrown when a value commit fails or refuses to be applied (value remains the same)
6+
*/
37
class ApplyValueException(message: String) : Exception(message)
8+
9+
/**
10+
* Exception thrown when a value commit fails and the commit mode is "sysctl"
11+
*/
412
class CommitModeException(message: String) : Exception(message)
13+
14+
/**
15+
* Exception thrown when a value to be committed is blank and blank values are not allowed
16+
*/
17+
class BlankValueNotAllowedException() : IllegalArgumentException()
18+
19+
/**
20+
* Exception thrown when a shell command fails
21+
*/
22+
class ShellCommandException(message: String, cause: Throwable) : Exception(message, cause)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
package com.androidvip.sysctlgui.domain.exceptions
22

3+
/**
4+
* Exception thrown when no parameter is found for a given kernel file path.
5+
*/
36
class NoParameterFoundException : Exception()

0 commit comments

Comments
 (0)