From 16a3188ef42a6ae2ed0df707a6b6fcc53b530c37 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Sun, 23 Jan 2022 19:43:17 +0100 Subject: Grey list of apps on my internet activity while tor disabled. --- .../e/privacycentralapp/common/ToggleAppsAdapter.kt | 12 ++++++++++-- .../features/internetprivacy/InternetPrivacyFragment.kt | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/foundation') 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 82f8d43..9d62381 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToggleAppsAdapter.kt @@ -38,9 +38,10 @@ class ToggleAppsAdapter( val togglePermission: CheckBox = view.findViewById(R.id.toggle) - fun bind(item: Pair) { + fun bind(item: Pair, isEnabled: Boolean) { appName.text = item.first.label togglePermission.isChecked = item.second + togglePermission.isEnabled = isEnabled itemView.findViewById(R.id.icon).setImageDrawable(item.first.icon) } @@ -52,6 +53,13 @@ class ToggleAppsAdapter( notifyDataSetChanged() } + var isEnabled: Boolean = true + + fun setData(list: List>, isEnabled: Boolean = true) { + this.isEnabled = isEnabled + dataSet = list + } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(parent.context) .inflate(itemsLayout, parent, false) @@ -64,7 +72,7 @@ class ToggleAppsAdapter( override fun onBindViewHolder(holder: ViewHolder, position: Int) { val permission = dataSet[position] - holder.bind(permission) + holder.bind(permission, isEnabled) } override fun getItemCount(): Int = dataSet.size 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 3e0b549..f288320 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 @@ -155,7 +155,10 @@ class InternetPrivacyFragment : // TODO: this should not be mandatory. binding.apps.post { - (binding.apps.adapter as ToggleAppsAdapter?)?.dataSet = state.getApps() + (binding.apps.adapter as ToggleAppsAdapter?)?.setData( + list = state.getApps(), + isEnabled = state.mode == InternetPrivacyMode.HIDE_IP + ) } val viewIdsToHide = listOf( -- cgit v1.2.1