diff --git a/shell/platform/android/AndroidManifest.xml b/shell/platform/android/AndroidManifest.xml index 82f4b0a7c5da9..2a5d3b89be28b 100644 --- a/shell/platform/android/AndroidManifest.xml +++ b/shell/platform/android/AndroidManifest.xml @@ -5,7 +5,7 @@ --> - + diff --git a/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java b/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java index f7c4db3e09658..8ef7237a7a9e9 100644 --- a/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java +++ b/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java @@ -204,9 +204,7 @@ public boolean onTouchEvent(@NonNull MotionEvent event, @NonNull Matrix transfor public boolean onGenericMotionEvent(@NonNull MotionEvent event, @NonNull Context context) { // Method isFromSource is only available in API 18+ (Jelly Bean MR2) // Mouse hover support is not implemented for API < 18. - boolean isPointerEvent = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 - && event.isFromSource(InputDevice.SOURCE_CLASS_POINTER); + boolean isPointerEvent = event.isFromSource(InputDevice.SOURCE_CLASS_POINTER); boolean isMovementEvent = (event.getActionMasked() == MotionEvent.ACTION_HOVER_MOVE || event.getActionMasked() == MotionEvent.ACTION_SCROLL); diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java index 586d60c9c6980..a83f9d80c1041 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java @@ -8,7 +8,6 @@ import android.content.ComponentCallbacks2; import android.content.Context; import android.content.Intent; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -172,16 +171,14 @@ public class FlutterFragment extends Fragment @RequiresApi(18) private final OnWindowFocusChangeListener onWindowFocusChangeListener = - Build.VERSION.SDK_INT >= 18 - ? new OnWindowFocusChangeListener() { - @Override - public void onWindowFocusChanged(boolean hasFocus) { - if (stillAttachedForEvent("onWindowFocusChanged")) { - delegate.onWindowFocusChanged(hasFocus); - } - } + new OnWindowFocusChangeListener() { + @Override + public void onWindowFocusChanged(boolean hasFocus) { + if (stillAttachedForEvent("onWindowFocusChanged")) { + delegate.onWindowFocusChanged(hasFocus); } - : null; + } + }; /** * Creates a {@code FlutterFragment} with a default configuration. @@ -1128,20 +1125,16 @@ public void onStop() { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - if (Build.VERSION.SDK_INT >= 18) { - view.getViewTreeObserver().addOnWindowFocusChangeListener(onWindowFocusChangeListener); - } + view.getViewTreeObserver().addOnWindowFocusChangeListener(onWindowFocusChangeListener); } @Override public void onDestroyView() { super.onDestroyView(); - if (Build.VERSION.SDK_INT >= 18) { - // onWindowFocusChangeListener is API 18+ only. - requireView() - .getViewTreeObserver() - .removeOnWindowFocusChangeListener(onWindowFocusChangeListener); - } + // onWindowFocusChangeListener is API 18+ only. + requireView() + .getViewTreeObserver() + .removeOnWindowFocusChangeListener(onWindowFocusChangeListener); if (stillAttachedForEvent("onDestroyView")) { delegate.onDestroyView(); } diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java b/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java index dcdf04e08bd21..9fd0f600ac3e4 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java @@ -39,7 +39,6 @@ * an {@link android.media.Image} and renders it to the {@link android.graphics.Canvas} in {@code * onDraw}. */ -@TargetApi(19) public class FlutterImageView extends View implements RenderSurface { private static final String TAG = "FlutterImageView"; @@ -99,7 +98,6 @@ private static void logW(String format, Object... args) { Log.w(TAG, String.format(Locale.US, format, args)); } - @TargetApi(19) @SuppressLint("WrongConstant") // RGBA_8888 is a valid constant. @NonNull private static ImageReader createImageReader(int width, int height) { @@ -187,7 +185,6 @@ public void resume() { * Acquires the next image to be drawn to the {@link android.graphics.Canvas}. Returns true if * there's an image available in the queue. */ - @TargetApi(19) public boolean acquireLatestImage() { if (!isAttachedToFlutterRenderer) { return false; diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterView.java b/shell/platform/android/io/flutter/embedding/android/FlutterView.java index 4cfa3c8839ddc..9623d48872574 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterView.java @@ -290,7 +290,6 @@ public FlutterView(@NonNull Context context, @NonNull FlutterTextureView flutter *

{@code FlutterView} requires an {@code Activity} instead of a generic {@code Context} to be * compatible with {@link PlatformViewsController}. */ - @TargetApi(19) public FlutterView(@NonNull Context context, @NonNull FlutterImageView flutterImageView) { this(context, null, flutterImageView); } @@ -357,7 +356,6 @@ private FlutterView( init(); } - @TargetApi(19) private FlutterView( @NonNull Context context, @Nullable AttributeSet attrs, diff --git a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java index 82a3b8c20ec6c..fc04a96917d67 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -16,7 +16,6 @@ import android.os.Looper; import android.os.SystemClock; import android.util.DisplayMetrics; -import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import io.flutter.BuildConfig; @@ -169,17 +168,9 @@ public void startInitialization(@NonNull Context applicationContext, @NonNull Se flutterApplicationInfo = ApplicationInfoLoader.load(appContext); VsyncWaiter waiter; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 /* 17 */) { - final DisplayManager dm = - (DisplayManager) appContext.getSystemService(Context.DISPLAY_SERVICE); - waiter = VsyncWaiter.getInstance(dm, flutterJNI); - } else { - float fps = - ((WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE)) - .getDefaultDisplay() - .getRefreshRate(); - waiter = VsyncWaiter.getInstance(fps, flutterJNI); - } + final DisplayManager dm = + (DisplayManager) appContext.getSystemService(Context.DISPLAY_SERVICE); + waiter = VsyncWaiter.getInstance(dm, flutterJNI); waiter.init(); // Use a background thread for initialization tasks that require disk access. diff --git a/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java b/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java index c195b28728e9b..b6eaa3d434725 100644 --- a/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java +++ b/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java @@ -3,7 +3,6 @@ import static android.view.View.OnFocusChangeListener; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Matrix; @@ -23,7 +22,6 @@ * A view that applies the {@link io.flutter.embedding.engine.mutatorsstack.FlutterMutatorsStack} to * its children. */ -@TargetApi(19) public class FlutterMutatorView extends FrameLayout { private FlutterMutatorsStack mutatorsStack; private float screenDensity; diff --git a/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java b/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java index 8052f59b6d1c6..668445a954ff5 100644 --- a/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java +++ b/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java @@ -895,7 +895,6 @@ public long id() { } @Override - @TargetApi(19) public void release() { if (released) { return; @@ -909,7 +908,6 @@ public void release() { } @Override - @TargetApi(19) public void pushImage(Image image) { if (released) { return; @@ -970,7 +968,6 @@ public Image acquireLatestImage() { } @Override - @TargetApi(19) protected void finalize() throws Throwable { try { if (released) { diff --git a/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java b/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java index acb1e904ca629..4ce63975928be 100644 --- a/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java +++ b/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java @@ -7,7 +7,6 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Configuration; -import android.content.res.Resources; import android.os.Build; import android.os.LocaleList; import androidx.annotation.NonNull; @@ -40,18 +39,9 @@ public String getStringResource(@NonNull String key, @Nullable String localeStri Locale locale = localeFromString(localeString); // setLocale and createConfigurationContext is only available on API >= 17 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - Configuration config = new Configuration(context.getResources().getConfiguration()); - config.setLocale(locale); - localContext = context.createConfigurationContext(config); - } else { - // In API < 17, we have to update the locale in Configuration. - Resources resources = context.getResources(); - Configuration config = resources.getConfiguration(); - savedLocale = config.locale; - config.locale = locale; - resources.updateConfiguration(config, null); - } + Configuration config = new Configuration(context.getResources().getConfiguration()); + config.setLocale(locale); + localContext = context.createConfigurationContext(config); } String packageName = context.getPackageName(); @@ -61,14 +51,6 @@ public String getStringResource(@NonNull String key, @Nullable String localeStri stringToReturn = localContext.getResources().getString(resId); } - // In API < 17, we had to restore the original locale after using. - if (localeString != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { - Resources resources = context.getResources(); - Configuration config = resources.getConfiguration(); - config.locale = savedLocale; - resources.updateConfiguration(config, null); - } - return stringToReturn; } }; diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 9100476b7449e..eb5939d7a7ffb 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -291,8 +291,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; - } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE) { // IMMERSIVE // Available starting at 19 // Should not show overlays, swipe from edges to reveal overlays, needs onChange callback @@ -307,8 +306,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; - } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY) { // STICKY IMMERSIVE // Available starting at 19 // Should not show overlays, swipe from edges to reveal overlays. The app will also receive @@ -355,7 +353,7 @@ private void setSystemChromeEnabledSystemUIOverlays( // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we // apply it // if desired, and if the current Android version is 19 or greater. - if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (overlaysToShow.size() == 0) { enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 0ce64f0c9cb51..00b8cafa6b936 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -156,7 +156,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega private final PlatformViewsChannel.PlatformViewsHandler channelHandler = new PlatformViewsChannel.PlatformViewsHandler() { - @TargetApi(19) @Override // TODO(egarciad): Remove the need for this. // https://github.com/flutter/flutter/issues/96679 @@ -419,7 +418,6 @@ public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) { view.dispatchTouchEvent(event); } - @TargetApi(17) @Override public void setDirection(int viewId, int direction) { if (!validateDirection(direction)) { @@ -504,7 +502,6 @@ private void ensureValidRequest( // Creates a platform view based on `request`, performs configuration that's common to // all display modes, and adds it to `platformViews`. - @TargetApi(19) @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public PlatformView createPlatformView( @NonNull PlatformViewsChannel.PlatformViewCreationRequest request, boolean wrapContext) { @@ -1080,7 +1077,6 @@ private void initializeRootImageViewIfNeeded() { * testing. */ @VisibleForTesting - @TargetApi(Build.VERSION_CODES.KITKAT) void initializePlatformViewIfNeeded(int viewId) { final PlatformView platformView = platformViews.get(viewId); if (platformView == null) { @@ -1292,7 +1288,6 @@ private void finishFrame(boolean isFrameRenderedUsingImageReaders) { * for public use, and is only visible for testing. */ @VisibleForTesting - @TargetApi(19) @NonNull public FlutterOverlaySurface createOverlaySurface(@NonNull PlatformOverlayView imageView) { final int id = nextOverlayLayerId++; @@ -1307,7 +1302,6 @@ public FlutterOverlaySurface createOverlaySurface(@NonNull PlatformOverlayView i * *

This member is not intended for public use, and is only visible for testing. */ - @TargetApi(19) @NonNull public FlutterOverlaySurface createOverlaySurface() { // Overlay surfaces have the same size as the background surface. diff --git a/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java b/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java index b7ca559ac7c64..c272f859286ee 100644 --- a/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java +++ b/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java @@ -7,7 +7,6 @@ import static android.content.Context.WINDOW_SERVICE; import static android.view.View.OnFocusChangeListener; -import android.annotation.TargetApi; import android.app.AlertDialog; import android.app.Presentation; import android.content.Context; @@ -15,7 +14,6 @@ import android.content.MutableContextWrapper; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; -import android.os.Build; import android.os.Bundle; import android.view.Display; import android.view.Gravity; @@ -51,7 +49,6 @@ * EmbeddedView */ @Keep -@TargetApi(Build.VERSION_CODES.KITKAT) class SingleViewPresentation extends Presentation { private static final String TAG = "PlatformViewsController"; @@ -123,9 +120,7 @@ public SingleViewPresentation( .setFlags( WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - getWindow().setType(WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION); - } + getWindow().setType(WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION); } /** diff --git a/shell/platform/android/io/flutter/util/ViewUtils.java b/shell/platform/android/io/flutter/util/ViewUtils.java index 7915f28ff427d..abcd807714dcd 100644 --- a/shell/platform/android/io/flutter/util/ViewUtils.java +++ b/shell/platform/android/io/flutter/util/ViewUtils.java @@ -7,7 +7,6 @@ import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; -import android.os.Build; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -68,10 +67,7 @@ public static Activity getActivity(@Nullable Context context) { * @return the view id. */ public static int generateViewId(int fallbackId) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - return View.generateViewId(); - } - return fallbackId; + return View.generateViewId(); } /** diff --git a/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/shell/platform/android/io/flutter/view/AccessibilityBridge.java index dc5c257ade591..2b838e00d9490 100644 --- a/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -379,7 +379,6 @@ public void onAccessibilityStateChanged(boolean accessibilityEnabled) { // Listener that is notified when accessibility touch exploration is turned on/off. // This is guarded at instantiation time. - @TargetApi(19) @RequiresApi(19) private final AccessibilityManager.TouchExplorationStateChangeListener touchExplorationStateChangeListener; @@ -400,10 +399,8 @@ public void onChange(boolean selfChange, Uri uri) { } // Retrieve the current value of TRANSITION_ANIMATION_SCALE from the OS. String value = - Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 - ? null - : Settings.Global.getString( - contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE); + Settings.Global.getString( + contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE); boolean shouldAnimationsBeDisabled = value != null && value.equals("0"); if (shouldAnimationsBeDisabled) { @@ -451,40 +448,34 @@ public AccessibilityBridge( // Tell Flutter whether touch exploration is initially active or not. Then register a listener // to be notified of changes in the future. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - touchExplorationStateChangeListener = - new AccessibilityManager.TouchExplorationStateChangeListener() { - @Override - public void onTouchExplorationStateChanged(boolean isTouchExplorationEnabled) { - if (isReleased) { - return; - } - if (!isTouchExplorationEnabled) { - setAccessibleNavigation(false); - onTouchExplorationExit(); - } + touchExplorationStateChangeListener = + new AccessibilityManager.TouchExplorationStateChangeListener() { + @Override + public void onTouchExplorationStateChanged(boolean isTouchExplorationEnabled) { + if (isReleased) { + return; + } + if (!isTouchExplorationEnabled) { + setAccessibleNavigation(false); + onTouchExplorationExit(); + } - if (onAccessibilityChangeListener != null) { - onAccessibilityChangeListener.onAccessibilityChanged( - accessibilityManager.isEnabled(), isTouchExplorationEnabled); - } + if (onAccessibilityChangeListener != null) { + onAccessibilityChangeListener.onAccessibilityChanged( + accessibilityManager.isEnabled(), isTouchExplorationEnabled); } - }; - touchExplorationStateChangeListener.onTouchExplorationStateChanged( - accessibilityManager.isTouchExplorationEnabled()); - this.accessibilityManager.addTouchExplorationStateChangeListener( - touchExplorationStateChangeListener); - } else { - touchExplorationStateChangeListener = null; - } + } + }; + touchExplorationStateChangeListener.onTouchExplorationStateChanged( + accessibilityManager.isTouchExplorationEnabled()); + this.accessibilityManager.addTouchExplorationStateChangeListener( + touchExplorationStateChangeListener); // Tell Flutter whether animations should initially be enabled or disabled. Then register a // listener to be notified of changes in the future. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - animationScaleObserver.onChange(false); - Uri transitionUri = Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE); - this.contentResolver.registerContentObserver(transitionUri, false, animationScaleObserver); - } + animationScaleObserver.onChange(false); + Uri transitionUri = Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE); + this.contentResolver.registerContentObserver(transitionUri, false, animationScaleObserver); // Tells Flutter whether the text should be bolded or not. If the user changes bold text // setting, the configuration will change and trigger a re-build of the accesibiltyBridge. @@ -507,10 +498,8 @@ public void release() { platformViewsAccessibilityDelegate.detachAccessibilityBridge(); setOnAccessibilityChangeListener(null); accessibilityManager.removeAccessibilityStateChangeListener(accessibilityStateChangeListener); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - accessibilityManager.removeTouchExplorationStateChangeListener( - touchExplorationStateChangeListener); - } + accessibilityManager.removeTouchExplorationStateChangeListener( + touchExplorationStateChangeListener); contentResolver.unregisterContentObserver(animationScaleObserver); accessibilityChannel.setAccessibilityMessageHandler(null); } @@ -669,11 +658,9 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { } // Work around for https://github.com/flutter/flutter/issues/21030 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - result.setViewIdResourceName(""); - if (semanticsNode.identifier != null) { - result.setViewIdResourceName(semanticsNode.identifier); - } + result.setViewIdResourceName(""); + if (semanticsNode.identifier != null) { + result.setViewIdResourceName(semanticsNode.identifier); } result.setPackageName(rootAccessibilityView.getContext().getPackageName()); result.setClassName("android.view.View"); @@ -692,20 +679,16 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { if (!semanticsNode.hasFlag(Flag.IS_READ_ONLY)) { result.setClassName("android.widget.EditText"); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - result.setEditable(!semanticsNode.hasFlag(Flag.IS_READ_ONLY)); - if (semanticsNode.textSelectionBase != -1 && semanticsNode.textSelectionExtent != -1) { - result.setTextSelection( - semanticsNode.textSelectionBase, semanticsNode.textSelectionExtent); - } - // Text fields will always be created as a live region when they have input focus, - // so that updates to the label trigger polite announcements. This makes it easy to - // follow a11y guidelines for text fields on Android. - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2 - && accessibilityFocusedSemanticsNode != null - && accessibilityFocusedSemanticsNode.id == virtualViewId) { - result.setLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE); - } + result.setEditable(!semanticsNode.hasFlag(Flag.IS_READ_ONLY)); + if (semanticsNode.textSelectionBase != -1 && semanticsNode.textSelectionExtent != -1) { + result.setTextSelection(semanticsNode.textSelectionBase, semanticsNode.textSelectionExtent); + } + // Text fields will always be created as a live region when they have input focus, + // so that updates to the label trigger polite announcements. This makes it easy to + // follow a11y guidelines for text fields on Android. + if (accessibilityFocusedSemanticsNode != null + && accessibilityFocusedSemanticsNode.id == virtualViewId) { + result.setLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE); } // Cursor movements @@ -740,19 +723,17 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { // These are non-ops on older devices. Attempting to interact with the text will cause Talkback // to read the contents of the text box instead. - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { - if (semanticsNode.hasAction(Action.SET_SELECTION)) { - result.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION); - } - if (semanticsNode.hasAction(Action.COPY)) { - result.addAction(AccessibilityNodeInfo.ACTION_COPY); - } - if (semanticsNode.hasAction(Action.CUT)) { - result.addAction(AccessibilityNodeInfo.ACTION_CUT); - } - if (semanticsNode.hasAction(Action.PASTE)) { - result.addAction(AccessibilityNodeInfo.ACTION_PASTE); - } + if (semanticsNode.hasAction(Action.SET_SELECTION)) { + result.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION); + } + if (semanticsNode.hasAction(Action.COPY)) { + result.addAction(AccessibilityNodeInfo.ACTION_COPY); + } + if (semanticsNode.hasAction(Action.CUT)) { + result.addAction(AccessibilityNodeInfo.ACTION_CUT); + } + if (semanticsNode.hasAction(Action.PASTE)) { + result.addAction(AccessibilityNodeInfo.ACTION_PASTE); } // Set text API isn't available until API 21. @@ -770,8 +751,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { // TODO(jonahwilliams): Figure out a way conform to the expected id from TalkBack's // CustomLabelManager. talkback/src/main/java/labeling/CustomLabelManager.java#L525 } - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2 - && semanticsNode.hasAction(Action.DISMISS)) { + if (semanticsNode.hasAction(Action.DISMISS)) { result.setDismissable(true); result.addAction(AccessibilityNodeInfo.ACTION_DISMISS); } @@ -865,8 +845,7 @@ && shouldSetCollectionInfo(semanticsNode)) { result.setClassName("android.widget.HorizontalScrollView"); } } else { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2 - && shouldSetCollectionInfo(semanticsNode)) { + if (shouldSetCollectionInfo(semanticsNode)) { result.setCollectionInfo( AccessibilityNodeInfo.CollectionInfo.obtain( semanticsNode.scrollChildren, // rows @@ -901,8 +880,7 @@ && shouldSetCollectionInfo(semanticsNode)) { result.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); } } - if (semanticsNode.hasFlag(Flag.IS_LIVE_REGION) - && Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { + if (semanticsNode.hasFlag(Flag.IS_LIVE_REGION)) { result.setLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE); } @@ -1114,26 +1092,10 @@ public boolean performAction( } case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: { - // Text selection APIs aren't available until API 18. We can't handle the case here so - // return false - // instead. It's extremely unlikely that this case would ever be triggered in the first - // place in API < - // 18. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { - return false; - } return performCursorMoveAction(semanticsNode, virtualViewId, arguments, false); } case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY: { - // Text selection APIs aren't available until API 18. We can't handle the case here so - // return false - // instead. It's extremely unlikely that this case would ever be triggered in the first - // place in API < - // 18. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { - return false; - } return performCursorMoveAction(semanticsNode, virtualViewId, arguments, true); } case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: @@ -1192,14 +1154,6 @@ public boolean performAction( } case AccessibilityNodeInfo.ACTION_SET_SELECTION: { - // Text selection APIs aren't available until API 18. We can't handle the case here so - // return false - // instead. It's extremely unlikely that this case would ever be triggered in the first - // place in API < - // 18. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { - return false; - } final Map selection = new HashMap<>(); final boolean hasSelection = arguments != null @@ -1275,7 +1229,6 @@ public boolean performAction( * Handles the responsibilities of {@link #performAction(int, int, Bundle)} for the specific * scenario of cursor movement. */ - @TargetApi(18) @RequiresApi(18) private boolean performCursorMoveAction( @NonNull SemanticsNode semanticsNode, @@ -2005,9 +1958,7 @@ private void setAccessibilityPaneTitle(String title) { private void sendWindowContentChangeEvent(int virtualViewId) { AccessibilityEvent event = obtainAccessibilityEvent(virtualViewId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE); - } + event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE); sendAccessibilityEvent(event); } @@ -2058,7 +2009,6 @@ private boolean doesLayoutInDisplayCutoutModeRequireLeftInset() { * Hook called just before a {@link SemanticsNode} is removed from the Android cache of Flutter's * semantics tree. */ - @TargetApi(19) @RequiresApi(19) private void willRemoveSemanticsNode(SemanticsNode semanticsNodeToBeRemoved) { if (BuildConfig.DEBUG) { diff --git a/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java b/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java index 368e14ce5fc29..eb4981d0533d1 100644 --- a/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java +++ b/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java @@ -230,20 +230,16 @@ private void copyAccessibilityFields( output.setText(input.getText()); output.setVisibleToUser(input.isVisibleToUser()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - output.setEditable(input.isEditable()); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - output.setCanOpenPopup(input.canOpenPopup()); - output.setCollectionInfo(input.getCollectionInfo()); - output.setCollectionItemInfo(input.getCollectionItemInfo()); - output.setContentInvalid(input.isContentInvalid()); - output.setDismissable(input.isDismissable()); - output.setInputType(input.getInputType()); - output.setLiveRegion(input.getLiveRegion()); - output.setMultiLine(input.isMultiLine()); - output.setRangeInfo(input.getRangeInfo()); - } + output.setEditable(input.isEditable()); + output.setCanOpenPopup(input.canOpenPopup()); + output.setCollectionInfo(input.getCollectionInfo()); + output.setCollectionItemInfo(input.getCollectionItemInfo()); + output.setContentInvalid(input.isContentInvalid()); + output.setDismissable(input.isDismissable()); + output.setInputType(input.getInputType()); + output.setLiveRegion(input.getLiveRegion()); + output.setMultiLine(input.isMultiLine()); + output.setRangeInfo(input.getRangeInfo()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { output.setError(input.getError()); output.setMaxTextLength(input.getMaxTextLength()); diff --git a/shell/platform/android/io/flutter/view/VsyncWaiter.java b/shell/platform/android/io/flutter/view/VsyncWaiter.java index 80f5658dea569..b99b089a5c55e 100644 --- a/shell/platform/android/io/flutter/view/VsyncWaiter.java +++ b/shell/platform/android/io/flutter/view/VsyncWaiter.java @@ -4,7 +4,6 @@ package io.flutter.view; -import android.annotation.TargetApi; import android.hardware.display.DisplayManager; import android.view.Choreographer; import android.view.Display; @@ -14,7 +13,6 @@ // TODO(mattcarroll): add javadoc. public class VsyncWaiter { - @TargetApi(17) class DisplayListener implements DisplayManager.DisplayListener { DisplayListener(DisplayManager displayManager) { this.displayManager = displayManager; @@ -59,7 +57,6 @@ public static VsyncWaiter getInstance(float fps, @NonNull FlutterJNI flutterJNI) return instance; } - @TargetApi(17) @NonNull public static VsyncWaiter getInstance( @NonNull DisplayManager displayManager, @NonNull FlutterJNI flutterJNI) { diff --git a/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java b/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java index de209e29b448e..bdb09ab38dfb8 100644 --- a/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java +++ b/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java @@ -64,7 +64,6 @@ @Config(manifest = Config.NONE) @RunWith(AndroidJUnit4.class) -@TargetApi(19) public class AccessibilityBridgeTest { @Test diff --git a/shell/platform/android/test/io/flutter/view/VsyncWaiterTest.java b/shell/platform/android/test/io/flutter/view/VsyncWaiterTest.java index 9afeb9c5deebb..ef56b9936b87b 100644 --- a/shell/platform/android/test/io/flutter/view/VsyncWaiterTest.java +++ b/shell/platform/android/test/io/flutter/view/VsyncWaiterTest.java @@ -14,7 +14,6 @@ import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; -import android.annotation.TargetApi; import android.hardware.display.DisplayManager; import android.os.Looper; import android.view.Display; @@ -50,7 +49,6 @@ public void itSetsFpsBelowApi17() { verify(mockFlutterJNI, times(1)).onVsync(anyLong(), eq(1000000000l / 10l), eq(1l)); } - @TargetApi(17) @Test public void itSetsFpsWhenDisplayManagerUpdates() { FlutterJNI mockFlutterJNI = mock(FlutterJNI.class); @@ -86,7 +84,6 @@ public void itSetsFpsWhenDisplayManagerUpdates() { verify(mockFlutterJNI, times(1)).onVsync(anyLong(), eq(1000000000l / 60l), eq(1l)); } - @TargetApi(17) @Test public void itSetsFpsWhenDisplayManagerDoesNotUpdate() { FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);