diff options
Diffstat (limited to 'app/src/main/java')
2 files changed, 14 insertions, 3 deletions
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<ApplicationDescription, Boolean>) { + fun bind(item: Pair<ApplicationDescription, Boolean>, isEnabled: Boolean) { appName.text = item.first.label togglePermission.isChecked = item.second + togglePermission.isEnabled = isEnabled itemView.findViewById<ImageView>(R.id.icon).setImageDrawable(item.first.icon) } @@ -52,6 +53,13 @@ class ToggleAppsAdapter( notifyDataSetChanged() } + var isEnabled: Boolean = true + + fun setData(list: List<Pair<ApplicationDescription, Boolean>>, 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( |