[Cleanup] Removed redundant API 21(Lollipop) or lower version checks as the minimum SDK version is 21

This commit is contained in:
Prathamesh More 2021-11-28 12:17:20 +05:30
parent aefd52c12e
commit de14e72689
11 changed files with 36 additions and 68 deletions

View file

@ -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);
} }
} }

View file

@ -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 {

View file

@ -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: "

View file

@ -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);

View file

@ -178,7 +178,6 @@ 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)
@ -190,7 +189,6 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent {
) { ) {
builder.color = color builder.color = color
} }
}
if (stopped) { if (stopped) {
return // notification has been stopped before loading was finished return // notification has been stopped before loading was finished

View file

@ -102,11 +102,8 @@ 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}. */
private static void ensureBufferSize(int size) { private static void ensureBufferSize(int size) {

View file

@ -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) {

View file

@ -209,9 +209,7 @@ 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);
} }

View file

@ -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);
} }
} }

View file

@ -91,7 +91,6 @@ 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
@ -107,7 +106,6 @@ object ATH {
activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String?)) activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String?))
} }
} }
}
fun setTint(view: View, @ColorInt color: Int) { fun setTint(view: View, @ColorInt color: Int) {
TintHelper.setTintAuto(view, color, false) TintHelper.setTintAuto(view, color, false)

View file

@ -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
*/ */