From da842396556248654acacfdebbc01f5e20132eb6 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 14 May 2021 21:20:57 +0530 Subject: Extract toolbar implementation and add back navigation support --- .../privacycentralapp/common/NavToolbarFragment.kt | 34 ++++++++++++++++++ .../e/privacycentralapp/common/ToolbarFragment.kt | 42 ++++++++++++++++++++++ .../features/dashboard/DashboardFragment.kt | 13 ++----- .../features/dashboard/QuickProtectionFragment.kt | 19 ++-------- .../internetprivacy/InternetPrivacyFragment.kt | 13 ++----- .../features/location/FakeLocationFragment.kt | 25 ++++--------- .../features/location/FakeLocationMapView.kt | 8 +++++ .../features/permissions/PermissionAppsFragment.kt | 18 ++-------- .../features/permissions/PermissionsFragment.kt | 13 ++----- app/src/main/res/layout/fragment_dashboard.xml | 9 +---- app/src/main/res/layout/fragment_fake_location.xml | 23 +----------- .../layout/fragment_internet_activity_policy.xml | 9 +---- .../main/res/layout/fragment_permission_apps.xml | 9 +---- app/src/main/res/layout/fragment_permissions.xml | 9 +---- .../main/res/layout/fragment_quick_protection.xml | 10 +----- app/src/main/res/layout/toolbar.xml | 28 +++++++++++++++ 16 files changed, 140 insertions(+), 142 deletions(-) create mode 100644 app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt create mode 100644 app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt create mode 100644 app/src/main/res/layout/toolbar.xml (limited to 'app/src') diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt new file mode 100644 index 0000000..0a9d102 --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt @@ -0,0 +1,34 @@ +/* + * 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.common + +import android.widget.Toolbar +import androidx.annotation.LayoutRes + +abstract class NavToolbarFragment(@LayoutRes contentLayoutId: Int) : ToolbarFragment(contentLayoutId) { + + override fun setupToolbar(toolbar: Toolbar) { + super.setupToolbar(toolbar) + toolbar.apply { + setNavigationIcon(lineageos.platform.R.drawable.ic_back) + setNavigationOnClickListener { + requireActivity().onBackPressed() + } + } + } +} diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt new file mode 100644 index 0000000..c316340 --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt @@ -0,0 +1,42 @@ +/* + * 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.common + +import android.os.Bundle +import android.view.View +import android.widget.Toolbar +import androidx.annotation.LayoutRes +import androidx.fragment.app.Fragment +import foundation.e.privacycentralapp.R + +abstract class ToolbarFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId) { + + /** + * @return title to be used in toolbar + */ + abstract fun getTitle(): String + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setupToolbar(view.findViewById(R.id.toolbar)) + } + + open fun setupToolbar(toolbar: Toolbar) { + toolbar.title = getTitle() + } +} diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt index f0a7397..4164fea 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt @@ -26,15 +26,14 @@ import android.view.View import android.widget.ProgressBar import android.widget.RelativeLayout import android.widget.TextView -import android.widget.Toolbar import androidx.core.widget.NestedScrollView -import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.add import androidx.fragment.app.commit import androidx.lifecycle.lifecycleScope import foundation.e.flowmvi.MVIView import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.ToolbarFragment import foundation.e.privacycentralapp.dummy.mapToString import foundation.e.privacycentralapp.features.internetprivacy.InternetPrivacyFragment import foundation.e.privacycentralapp.features.location.FakeLocationFragment @@ -43,7 +42,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect class DashboardFragment : - Fragment(R.layout.fragment_dashboard), + ToolbarFragment(R.layout.fragment_dashboard), MVIView { private val viewModel: DashboardViewModel by activityViewModels() @@ -97,8 +96,6 @@ class DashboardFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val toolbar = view.findViewById(R.id.toolbar) - setupToolbar(toolbar) addClickToMore(view.findViewById(R.id.personal_leakag_info)) view.let { it.findViewById(R.id.tap_to_enable_quick_protection).setOnClickListener { @@ -116,11 +113,7 @@ class DashboardFragment : } } - private fun setupToolbar(toolbar: Toolbar) { - val activity = requireActivity() - activity.setActionBar(toolbar) - activity.title = "My Privacy Dashboard" - } + override fun getTitle(): String = "My Privacy Dashboard" private fun addClickToMore(textView: TextView) { val clickToMore = SpannableString("Click to learn more") diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt index c120b49..442cfd2 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt @@ -18,23 +18,16 @@ package foundation.e.privacycentralapp.features.dashboard import android.content.Context -import android.os.Bundle -import android.view.View -import android.widget.Toolbar import androidx.activity.addCallback -import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.NavToolbarFragment -class QuickProtectionFragment : Fragment(R.layout.fragment_quick_protection) { +class QuickProtectionFragment : NavToolbarFragment(R.layout.fragment_quick_protection) { private val viewModel: DashboardViewModel by activityViewModels() - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val toolbar = view.findViewById(R.id.toolbar) - setupToolbar(toolbar) - } + override fun getTitle(): String = "Quick protection" override fun onAttach(context: Context) { super.onAttach(context) @@ -44,10 +37,4 @@ class QuickProtectionFragment : Fragment(R.layout.fragment_quick_protection) { requireActivity().onBackPressed() } } - - private fun setupToolbar(toolbar: Toolbar) { - val activity = requireActivity() - activity.setActionBar(toolbar) - activity.title = "Quick protection" - } } diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt index a8c1671..1844129 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt @@ -21,18 +21,17 @@ import android.os.Bundle import android.view.View import android.widget.RadioButton import android.widget.Toast -import android.widget.Toolbar -import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import foundation.e.flowmvi.MVIView import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.NavToolbarFragment import foundation.e.privacycentralapp.dummy.InternetPrivacyMode import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect class InternetPrivacyFragment : - Fragment(R.layout.fragment_internet_activity_policy), + NavToolbarFragment(R.layout.fragment_internet_activity_policy), MVIView { private val viewModel: InternetPrivacyViewModel by viewModels() @@ -63,16 +62,10 @@ class InternetPrivacyFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val toolbar = view.findViewById(R.id.toolbar) - setupToolbar(toolbar) bindClickListeners(view) } - private fun setupToolbar(toolbar: Toolbar) { - val activity = requireActivity() - activity.setActionBar(toolbar) - activity.title = "My Internet Activity Privacy" - } + override fun getTitle(): String = "My Internet Activity Privacy" private fun bindClickListeners(fragmentView: View) { fragmentView.let { diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt index d569e2f..2d174f0 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt @@ -31,10 +31,8 @@ import android.widget.FrameLayout import android.widget.ImageView import android.widget.RadioButton import android.widget.Toast -import android.widget.Toolbar import androidx.annotation.NonNull import androidx.core.widget.addTextChangedListener -import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import com.google.android.material.textfield.TextInputLayout @@ -52,12 +50,12 @@ import com.mapbox.mapboxsdk.location.LocationUpdate import com.mapbox.mapboxsdk.location.modes.CameraMode import com.mapbox.mapboxsdk.location.modes.RenderMode import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback import com.mapbox.mapboxsdk.maps.Style import foundation.e.flowmvi.MVIView import foundation.e.privacycentralapp.DependencyContainer import foundation.e.privacycentralapp.PrivacyCentralApplication import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.NavToolbarFragment import foundation.e.privacycentralapp.dummy.LocationMode import foundation.e.privacycentralapp.extensions.viewModelProviderFactoryOf import kotlinx.coroutines.Job @@ -68,7 +66,7 @@ import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch class FakeLocationFragment : - Fragment(R.layout.fragment_fake_location), + NavToolbarFragment(R.layout.fragment_fake_location), MVIView, PermissionsListener { @@ -180,6 +178,10 @@ class FakeLocationFragment : Mapbox.getInstance(requireContext(), getString(R.string.mapbox_key)) } + override fun getTitle(): String { + return getString(R.string.my_location_title) + } + private fun displayToast(message: String) { Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT) .show() @@ -187,8 +189,7 @@ class FakeLocationFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val toolbar = view.findViewById(R.id.toolbar) - setupToolbar(toolbar) + setupViews(view) mapView = view.findViewById(R.id.mapView) .setup(savedInstanceState) { mapboxMap -> @@ -313,12 +314,6 @@ class FakeLocationFragment : } } - private fun setupToolbar(toolbar: Toolbar) { - val activity = requireActivity() - activity.setActionBar(toolbar) - activity.title = "Fake My Location" - } - override fun render(state: FakeLocationFeature.State) { Log.d("FakeMyLocation", "State: $state") latEditText.text = @@ -418,9 +413,3 @@ class FakeLocationFragment : } } } - -fun FakeLocationMapView.setup(savedInstanceState: Bundle?, callback: OnMapReadyCallback) = - this.apply { - onCreate(savedInstanceState) - getMapAsync(callback) - } diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationMapView.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationMapView.kt index cd0030a..e71bfcc 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationMapView.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationMapView.kt @@ -19,9 +19,11 @@ package foundation.e.privacycentralapp.features.location import android.annotation.SuppressLint import android.content.Context +import android.os.Bundle import android.util.AttributeSet import android.view.MotionEvent import com.mapbox.mapboxsdk.maps.MapView +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback class FakeLocationMapView @JvmOverloads constructor( context: Context, @@ -43,3 +45,9 @@ class FakeLocationMapView @JvmOverloads constructor( return true } } + +fun FakeLocationMapView.setup(savedInstanceState: Bundle?, callback: OnMapReadyCallback) = + this.apply { + onCreate(savedInstanceState) + getMapAsync(callback) + } diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt index 224d1be..374a430 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt @@ -18,22 +18,20 @@ package foundation.e.privacycentralapp.features.permissions import android.os.Bundle -import android.view.View import android.widget.TextView import android.widget.Toast -import android.widget.Toolbar -import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import foundation.e.flowmvi.MVIView import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.NavToolbarFragment import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect class PermissionAppsFragment : - Fragment(R.layout.fragment_permission_apps), + NavToolbarFragment(R.layout.fragment_permission_apps), MVIView { private val viewModel: PermissionsViewModel by viewModels() @@ -66,17 +64,7 @@ class PermissionAppsFragment : .show() } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val toolbar = view.findViewById(R.id.toolbar) - setupToolbar(toolbar) - } - - private fun setupToolbar(toolbar: Toolbar) { - val activity = requireActivity() - activity.setActionBar(toolbar) - activity.title = "My Apps Permission" - } + override fun getTitle(): String = "My Apps Permission" override fun render(state: PermissionsFeature.State) { state.currentPermission?.let { permission -> diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt index 864a355..0b03343 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt @@ -19,9 +19,7 @@ package foundation.e.privacycentralapp.features.permissions import android.os.Bundle import android.view.View -import android.widget.Toolbar import androidx.core.os.bundleOf -import androidx.fragment.app.Fragment import androidx.fragment.app.add import androidx.fragment.app.commit import androidx.fragment.app.viewModels @@ -30,10 +28,11 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import foundation.e.flowmvi.MVIView import foundation.e.privacycentralapp.R +import foundation.e.privacycentralapp.common.NavToolbarFragment import kotlinx.coroutines.flow.Flow class PermissionsFragment : - Fragment(R.layout.fragment_permissions), + NavToolbarFragment(R.layout.fragment_permissions), MVIView { private val viewModel: PermissionsViewModel by viewModels() @@ -50,15 +49,9 @@ class PermissionsFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val toolbar = view.findViewById(R.id.toolbar) - setupToolbar(toolbar) } - private fun setupToolbar(toolbar: Toolbar) { - val activity = requireActivity() - activity.setActionBar(toolbar) - activity.title = "My Apps Permission" - } + override fun getTitle(): String = "My Apps Permission" override fun render(state: PermissionsFeature.State) { view?.findViewById(R.id.recylcer_view_permissions)?.apply { diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index 663c270..027945d 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -6,14 +6,7 @@ android:layout_height="match_parent" > - + - + - - - + - + - + - - + + + + + \ No newline at end of file -- cgit v1.2.1 From 47194484d7c2ca6ce8103312b9dbfb1244e8c4e6 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Sat, 15 May 2021 01:18:21 +0530 Subject: Use MaterialToolbar from MDC instead of android Toolbar --- .../privacycentralapp/common/NavToolbarFragment.kt | 4 +-- .../e/privacycentralapp/common/ToolbarFragment.kt | 5 +-- app/src/main/res/layout/fragment_dashboard.xml | 8 ++--- app/src/main/res/layout/fragment_fake_location.xml | 10 +++--- .../layout/fragment_internet_activity_policy.xml | 8 ++--- .../main/res/layout/fragment_permission_apps.xml | 7 ++-- app/src/main/res/layout/fragment_permissions.xml | 7 ++-- .../main/res/layout/fragment_quick_protection.xml | 7 ++-- app/src/main/res/layout/toolbar.xml | 28 ---------------- app/src/main/res/layout/topbar.xml | 37 ++++++++++++++++++++++ 10 files changed, 64 insertions(+), 57 deletions(-) delete mode 100644 app/src/main/res/layout/toolbar.xml create mode 100644 app/src/main/res/layout/topbar.xml (limited to 'app/src') diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt index 0a9d102..52197cd 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt @@ -17,12 +17,12 @@ package foundation.e.privacycentralapp.common -import android.widget.Toolbar import androidx.annotation.LayoutRes +import com.google.android.material.appbar.MaterialToolbar abstract class NavToolbarFragment(@LayoutRes contentLayoutId: Int) : ToolbarFragment(contentLayoutId) { - override fun setupToolbar(toolbar: Toolbar) { + override fun setupToolbar(toolbar: MaterialToolbar) { super.setupToolbar(toolbar) toolbar.apply { setNavigationIcon(lineageos.platform.R.drawable.ic_back) diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt index c316340..f156e09 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt @@ -19,9 +19,9 @@ package foundation.e.privacycentralapp.common import android.os.Bundle import android.view.View -import android.widget.Toolbar import androidx.annotation.LayoutRes import androidx.fragment.app.Fragment +import com.google.android.material.appbar.MaterialToolbar import foundation.e.privacycentralapp.R abstract class ToolbarFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId) { @@ -33,10 +33,11 @@ abstract class ToolbarFragment(@LayoutRes contentLayoutId: Int) : Fragment(conte override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + setupToolbar(view.findViewById(R.id.toolbar)) } - open fun setupToolbar(toolbar: Toolbar) { + open fun setupToolbar(toolbar: MaterialToolbar) { toolbar.title = getTitle() } } diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index 027945d..dc79878 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -1,12 +1,12 @@ - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_fake_location.xml b/app/src/main/res/layout/fragment_fake_location.xml index de62537..40324a1 100644 --- a/app/src/main/res/layout/fragment_fake_location.xml +++ b/app/src/main/res/layout/fragment_fake_location.xml @@ -1,5 +1,5 @@ - - + @@ -131,4 +131,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_internet_activity_policy.xml b/app/src/main/res/layout/fragment_internet_activity_policy.xml index 66ff2b4..7a5d8b5 100644 --- a/app/src/main/res/layout/fragment_internet_activity_policy.xml +++ b/app/src/main/res/layout/fragment_internet_activity_policy.xml @@ -1,5 +1,5 @@ - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_permission_apps.xml b/app/src/main/res/layout/fragment_permission_apps.xml index 605b6ff..65f4169 100644 --- a/app/src/main/res/layout/fragment_permission_apps.xml +++ b/app/src/main/res/layout/fragment_permission_apps.xml @@ -1,5 +1,5 @@ - - + @@ -36,4 +35,4 @@ tools:listitem="@layout/item_permission_apps" android:id="@+id/recylcer_view_permission_apps"/> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_permissions.xml b/app/src/main/res/layout/fragment_permissions.xml index 72748b4..a452570 100644 --- a/app/src/main/res/layout/fragment_permissions.xml +++ b/app/src/main/res/layout/fragment_permissions.xml @@ -1,5 +1,5 @@ - - + @@ -47,4 +46,4 @@ tools:listitem="@layout/item_permission" android:id="@+id/recylcer_view_permissions"/> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_quick_protection.xml b/app/src/main/res/layout/fragment_quick_protection.xml index 55d6f71..d57a101 100644 --- a/app/src/main/res/layout/fragment_quick_protection.xml +++ b/app/src/main/res/layout/fragment_quick_protection.xml @@ -1,18 +1,17 @@ - - + @@ -57,4 +56,4 @@ android:textSize="14sp" android:fontFamily="sans-serif-medium" android:layout_gravity="bottom|right"/> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/toolbar.xml b/app/src/main/res/layout/toolbar.xml deleted file mode 100644 index 29c1fa1..0000000 --- a/app/src/main/res/layout/toolbar.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/topbar.xml b/app/src/main/res/layout/topbar.xml new file mode 100644 index 0000000..9142d79 --- /dev/null +++ b/app/src/main/res/layout/topbar.xml @@ -0,0 +1,37 @@ + + + + + + + + -- cgit v1.2.1 From fafd978342abb8332fcf3ed45cdc3b7d437576ba Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 17 May 2021 17:02:35 +0530 Subject: Use string resources for titles --- .../e/privacycentralapp/features/dashboard/DashboardFragment.kt | 4 ++-- .../privacycentralapp/features/dashboard/QuickProtectionFragment.kt | 2 +- .../features/internetprivacy/InternetPrivacyFragment.kt | 2 +- .../e/privacycentralapp/features/location/FakeLocationFragment.kt | 5 +---- .../privacycentralapp/features/permissions/PermissionAppsFragment.kt | 2 +- .../e/privacycentralapp/features/permissions/PermissionsFragment.kt | 2 +- app/src/main/res/values/strings.xml | 5 +++++ 7 files changed, 12 insertions(+), 10 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt index 4164fea..c57e6cc 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt @@ -113,10 +113,10 @@ class DashboardFragment : } } - override fun getTitle(): String = "My Privacy Dashboard" + override fun getTitle(): String = getString(R.string.privacy_dashboard) private fun addClickToMore(textView: TextView) { - val clickToMore = SpannableString("Click to learn more") + val clickToMore = SpannableString(getString(R.string.click_to_learn_more)) clickToMore.setSpan( ForegroundColorSpan(Color.parseColor("#007fff")), 0, diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt index 442cfd2..727afa9 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/QuickProtectionFragment.kt @@ -27,7 +27,7 @@ class QuickProtectionFragment : NavToolbarFragment(R.layout.fragment_quick_prote private val viewModel: DashboardViewModel by activityViewModels() - override fun getTitle(): String = "Quick protection" + override fun getTitle(): String = getString(R.string.quick_protection) override fun onAttach(context: Context) { super.onAttach(context) diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt index 1844129..5baae81 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt @@ -65,7 +65,7 @@ class InternetPrivacyFragment : bindClickListeners(view) } - override fun getTitle(): String = "My Internet Activity Privacy" + override fun getTitle(): String = getString(R.string.internet_activity_privacy) private fun bindClickListeners(fragmentView: View) { fragmentView.let { diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt index 2d174f0..7281afc 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt @@ -178,9 +178,7 @@ class FakeLocationFragment : Mapbox.getInstance(requireContext(), getString(R.string.mapbox_key)) } - override fun getTitle(): String { - return getString(R.string.my_location_title) - } + override fun getTitle(): String = getString(R.string.my_location_title) private fun displayToast(message: String) { Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT) @@ -315,7 +313,6 @@ class FakeLocationFragment : } override fun render(state: FakeLocationFeature.State) { - Log.d("FakeMyLocation", "State: $state") latEditText.text = Editable.Factory.getInstance().newEditable(state.location.latitude.toString()) longEditText.text = diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt index 374a430..72d8b0c 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionAppsFragment.kt @@ -64,7 +64,7 @@ class PermissionAppsFragment : .show() } - override fun getTitle(): String = "My Apps Permission" + override fun getTitle(): String = getString(R.string.apps_permissions) override fun render(state: PermissionsFeature.State) { state.currentPermission?.let { permission -> diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt index 0b03343..be84e31 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/permissions/PermissionsFragment.kt @@ -51,7 +51,7 @@ class PermissionsFragment : super.onViewCreated(view, savedInstanceState) } - override fun getTitle(): String = "My Apps Permission" + override fun getTitle(): String = getString(R.string.apps_permissions) override fun render(state: PermissionsFeature.State) { view?.findViewById(R.id.recylcer_view_permissions)?.apply { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8fc7c92..fd24223 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,6 +9,7 @@ %1$d apps are requesting %2$d permissions My Location "%1$d apps are using location permission\nCurrent location mode: " + Internet Activity Privacy My Internet Activity Privacy "Current internet activity mode: " Quick protection enables these settings when turned on @@ -38,4 +39,8 @@ This app needs location permissions in order to show its functionality. You didn\'t grant location permission Please enter valid latitude and longitude value + Quick Protection + Privacy Dashboard + Click to learn more + \"Apps Permission\" \ No newline at end of file -- cgit v1.2.1