[Cleanup] Removed redundant API 21(Lollipop) or lower version checks as the minimum SDK version is 21
This commit is contained in:
parent
aefd52c12e
commit
de14e72689
11 changed files with 36 additions and 68 deletions
|
@ -29,18 +29,10 @@ public class LanguageContextWrapper extends ContextWrapper {
|
||||||
LocaleList localeList = new LocaleList(newLocale);
|
LocaleList localeList = new LocaleList(newLocale);
|
||||||
LocaleList.setDefault(localeList);
|
LocaleList.setDefault(localeList);
|
||||||
configuration.setLocales(localeList);
|
configuration.setLocales(localeList);
|
||||||
|
|
||||||
context = context.createConfigurationContext(configuration);
|
|
||||||
|
|
||||||
} else if (VersionUtils.INSTANCE.hasLollipop()) {
|
|
||||||
configuration.setLocale(newLocale);
|
|
||||||
context = context.createConfigurationContext(configuration);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
configuration.locale = newLocale;
|
configuration.setLocale(newLocale);
|
||||||
res.updateConfiguration(configuration, res.getDisplayMetrics());
|
|
||||||
}
|
}
|
||||||
|
context = context.createConfigurationContext(configuration);
|
||||||
return new LanguageContextWrapper(context);
|
return new LanguageContextWrapper(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,12 +118,11 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
if (statusBar != null) {
|
if (statusBar != null) {
|
||||||
when {
|
when {
|
||||||
VersionUtils.hasMarshmallow() -> statusBar.setBackgroundColor(color)
|
VersionUtils.hasMarshmallow() -> statusBar.setBackgroundColor(color)
|
||||||
VersionUtils.hasLollipop() -> statusBar.setBackgroundColor(
|
else -> statusBar.setBackgroundColor(
|
||||||
ColorUtil.darkenColor(
|
ColorUtil.darkenColor(
|
||||||
color
|
color
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else -> statusBar.setBackgroundColor(color)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
when {
|
when {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.IntRange;
|
import androidx.annotation.IntRange;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -16,19 +17,16 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||||
public class DeviceInfo {
|
public class DeviceInfo {
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private final String[] abis =
|
private final String[] abis =
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
Build.SUPPORTED_ABIS;
|
||||||
? Build.SUPPORTED_ABIS
|
|
||||||
: new String[] {Build.CPU_ABI, Build.CPU_ABI2};
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private final String[] abis32Bits =
|
private final String[] abis32Bits =
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_32_BIT_ABIS : null;
|
Build.SUPPORTED_32_BIT_ABIS;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private final String[] abis64Bits =
|
private final String[] abis64Bits =
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_64_BIT_ABIS : null;
|
Build.SUPPORTED_64_BIT_ABIS;
|
||||||
|
|
||||||
private final String baseTheme;
|
private final String baseTheme;
|
||||||
|
|
||||||
|
@ -138,6 +136,7 @@ public class DeviceInfo {
|
||||||
+ "</table>\n";
|
+ "</table>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "App version: "
|
return "App version: "
|
||||||
|
|
|
@ -836,8 +836,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
// Request from an untrusted package: return an empty browser root
|
// Request from an untrusted package: return an empty browser root
|
||||||
return new BrowserRoot(AutoMediaIDHelper.MEDIA_ID_EMPTY_ROOT, null);
|
return new BrowserRoot(AutoMediaIDHelper.MEDIA_ID_EMPTY_ROOT, null);
|
||||||
} else {
|
} else {
|
||||||
/**
|
/** By default return the browsable root. Treat the EXTRA_RECENT flag as a special case
|
||||||
* By default return the browsable root. Treat the EXTRA_RECENT flag as a special case
|
|
||||||
* and return the recent root instead.
|
* and return the recent root instead.
|
||||||
*/
|
*/
|
||||||
boolean isRecentRequest = false;
|
boolean isRecentRequest = false;
|
||||||
|
@ -1349,9 +1348,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.getYear())
|
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.getYear())
|
||||||
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
|
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
|
||||||
metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PreferenceUtil.INSTANCE.isAlbumArtOnLockScreen()) {
|
if (PreferenceUtil.INSTANCE.isAlbumArtOnLockScreen()) {
|
||||||
final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
|
final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
|
||||||
|
|
|
@ -178,18 +178,16 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent {
|
||||||
.addAction(playPauseAction)
|
.addAction(playPauseAction)
|
||||||
.addAction(nextAction)
|
.addAction(nextAction)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
builder.setStyle(
|
||||||
builder.setStyle(
|
MediaStyle()
|
||||||
MediaStyle()
|
.setMediaSession(service.mediaSession.sessionToken)
|
||||||
.setMediaSession(service.mediaSession.sessionToken)
|
.setShowActionsInCompactView(1, 2, 3)
|
||||||
.setShowActionsInCompactView(1, 2, 3)
|
)
|
||||||
)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
if (Build.VERSION.SDK_INT <=
|
||||||
if (Build.VERSION.SDK_INT <=
|
Build.VERSION_CODES.O && PreferenceUtil.isColoredNotification
|
||||||
Build.VERSION_CODES.O && PreferenceUtil.isColoredNotification
|
) {
|
||||||
) {
|
builder.color = color
|
||||||
builder.color = color
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopped) {
|
if (stopped) {
|
||||||
|
|
|
@ -102,10 +102,7 @@ public class ImageUtil {
|
||||||
|
|
||||||
public static Drawable getVectorDrawable(
|
public static Drawable getVectorDrawable(
|
||||||
@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
|
@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
return res.getDrawable(resId, theme);
|
||||||
return res.getDrawable(resId, theme);
|
|
||||||
}
|
|
||||||
return VectorDrawableCompat.create(res, resId, theme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Makes sure that {@code mTempBuffer} has at least length {@code size}. */
|
/** Makes sure that {@code mTempBuffer} has at least length {@code size}. */
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class SAFUtil {
|
||||||
public static final int REQUEST_SAF_PICK_TREE = 43;
|
public static final int REQUEST_SAF_PICK_TREE = 43;
|
||||||
|
|
||||||
public static boolean isSAFRequired(File file) {
|
public static boolean isSAFRequired(File file) {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !file.canWrite();
|
return !file.canWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSAFRequired(String path) {
|
public static boolean isSAFRequired(String path) {
|
||||||
|
|
|
@ -209,10 +209,8 @@ public class CircularImageView extends AppCompatImageView {
|
||||||
private void drawShadow(float shadowRadius, int shadowColor) {
|
private void drawShadow(float shadowRadius, int shadowColor) {
|
||||||
this.shadowRadius = shadowRadius;
|
this.shadowRadius = shadowRadius;
|
||||||
this.shadowColor = shadowColor;
|
this.shadowColor = shadowColor;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
|
|
||||||
setLayerType(LAYER_TYPE_SOFTWARE, paintBorder);
|
setLayerType(LAYER_TYPE_SOFTWARE, paintBorder);
|
||||||
}
|
paintBorder.setShadowLayer(shadowRadius, 0.0f, shadowRadius / 2, shadowColor);
|
||||||
paintBorder.setShadowLayer(shadowRadius, 0.0f, shadowRadius / 2, shadowColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShader() {
|
private void updateShader() {
|
||||||
|
|
|
@ -40,12 +40,10 @@ public class StatusBarMarginFrameLayout extends FrameLayout {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public WindowInsets onApplyWindowInsets(@NonNull WindowInsets insets) {
|
public WindowInsets onApplyWindowInsets(@NonNull WindowInsets insets) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
|
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
|
||||||
lp.topMargin = insets.getSystemWindowInsetTop();
|
lp.topMargin = insets.getSystemWindowInsetTop();
|
||||||
lp.bottomMargin = insets.getSystemWindowInsetBottom();
|
lp.bottomMargin = insets.getSystemWindowInsetBottom();
|
||||||
setLayoutParams(lp);
|
setLayoutParams(lp);
|
||||||
}
|
return super.onApplyWindowInsets(insets);
|
||||||
return super.onApplyWindowInsets(insets);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,21 +91,19 @@ object ATH {
|
||||||
|
|
||||||
fun setTaskDescriptionColor(activity: Activity, @ColorInt color: Int) {
|
fun setTaskDescriptionColor(activity: Activity, @ColorInt color: Int) {
|
||||||
var colorFinal = color
|
var colorFinal = color
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
// Task description requires fully opaque color
|
||||||
// Task description requires fully opaque color
|
colorFinal = ColorUtil.stripAlpha(colorFinal)
|
||||||
colorFinal = ColorUtil.stripAlpha(colorFinal)
|
// Sets color of entry in the system recents page
|
||||||
// Sets color of entry in the system recents page
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
activity.setTaskDescription(
|
||||||
activity.setTaskDescription(
|
ActivityManager.TaskDescription(
|
||||||
ActivityManager.TaskDescription(
|
activity.title as String?,
|
||||||
activity.title as String?,
|
-1,
|
||||||
-1,
|
colorFinal
|
||||||
colorFinal
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
} else {
|
)
|
||||||
activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String?))
|
} else {
|
||||||
}
|
activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,6 @@ import android.os.Build
|
||||||
*/
|
*/
|
||||||
|
|
||||||
object VersionUtils {
|
object VersionUtils {
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if device is running API >= 21
|
|
||||||
*/
|
|
||||||
fun hasLollipop(): Boolean {
|
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if device is running API >= 23
|
* @return true if device is running API >= 23
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue