Remove always true Build.VERSION.SDK_INT >= 17 if checks
Test: refactoring
Change-Id: I0aadce346fdc5183675365bce47b441882d797db
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/LocalesLateOnCreateActivity.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/LocalesLateOnCreateActivity.java
index 35ee8d3..a25e6a5 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/LocalesLateOnCreateActivity.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/LocalesLateOnCreateActivity.java
@@ -68,10 +68,8 @@
Configuration conf = context.getResources().getConfiguration();
if (Build.VERSION.SDK_INT >= 24) {
conf.setLocales(LocaleList.forLanguageTags(locales.toLanguageTags()));
- } else if (Build.VERSION.SDK_INT >= 17) {
- conf.setLocale(locales.get(0));
} else {
- conf.locale = locales.get(0);
+ conf.setLocale(locales.get(0));
}
// updateConfiguration is required to make the configuration change stick.
// updateConfiguration must be called before any use of the actual Resources.
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplicationConfigurationTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplicationConfigurationTestCase.kt
index bab064a..80561e1 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplicationConfigurationTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplicationConfigurationTestCase.kt
@@ -18,7 +18,6 @@
import android.content.res.Configuration
import android.content.res.Resources
-import android.os.Build
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.appcompat.app.NightModeCustomAttachBaseContextActivity.CUSTOM_FONT_SCALE
import androidx.appcompat.app.NightModeCustomAttachBaseContextActivity.CUSTOM_LOCALE
@@ -115,10 +114,6 @@
companion object {
@JvmStatic
@Parameterized.Parameters
- fun data() = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ fun data() = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationActivity.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationActivity.java
index 5c9e24e..9e0e311 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationActivity.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationActivity.java
@@ -59,11 +59,7 @@
if (locale != null) {
// Configuration.setLocale is added after 17 and Configuration.locale is deprecated
// after 24
- if (Build.VERSION.SDK_INT >= 17) {
- config.setLocale(locale);
- } else {
- config.locale = locale;
- }
+ config.setLocale(locale);
}
return config;
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationTestCase.kt
index fea48d4..e502df0 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomApplyOverrideConfigurationTestCase.kt
@@ -16,7 +16,6 @@
package androidx.appcompat.app
-import android.os.Build
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.appcompat.app.NightModeCustomApplyOverrideConfigurationActivity.CUSTOM_FONT_SCALE
import androidx.appcompat.app.NightModeCustomApplyOverrideConfigurationActivity.CUSTOM_LOCALE
@@ -83,10 +82,6 @@
companion object {
@JvmStatic
@Parameterized.Parameters
- fun data() = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ fun data() = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomAttachBaseContextTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomAttachBaseContextTestCase.kt
index da4f6d1..62d0906 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomAttachBaseContextTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeCustomAttachBaseContextTestCase.kt
@@ -16,7 +16,6 @@
package androidx.appcompat.app
-import android.os.Build
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.appcompat.app.NightModeCustomAttachBaseContextActivity.CUSTOM_FONT_SCALE
import androidx.appcompat.app.NightModeCustomAttachBaseContextActivity.CUSTOM_LOCALE
@@ -78,10 +77,6 @@
companion object {
@JvmStatic
@Parameterized.Parameters
- fun data() = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ fun data() = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModePreventOverrideConfigTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModePreventOverrideConfigTestCase.kt
index 29d06b1..075ff08 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModePreventOverrideConfigTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModePreventOverrideConfigTestCase.kt
@@ -17,7 +17,6 @@
package androidx.appcompat.app
import android.content.res.Configuration
-import android.os.Build
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.appcompat.testutils.NightModeActivityTestRule
import androidx.appcompat.testutils.NightModeUtils.NightSetMode
@@ -67,10 +66,6 @@
companion object {
@JvmStatic
@Parameterized.Parameters
- fun data() = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ fun data() = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateDoesNotRecreateActivityTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateDoesNotRecreateActivityTestCase.kt
index 523d88d..c698bba 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateDoesNotRecreateActivityTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateDoesNotRecreateActivityTestCase.kt
@@ -17,7 +17,6 @@
package androidx.appcompat.app
import android.content.res.Configuration
-import android.os.Build
import androidx.appcompat.Orientation
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
@@ -109,10 +108,6 @@
public companion object {
@JvmStatic
@Parameterized.Parameters
- public fun data(): List<NightSetMode> = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ public fun data(): List<NightSetMode> = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateRecreatesActivityWithConfigTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateRecreatesActivityWithConfigTestCase.kt
index f5f1e53..962dfd5 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateRecreatesActivityWithConfigTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeRotateRecreatesActivityWithConfigTestCase.kt
@@ -19,7 +19,6 @@
import android.app.Activity
import android.app.Instrumentation
import android.content.res.Configuration
-import android.os.Build
import androidx.appcompat.Orientation
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
@@ -132,10 +131,6 @@
public companion object {
@JvmStatic
@Parameterized.Parameters
- public fun data(): List<NightSetMode> = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ public fun data(): List<NightSetMode> = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeTestCase.kt
index 1e3451f..51fc6d3a 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeTestCase.kt
@@ -19,7 +19,6 @@
import android.content.Context
import android.content.res.Configuration
import android.location.LocationManager
-import android.os.Build
import android.webkit.WebView
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
@@ -282,10 +281,6 @@
@Parameterized.Parameters
@JvmStatic
- fun data() = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ fun data() = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt
index fe35b47..f0ebe47 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt
@@ -17,7 +17,6 @@
package androidx.appcompat.app
import android.content.res.Configuration
-import android.os.Build
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.appcompat.testutils.NightModeUtils.NightSetMode
@@ -161,10 +160,6 @@
companion object {
@JvmStatic
@Parameterized.Parameters
- fun data() = if (Build.VERSION.SDK_INT >= 17) {
- listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
- } else {
- listOf(NightSetMode.DEFAULT)
- }
+ fun data() = listOf(NightSetMode.DEFAULT, NightSetMode.LOCAL)
}
}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/NightModeUtils.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/NightModeUtils.kt
index 1fb9286..a666cda 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/NightModeUtils.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/NightModeUtils.kt
@@ -20,7 +20,6 @@
import android.content.Context
import android.content.pm.ActivityInfo
import android.content.res.Configuration
-import android.os.Build
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
@@ -189,12 +188,7 @@
setMode: NightSetMode
) = when (setMode) {
NightSetMode.DEFAULT -> AppCompatDelegate.setDefaultNightMode(nightMode)
- NightSetMode.LOCAL ->
- if (Build.VERSION.SDK_INT >= 17) {
- activity!!.delegate.localNightMode = nightMode
- } else {
- throw Exception("Local night mode is not supported on SDK_INT < 17")
- }
+ NightSetMode.LOCAL -> activity!!.delegate.localNightMode = nightMode
}
@NightMode
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseAutoSizeTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseAutoSizeTest.java
index 525e43a..8502458 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseAutoSizeTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseAutoSizeTest.java
@@ -431,10 +431,8 @@
mActivityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
- if (Build.VERSION.SDK_INT >= 17) {
- autoSizeView.setCompoundDrawablesRelative(
- drawable, drawable, drawable, drawable);
- }
+ autoSizeView.setCompoundDrawablesRelative(
+ drawable, drawable, drawable, drawable);
}
});
mInstrumentation.waitForIdleSync();
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java b/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
index 4976f99..28d90ef 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
@@ -475,7 +475,7 @@
// Workaround for incorrect default fontScale on earlier SDKs.
overrideConfig.fontScale = 0f;
Configuration referenceConfig =
- Api17Impl.createConfigurationContext(baseContext, overrideConfig)
+ baseContext.createConfigurationContext(overrideConfig)
.getResources().getConfiguration();
// Revert the uiMode change so that the diff doesn't include uiMode.
Configuration baseConfig = baseContext.getResources().getConfiguration();
@@ -2687,11 +2687,9 @@
void setConfigurationLocales(Configuration conf, @NonNull LocaleListCompat locales) {
if (Build.VERSION.SDK_INT >= 24) {
Api24Impl.setLocales(conf, locales);
- } else if (Build.VERSION.SDK_INT >= 17) {
- Api17Impl.setLocale(conf, locales.get(0));
- Api17Impl.setLayoutDirection(conf, locales.get(0));
} else {
- conf.locale = locales.get(0);
+ conf.setLocale(locales.get(0));
+ conf.setLayoutDirection(locales.get(0));
}
}
@@ -2795,9 +2793,7 @@
}
if (newLocales != null && !currentLocales.equals(newLocales)) {
configChanges |= ActivityInfo.CONFIG_LOCALE;
- if (Build.VERSION.SDK_INT >= 17) {
- configChanges |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
- }
+ configChanges |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
}
if (DEBUG) {
@@ -2836,9 +2832,8 @@
// layout direction after recreating in Android S.
if (Build.VERSION.SDK_INT >= 31
&& (configChanges & ActivityInfo.CONFIG_LAYOUT_DIRECTION) != 0) {
- Api17Impl.setLayoutDirection(
- ((Activity) mHost).getWindow().getDecorView(),
- Api17Impl.getLayoutDirection(overrideConfig));
+ View view = ((Activity) mHost).getWindow().getDecorView();
+ view.setLayoutDirection(overrideConfig.getLayoutDirection());
}
ActivityCompat.recreate((Activity) mHost);
handled = true;
@@ -3908,8 +3903,8 @@
delta.smallestScreenWidthDp = change.smallestScreenWidthDp;
}
- if (Build.VERSION.SDK_INT >= 17) {
- Api17Impl.generateConfigDelta_densityDpi(base, change, delta);
+ if (base.densityDpi != change.densityDpi) {
+ delta.densityDpi = change.densityDpi;
}
// Assets sequence and window configuration are not supported.
@@ -3917,44 +3912,6 @@
return delta;
}
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() { }
-
- static void generateConfigDelta_densityDpi(@NonNull Configuration base,
- @NonNull Configuration change, @NonNull Configuration delta) {
- if (base.densityDpi != change.densityDpi) {
- delta.densityDpi = change.densityDpi;
- }
- }
-
- @DoNotInline
- static Context createConfigurationContext(@NonNull Context context,
- @NonNull Configuration overrideConfiguration) {
- return context.createConfigurationContext(overrideConfiguration);
- }
-
- @DoNotInline
- static void setLayoutDirection(Configuration configuration, Locale loc) {
- configuration.setLayoutDirection(loc);
- }
-
- @DoNotInline
- static void setLayoutDirection(View view, int layoutDirection) {
- view.setLayoutDirection(layoutDirection);
- }
-
- @DoNotInline
- static void setLocale(Configuration configuration, Locale loc) {
- configuration.setLocale(loc);
- }
-
- @DoNotInline
- static int getLayoutDirection(Configuration configuration) {
- return configuration.getLayoutDirection();
- }
- }
-
@RequiresApi(21)
static class Api21Impl {
private Api21Impl() { }
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/view/menu/MenuPopupHelper.java b/appcompat/appcompat/src/main/java/androidx/appcompat/view/menu/MenuPopupHelper.java
index 69c498c..aa98768 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/view/menu/MenuPopupHelper.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/view/menu/MenuPopupHelper.java
@@ -22,7 +22,6 @@
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
-import android.os.Build;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
@@ -32,10 +31,8 @@
import android.widget.PopupWindow.OnDismissListener;
import androidx.annotation.AttrRes;
-import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleRes;
import androidx.appcompat.R;
@@ -233,11 +230,7 @@
final Display display = windowManager.getDefaultDisplay();
final Point displaySize = new Point();
- if (Build.VERSION.SDK_INT >= 17) {
- Api17Impl.getRealSize(display, displaySize);
- } else {
- display.getSize(displaySize);
- }
+ display.getRealSize(displaySize);
final int smallestWidth = Math.min(displaySize.x, displaySize.y);
final int minSmallestWidthCascading = mContext.getResources().getDimensionPixelSize(
@@ -351,16 +344,4 @@
public ListView getListView() {
return getPopup().getListView();
}
-
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static void getRealSize(Display display, Point outSize) {
- display.getRealSize(outSize);
- }
- }
}
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextHelper.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextHelper.java
index 4eb3371..8408ef6 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextHelper.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextHelper.java
@@ -548,12 +548,10 @@
applyCompoundDrawableTint(compoundDrawables[2], mDrawableRightTint);
applyCompoundDrawableTint(compoundDrawables[3], mDrawableBottomTint);
}
- if (Build.VERSION.SDK_INT >= 17) {
- if (mDrawableStartTint != null || mDrawableEndTint != null) {
- final Drawable[] compoundDrawables = Api17Impl.getCompoundDrawablesRelative(mView);
- applyCompoundDrawableTint(compoundDrawables[0], mDrawableStartTint);
- applyCompoundDrawableTint(compoundDrawables[2], mDrawableEndTint);
- }
+ if (mDrawableStartTint != null || mDrawableEndTint != null) {
+ final Drawable[] compoundDrawables = Api17Impl.getCompoundDrawablesRelative(mView);
+ applyCompoundDrawableTint(compoundDrawables[0], mDrawableStartTint);
+ applyCompoundDrawableTint(compoundDrawables[2], mDrawableEndTint);
}
}
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/Toolbar.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/Toolbar.java
index b48c66c..9198f6a 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/Toolbar.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/Toolbar.java
@@ -559,9 +559,7 @@
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
- if (Build.VERSION.SDK_INT >= 17) {
- super.onRtlPropertiesChanged(layoutDirection);
- }
+ super.onRtlPropertiesChanged(layoutDirection);
ensureContentInsets();
mContentInsets.setDirection(layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL);
diff --git a/arch/core/core-runtime/src/main/java/androidx/arch/core/executor/DefaultTaskExecutor.java b/arch/core/core-runtime/src/main/java/androidx/arch/core/executor/DefaultTaskExecutor.java
index b164eb5..99433a0 100644
--- a/arch/core/core-runtime/src/main/java/androidx/arch/core/executor/DefaultTaskExecutor.java
+++ b/arch/core/core-runtime/src/main/java/androidx/arch/core/executor/DefaultTaskExecutor.java
@@ -82,7 +82,7 @@
private static Handler createAsync(@NonNull Looper looper) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.createAsync(looper);
- } else if (Build.VERSION.SDK_INT >= 17) {
+ } else {
try {
// This constructor was added as private in JB MR1:
// https://android.googlesource.com/platform/frameworks/base/+/refs/heads/jb-mr1-release/core/java/android/os/Handler.java
diff --git a/cardview/cardview/src/main/java/androidx/cardview/widget/CardView.java b/cardview/cardview/src/main/java/androidx/cardview/widget/CardView.java
index 08b5580..b940212 100644
--- a/cardview/cardview/src/main/java/androidx/cardview/widget/CardView.java
+++ b/cardview/cardview/src/main/java/androidx/cardview/widget/CardView.java
@@ -86,8 +86,6 @@
static {
if (Build.VERSION.SDK_INT >= 21) {
IMPL = new CardViewApi21Impl();
- } else if (Build.VERSION.SDK_INT >= 17) {
- IMPL = new CardViewApi17Impl();
} else {
IMPL = new CardViewBaseImpl();
}
diff --git a/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewApi17Impl.java b/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewApi17Impl.java
deleted file mode 100644
index 49387fd..0000000
--- a/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewApi17Impl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package androidx.cardview.widget;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.RectF;
-
-import androidx.annotation.RequiresApi;
-
-@RequiresApi(17)
-class CardViewApi17Impl extends CardViewBaseImpl {
-
- @Override
- public void initStatic() {
- RoundRectDrawableWithShadow.sRoundRectHelper =
- new RoundRectDrawableWithShadow.RoundRectHelper() {
- @Override
- public void drawRoundRect(Canvas canvas, RectF bounds, float cornerRadius,
- Paint paint) {
- canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
- }
- };
- }
-}
diff --git a/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewBaseImpl.java b/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewBaseImpl.java
index bc6cd5d..c5a8dec 100644
--- a/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewBaseImpl.java
+++ b/cardview/cardview/src/main/java/androidx/cardview/widget/CardViewBaseImpl.java
@@ -17,64 +17,17 @@
import android.content.Context;
import android.content.res.ColorStateList;
-import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.Rect;
-import android.graphics.RectF;
import androidx.annotation.Nullable;
class CardViewBaseImpl implements CardViewImpl {
- @SuppressWarnings("WeakerAccess") /* synthetic access */
- final RectF mCornerRect = new RectF();
-
@Override
public void initStatic() {
- // Draws a round rect using 7 draw operations. This is faster than using
- // canvas.drawRoundRect before JBMR1 because API 11-16 used alpha mask textures to draw
- // shapes.
RoundRectDrawableWithShadow.sRoundRectHelper =
- new RoundRectDrawableWithShadow.RoundRectHelper() {
- @Override
- public void drawRoundRect(Canvas canvas, RectF bounds, float cornerRadius,
- Paint paint) {
- final float twoRadius = cornerRadius * 2;
- final float innerWidth = bounds.width() - twoRadius - 1;
- final float innerHeight = bounds.height() - twoRadius - 1;
- if (cornerRadius >= 1f) {
- // increment corner radius to account for half pixels.
- float roundedCornerRadius = cornerRadius + .5f;
- mCornerRect.set(-roundedCornerRadius, -roundedCornerRadius, roundedCornerRadius,
- roundedCornerRadius);
- int saved = canvas.save();
- canvas.translate(bounds.left + roundedCornerRadius,
- bounds.top + roundedCornerRadius);
- canvas.drawArc(mCornerRect, 180, 90, true, paint);
- canvas.translate(innerWidth, 0);
- canvas.rotate(90);
- canvas.drawArc(mCornerRect, 180, 90, true, paint);
- canvas.translate(innerHeight, 0);
- canvas.rotate(90);
- canvas.drawArc(mCornerRect, 180, 90, true, paint);
- canvas.translate(innerWidth, 0);
- canvas.rotate(90);
- canvas.drawArc(mCornerRect, 180, 90, true, paint);
- canvas.restoreToCount(saved);
- //draw top and bottom pieces
- canvas.drawRect(bounds.left + roundedCornerRadius - 1f, bounds.top,
- bounds.right - roundedCornerRadius + 1f,
- bounds.top + roundedCornerRadius, paint);
-
- canvas.drawRect(bounds.left + roundedCornerRadius - 1f,
- bounds.bottom - roundedCornerRadius,
- bounds.right - roundedCornerRadius + 1f, bounds.bottom, paint);
- }
- // center
- canvas.drawRect(bounds.left, bounds.top + cornerRadius,
- bounds.right, bounds.bottom - cornerRadius , paint);
- }
- };
+ (canvas, bounds, cornerRadius, paint) ->
+ canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
}
@Override
diff --git a/core/core/src/androidTest/java/androidx/core/location/LocationCompatTest.java b/core/core/src/androidTest/java/androidx/core/location/LocationCompatTest.java
index 2c9770b..6cf5ee3 100644
--- a/core/core/src/androidTest/java/androidx/core/location/LocationCompatTest.java
+++ b/core/core/src/androidTest/java/androidx/core/location/LocationCompatTest.java
@@ -25,7 +25,6 @@
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import android.location.Location;
-import android.os.Build;
import android.os.SystemClock;
import androidx.test.filters.SmallTest;
@@ -40,16 +39,10 @@
@Test
public void testGetElapsedRealtimeNanos() {
long locationElapsedRealtimeNs;
- if (Build.VERSION.SDK_INT >= 17) {
- locationElapsedRealtimeNs = SystemClock.elapsedRealtimeNanos();
- } else {
- locationElapsedRealtimeNs = MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
- }
+ locationElapsedRealtimeNs = SystemClock.elapsedRealtimeNanos();
Location location = new Location("");
- if (Build.VERSION.SDK_INT >= 17) {
- location.setElapsedRealtimeNanos(locationElapsedRealtimeNs);
- }
+ location.setElapsedRealtimeNanos(locationElapsedRealtimeNs);
location.setTime(System.currentTimeMillis());
assertTrue(NANOSECONDS.toMillis(Math.abs(
@@ -62,9 +55,7 @@
long locationElapsedRealtimeMs = SystemClock.elapsedRealtime();
Location location = new Location("");
- if (Build.VERSION.SDK_INT >= 17) {
- location.setElapsedRealtimeNanos(MILLISECONDS.toNanos(locationElapsedRealtimeMs));
- }
+ location.setElapsedRealtimeNanos(MILLISECONDS.toNanos(locationElapsedRealtimeMs));
location.setTime(System.currentTimeMillis());
assertTrue(Math.abs(
diff --git a/core/core/src/androidTest/java/androidx/core/view/MarginLayoutParamsCompatTest.java b/core/core/src/androidTest/java/androidx/core/view/MarginLayoutParamsCompatTest.java
index 77676e7..7289810 100644
--- a/core/core/src/androidTest/java/androidx/core/view/MarginLayoutParamsCompatTest.java
+++ b/core/core/src/androidTest/java/androidx/core/view/MarginLayoutParamsCompatTest.java
@@ -37,14 +37,8 @@
MarginLayoutParamsCompat.getLayoutDirection(mlp));
MarginLayoutParamsCompat.setLayoutDirection(mlp, ViewCompat.LAYOUT_DIRECTION_RTL);
- if (Build.VERSION.SDK_INT >= 17) {
- assertEquals("RTL layout direction", ViewCompat.LAYOUT_DIRECTION_RTL,
- MarginLayoutParamsCompat.getLayoutDirection(mlp));
- } else {
- assertEquals("Still LTR layout direction on older devices",
- ViewCompat.LAYOUT_DIRECTION_LTR,
- MarginLayoutParamsCompat.getLayoutDirection(mlp));
- }
+ assertEquals("RTL layout direction", ViewCompat.LAYOUT_DIRECTION_RTL,
+ MarginLayoutParamsCompat.getLayoutDirection(mlp));
MarginLayoutParamsCompat.setLayoutDirection(mlp, ViewCompat.LAYOUT_DIRECTION_LTR);
assertEquals("Back to LTR layout direction", ViewCompat.LAYOUT_DIRECTION_LTR,
diff --git a/core/core/src/main/java/androidx/core/app/NotificationCompatBuilder.java b/core/core/src/main/java/androidx/core/app/NotificationCompatBuilder.java
index 927e008..9f30326 100644
--- a/core/core/src/main/java/androidx/core/app/NotificationCompatBuilder.java
+++ b/core/core/src/main/java/androidx/core/app/NotificationCompatBuilder.java
@@ -157,9 +157,7 @@
mContentView = b.mContentView;
mBigContentView = b.mBigContentView;
}
- if (Build.VERSION.SDK_INT >= 17) {
- Api17Impl.setShowWhen(mBuilder, b.mShowWhen);
- }
+ mBuilder.setShowWhen(b.mShowWhen);
if (Build.VERSION.SDK_INT >= 19) {
if (Build.VERSION.SDK_INT < 21) {
final List<String> people = combineLists(getPeople(b.mPersonList), b.mPeople);
@@ -597,23 +595,6 @@
/**
* A class for wrapping calls to {@link NotificationCompatBuilder} methods which
- * were added in API 17; these calls must be wrapped to avoid performance issues.
- * See the UnsafeNewApiCall lint rule for more details.
- */
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- }
-
- @DoNotInline
- static Notification.Builder setShowWhen(Notification.Builder builder, boolean show) {
- return builder.setShowWhen(show);
- }
-
- }
-
- /**
- * A class for wrapping calls to {@link NotificationCompatBuilder} methods which
* were added in API 19; these calls must be wrapped to avoid performance issues.
* See the UnsafeNewApiCall lint rule for more details.
*/
diff --git a/core/core/src/main/java/androidx/core/content/res/ConfigurationHelper.java b/core/core/src/main/java/androidx/core/content/res/ConfigurationHelper.java
index ca5094d..dcfb64c 100644
--- a/core/core/src/main/java/androidx/core/content/res/ConfigurationHelper.java
+++ b/core/core/src/main/java/androidx/core/content/res/ConfigurationHelper.java
@@ -16,8 +16,6 @@
package androidx.core.content.res;
-import static android.os.Build.VERSION.SDK_INT;
-
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -38,10 +36,6 @@
* is computed and returned.</p>
*/
public static int getDensityDpi(@NonNull Resources resources) {
- if (SDK_INT >= 17) {
- return resources.getConfiguration().densityDpi;
- } else {
- return resources.getDisplayMetrics().densityDpi;
- }
+ return resources.getConfiguration().densityDpi;
}
}
diff --git a/core/core/src/main/java/androidx/core/graphics/BitmapCompat.java b/core/core/src/main/java/androidx/core/graphics/BitmapCompat.java
index b10563e..74ad5c7 100644
--- a/core/core/src/main/java/androidx/core/graphics/BitmapCompat.java
+++ b/core/core/src/main/java/androidx/core/graphics/BitmapCompat.java
@@ -54,10 +54,7 @@
* @see Bitmap#hasMipMap()
*/
public static boolean hasMipMap(@NonNull Bitmap bitmap) {
- if (Build.VERSION.SDK_INT >= 17) {
- return Api17Impl.hasMipMap(bitmap);
- }
- return false;
+ return bitmap.hasMipMap();
}
/**
@@ -81,9 +78,7 @@
* @see Bitmap#setHasMipMap(boolean)
*/
public static void setHasMipMap(@NonNull Bitmap bitmap, boolean hasMipMap) {
- if (Build.VERSION.SDK_INT >= 17) {
- Api17Impl.setHasMipMap(bitmap, hasMipMap);
- }
+ bitmap.setHasMipMap(hasMipMap);
}
/**
@@ -334,23 +329,6 @@
// This class is not instantiable.
}
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static boolean hasMipMap(Bitmap bitmap) {
- return bitmap.hasMipMap();
- }
-
- @DoNotInline
- static void setHasMipMap(Bitmap bitmap, boolean hasMipMap) {
- bitmap.setHasMipMap(hasMipMap);
- }
- }
-
@RequiresApi(19)
static class Api19Impl {
private Api19Impl() {
diff --git a/core/core/src/main/java/androidx/core/hardware/display/DisplayManagerCompat.java b/core/core/src/main/java/androidx/core/hardware/display/DisplayManagerCompat.java
index 4f6a511..396cadf 100644
--- a/core/core/src/main/java/androidx/core/hardware/display/DisplayManagerCompat.java
+++ b/core/core/src/main/java/androidx/core/hardware/display/DisplayManagerCompat.java
@@ -18,14 +18,10 @@
import android.content.Context;
import android.hardware.display.DisplayManager;
-import android.os.Build;
import android.view.Display;
-import android.view.WindowManager;
-import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
/**
* Helper for accessing features in {@link android.hardware.display.DisplayManager}.
@@ -73,17 +69,9 @@
@Nullable
@SuppressWarnings("deprecation")
public Display getDisplay(int displayId) {
- if (Build.VERSION.SDK_INT >= 17) {
- return Api17Impl.getDisplay(
- (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE), displayId);
- }
-
- Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- if (display.getDisplayId() == displayId) {
- return display;
- }
- return null;
+ DisplayManager displayManager =
+ (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
+ return displayManager.getDisplay(displayId);
}
/**
@@ -94,14 +82,7 @@
@SuppressWarnings("deprecation")
@NonNull
public Display[] getDisplays() {
- if (Build.VERSION.SDK_INT >= 17) {
- return Api17Impl.getDisplays(
- (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE));
- }
-
- Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- return new Display[] { display };
+ return ((DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE)).getDisplays();
}
/**
@@ -123,33 +104,6 @@
@NonNull
@SuppressWarnings("deprecation")
public Display[] getDisplays(@Nullable String category) {
- if (Build.VERSION.SDK_INT >= 17) {
- return Api17Impl.getDisplays(
- (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE));
- }
- if (category == null) {
- return new Display[0];
- }
-
- Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- return new Display[]{display};
- }
-
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static Display getDisplay(DisplayManager displayManager, int displayId) {
- return displayManager.getDisplay(displayId);
- }
-
- @DoNotInline
- static Display[] getDisplays(DisplayManager displayManager) {
- return displayManager.getDisplays();
- }
+ return ((DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE)).getDisplays();
}
}
diff --git a/core/core/src/main/java/androidx/core/location/LocationCompat.java b/core/core/src/main/java/androidx/core/location/LocationCompat.java
index 634dea0..a1ab899 100644
--- a/core/core/src/main/java/androidx/core/location/LocationCompat.java
+++ b/core/core/src/main/java/androidx/core/location/LocationCompat.java
@@ -16,14 +16,12 @@
package androidx.core.location;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import android.annotation.SuppressLint;
import android.location.Location;
import android.os.Build.VERSION;
import android.os.Bundle;
-import android.os.SystemClock;
import androidx.annotation.DoNotInline;
import androidx.annotation.FloatRange;
@@ -111,11 +109,7 @@
* location derivation is different from the system clock, the results may be inaccurate.
*/
public static long getElapsedRealtimeNanos(@NonNull Location location) {
- if (VERSION.SDK_INT >= 17) {
- return Api17Impl.getElapsedRealtimeNanos(location);
- } else {
- return MILLISECONDS.toNanos(getElapsedRealtimeMillis(location));
- }
+ return location.getElapsedRealtimeNanos();
}
/**
@@ -124,21 +118,7 @@
* @see #getElapsedRealtimeNanos(Location)
*/
public static long getElapsedRealtimeMillis(@NonNull Location location) {
- if (VERSION.SDK_INT >= 17) {
- return NANOSECONDS.toMillis(Api17Impl.getElapsedRealtimeNanos(location));
- } else {
- long timeDeltaMs = System.currentTimeMillis() - location.getTime();
- long elapsedRealtimeMs = SystemClock.elapsedRealtime();
- if (timeDeltaMs < 0) {
- // don't return an elapsed realtime from the future
- return elapsedRealtimeMs;
- } else if (timeDeltaMs > elapsedRealtimeMs) {
- // don't return an elapsed realtime from before boot
- return 0;
- } else {
- return elapsedRealtimeMs - timeDeltaMs;
- }
- }
+ return NANOSECONDS.toMillis(location.getElapsedRealtimeNanos());
}
/**
@@ -972,18 +952,6 @@
}
}
- @RequiresApi(17)
- private static class Api17Impl {
-
- private Api17Impl() {
- }
-
- @DoNotInline
- static long getElapsedRealtimeNanos(Location location) {
- return location.getElapsedRealtimeNanos();
- }
- }
-
private static Method getSetIsFromMockProviderMethod() throws NoSuchMethodException {
if (sSetIsFromMockProviderMethod == null) {
sSetIsFromMockProviderMethod = Location.class.getDeclaredMethod("setIsFromMockProvider",
diff --git a/core/core/src/main/java/androidx/core/os/ConfigurationCompat.java b/core/core/src/main/java/androidx/core/os/ConfigurationCompat.java
index e5e80dc..d4438ce 100644
--- a/core/core/src/main/java/androidx/core/os/ConfigurationCompat.java
+++ b/core/core/src/main/java/androidx/core/os/ConfigurationCompat.java
@@ -57,20 +57,7 @@
@NonNull Configuration configuration, @NonNull LocaleListCompat locales) {
if (SDK_INT >= 24) {
Api24Impl.setLocales(configuration, locales);
- } else if (SDK_INT >= 17) {
- Api17Impl.setLocale(configuration, locales);
- }
- }
-
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static void setLocale(
- @NonNull Configuration configuration, @NonNull LocaleListCompat locales) {
+ } else {
if (!locales.isEmpty()) {
configuration.setLocale(locales.get(0));
}
diff --git a/core/core/src/main/java/androidx/core/os/ProcessCompat.java b/core/core/src/main/java/androidx/core/os/ProcessCompat.java
index 6343cf3..f2c38d0 100644
--- a/core/core/src/main/java/androidx/core/os/ProcessCompat.java
+++ b/core/core/src/main/java/androidx/core/os/ProcessCompat.java
@@ -54,12 +54,8 @@
public static boolean isApplicationUid(int uid) {
if (Build.VERSION.SDK_INT >= 24) {
return Api24Impl.isApplicationUid(uid);
- } else if (Build.VERSION.SDK_INT >= 17) {
- return Api17Impl.isApplicationUid(uid);
- } else if (Build.VERSION.SDK_INT == 16) {
- return Api16Impl.isApplicationUid(uid);
} else {
- return true;
+ return Api17Impl.isApplicationUid(uid);
}
}
@@ -76,7 +72,6 @@
}
}
- @RequiresApi(17)
static class Api17Impl {
private static final Object sResolvedLock = new Object();
@@ -114,43 +109,4 @@
return true;
}
}
-
- @RequiresApi(16)
- static class Api16Impl {
- private static final Object sResolvedLock = new Object();
-
- private static Method sMethodUserIdIsAppMethod;
- private static boolean sResolved;
-
- private Api16Impl() {
- // This class is non-instantiable.
- }
-
- @SuppressLint("PrivateApi")
- @SuppressWarnings("CatchAndPrintStackTrace")
- static boolean isApplicationUid(int uid) {
- // In JELLY_BEAN_MR1, the equivalent isApp(int) hidden method was available on hidden
- // class android.os.UserId.
- try {
- synchronized (sResolvedLock) {
- if (!sResolved) {
- sResolved = true;
- sMethodUserIdIsAppMethod = Class.forName("android.os.UserId")
- .getDeclaredMethod("isApp", int.class);
- }
- }
- if (sMethodUserIdIsAppMethod != null) {
- Boolean result = (Boolean) sMethodUserIdIsAppMethod.invoke(null, uid);
- if (result == null) {
- // This should never happen, as the method returns a boolean primitive.
- throw new NullPointerException();
- }
- return result;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return true;
- }
- }
}
diff --git a/core/core/src/main/java/androidx/core/text/TextUtilsCompat.java b/core/core/src/main/java/androidx/core/text/TextUtilsCompat.java
index 3085998..bdcd81ee 100644
--- a/core/core/src/main/java/androidx/core/text/TextUtilsCompat.java
+++ b/core/core/src/main/java/androidx/core/text/TextUtilsCompat.java
@@ -16,14 +16,10 @@
package androidx.core.text;
-import static android.os.Build.VERSION.SDK_INT;
-
import android.text.TextUtils;
-import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.core.view.ViewCompat;
import java.util.Locale;
@@ -32,9 +28,6 @@
* Backwards compatible version of {@link TextUtils}.
*/
public final class TextUtilsCompat {
- private static final Locale ROOT = new Locale("", "");
- private static final String ARAB_SCRIPT_SUBTAG = "Arab";
- private static final String HEBR_SCRIPT_SUBTAG = "Hebr";
/**
* Html-encode the string.
@@ -44,40 +37,7 @@
*/
@NonNull
public static String htmlEncode(@NonNull String s) {
- if (SDK_INT >= 17) {
- return TextUtils.htmlEncode(s);
- } else {
- StringBuilder sb = new StringBuilder();
- char c;
- for (int i = 0; i < s.length(); i++) {
- c = s.charAt(i);
- switch (c) {
- case '<':
- sb.append("<"); //$NON-NLS-1$
- break;
- case '>':
- sb.append(">"); //$NON-NLS-1$
- break;
- case '&':
- sb.append("&"); //$NON-NLS-1$
- break;
- case '\'':
- //http://www.w3.org/TR/xhtml1
- // The named character reference ' (the apostrophe, U+0027) was
- // introduced in XML 1.0 but does not appear in HTML. Authors should
- // therefore use ' instead of ' to work as expected in HTML 4
- // user agents.
- sb.append("'"); //$NON-NLS-1$
- break;
- case '"':
- sb.append("""); //$NON-NLS-1$
- break;
- default:
- sb.append(c);
- }
- }
- return sb.toString();
- }
+ return TextUtils.htmlEncode(s);
}
/**
@@ -89,58 +49,9 @@
* {@link ViewCompat#LAYOUT_DIRECTION_RTL}.
*/
public static int getLayoutDirectionFromLocale(@Nullable Locale locale) {
- if (SDK_INT >= 17) {
- return Api17Impl.getLayoutDirectionFromLocale(locale);
- } else {
- if (locale != null && !locale.equals(ROOT)) {
- final String scriptSubtag = ICUCompat.maximizeAndGetScript(locale);
- if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale);
-
- // This is intentionally limited to Arabic and Hebrew scripts, since older
- // versions of Android platform only considered those scripts to be right-to-left.
- if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG)
- || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
- return ViewCompat.LAYOUT_DIRECTION_RTL;
- }
- }
- return ViewCompat.LAYOUT_DIRECTION_LTR;
- }
- }
-
- /**
- * Fallback algorithm to detect the locale direction. Rely on the first char of the
- * localized locale name. This will not work if the localized locale name is in English
- * (this is the case for ICU 4.4 and "Urdu" script)
- *
- * @param locale the {@link Locale} for which we want the layout direction, maybe be
- * {@code null}.
- * @return the layout direction, either {@link ViewCompat#LAYOUT_DIRECTION_LTR} or
- * {@link ViewCompat#LAYOUT_DIRECTION_RTL}.
- */
- private static int getLayoutDirectionFromFirstChar(@NonNull Locale locale) {
- switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
- case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
- case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
- return ViewCompat.LAYOUT_DIRECTION_RTL;
-
- case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
- default:
- return ViewCompat.LAYOUT_DIRECTION_LTR;
- }
+ return TextUtils.getLayoutDirectionFromLocale(locale);
}
private TextUtilsCompat() {
}
-
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static int getLayoutDirectionFromLocale(Locale locale) {
- return TextUtils.getLayoutDirectionFromLocale(locale);
- }
- }
}
diff --git a/core/core/src/main/java/androidx/core/view/GravityCompat.java b/core/core/src/main/java/androidx/core/view/GravityCompat.java
index 5935241..b7e1215 100644
--- a/core/core/src/main/java/androidx/core/view/GravityCompat.java
+++ b/core/core/src/main/java/androidx/core/view/GravityCompat.java
@@ -17,14 +17,10 @@
package androidx.core.view;
-import static android.os.Build.VERSION.SDK_INT;
-
import android.graphics.Rect;
import android.view.Gravity;
-import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
/**
* Compatibility shim for accessing newer functionality from {@link Gravity}.
@@ -65,11 +61,7 @@
*/
public static void apply(int gravity, int w, int h, @NonNull Rect container,
@NonNull Rect outRect, int layoutDirection) {
- if (SDK_INT >= 17) {
- Api17Impl.apply(gravity, w, h, container, outRect, layoutDirection);
- } else {
- Gravity.apply(gravity, w, h, container, outRect);
- }
+ Gravity.apply(gravity, w, h, container, outRect, layoutDirection);
}
/**
@@ -99,11 +91,7 @@
*/
public static void apply(int gravity, int w, int h, @NonNull Rect container,
int xAdj, int yAdj, @NonNull Rect outRect, int layoutDirection) {
- if (SDK_INT >= 17) {
- Api17Impl.apply(gravity, w, h, container, xAdj, yAdj, outRect, layoutDirection);
- } else {
- Gravity.apply(gravity, w, h, container, xAdj, yAdj, outRect);
- }
+ Gravity.apply(gravity, w, h, container, xAdj, yAdj, outRect, layoutDirection);
}
/**
@@ -128,11 +116,7 @@
*/
public static void applyDisplay(int gravity, @NonNull Rect display, @NonNull Rect inoutObj,
int layoutDirection) {
- if (SDK_INT >= 17) {
- Api17Impl.applyDisplay(gravity, display, inoutObj, layoutDirection);
- } else {
- Gravity.applyDisplay(gravity, display, inoutObj);
- }
+ Gravity.applyDisplay(gravity, display, inoutObj, layoutDirection);
}
/**
@@ -147,38 +131,9 @@
* @return gravity converted to absolute (horizontal) values.
*/
public static int getAbsoluteGravity(int gravity, int layoutDirection) {
- if (SDK_INT >= 17) {
- return Gravity.getAbsoluteGravity(gravity, layoutDirection);
- } else {
- // Just strip off the relative bit to get LEFT/RIGHT.
- return gravity & ~RELATIVE_LAYOUT_DIRECTION;
- }
+ return Gravity.getAbsoluteGravity(gravity, layoutDirection);
}
private GravityCompat() {
}
-
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static void apply(int gravity, int w, int h, Rect container, Rect outRect,
- int layoutDirection) {
- Gravity.apply(gravity, w, h, container, outRect, layoutDirection);
- }
-
- @DoNotInline
- static void apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj,
- Rect outRect, int layoutDirection) {
- Gravity.apply(gravity, w, h, container, xAdj, yAdj, outRect, layoutDirection);
- }
-
- @DoNotInline
- static void applyDisplay(int gravity, Rect display, Rect inoutObj, int layoutDirection) {
- Gravity.applyDisplay(gravity, display, inoutObj, layoutDirection);
- }
- }
}
diff --git a/core/core/src/main/java/androidx/core/view/MarginLayoutParamsCompat.java b/core/core/src/main/java/androidx/core/view/MarginLayoutParamsCompat.java
index 4237d43..8039d09 100644
--- a/core/core/src/main/java/androidx/core/view/MarginLayoutParamsCompat.java
+++ b/core/core/src/main/java/androidx/core/view/MarginLayoutParamsCompat.java
@@ -17,14 +17,10 @@
package androidx.core.view;
-import static android.os.Build.VERSION.SDK_INT;
-
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
/**
* Helper for accessing API features in
@@ -44,11 +40,7 @@
* @return the margin along the starting edge in pixels
*/
public static int getMarginStart(@NonNull ViewGroup.MarginLayoutParams lp) {
- if (SDK_INT >= 17) {
- return Api17Impl.getMarginStart(lp);
- } else {
- return lp.leftMargin;
- }
+ return lp.getMarginStart();
}
/**
@@ -63,11 +55,7 @@
* @return the margin along the ending edge in pixels
*/
public static int getMarginEnd(@NonNull ViewGroup.MarginLayoutParams lp) {
- if (SDK_INT >= 17) {
- return Api17Impl.getMarginEnd(lp);
- } else {
- return lp.rightMargin;
- }
+ return lp.getMarginEnd();
}
/**
@@ -82,11 +70,7 @@
* @param marginStart the desired start margin in pixels
*/
public static void setMarginStart(@NonNull ViewGroup.MarginLayoutParams lp, int marginStart) {
- if (SDK_INT >= 17) {
- Api17Impl.setMarginStart(lp, marginStart);
- } else {
- lp.leftMargin = marginStart;
- }
+ lp.setMarginStart(marginStart);
}
/**
@@ -101,11 +85,7 @@
* @param marginEnd the desired end margin in pixels
*/
public static void setMarginEnd(@NonNull ViewGroup.MarginLayoutParams lp, int marginEnd) {
- if (SDK_INT >= 17) {
- Api17Impl.setMarginEnd(lp, marginEnd);
- } else {
- lp.rightMargin = marginEnd;
- }
+ lp.setMarginEnd(marginEnd);
}
/**
@@ -114,11 +94,7 @@
* @return true if either marginStart or marginEnd has been set.
*/
public static boolean isMarginRelative(@NonNull ViewGroup.MarginLayoutParams lp) {
- if (SDK_INT >= 17) {
- return Api17Impl.isMarginRelative(lp);
- } else {
- return false;
- }
+ return lp.isMarginRelative();
}
/**
@@ -129,11 +105,7 @@
*/
public static int getLayoutDirection(@NonNull ViewGroup.MarginLayoutParams lp) {
int result;
- if (SDK_INT >= 17) {
- result = Api17Impl.getLayoutDirection(lp);
- } else {
- result = ViewCompat.LAYOUT_DIRECTION_LTR;
- }
+ result = lp.getLayoutDirection();
if ((result != ViewCompat.LAYOUT_DIRECTION_LTR)
&& (result != ViewCompat.LAYOUT_DIRECTION_RTL)) {
@@ -154,9 +126,7 @@
*/
public static void setLayoutDirection(@NonNull ViewGroup.MarginLayoutParams lp,
int layoutDirection) {
- if (SDK_INT >= 17) {
- Api17Impl.setLayoutDirection(lp, layoutDirection);
- }
+ lp.setLayoutDirection(layoutDirection);
}
/**
@@ -165,60 +135,10 @@
*/
public static void resolveLayoutDirection(@NonNull ViewGroup.MarginLayoutParams lp,
int layoutDirection) {
- if (SDK_INT >= 17) {
- Api17Impl.resolveLayoutDirection(lp, layoutDirection);
- }
+ lp.resolveLayoutDirection(layoutDirection);
}
private MarginLayoutParamsCompat() {
}
- @RequiresApi(17)
- static class Api17Impl {
- private Api17Impl() {
- // This class is not instantiable.
- }
-
- @DoNotInline
- static int getMarginStart(ViewGroup.MarginLayoutParams marginLayoutParams) {
- return marginLayoutParams.getMarginStart();
- }
-
- @DoNotInline
- static int getMarginEnd(ViewGroup.MarginLayoutParams marginLayoutParams) {
- return marginLayoutParams.getMarginEnd();
- }
-
- @DoNotInline
- static void setMarginStart(ViewGroup.MarginLayoutParams marginLayoutParams, int start) {
- marginLayoutParams.setMarginStart(start);
- }
-
- @DoNotInline
- static void setMarginEnd(ViewGroup.MarginLayoutParams marginLayoutParams, int end) {
- marginLayoutParams.setMarginEnd(end);
- }
-
- @DoNotInline
- static boolean isMarginRelative(ViewGroup.MarginLayoutParams marginLayoutParams) {
- return marginLayoutParams.isMarginRelative();
- }
-
- @DoNotInline
- static int getLayoutDirection(ViewGroup.MarginLayoutParams marginLayoutParams) {
- return marginLayoutParams.getLayoutDirection();
- }
-
- @DoNotInline
- static void setLayoutDirection(ViewGroup.MarginLayoutParams marginLayoutParams,
- int layoutDirection) {
- marginLayoutParams.setLayoutDirection(layoutDirection);
- }
-
- @DoNotInline
- static void resolveLayoutDirection(ViewGroup.MarginLayoutParams marginLayoutParams,
- int layoutDirection) {
- marginLayoutParams.resolveLayoutDirection(layoutDirection);
- }
- }
}
diff --git a/core/core/src/main/java/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.java b/core/core/src/main/java/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.java
index 16d3db0..48f9d84 100644
--- a/core/core/src/main/java/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.java
+++ b/core/core/src/main/java/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.java
@@ -4155,9 +4155,7 @@
* @param labeled The view for which this info serves as a label.
*/
public void setLabelFor(View labeled) {
- if (Build.VERSION.SDK_INT >= 17) {
- mInfo.setLabelFor(labeled);
- }
+ mInfo.setLabelFor(labeled);
}
/**
@@ -4175,9 +4173,7 @@
* @param virtualDescendantId The id of the virtual descendant.
*/
public void setLabelFor(View root, int virtualDescendantId) {
- if (Build.VERSION.SDK_INT >= 17) {
- mInfo.setLabelFor(root, virtualDescendantId);
- }
+ mInfo.setLabelFor(root, virtualDescendantId);
}
/**
@@ -4187,11 +4183,7 @@
* @return The labeled info.
*/
public AccessibilityNodeInfoCompat getLabelFor() {
- if (Build.VERSION.SDK_INT >= 17) {
- return AccessibilityNodeInfoCompat.wrapNonNullInstance(mInfo.getLabelFor());
- } else {
- return null;
- }
+ return AccessibilityNodeInfoCompat.wrapNonNullInstance(mInfo.getLabelFor());
}
/**
@@ -4201,9 +4193,7 @@
* @param label The view that labels this node's source.
*/
public void setLabeledBy(View label) {
- if (Build.VERSION.SDK_INT >= 17) {
- mInfo.setLabeledBy(label);
- }
+ mInfo.setLabeledBy(label);
}
/**
@@ -4226,9 +4216,7 @@
* @param virtualDescendantId The id of the virtual descendant.
*/
public void setLabeledBy(View root, int virtualDescendantId) {
- if (Build.VERSION.SDK_INT >= 17) {
- mInfo.setLabeledBy(root, virtualDescendantId);
- }
+ mInfo.setLabeledBy(root, virtualDescendantId);
}
/**
@@ -4238,11 +4226,7 @@
* @return The label.
*/
public AccessibilityNodeInfoCompat getLabeledBy() {
- if (Build.VERSION.SDK_INT >= 17) {
- return AccessibilityNodeInfoCompat.wrapNonNullInstance(mInfo.getLabeledBy());
- } else {
- return null;
- }
+ return AccessibilityNodeInfoCompat.wrapNonNullInstance(mInfo.getLabeledBy());
}
/**
diff --git a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java
index 640be5b..68d01a3 100644
--- a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java
+++ b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java
@@ -161,22 +161,14 @@
@Test
public void testStartChild() {
- if (Build.VERSION.SDK_INT == 17) {
- return;
- }
+
final View childToTest = mPercentRelativeLayout.findViewById(R.id.child_start);
- if (Build.VERSION.SDK_INT >= 17) {
- switchToRtl();
+ switchToRtl();
- final int childRight = childToTest.getRight();
- assertFuzzyEquals("Child start margin as 5% of the container",
- 0.05f * mContainerWidth, mContainerWidth - childRight);
- } else {
- final int childLeft = childToTest.getLeft();
- assertFuzzyEquals("Child start margin as 5% of the container",
- 0.05f * mContainerWidth, childLeft);
- }
+ final int childRight = childToTest.getRight();
+ assertFuzzyEquals("Child start margin as 5% of the container",
+ 0.05f * mContainerWidth, mContainerWidth - childRight);
final int childWidth = childToTest.getWidth();
final int childHeight = childToTest.getHeight();
@@ -194,23 +186,13 @@
@Test
public void testBottomChild() {
- if (Build.VERSION.SDK_INT == 17) {
- return;
- }
final View childToTest = mPercentRelativeLayout.findViewById(R.id.child_bottom);
- if (Build.VERSION.SDK_INT >= 17) {
- switchToRtl();
+ switchToRtl();
- final int childLeft = childToTest.getLeft();
- assertFuzzyEquals("Child end margin as 20% of the container",
- 0.2f * mContainerWidth, childLeft);
- } else {
- final int childRight = childToTest.getRight();
- assertFuzzyEquals("Child end margin as 20% of the container",
- 0.2f * mContainerWidth, mContainerWidth - childRight);
- }
-
+ final int childLeft = childToTest.getLeft();
+ assertFuzzyEquals("Child end margin as 20% of the container",
+ 0.2f * mContainerWidth, childLeft);
final int childWidth = childToTest.getWidth();
final int childHeight = childToTest.getHeight();
@@ -228,22 +210,13 @@
@Test
public void testEndChild() {
- if (Build.VERSION.SDK_INT == 17) {
- return;
- }
final View childToTest = mPercentRelativeLayout.findViewById(R.id.child_end);
- if (Build.VERSION.SDK_INT >= 17) {
- switchToRtl();
+ switchToRtl();
- final int childLeft = childToTest.getLeft();
- assertFuzzyEquals("Child end margin as 5% of the container",
- 0.05f * mContainerWidth, childLeft);
- } else {
- final int childRight = childToTest.getRight();
- assertFuzzyEquals("Child end margin as 5% of the container",
- 0.05f * mContainerWidth, mContainerWidth - childRight);
- }
+ final int childLeft = childToTest.getLeft();
+ assertFuzzyEquals("Child end margin as 5% of the container",
+ 0.05f * mContainerWidth, childLeft);
final int childWidth = childToTest.getWidth();
final int childHeight = childToTest.getHeight();
@@ -261,24 +234,15 @@
@Test
public void testCenterChild() {
- if (Build.VERSION.SDK_INT == 17) {
- return;
- }
final View childToTest = mPercentRelativeLayout.findViewById(R.id.child_center);
-
- boolean supportsRtl = Build.VERSION.SDK_INT >= 17;
- if (supportsRtl) {
- switchToRtl();
- }
+ switchToRtl();
final int childLeft = childToTest.getLeft();
final int childTop = childToTest.getTop();
final int childRight = childToTest.getRight();
final int childBottom = childToTest.getBottom();
- final View leftChild = supportsRtl
- ? mPercentRelativeLayout.findViewById(R.id.child_end)
- : mPercentRelativeLayout.findViewById(R.id.child_start);
+ final View leftChild = mPercentRelativeLayout.findViewById(R.id.child_end);
assertFuzzyEquals("Child left margin as 10% of the container",
leftChild.getRight() + 0.1f * mContainerWidth, childLeft);
@@ -286,9 +250,8 @@
assertFuzzyEquals("Child top margin as 10% of the container",
topChild.getBottom() + 0.1f * mContainerHeight, childTop);
- final View rightChild = supportsRtl
- ? mPercentRelativeLayout.findViewById(R.id.child_start)
- : mPercentRelativeLayout.findViewById(R.id.child_end);
+ final View rightChild = mPercentRelativeLayout.findViewById(R.id.child_start);
+
assertFuzzyEquals("Child right margin as 10% of the container",
rightChild.getLeft() - 0.1f * mContainerWidth, childRight);
diff --git a/testutils/testutils-runtime/src/main/java/androidx/fragment/app/StrictFragment.kt b/testutils/testutils-runtime/src/main/java/androidx/fragment/app/StrictFragment.kt
index fe1c603..f3fa6a7 100644
--- a/testutils/testutils-runtime/src/main/java/androidx/fragment/app/StrictFragment.kt
+++ b/testutils/testutils-runtime/src/main/java/androidx/fragment/app/StrictFragment.kt
@@ -17,7 +17,6 @@
package androidx.fragment.app
import android.content.Context
-import android.os.Build
import android.os.Bundle
import android.util.AttributeSet
import androidx.annotation.LayoutRes
@@ -53,9 +52,7 @@
}
fun checkActivityNotDestroyed() {
- if (Build.VERSION.SDK_INT >= 17) {
- check(!requireActivity().isDestroyed)
- }
+ check(!requireActivity().isDestroyed)
}
fun checkState(caller: String, vararg expected: State) {
diff --git a/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java b/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java
index 2b8df02..2ae01e1 100644
--- a/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java
+++ b/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java
@@ -918,12 +918,8 @@
// We don't support RTL auto mirroring since the getLayoutDirection() is for API 17+.
private boolean needMirroring() {
- if (Build.VERSION.SDK_INT >= 17) {
- return isAutoMirrored()
- && DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
- } else {
- return false;
- }
+ return isAutoMirrored()
+ && DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
// Extra override functions for delegation for SDK >= 7.
diff --git a/viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/MutableCollectionBaseActivity.kt b/viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/MutableCollectionBaseActivity.kt
index 2f3ca9d..46f34c1 100644
--- a/viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/MutableCollectionBaseActivity.kt
+++ b/viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/MutableCollectionBaseActivity.kt
@@ -16,7 +16,6 @@
package androidx.viewpager2.integration.testapp
-import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
@@ -61,9 +60,7 @@
itemSpinner.adapter = object : BaseAdapter() {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View =
((convertView as TextView?) ?: TextView(parent.context)).apply {
- if (Build.VERSION.SDK_INT >= 17) {
- textDirection = View.TEXT_DIRECTION_LOCALE
- }
+ textDirection = View.TEXT_DIRECTION_LOCALE
text = getItem(position)
}