summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-03-26 00:51:36 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-03-26 00:51:36 -0600
commit2958144fd0082489a996fbc7a11572f3edbe42eb (patch)
treee18ffe04ca272dd1e9732b56ce4581027beada0b /ui/src/main
parentade8f18a9550b340904cc608029c0fa4fe7186c0 (diff)
ui: cleanup various pieces of kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt1
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt4
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt4
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt8
-rw-r--r--ui/src/main/java/com/wireguard/android/model/ApplicationData.kt2
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt15
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/SlashDrawable.kt3
7 files changed, 21 insertions, 16 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
index ebf2e161..14ab0bdb 100644
--- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
@@ -23,6 +23,7 @@ abstract class BaseActivity : ThemeChangeAwareActivity() {
onSelectedTunnelChanged(oldTunnel, value)
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, value)
}
+
fun addOnSelectedTunnelChangedListener(listener: OnSelectedTunnelChangedListener) {
selectionChangeRegistry.add(listener)
}
diff --git a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt
index 460c2146..d1b01944 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt
@@ -49,8 +49,8 @@ class ConfigNamingDialogFragment : DialogFragment() {
val configBytes = configText!!.toByteArray(StandardCharsets.UTF_8)
config = try {
Config.parse(ByteArrayInputStream(configBytes))
- } catch(e: Exception) {
- when(e) {
+ } catch (e: Exception) {
+ when (e) {
is BadConfigException, is IOException -> throw IllegalArgumentException("Invalid config passed to ${javaClass.simpleName}", e)
else -> throw e
}
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 b6f3043b..691731d3 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
@@ -22,10 +22,10 @@ import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelEditorFragmentBinding
import com.wireguard.android.fragment.AppListDialogFragment.AppExclusionListener
import com.wireguard.android.model.ObservableTunnel
-import com.wireguard.android.widget.EdgeToEdge.setUpRoot
-import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.viewmodel.ConfigProxy
+import com.wireguard.android.widget.EdgeToEdge.setUpRoot
+import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
import com.wireguard.config.Config
/**
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
index 4355d495..ca4b1eee 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
@@ -28,10 +28,10 @@ import com.wireguard.android.databinding.TunnelListFragmentBinding
import com.wireguard.android.databinding.TunnelListItemBinding
import com.wireguard.android.fragment.ConfigNamingDialogFragment.Companion.newInstance
import com.wireguard.android.model.ObservableTunnel
+import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.widget.EdgeToEdge.setUpFAB
import com.wireguard.android.widget.EdgeToEdge.setUpRoot
import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
-import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.widget.MultiselectableRelativeLayout
import com.wireguard.config.Config
import java9.util.concurrent.CompletableFuture
@@ -254,11 +254,11 @@ class TunnelListFragment : BaseFragment() {
else if (tunnels.isEmpty() && throwables.size == 1)
else if (throwables.isEmpty())
message = resources.getQuantityString(R.plurals.import_total_success,
- tunnels.size, tunnels.size)
+ tunnels.size, tunnels.size)
else if (!throwables.isEmpty())
message = resources.getQuantityString(R.plurals.import_partial_success,
- tunnels.size + throwables.size,
- tunnels.size, tunnels.size + throwables.size)
+ tunnels.size + throwables.size,
+ tunnels.size, tunnels.size + throwables.size)
showSnackbar(message)
}
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 8d4708fd..6d536e71 100644
--- a/ui/src/main/java/com/wireguard/android/model/ApplicationData.kt
+++ b/ui/src/main/java/com/wireguard/android/model/ApplicationData.kt
@@ -10,7 +10,7 @@ import androidx.databinding.Bindable
import com.wireguard.android.BR
import com.wireguard.util.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, isExcludedFromTunnel: Boolean) : BaseObservable(), Keyed<String> {
override fun getKey(): String {
return name
}
diff --git a/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt b/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt
index 45b83aad..c31d1bb1 100644
--- a/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt
+++ b/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt
@@ -6,7 +6,12 @@ package com.wireguard.android.widget
import android.view.View
import android.view.ViewGroup
-import androidx.core.view.*
+import androidx.core.view.marginBottom
+import androidx.core.view.marginLeft
+import androidx.core.view.marginRight
+import androidx.core.view.marginTop
+import androidx.core.view.updateLayoutParams
+import androidx.core.view.updatePadding
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
/**
@@ -18,7 +23,7 @@ object EdgeToEdge {
@JvmStatic
fun setUpRoot(root: ViewGroup) {
root.systemUiVisibility =
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
@JvmStatic
@@ -33,9 +38,9 @@ object EdgeToEdge {
scrollingContent.setOnApplyWindowInsetsListener { _, windowInsets ->
scrollingContent.updatePadding(
- left = originalPaddingLeft + windowInsets.systemWindowInsetLeft,
- right = originalPaddingRight + windowInsets.systemWindowInsetRight,
- bottom = originalPaddingBottom + fabPaddingBottom + windowInsets.systemWindowInsetBottom
+ left = originalPaddingLeft + windowInsets.systemWindowInsetLeft,
+ right = originalPaddingRight + windowInsets.systemWindowInsetRight,
+ bottom = originalPaddingBottom + fabPaddingBottom + windowInsets.systemWindowInsetBottom
)
scrollingContent.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = originalMarginTop + windowInsets.systemWindowInsetTop
diff --git a/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.kt b/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.kt
index 50741264..ee4d278f 100644
--- a/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.kt
+++ b/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.kt
@@ -6,13 +6,11 @@
package com.wireguard.android.widget
import android.animation.ObjectAnimator
-import android.animation.ValueAnimator
import android.content.res.ColorStateList
import android.graphics.*
import android.graphics.drawable.Drawable
import android.os.Build
import android.util.FloatProperty
-import android.util.Property
import androidx.annotation.ColorInt
import androidx.annotation.IntRange
import androidx.annotation.RequiresApi
@@ -23,6 +21,7 @@ class SlashDrawable(private val mDrawable: Drawable) : Drawable() {
private val mPath = Path()
private val mSlashRect = RectF()
private var mAnimationEnabled = true
+
// Animate this value on change
private var mCurrentSlashLength = 0f
private var mRotation = 0f