From 75843f012b09f0f11da4aec10be2f378465a94c2 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Thu, 29 Apr 2021 14:49:04 +0530 Subject: Add dashboard feature UI --- app/src/main/AndroidManifest.xml | 2 +- .../e/privacycentralapp/features/HomeFeature.kt | 71 ----- .../e/privacycentralapp/features/HomeViewModel.kt | 30 --- .../e/privacycentralapp/features/MainActivity.kt | 29 -- .../features/dashboard/DashboardActivity.kt | 49 ++++ .../features/dashboard/DashboardFeature.kt | 71 +++++ .../features/dashboard/DashboardViewModel.kt | 30 +++ .../main/res/drawable/dummy_leakage_analytics.png | Bin 0 -> 25328 bytes app/src/main/res/drawable/ic_apps_permissions.xml | 22 ++ .../main/res/drawable/ic_chevron_right_24dp.xml | 27 ++ app/src/main/res/drawable/ic_internet_activity.xml | 22 ++ app/src/main/res/drawable/ic_location.xml | 22 ++ app/src/main/res/drawable/ic_privacy_toggle.xml | 22 ++ app/src/main/res/drawable/ic_tracked.xml | 22 ++ app/src/main/res/layout/activity_main.xml | 294 ++++++++++++++++++++- app/src/main/res/values-night/themes.xml | 16 -- app/src/main/res/values/strings.xml | 11 + app/src/main/res/values/themes.xml | 9 +- 18 files changed, 581 insertions(+), 168 deletions(-) delete mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt delete mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt delete mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt create mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardActivity.kt create mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt create mode 100644 app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt create mode 100644 app/src/main/res/drawable/dummy_leakage_analytics.png create mode 100644 app/src/main/res/drawable/ic_apps_permissions.xml create mode 100644 app/src/main/res/drawable/ic_chevron_right_24dp.xml create mode 100644 app/src/main/res/drawable/ic_internet_activity.xml create mode 100644 app/src/main/res/drawable/ic_location.xml create mode 100644 app/src/main/res/drawable/ic_privacy_toggle.xml create mode 100644 app/src/main/res/drawable/ic_tracked.xml delete mode 100644 app/src/main/res/values-night/themes.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b1db8d0..585961c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.PrivacyCentralApp"> - + diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt deleted file mode 100644 index 766d1fa..0000000 --- a/app/src/main/java/foundation/e/privacycentralapp/features/HomeFeature.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 . - */ - -package foundation.e.privacycentralapp.features - -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 = { _, effect -> - when (effect) { - HomeFeature.Effect.LoadingFinished -> HomeFeature.State.Loaded - } -} - -private val actor: Actor = - { _, action -> - when (action) { - HomeFeature.Action.load -> flowOf(HomeFeature.Effect.LoadingFinished) - } - } - -fun homeFeature( - initialState: HomeFeature.State = HomeFeature.State.Loading, - coroutineScope: CoroutineScope -) = BaseFeature( - 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 deleted file mode 100644 index 1a338f9..0000000 --- a/app/src/main/java/foundation/e/privacycentralapp/features/HomeViewModel.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 . - */ - -package foundation.e.privacycentralapp.features - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import foundation.e.flowmvi.feature.BaseFeature - -class HomeViewModel : ViewModel() { - - val homeFeature: BaseFeature 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 deleted file mode 100644 index eefb5e1..0000000 --- a/app/src/main/java/foundation/e/privacycentralapp/features/MainActivity.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 . - */ - -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?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - } -} diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardActivity.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardActivity.kt new file mode 100644 index 0000000..ef296ce --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardActivity.kt @@ -0,0 +1,49 @@ +/* + * 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 . + */ + +package foundation.e.privacycentralapp.features.dashboard + +import android.graphics.Color +import android.os.Bundle +import android.text.Spannable +import android.text.SpannableString +import android.text.style.ForegroundColorSpan +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import foundation.e.privacycentralapp.R + +class DashboardActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + title = "My Privacy Dashboard" + setSupportActionBar(findViewById(R.id.toolbar)) + + addClickToMore(findViewById(R.id.personal_leakag_info)) + } + + private fun addClickToMore(textView: TextView) { + val clickToMore = SpannableString("Click to learn more") + clickToMore.setSpan( + ForegroundColorSpan(Color.parseColor("#007fff")), + 0, + clickToMore.length, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE + ) + textView.append(clickToMore) + } +} diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt new file mode 100644 index 0000000..9b8e28f --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFeature.kt @@ -0,0 +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 . + */ + +package foundation.e.privacycentralapp.features.dashboard + +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 = { _, effect -> + when (effect) { + HomeFeature.Effect.LoadingFinished -> HomeFeature.State.Loaded + } +} + +private val actor: Actor = + { _, action -> + when (action) { + HomeFeature.Action.load -> flowOf(HomeFeature.Effect.LoadingFinished) + } + } + +fun homeFeature( + initialState: HomeFeature.State = HomeFeature.State.Loading, + coroutineScope: CoroutineScope +) = BaseFeature( + initialState, + actor, + reducer, + coroutineScope +) diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt new file mode 100644 index 0000000..82c6c11 --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardViewModel.kt @@ -0,0 +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 . + */ + +package foundation.e.privacycentralapp.features.dashboard + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import foundation.e.flowmvi.feature.BaseFeature + +class DashboardViewModel : ViewModel() { + + val homeFeature: BaseFeature by lazy { + homeFeature(coroutineScope = viewModelScope) + } +} diff --git a/app/src/main/res/drawable/dummy_leakage_analytics.png b/app/src/main/res/drawable/dummy_leakage_analytics.png new file mode 100644 index 0000000..5379cd4 Binary files /dev/null and b/app/src/main/res/drawable/dummy_leakage_analytics.png differ diff --git a/app/src/main/res/drawable/ic_apps_permissions.xml b/app/src/main/res/drawable/ic_apps_permissions.xml new file mode 100644 index 0000000..b7eb1ab --- /dev/null +++ b/app/src/main/res/drawable/ic_apps_permissions.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_chevron_right_24dp.xml b/app/src/main/res/drawable/ic_chevron_right_24dp.xml new file mode 100644 index 0000000..c0a38c1 --- /dev/null +++ b/app/src/main/res/drawable/ic_chevron_right_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_internet_activity.xml b/app/src/main/res/drawable/ic_internet_activity.xml new file mode 100644 index 0000000..ef34960 --- /dev/null +++ b/app/src/main/res/drawable/ic_internet_activity.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_location.xml b/app/src/main/res/drawable/ic_location.xml new file mode 100644 index 0000000..3b04dc4 --- /dev/null +++ b/app/src/main/res/drawable/ic_location.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_privacy_toggle.xml b/app/src/main/res/drawable/ic_privacy_toggle.xml new file mode 100644 index 0000000..6a0f647 --- /dev/null +++ b/app/src/main/res/drawable/ic_privacy_toggle.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_tracked.xml b/app/src/main/res/drawable/ic_tracked.xml new file mode 100644 index 0000000..9aa4736 --- /dev/null +++ b/app/src/main/res/drawable/ic_tracked.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index bdbfeeb..9bf4396 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,18 +1,286 @@ - - - - - \ No newline at end of file + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml deleted file mode 100644 index 647c8ce..0000000 --- a/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fdb9ac8..146bad7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,14 @@ PrivacyCentralApp + Privacy dashboard helps you control and better protect your privacy + Tap to enable quick privacy protection + Personal data leakage over past 24 hours. + Am I tracked? + Currently there are 77 trackers in your apps, 12 trackers are active + Apps Permissions + 120 apps are requesting 72 permissions + My Location + "7 apps are using location permission\n Current location mode: " + My Internet Activity Privacy + "Current internet activity mode: " \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 29ff5b8..e7a4431 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,16 +1,9 @@ - \ No newline at end of file -- cgit v1.2.1