summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-08-16 16:51:15 +0200
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-08-23 14:15:10 +0200
commitd704b7780d43a719ec3c687234a983979e8f4cb6 (patch)
tree4cbf809b42275ea0d0781a1a5efc9e3c44e9a37e /android
parent258a7667e5dab869e7d714fb862ec8f18453907a (diff)
downloadmullvadvpn-d704b7780d43a719ec3c687234a983979e8f4cb6.tar.xz
mullvadvpn-d704b7780d43a719ec3c687234a983979e8f4cb6.zip
Fix usecompatloadingfordrawables baselint issues
Diffstat (limited to 'android')
-rw-r--r--android/app/lint-baseline.xml132
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt25
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt7
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt3
4 files changed, 20 insertions, 147 deletions
diff --git a/android/app/lint-baseline.xml b/android/app/lint-baseline.xml
index 9df8e041a9..a64f278ba5 100644
--- a/android/app/lint-baseline.xml
+++ b/android/app/lint-baseline.xml
@@ -200,138 +200,6 @@
</issue>
<issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_corner, null),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="31"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_border, null),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="32"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_border, null)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="33"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_corner_focused, null),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="38"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_border_focused, null),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="39"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_border_focused, null)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="40"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_corner_error, null),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="45"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_border_error, null),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="46"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" resources.getDrawable(R.drawable.account_login_border_error, null)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt"
- line="47"
- column="13"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" private val errorImage = resources.getDrawable(R.drawable.icon_notification_error, null)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt"
- line="66"
- column="30"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `ResourcesCompat.getDrawable()`"
- errorLine1=" private val warningImage = resources.getDrawable(R.drawable.icon_notification_warning, null)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt"
- line="67"
- column="32"/>
- </issue>
-
- <issue
- id="UseCompatLoadingForDrawables"
- message="Use `AppCompatResources.getDrawable()`"
- errorLine1=" super.detailImage = context.getDrawable(R.drawable.icon_extlink)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt"
- line="20"
- column="29"/>
- </issue>
-
- <issue
id="UseCheckPermission"
message="The result of `checkPermission` is not used"
errorLine1=" mockedPackageManager.checkPermission(internet, packageName)"
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt
index c728941264..553ce7a4cf 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountLoginBorder.kt
@@ -6,6 +6,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.RelativeLayout
+import androidx.core.content.res.ResourcesCompat
import net.mullvad.mullvadvpn.R
class AccountLoginBorder : RelativeLayout {
@@ -21,30 +22,30 @@ class AccountLoginBorder : RelativeLayout {
// horizontal line, and as a consequence either the horizontal or the vertical borders don't
// show correctly, respectively.
private class StateDrawables(
- val corner: Drawable,
- val horizontalBorder: Drawable,
- val verticalBorder: Drawable
+ val corner: Drawable?,
+ val horizontalBorder: Drawable?,
+ val verticalBorder: Drawable?
)
private val unfocusedDrawables =
StateDrawables(
- resources.getDrawable(R.drawable.account_login_corner, null),
- resources.getDrawable(R.drawable.account_login_border, null),
- resources.getDrawable(R.drawable.account_login_border, null)
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_corner, null),
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_border, null),
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_border, null)
)
private val focusedDrawables =
StateDrawables(
- resources.getDrawable(R.drawable.account_login_corner_focused, null),
- resources.getDrawable(R.drawable.account_login_border_focused, null),
- resources.getDrawable(R.drawable.account_login_border_focused, null)
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_corner_focused, null),
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_border_focused, null),
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_border_focused, null)
)
private val errorDrawables =
StateDrawables(
- resources.getDrawable(R.drawable.account_login_corner_error, null),
- resources.getDrawable(R.drawable.account_login_border_error, null),
- resources.getDrawable(R.drawable.account_login_border_error, null)
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_corner_error, null),
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_border_error, null),
+ ResourcesCompat.getDrawable(resources, R.drawable.account_login_border_error, null)
)
private val container =
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
index 42f3f16122..da30945abc 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
@@ -11,6 +11,7 @@ import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
+import androidx.core.content.res.ResourcesCompat
import androidx.core.text.HtmlCompat
import androidx.core.view.isVisible
import net.mullvad.mullvadvpn.R
@@ -64,8 +65,10 @@ class NotificationBanner : FrameLayout {
inflater.inflate(R.layout.notification_banner, this)
}
- private val errorImage = resources.getDrawable(R.drawable.icon_notification_error, null)
- private val warningImage = resources.getDrawable(R.drawable.icon_notification_warning, null)
+ private val errorImage =
+ ResourcesCompat.getDrawable(resources, R.drawable.icon_notification_error, null)
+ private val warningImage =
+ ResourcesCompat.getDrawable(resources, R.drawable.icon_notification_warning, null)
private val status: ImageView = container.findViewById(R.id.notification_status)
private val title: TextView = container.findViewById(R.id.notification_title)
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt
index db3da99270..f6090bdafa 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlButton.kt
@@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn.ui.widget
import android.content.Context
import android.util.AttributeSet
+import androidx.appcompat.content.res.AppCompatResources
import net.mullvad.mullvadvpn.R
open class UrlButton : Button {
@@ -17,7 +18,7 @@ open class UrlButton : Button {
init {
super.setEnabled(false)
- super.detailImage = context.getDrawable(R.drawable.icon_extlink)
+ super.detailImage = AppCompatResources.getDrawable(context, R.drawable.icon_extlink)
super.showSpinner = true
}
}