aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt36
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt8
-rw-r--r--ui/src/main/java/com/wireguard/android/model/ApplicationData.kt6
-rw-r--r--ui/src/main/res/layout/app_list_item.xml6
-rw-r--r--ui/src/main/res/layout/tunnel_editor_peer.xml2
5 files changed, 29 insertions, 29 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt
index 8bf0cf14..e5a9c9ca 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt
@@ -21,7 +21,7 @@ import com.wireguard.android.util.ErrorMessages
class AppListDialogFragment : DialogFragment() {
private val appData: ObservableKeyedArrayList<String, ApplicationData> = ObservableKeyedArrayList()
- private var currentlyExcludedApps = emptyList<String>()
+ private var currentlySelectedApps = emptyList<String>()
private fun loadData() {
val activity = activity ?: return
@@ -33,7 +33,7 @@ class AppListDialogFragment : DialogFragment() {
val applicationData: MutableList<ApplicationData> = ArrayList()
resolveInfos.forEach {
val packageName = it.activityInfo.packageName
- applicationData.add(ApplicationData(it.loadIcon(pm), it.loadLabel(pm).toString(), packageName, currentlyExcludedApps.contains(packageName)))
+ applicationData.add(ApplicationData(it.loadIcon(pm), it.loadLabel(pm).toString(), packageName, currentlySelectedApps.contains(packageName)))
}
applicationData.sortWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
applicationData
@@ -52,8 +52,8 @@ class AppListDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- val excludedApps = requireArguments().getStringArrayList(KEY_EXCLUDED_APPS)
- currentlyExcludedApps = (excludedApps ?: emptyList())
+ val selectedApps = requireArguments().getStringArrayList(KEY_SELECTED_APPS)
+ currentlySelectedApps = (selectedApps ?: emptyList())
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@@ -62,7 +62,7 @@ class AppListDialogFragment : DialogFragment() {
val binding = AppListDialogFragmentBinding.inflate(requireActivity().layoutInflater, null, false)
binding.executePendingBindings()
alertDialogBuilder.setView(binding.root)
- alertDialogBuilder.setPositiveButton(R.string.set_exclusions) { _, _ -> setExclusionsAndDismiss() }
+ alertDialogBuilder.setPositiveButton(R.string.set_exclusions) { _, _ -> setSelectionAndDismiss() }
alertDialogBuilder.setNegativeButton(R.string.cancel) { dialog, _ -> dialog.dismiss() }
alertDialogBuilder.setNeutralButton(R.string.toggle_all) { _, _ -> }
binding.fragment = this
@@ -72,37 +72,37 @@ class AppListDialogFragment : DialogFragment() {
dialog.setOnShowListener {
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener {
val selectedItems = appData
- .filter { it.isExcludedFromTunnel }
+ .filter { it.isSelected }
- val excludeAll = selectedItems.isEmpty()
+ val selectAll = selectedItems.isEmpty()
appData.forEach {
- it.isExcludedFromTunnel = excludeAll
+ it.isSelected = selectAll
}
}
}
return dialog
}
- private fun setExclusionsAndDismiss() {
- val excludedApps: MutableList<String> = ArrayList()
+ private fun setSelectionAndDismiss() {
+ val selectedApps: MutableList<String> = ArrayList()
for (data in appData) {
- if (data.isExcludedFromTunnel) {
- excludedApps.add(data.packageName)
+ if (data.isSelected) {
+ selectedApps.add(data.packageName)
}
}
- (targetFragment as AppExclusionListener?)!!.onExcludedAppsSelected(excludedApps)
+ (targetFragment as AppSelectionListener?)!!.onSelectedAppsSelected(selectedApps)
dismiss()
}
- interface AppExclusionListener {
- fun onExcludedAppsSelected(excludedApps: List<String>)
+ interface AppSelectionListener {
+ fun onSelectedAppsSelected(selectedApps: List<String>)
}
companion object {
- private const val KEY_EXCLUDED_APPS = "excludedApps"
- fun <T> newInstance(excludedApps: ArrayList<String?>?, target: T): AppListDialogFragment where T : Fragment?, T : AppExclusionListener? {
+ private const val KEY_SELECTED_APPS = "selected_apps"
+ fun <T> newInstance(selectedApps: ArrayList<String?>?, target: T): AppListDialogFragment where T : Fragment?, T : AppSelectionListener? {
val extras = Bundle()
- extras.putStringArrayList(KEY_EXCLUDED_APPS, excludedApps)
+ extras.putStringArrayList(KEY_SELECTED_APPS, selectedApps)
val fragment = AppListDialogFragment()
fragment.setTargetFragment(target, 0)
fragment.arguments = extras
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
index 2e1e4531..1de04339 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
@@ -23,7 +23,7 @@ import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelEditorFragmentBinding
-import com.wireguard.android.fragment.AppListDialogFragment.AppExclusionListener
+import com.wireguard.android.fragment.AppListDialogFragment.AppSelectionListener
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.BiometricAuthenticator
import com.wireguard.android.util.ErrorMessages
@@ -35,7 +35,7 @@ import com.wireguard.config.Config
/**
* Fragment for editing a WireGuard configuration.
*/
-class TunnelEditorFragment : BaseFragment(), AppExclusionListener {
+class TunnelEditorFragment : BaseFragment(), AppSelectionListener {
private var haveShownKeys = false
private var binding: TunnelEditorFragmentBinding? = null
private var tunnel: ObservableTunnel? = null
@@ -88,11 +88,11 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener {
super.onDestroyView()
}
- override fun onExcludedAppsSelected(excludedApps: List<String>) {
+ override fun onSelectedAppsSelected(selectedApps: List<String>) {
requireNotNull(binding) { "Tried to set excluded apps while no view was loaded" }
binding!!.config!!.`interface`.excludedApplications.apply {
clear()
- addAll(excludedApps)
+ addAll(selectedApps)
}
}
diff --git a/ui/src/main/java/com/wireguard/android/model/ApplicationData.kt b/ui/src/main/java/com/wireguard/android/model/ApplicationData.kt
index e931cdd2..e0961f04 100644
--- a/ui/src/main/java/com/wireguard/android/model/ApplicationData.kt
+++ b/ui/src/main/java/com/wireguard/android/model/ApplicationData.kt
@@ -10,13 +10,13 @@ import androidx.databinding.Bindable
import com.wireguard.android.BR
import com.wireguard.android.databinding.Keyed
-class ApplicationData(val icon: Drawable, val name: String, val packageName: String, isExcludedFromTunnel: Boolean) : BaseObservable(), Keyed<String> {
+class ApplicationData(val icon: Drawable, val name: String, val packageName: String, isSelected: Boolean) : BaseObservable(), Keyed<String> {
override val key = name
@get:Bindable
- var isExcludedFromTunnel = isExcludedFromTunnel
+ var isSelected = isSelected
set(value) {
field = value
- notifyPropertyChanged(BR.excludedFromTunnel)
+ notifyPropertyChanged(BR.selected)
}
}
diff --git a/ui/src/main/res/layout/app_list_item.xml b/ui/src/main/res/layout/app_list_item.xml
index 5ce7a8a5..e4e4483c 100644
--- a/ui/src/main/res/layout/app_list_item.xml
+++ b/ui/src/main/res/layout/app_list_item.xml
@@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:background="@drawable/list_item_background"
android:gravity="center_vertical"
- android:onClick="@{(view) -> item.setExcludedFromTunnel(!item.excludedFromTunnel)}"
+ android:onClick="@{(view) -> item.setSelected(!item.selected)}"
android:orientation="horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
@@ -51,10 +51,10 @@
tools:text="@tools:sample/full_names" />
<CheckBox
- android:id="@+id/excluded_checkbox"
+ android:id="@+id/selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:checked="@={item.excludedFromTunnel}"
+ android:checked="@={item.selected}"
tools:checked="true" />
</LinearLayout>
diff --git a/ui/src/main/res/layout/tunnel_editor_peer.xml b/ui/src/main/res/layout/tunnel_editor_peer.xml
index f00a6d26..d17378f2 100644
--- a/ui/src/main/res/layout/tunnel_editor_peer.xml
+++ b/ui/src/main/res/layout/tunnel_editor_peer.xml
@@ -159,7 +159,7 @@
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
- android:id="@+id/excluded_checkbox"
+ android:id="@+id/selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="4dp"