Code Cleanup
This commit is contained in:
parent
51f298be8f
commit
1b544d62c3
12 changed files with 49 additions and 59 deletions
|
@ -40,6 +40,8 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
|
|
||||||
|
const val ANIM_DURATION = 300L
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T : View> ViewGroup.inflate(@LayoutRes layout: Int): T {
|
fun <T : View> ViewGroup.inflate(@LayoutRes layout: Int): T {
|
||||||
return LayoutInflater.from(context).inflate(layout, this, false) as T
|
return LayoutInflater.from(context).inflate(layout, this, false) as T
|
||||||
|
@ -90,10 +92,10 @@ fun BottomNavigationView.show() {
|
||||||
drawable.setBounds(left, parent.height, right, parent.height + height)
|
drawable.setBounds(left, parent.height, right, parent.height + height)
|
||||||
parent.overlay.add(drawable)
|
parent.overlay.add(drawable)
|
||||||
ValueAnimator.ofInt(parent.height, top).apply {
|
ValueAnimator.ofInt(parent.height, top).apply {
|
||||||
duration = 300
|
duration = ANIM_DURATION
|
||||||
interpolator = AnimationUtils.loadInterpolator(
|
interpolator = AnimationUtils.loadInterpolator(
|
||||||
context,
|
context,
|
||||||
android.R.interpolator.linear_out_slow_in
|
android.R.interpolator.accelerate_decelerate
|
||||||
)
|
)
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
val newTop = it.animatedValue as Int
|
val newTop = it.animatedValue as Int
|
||||||
|
@ -130,10 +132,10 @@ fun BottomNavigationView.hide() {
|
||||||
parent.overlay.add(drawable)
|
parent.overlay.add(drawable)
|
||||||
isGone = true
|
isGone = true
|
||||||
ValueAnimator.ofInt(top, parent.height).apply {
|
ValueAnimator.ofInt(top, parent.height).apply {
|
||||||
duration = 300L
|
duration = ANIM_DURATION
|
||||||
interpolator = AnimationUtils.loadInterpolator(
|
interpolator = AnimationUtils.loadInterpolator(
|
||||||
context,
|
context,
|
||||||
android.R.interpolator.fast_out_linear_in
|
android.R.interpolator.accelerate_decelerate
|
||||||
)
|
)
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
val newTop = it.animatedValue as Int
|
val newTop = it.animatedValue as Int
|
||||||
|
@ -164,7 +166,7 @@ fun View.translateYAnimate(value: Float): Animator {
|
||||||
fun BottomSheetBehavior<*>.peekHeightAnimate(value: Int): Animator {
|
fun BottomSheetBehavior<*>.peekHeightAnimate(value: Int): Animator {
|
||||||
return ObjectAnimator.ofInt(this, "peekHeight", value)
|
return ObjectAnimator.ofInt(this, "peekHeight", value)
|
||||||
.apply {
|
.apply {
|
||||||
duration = 300
|
duration = ANIM_DURATION
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,10 +177,9 @@ class FullPlaybackControlsFragment :
|
||||||
|
|
||||||
private fun setUpPlayPauseFab() {
|
private fun setUpPlayPauseFab() {
|
||||||
binding.playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
|
binding.playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
|
||||||
binding.playPauseButton.post {
|
|
||||||
binding.playPauseButton.pivotX = (binding.playPauseButton.width / 2).toFloat()
|
binding.playPauseButton.pivotX = (binding.playPauseButton.width / 2).toFloat()
|
||||||
binding.playPauseButton.pivotY = (binding.playPauseButton.height / 2).toFloat()
|
binding.playPauseButton.pivotY = (binding.playPauseButton.height / 2).toFloat()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpMusicControllers() {
|
private fun setUpMusicControllers() {
|
||||||
|
|
|
@ -65,9 +65,6 @@ object MusicPlayerRemote : KoinComponent {
|
||||||
musicService?.nextSong
|
musicService?.nextSong
|
||||||
} else Song.emptySong
|
} else Song.emptySong
|
||||||
|
|
||||||
/**
|
|
||||||
* Async
|
|
||||||
*/
|
|
||||||
var position: Int
|
var position: Int
|
||||||
get() = if (musicService != null) {
|
get() = if (musicService != null) {
|
||||||
musicService!!.position
|
musicService!!.position
|
||||||
|
|
|
@ -46,7 +46,7 @@ import kotlin.math.abs
|
||||||
class CoverLrcView @JvmOverloads constructor(
|
class CoverLrcView @JvmOverloads constructor(
|
||||||
context: Context?,
|
context: Context?,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = 0
|
defStyleAttr: Int = 0,
|
||||||
) : View(context, attrs, defStyleAttr) {
|
) : View(context, attrs, defStyleAttr) {
|
||||||
private val mLrcEntryList: MutableList<LrcEntry> = ArrayList()
|
private val mLrcEntryList: MutableList<LrcEntry> = ArrayList()
|
||||||
private val mLrcPaint = TextPaint()
|
private val mLrcPaint = TextPaint()
|
||||||
|
@ -109,7 +109,7 @@ class CoverLrcView @JvmOverloads constructor(
|
||||||
e1: MotionEvent,
|
e1: MotionEvent,
|
||||||
e2: MotionEvent,
|
e2: MotionEvent,
|
||||||
distanceX: Float,
|
distanceX: Float,
|
||||||
distanceY: Float
|
distanceY: Float,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (mOffset == getOffset(0) && distanceY < 0F) {
|
if (mOffset == getOffset(0) && distanceY < 0F) {
|
||||||
return super.onScroll(e1, e2, distanceX, distanceY)
|
return super.onScroll(e1, e2, distanceX, distanceY)
|
||||||
|
@ -129,7 +129,7 @@ class CoverLrcView @JvmOverloads constructor(
|
||||||
e1: MotionEvent,
|
e1: MotionEvent,
|
||||||
e2: MotionEvent,
|
e2: MotionEvent,
|
||||||
velocityX: Float,
|
velocityX: Float,
|
||||||
velocityY: Float
|
velocityY: Float,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (hasLrc()) {
|
if (hasLrc()) {
|
||||||
mScroller!!.fling(
|
mScroller!!.fling(
|
||||||
|
@ -598,7 +598,6 @@ class CoverLrcView @JvmOverloads constructor(
|
||||||
mOffset = animation.animatedValue as Float
|
mOffset = animation.animatedValue as Float
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
LrcUtils.resetDurationScale()
|
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,14 +208,4 @@ class LrcUtils {
|
||||||
String ss = String.format(Locale.getDefault(), "%02d", s);
|
String ss = String.format(Locale.getDefault(), "%02d", s);
|
||||||
return mm + ":" + ss;
|
return mm + ":" + ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetDurationScale() {
|
|
||||||
try {
|
|
||||||
Field mField = ValueAnimator.class.getDeclaredField("sDurationScale");
|
|
||||||
mField.setAccessible(true);
|
|
||||||
mField.setFloat(null, 1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,7 +684,6 @@ public class LrcView extends View {
|
||||||
mOffset = (float) animation.getAnimatedValue();
|
mOffset = (float) animation.getAnimatedValue();
|
||||||
invalidate();
|
invalidate();
|
||||||
});
|
});
|
||||||
LrcUtils.resetDurationScale();
|
|
||||||
mAnimator.start();
|
mAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ class AudioFader {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
inline fun createFadeAnimator(
|
inline fun createFadeAnimator(
|
||||||
fadeIn: Boolean /* fadeIn -> true fadeOut -> false*/,
|
fadeIn: Boolean, /* fadeIn -> true fadeOut -> false*/
|
||||||
mediaPlayer: MediaPlayer,
|
mediaPlayer: MediaPlayer,
|
||||||
crossinline endAction: (animator: Animator) -> Unit /* Code to run when Animator Ends*/
|
crossinline endAction: (animator: Animator) -> Unit, /* Code to run when Animator Ends*/
|
||||||
): Animator? {
|
): Animator? {
|
||||||
val duration = PreferenceUtil.crossFadeDuration * 1000
|
val duration = PreferenceUtil.crossFadeDuration * 1000
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
|
@ -40,8 +40,8 @@ class AudioFader {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun startFadeAnimator(
|
fun startFadeAnimator(
|
||||||
playback: Playback,
|
playback: Playback,
|
||||||
fadeIn: Boolean /* fadeIn -> true fadeOut -> false*/,
|
fadeIn: Boolean, /* fadeIn -> true fadeOut -> false*/
|
||||||
callback: Runnable /* Code to run when Animator Ends*/
|
callback: Runnable, /* Code to run when Animator Ends*/
|
||||||
) {
|
) {
|
||||||
val duration = PreferenceUtil.audioFadeDuration.toLong()
|
val duration = PreferenceUtil.audioFadeDuration.toLong()
|
||||||
if (duration == 0L) {
|
if (duration == 0L) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.util
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import androidx.core.content.edit
|
||||||
import com.google.android.play.core.review.ReviewManagerFactory
|
import com.google.android.play.core.review.ReviewManagerFactory
|
||||||
|
|
||||||
object AppRater {
|
object AppRater {
|
||||||
|
@ -34,28 +35,27 @@ object AppRater {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val editor = prefs.edit()
|
prefs.edit {
|
||||||
|
|
||||||
// Increment launch counter
|
// Increment launch counter
|
||||||
val launchCount = prefs.getLong(LAUNCH_COUNT, 0) + 1
|
val launchCount = prefs.getLong(LAUNCH_COUNT, 0) + 1
|
||||||
editor.putLong(LAUNCH_COUNT, launchCount)
|
putLong(LAUNCH_COUNT, launchCount)
|
||||||
|
|
||||||
// Get date of first launch
|
// Get date of first launch
|
||||||
var dateFirstLaunch = prefs.getLong(DATE_FIRST_LAUNCH, 0)
|
var dateFirstLaunch = prefs.getLong(DATE_FIRST_LAUNCH, 0)
|
||||||
if (dateFirstLaunch == 0L) {
|
if (dateFirstLaunch == 0L) {
|
||||||
dateFirstLaunch = System.currentTimeMillis()
|
dateFirstLaunch = System.currentTimeMillis()
|
||||||
editor.putLong(DATE_FIRST_LAUNCH, dateFirstLaunch)
|
putLong(DATE_FIRST_LAUNCH, dateFirstLaunch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait at least n days before opening
|
// Wait at least n days before opening
|
||||||
if (launchCount >= LAUNCHES_UNTIL_PROMPT) {
|
if (launchCount >= LAUNCHES_UNTIL_PROMPT) {
|
||||||
if (System.currentTimeMillis() >= dateFirstLaunch + DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) {
|
if (System.currentTimeMillis() >= dateFirstLaunch + DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) {
|
||||||
//showRateDialog(context, editor)
|
//showRateDialog(context, editor)
|
||||||
showPlayStoreReviewDialog(context, editor)
|
showPlayStoreReviewDialog(context, this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showPlayStoreReviewDialog(context: Activity, editor: SharedPreferences.Editor) {
|
private fun showPlayStoreReviewDialog(context: Activity, editor: SharedPreferences.Editor) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.Constants;
|
import code.name.monkey.retromusic.Constants;
|
||||||
|
@ -178,7 +179,7 @@ public final class FileUtil {
|
||||||
if (dotPos == -1) {
|
if (dotPos == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String fileExtension = filename.substring(dotPos + 1).toLowerCase();
|
String fileExtension = filename.substring(dotPos + 1).toLowerCase(Locale.ROOT);
|
||||||
String fileType = mimeTypeMap.getMimeTypeFromExtension(fileExtension);
|
String fileType = mimeTypeMap.getMimeTypeFromExtension(fileExtension);
|
||||||
if (fileType == null) {
|
if (fileType == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -304,7 +305,7 @@ public final class FileUtil {
|
||||||
paths.add(path);
|
paths.add(path);
|
||||||
try {
|
try {
|
||||||
Storage item = new Storage();
|
Storage item = new Storage();
|
||||||
if (path.toLowerCase().contains("sd")) {
|
if (path.toLowerCase(Locale.ROOT).contains("sd")) {
|
||||||
item.title = "SD Card";
|
item.title = "SD Card";
|
||||||
} else {
|
} else {
|
||||||
item.title = "External Storage";
|
item.title = "External Storage";
|
||||||
|
|
|
@ -83,7 +83,6 @@ public class SAFUtil {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
||||||
public static void openFilePicker(Activity activity) {
|
public static void openFilePicker(Activity activity) {
|
||||||
Intent i = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
Intent i = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
@ -92,7 +91,6 @@ public class SAFUtil {
|
||||||
activity.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_FILE);
|
activity.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
||||||
public static void openFilePicker(Fragment fragment) {
|
public static void openFilePicker(Fragment fragment) {
|
||||||
Intent i = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
Intent i = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
@ -101,21 +99,18 @@ public class SAFUtil {
|
||||||
fragment.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_FILE);
|
fragment.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public static void openTreePicker(Activity activity) {
|
public static void openTreePicker(Activity activity) {
|
||||||
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
i.putExtra("android.content.extra.SHOW_ADVANCED", true);
|
i.putExtra("android.content.extra.SHOW_ADVANCED", true);
|
||||||
activity.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_TREE);
|
activity.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_TREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public static void openTreePicker(Fragment fragment) {
|
public static void openTreePicker(Fragment fragment) {
|
||||||
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
i.putExtra("android.content.extra.SHOW_ADVANCED", true);
|
i.putExtra("android.content.extra.SHOW_ADVANCED", true);
|
||||||
fragment.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_TREE);
|
fragment.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_TREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
||||||
public static void saveTreeUri(Context context, Intent data) {
|
public static void saveTreeUri(Context context, Intent data) {
|
||||||
Uri uri = data.getData();
|
Uri uri = data.getData();
|
||||||
context
|
context
|
||||||
|
@ -125,12 +120,10 @@ public class SAFUtil {
|
||||||
PreferenceUtil.INSTANCE.setSafSdCardUri(uri.toString());
|
PreferenceUtil.INSTANCE.setSafSdCardUri(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public static boolean isTreeUriSaved(Context context) {
|
public static boolean isTreeUriSaved(Context context) {
|
||||||
return !TextUtils.isEmpty(PreferenceUtil.INSTANCE.getSafSdCardUri());
|
return !TextUtils.isEmpty(PreferenceUtil.INSTANCE.getSafSdCardUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public static boolean isSDCardAccessGranted(Context context) {
|
public static boolean isSDCardAccessGranted(Context context) {
|
||||||
if (!isTreeUriSaved(context)) return false;
|
if (!isTreeUriSaved(context)) return false;
|
||||||
|
|
||||||
|
@ -267,7 +260,6 @@ public class SAFUtil {
|
||||||
new File(path).delete();
|
new File(path).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
||||||
public static void deleteSAF(Context context, String path, Uri safUri) {
|
public static void deleteSAF(Context context, String path, Uri safUri) {
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import androidx.annotation.IntRange;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
|
@ -329,7 +330,7 @@ public class NotificationColorUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String contrastChange(int colorOld, int colorNew, int bg) {
|
private static String contrastChange(int colorOld, int colorNew, int bg) {
|
||||||
return String.format(
|
return String.format(Locale.ROOT,
|
||||||
"from %.2f:1 to %.2f:1",
|
"from %.2f:1 to %.2f:1",
|
||||||
ColorUtilsFromCompat.calculateContrast(colorOld, bg),
|
ColorUtilsFromCompat.calculateContrast(colorOld, bg),
|
||||||
ColorUtilsFromCompat.calculateContrast(colorNew, bg));
|
ColorUtilsFromCompat.calculateContrast(colorNew, bg));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package code.name.monkey.appthemehelper.util
|
package code.name.monkey.appthemehelper.util
|
||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.annotation.ChecksSdkIntAtLeast
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hemanth S (h4h13).
|
* @author Hemanth S (h4h13).
|
||||||
|
@ -10,6 +11,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 23
|
* @return true if device is running API >= 23
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.M)
|
||||||
fun hasMarshmallow(): Boolean {
|
fun hasMarshmallow(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
}
|
}
|
||||||
|
@ -17,6 +19,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 24
|
* @return true if device is running API >= 24
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N)
|
||||||
fun hasNougat(): Boolean {
|
fun hasNougat(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
||||||
}
|
}
|
||||||
|
@ -24,6 +27,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 25
|
* @return true if device is running API >= 25
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1)
|
||||||
fun hasNougatMR(): Boolean {
|
fun hasNougatMR(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1
|
||||||
}
|
}
|
||||||
|
@ -31,6 +35,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 26
|
* @return true if device is running API >= 26
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
||||||
fun hasOreo(): Boolean {
|
fun hasOreo(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
}
|
}
|
||||||
|
@ -38,6 +43,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 27
|
* @return true if device is running API >= 27
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O_MR1)
|
||||||
fun hasOreoMR1(): Boolean {
|
fun hasOreoMR1(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
||||||
}
|
}
|
||||||
|
@ -45,6 +51,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 28
|
* @return true if device is running API >= 28
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.P)
|
||||||
fun hasP(): Boolean {
|
fun hasP(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
|
||||||
}
|
}
|
||||||
|
@ -52,6 +59,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 29
|
* @return true if device is running API >= 29
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.Q)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun hasQ(): Boolean {
|
fun hasQ(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||||
|
@ -60,6 +68,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 30
|
* @return true if device is running API >= 30
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.R)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun hasR(): Boolean {
|
fun hasR(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||||
|
@ -68,6 +77,7 @@ object VersionUtils {
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 31
|
* @return true if device is running API >= 31
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.S)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun hasS(): Boolean {
|
fun hasS(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue