summaryrefslogtreecommitdiffhomepage
path: root/android/lib
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2024-01-12 10:33:54 +0100
committerAlbin <albin@mullvad.net>2024-01-12 10:33:54 +0100
commit3b33f3f1bd5a137ed8b898c62e78a3745a7a9897 (patch)
tree325f82725bc5acecdb7c2439308ffa2f5f492fd4 /android/lib
parent2f05885b58dadfe89bf9b683f1be65bb9f704f01 (diff)
parent0dd07d9ecb2cfeddfe9247b723f742cd3494c1ed (diff)
downloadmullvadvpn-3b33f3f1bd5a137ed8b898c62e78a3745a7a9897.tar.xz
mullvadvpn-3b33f3f1bd5a137ed8b898c62e78a3745a7a9897.zip
Merge branch 'notification-permission-api-check-droid-386'
Diffstat (limited to 'android/lib')
-rw-r--r--android/lib/common/build.gradle.kts2
-rw-r--r--android/lib/common/lint-baseline.xml15
-rw-r--r--android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt15
-rw-r--r--android/lib/resource/lint-baseline.xml85
4 files changed, 56 insertions, 61 deletions
diff --git a/android/lib/common/build.gradle.kts b/android/lib/common/build.gradle.kts
index ba33ab7db7..e327a8922c 100644
--- a/android/lib/common/build.gradle.kts
+++ b/android/lib/common/build.gradle.kts
@@ -19,7 +19,6 @@ android {
lint {
lintConfig = file("${rootProject.projectDir}/config/lint.xml")
- baseline = file("lint-baseline.xml")
abortOnError = true
warningsAsErrors = true
}
@@ -30,6 +29,7 @@ dependencies {
implementation(project(Dependencies.Mullvad.resourceLib))
implementation(project(Dependencies.Mullvad.talpidLib))
+ implementation(Dependencies.AndroidX.appcompat)
implementation(Dependencies.jodaTime)
implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.KotlinX.coroutinesAndroid)
diff --git a/android/lib/common/lint-baseline.xml b/android/lib/common/lint-baseline.xml
deleted file mode 100644
index 141342d165..0000000000
--- a/android/lib/common/lint-baseline.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.0.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.0.2)" variant="all" version="8.0.2">
-
- <issue
- id="QueryAllPackagesPermission"
- message="A `&lt;queries>` declaration should generally be used instead of QUERY_ALL_PACKAGES; \&#xA;see https://g.co/dev/packagevisibility for details"
- errorLine1=" &lt;uses-permission android:name=&quot;android.permission.QUERY_ALL_PACKAGES&quot; />"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/AndroidManifest.xml"
- line="3"
- column="22"/>
- </issue>
-
-</issues>
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt
index fe9564c45d..92f97146f8 100644
--- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt
+++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt
@@ -8,6 +8,8 @@ import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Build
import android.service.quicksettings.Tile
+import androidx.activity.result.ActivityResultLauncher
+import androidx.annotation.ChecksSdkIntAtLeast
object SdkUtils {
fun getSupportedPendingIntentFlags(): Int {
@@ -22,12 +24,19 @@ object SdkUtils {
}
}
- fun Context.isNotificationPermissionGranted(): Boolean {
- return (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) ||
- checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) ==
+ @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.TIRAMISU)
+ fun Context.isNotificationPermissionMissing(): Boolean {
+ return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) &&
+ checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) !=
PackageManager.PERMISSION_GRANTED
}
+ fun Context.requestNotificationPermissionIfMissing(launcher: ActivityResultLauncher<String>) {
+ if (isNotificationPermissionMissing()) {
+ launcher.launch(Manifest.permission.POST_NOTIFICATIONS)
+ }
+ }
+
fun Tile.setSubtitleIfSupported(subtitleText: CharSequence) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
this.subtitle = subtitleText
diff --git a/android/lib/resource/lint-baseline.xml b/android/lib/resource/lint-baseline.xml
index 02060c3f43..13532ef7b2 100644
--- a/android/lib/resource/lint-baseline.xml
+++ b/android/lib/resource/lint-baseline.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
+<issues format="6" by="lint 8.1.4" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.4)" variant="all" version="8.1.4">
<issue
id="ImpliedQuantity"
@@ -70,154 +70,154 @@
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>il y a un jour&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>Les crédits du compte expirent dans un jour&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="16"
+ line="24"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>há um dia&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>O crédito da conta expira dentro de um dia&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="16"
+ line="24"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>il y a une minute&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>Les crédits du compte expirent dans une heure&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="20"
+ line="28"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>há um minuto&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>O crédito da conta expira dentro de uma hora&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="20"
+ line="28"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>il y a un mois&lt;/item>"
+ errorLine1=" &lt;item quantity=&quot;one&quot;>il y a un jour&lt;/item>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="24"
+ line="32"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>há um mês&lt;/item>"
+ errorLine1=" &lt;item quantity=&quot;one&quot;>há um dia&lt;/item>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="24"
+ line="32"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>il y a un an&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>il y a une minute&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="28"
+ line="36"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>há um ano&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>há um minuto&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="28"
+ line="36"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>il y a une heure&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>il y a un mois&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="32"
+ line="40"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>há uma hora&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>há um mês&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="32"
+ line="40"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>Les crédits du compte expirent dans un jour&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>il y a un an&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="36"
+ line="44"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>O crédito da conta expira dentro de um dia&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>há um ano&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="36"
+ line="44"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>Les crédits du compte expirent dans une heure&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>il y a une heure&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-fr/plurals.xml"
- line="40"
+ line="48"
column="9"/>
</issue>
<issue
id="ImpliedQuantity"
message="The quantity `&apos;one&apos;` matches more than one specific number in this locale (0, 1), but the message did not \&#xA;include a formatting argument (such as `%d`). This is usually an internationalization error. See full issue \&#xA;explanation for more."
- errorLine1=" &lt;item quantity=&quot;one&quot;>O crédito da conta expira dentro de uma hora&lt;/item>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" &lt;item quantity=&quot;one&quot;>há uma hora&lt;/item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-pt/plurals.xml"
- line="40"
+ line="48"
column="9"/>
</issue>
@@ -235,7 +235,8 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/main/res/drawable/account_history_remove_pressed.xml"
- line="8"/>
+ line="7"
+ column="30"/>
</issue>
<issue