diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2022-04-25 15:39:27 +0000 |
---|---|---|
committer | Alexandre Roux <alexandre.roux.danzi@lostpod.me> | 2022-04-25 15:39:27 +0000 |
commit | 729c47b96be952bdea5e90a664ff3f90bde23023 (patch) | |
tree | be21ed7c5aea337389e24f13de763df16b0bf735 /app/src/main | |
parent | f3c01e7bbf130c7f304b6bf50510c3800b8586f6 (diff) |
225 - 5286 trackers screens fixes
Diffstat (limited to 'app/src/main')
5 files changed, 28 insertions, 30 deletions
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<AppsAdapter.ViewHolder>() { - 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<ToggleAppsAdapter.ViewHolder>() { - 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<ImageView>(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" > <TextView android:id="@+id/trackers_info" android:layout_height="wrap_content" android:layout_width="match_parent" android:paddingTop="16dp" + android:paddingHorizontal="16dp" android:lineSpacingExtra="5sp" android:text="@string/trackers_info" /> @@ -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" /> <include layout="@layout/trackers_item_graph" android:id="@+id/graph_day" - android:layout_marginTop="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" app:period="@{@string/trackers_period_day}" @@ -68,6 +69,7 @@ android:layout_width="match_parent" android:layout_marginTop="32dp" android:paddingTop="16dp" + android:paddingHorizontal="16dp" android:text="@string/trackers_applist_title" /> </LinearLayout> 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 @@ <!-- Trackers --> <string name="trackers_title">Manage apps\' trackers</string> - <string name="trackers_info">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.</string> + <string name="trackers_info">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.</string> <string name="trackers_count_label">%d trackers</string> <string name="trackers_period_day">24 hours</string> <string name="trackers_period_month">past month</string> |