From 95abd25843b395982efa61573aefd7dfd8970883 Mon Sep 17 00:00:00 2001 From: Pranav Pandey Date: Tue, 14 Dec 2021 15:00:46 +0530 Subject: [PATCH] Target SDK 32 Build tools 32.0.0. Add helper methods to detect API 32. --- .travis.yml | 4 ++-- build.gradle | 6 ++--- .../android/dynamic/util/DynamicSdkUtils.java | 24 ++++++++++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b92a714..78cb204 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ android: components: - tools - platform-tools - - build-tools-31.0.0 - - android-31 + - build-tools-32.0.0 + - android-32 - extra-android-support - extra-android-m2repository - extra-google-m2repository diff --git a/build.gradle b/build.gradle index 9e3c8bc..6e6abed 100644 --- a/build.gradle +++ b/build.gradle @@ -16,10 +16,10 @@ buildscript { ext.versions = [ - 'compileSdk': 31, + 'compileSdk': 32, 'minSdk' : 14, - 'targetSdk' : 31, - 'buildTools': '31.0.0', + 'targetSdk' : 32, + 'buildTools': '32.0.0', 'androidx' : '1.8.0-alpha01' ] diff --git a/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/util/DynamicSdkUtils.java b/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/util/DynamicSdkUtils.java index 17dcbb4..0dd1c77 100644 --- a/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/util/DynamicSdkUtils.java +++ b/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/util/DynamicSdkUtils.java @@ -433,6 +433,28 @@ public static boolean is31() { return is31(false); } + /** + * Detects if the current API version is 31 or above. + * + * @param equals {@code true} to check for equality. + *

{@code false} to match greater than or equal. + * + * @return {@code true} if the current API version is 31 or above. + */ + public static boolean is32(boolean equals) { + return equals ? Build.VERSION.SDK_INT == Build.VERSION_CODES.S_V2 + : Build.VERSION.SDK_INT >= Build.VERSION_CODES.S_V2; + } + + /** + * Detects if the current API version is 32 or above. + * + * @return {@code true} if the current API version is 32 or above. + */ + public static boolean is32() { + return is32(false); + } + /** * Detects if the current API version is 31 or above. * @@ -442,7 +464,7 @@ public static boolean is31() { * @return {@code true} if the current API version is S or above. */ public static boolean isS(boolean equals) { - return is31(equals) || (is30(equals) && isPreview()); + return is32(equals) || (is31(equals) && isPreview()) || (is30(equals) && isPreview()); } /**