From 729c47b96be952bdea5e90a664ff3f90bde23023 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Mon, 25 Apr 2022 15:39:27 +0000 Subject: 225 - 5286 trackers screens fixes --- .../e/privacycentralapp/common/AppsAdapter.kt | 10 +++----- .../privacycentralapp/common/ToggleAppsAdapter.kt | 9 +++---- .../trackers/apptrackers/ToggleTrackersAdapter.kt | 29 +++++++++++----------- app/src/main/res/layout/fragment_trackers.xml | 8 +++--- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 28 insertions(+), 30 deletions(-) (limited to 'app') diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/AppsAdapter.kt b/app/src/main/java/foundation/e/privacycentralapp/common/AppsAdapter.kt index 07cf125..ed47cff 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/AppsAdapter.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/AppsAdapter.kt @@ -32,7 +32,7 @@ class AppsAdapter( ) : RecyclerView.Adapter() { - class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + class ViewHolder(view: View, private val listener: (String) -> Unit) : RecyclerView.ViewHolder(view) { val appName: TextView = view.findViewById(R.id.title) val counts: TextView = view.findViewById(R.id.counts) val icon: ImageView = view.findViewById(R.id.icon) @@ -44,6 +44,8 @@ class AppsAdapter( item.trackersCount ) icon.setImageDrawable(item.icon) + + itemView.setOnClickListener { listener(item.packageName) } } } @@ -56,11 +58,7 @@ class AppsAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(parent.context) .inflate(itemsLayout, parent, false) - val holder = ViewHolder(view) - holder.itemView.setOnClickListener { _ -> - listener(dataSet[holder.adapterPosition].packageName) - } - return holder + return ViewHolder(view, listener) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt b/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt index 9d62381..c41c0cf 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt @@ -33,7 +33,7 @@ class ToggleAppsAdapter( ) : RecyclerView.Adapter() { - class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + class ViewHolder(view: View, private val listener: (String) -> Unit) : RecyclerView.ViewHolder(view) { val appName: TextView = view.findViewById(R.id.title) val togglePermission: CheckBox = view.findViewById(R.id.toggle) @@ -44,6 +44,7 @@ class ToggleAppsAdapter( togglePermission.isEnabled = isEnabled itemView.findViewById(R.id.icon).setImageDrawable(item.first.icon) + togglePermission.setOnClickListener { listener(item.first.packageName) } } } @@ -63,11 +64,7 @@ class ToggleAppsAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(parent.context) .inflate(itemsLayout, parent, false) - val holder = ViewHolder(view) - holder.togglePermission.setOnClickListener { - listener(dataSet[holder.adapterPosition].first.packageName) - } - return holder + return ViewHolder(view, listener) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt index 9ffdd12..b9beccf 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/ToggleTrackersAdapter.kt @@ -38,7 +38,11 @@ class ToggleTrackersAdapter( var isEnabled = true - class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + class ViewHolder( + view: View, + private val onToggleSwitch: (Tracker, Boolean) -> Unit, + private val onClickTitle: (Tracker) -> Unit + ) : RecyclerView.ViewHolder(view) { val title: TextView = view.findViewById(R.id.title) val toggle: Switch = view.findViewById(R.id.toggle) @@ -59,6 +63,15 @@ class ToggleTrackersAdapter( toggle.isChecked = item.second toggle.isEnabled = isEnabled toggleOverlay.isVisible = !isEnabled + + toggle.setOnClickListener { + onToggleSwitch(item.first, toggle.isChecked) + } + toggleOverlay.setOnClickListener { + onToggleSwitch(item.first, false) + } + + title.setOnClickListener { onClickTitle(item.first) } } } @@ -73,19 +86,7 @@ class ToggleTrackersAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(parent.context) .inflate(itemsLayout, parent, false) - val holder = ViewHolder(view) - holder.toggle.setOnClickListener { - onToggleSwitch(dataSet[holder.adapterPosition].first, holder.toggle.isChecked) - } - holder.toggleOverlay.setOnClickListener { - onToggleSwitch(dataSet[holder.adapterPosition].first, false) - } - - holder.title.setOnClickListener { - onClickTitle(dataSet[holder.adapterPosition].first) - } - - return holder + return ViewHolder(view, onToggleSwitch, onClickTitle) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { diff --git a/app/src/main/res/layout/fragment_trackers.xml b/app/src/main/res/layout/fragment_trackers.xml index 7ee4d29..9828215 100644 --- a/app/src/main/res/layout/fragment_trackers.xml +++ b/app/src/main/res/layout/fragment_trackers.xml @@ -24,14 +24,13 @@ android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" - android:paddingLeft="16dp" - android:paddingRight="16dp" > @@ -39,12 +38,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/graph_subtitle" + android:textColor="@color/secondary_text" + android:textSize="14sp" android:paddingTop="24dp" + android:paddingHorizontal="16dp" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1fc7841..13ecf23 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -67,7 +67,7 @@ Manage apps\' trackers - Trackers are pieces of code hidden within applications. They collect your data and follow your activity 24/7: it feels like your phone listens to you.\n\nYou can see how many trackers are active behind the scenes, and you can block all trackers for the best protection. As it could cause some applications to malfunction, you can also fine tune your setting and choose specifically which trackers you want to block. + Trackers are pieces of code hidden in apps. They collect your data and follow your activity 24/7. See which trackers are active and block them all for best protection. As it could cause some applications to malfunction, you can choose specifically which trackers you want to block. %d trackers 24 hours past month -- cgit v1.2.1