summaryrefslogtreecommitdiff
path: root/app/src/main/java/foundation/e
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/foundation/e')
-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
4 files changed, 102 insertions, 7 deletions
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?) {