summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.idea/codeStyles/Project.xml1
-rw-r--r--app/build.gradle22
-rw-r--r--app/src/main/AndroidManifest.xml3
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/PrivacyCentralApplication.kt5
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt71
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt30
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt3
-rw-r--r--app/src/main/res/layout/activity_main.xml2
8 files changed, 116 insertions, 21 deletions
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index b66e2e7..c274a62 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -158,6 +158,7 @@
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
+ <option name="RIGHT_MARGIN" value="100" />
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
diff --git a/app/build.gradle b/app/build.gradle
index 35e1c73..3e1624b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,14 +4,14 @@ plugins {
}
android {
- compileSdkVersion 29
+ compileSdkVersion buildConfig.compileSdk
defaultConfig {
applicationId "foundation.e.privacycentralapp"
- minSdkVersion 24
- targetSdkVersion 29
- versionCode 1
- versionName "1.0"
+ minSdkVersion buildConfig.minSdk
+ targetSdkVersion buildConfig.targetSdk
+ versionCode buildConfig.version.code
+ versionName buildConfig.version.fullName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -26,17 +26,15 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
- kotlinOptions {
- jvmTarget = '1.8'
- }
}
dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.32"
- implementation 'androidx.core:core-ktx:1.3.2'
+ implementation project(":flow-mvi")
+ implementation Libs.Kotlin.stdlib
+ implementation Libs.AndroidX.coreKtx
implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation 'com.google.android.material:material:1.3.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+ implementation Libs.AndroidX.Lifecycle.runtime
+ implementation Libs.AndroidX.Lifecycle.viewmodel
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a28e77e..b1db8d0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,13 +3,14 @@
package="foundation.e.privacycentralapp">
<application
+ android:name=".PrivacyCentralApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PrivacyCentralApp">
- <activity android:name=".MainActivity">
+ <activity android:name=".features.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/app/src/main/java/foundation/e/privacycentralapp/PrivacyCentralApplication.kt b/app/src/main/java/foundation/e/privacycentralapp/PrivacyCentralApplication.kt
index 4f5039a..87be346 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/PrivacyCentralApplication.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/PrivacyCentralApplication.kt
@@ -17,5 +17,6 @@
package foundation.e.privacycentralapp
-class PrivacyCentralApplication {
-} \ No newline at end of file
+import android.app.Application
+
+class PrivacyCentralApplication : Application()
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt
index 43f29d2..766d1fa 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt
@@ -1,4 +1,71 @@
+/*
+ * Copyright (C) 2021 E FOUNDATION
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
package foundation.e.privacycentralapp.features
-class HomeFeature {
-} \ No newline at end of file
+import foundation.e.flowmvi.Actor
+import foundation.e.flowmvi.Reducer
+import foundation.e.flowmvi.feature.BaseFeature
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.flowOf
+
+// Define a state machine for HomeFeature
+object HomeFeature {
+ sealed class State {
+ object Loading : State()
+ object Loaded : State()
+ }
+
+ sealed class SingleEvent {
+ object NavigateToQuickProtection : SingleEvent()
+ object NavigateToTrackers : SingleEvent()
+ object NavigateToInternetActivityPolicy : SingleEvent()
+ object NavigateToLocation : SingleEvent()
+ object NavigateToPermissionManagement : SingleEvent()
+ }
+
+ sealed class Action {
+ object load : Action()
+ }
+
+ sealed class Effect {
+ object LoadingFinished : Effect()
+ }
+}
+
+private val reducer: Reducer<HomeFeature.State, HomeFeature.Effect> = { _, effect ->
+ when (effect) {
+ HomeFeature.Effect.LoadingFinished -> HomeFeature.State.Loaded
+ }
+}
+
+private val actor: Actor<HomeFeature.State, HomeFeature.Action, HomeFeature.Effect> =
+ { _, action ->
+ when (action) {
+ HomeFeature.Action.load -> flowOf(HomeFeature.Effect.LoadingFinished)
+ }
+ }
+
+fun homeFeature(
+ initialState: HomeFeature.State = HomeFeature.State.Loading,
+ coroutineScope: CoroutineScope
+) = BaseFeature<HomeFeature.State, HomeFeature.Action, HomeFeature.Effect, HomeFeature.SingleEvent>(
+ initialState,
+ actor,
+ reducer,
+ coroutineScope
+)
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt b/app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt
index 6cb37c6..1a338f9 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt
@@ -1,4 +1,30 @@
+/*
+ * Copyright (C) 2021 E FOUNDATION
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
package foundation.e.privacycentralapp.features
-class HomeViewModel {
-} \ No newline at end of file
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import foundation.e.flowmvi.feature.BaseFeature
+
+class HomeViewModel : ViewModel() {
+
+ val homeFeature: BaseFeature<HomeFeature.State, HomeFeature.Action,
+ HomeFeature.Effect, HomeFeature.SingleEvent> by lazy {
+ homeFeature(coroutineScope = viewModelScope)
+ }
+}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt b/app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt
index 3dd2145..eefb5e1 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt
@@ -15,10 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package foundation.e.privacycentralapp
+package foundation.e.privacycentralapp.features
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
+import foundation.e.privacycentralapp.R
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 4fc2444..bdbfeeb 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".MainActivity">
+ tools:context=".features.MainActivity">
<TextView
android:layout_width="wrap_content"