Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private void addPointerForIndex(
}

private float getHorizontalScrollFactor(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= 26) {
return ViewConfiguration.get(context).getScaledHorizontalScrollFactor();
} else {
// Vertical scroll factor is not a typo. This is what View.java does in android.
Expand All @@ -436,7 +436,7 @@ private float getHorizontalScrollFactor(@NonNull Context context) {
}

private float getVerticalScrollFactor(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= 26) {
return getVerticalScrollFactorAbove26(context);
} else {
return getVerticalScrollFactorPre26(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ public void onFlutterUiDisplayed() {
// * reportFullyDrawn behavior isn't tested on pre-Q versions.
// See https://github.com/flutter/flutter/issues/46172, and
// https://github.com/flutter/flutter/issues/88767.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (Build.VERSION.SDK_INT >= 29) {
reportFullyDrawn();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ private void init() {
// FlutterView needs to be focusable so that the InputMethodManager can interact with it.
setFocusable(true);
setFocusableInTouchMode(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= 26) {
setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);
}
}
Expand Down Expand Up @@ -677,7 +677,7 @@ public final WindowInsets onApplyWindowInsets(@NonNull WindowInsets insets) {
WindowInsets newInsets = super.onApplyWindowInsets(insets);

// getSystemGestureInsets() was introduced in API 29 and immediately deprecated in 30.
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
if (Build.VERSION.SDK_INT == 29) {
Insets systemGestureInsets = insets.getSystemGestureInsets();
viewportMetrics.systemGestureInsetTop = systemGestureInsets.top;
viewportMetrics.systemGestureInsetRight = systemGestureInsets.right;
Expand All @@ -689,7 +689,7 @@ public final WindowInsets onApplyWindowInsets(@NonNull WindowInsets insets) {
boolean navigationBarVisible =
(SYSTEM_UI_FLAG_HIDE_NAVIGATION & getWindowSystemUiVisibility()) == 0;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT >= 30) {
int mask = 0;
if (navigationBarVisible) {
mask = mask | android.view.WindowInsets.Type.navigationBars();
Expand Down Expand Up @@ -956,7 +956,7 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {
@SuppressLint("SoonBlockedPrivateApi")
@Nullable
public View findViewByAccessibilityIdTraversal(int accessibilityId) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (Build.VERSION.SDK_INT < 29) {
return findViewByAccessibilityIdRootedAtCurrentView(accessibilityId, this);
}
// Android Q or later doesn't call this method.
Expand Down Expand Up @@ -1032,8 +1032,8 @@ private void resetWillNotDraw(boolean isAccessibilityEnabled, boolean isTouchExp

// -------- Start: Mouse -------
@Override
@TargetApi(Build.VERSION_CODES.N)
@RequiresApi(Build.VERSION_CODES.N)
@TargetApi(24)
@RequiresApi(24)
@NonNull
public PointerIcon getSystemPointerIcon(int type) {
return PointerIcon.getSystemIcon(getContext(), type);
Expand Down Expand Up @@ -1098,7 +1098,7 @@ public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) {

// Initialize various components that know how to process Android View I/O
// in a way that Flutter understands.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (Build.VERSION.SDK_INT >= 24) {
mouseCursorPlugin = new MouseCursorPlugin(this, this.flutterEngine.getMouseCursorChannel());
}
textInputPlugin =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public InitResult call() {
}

private static boolean areValidationLayersOnByDefault() {
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= 26) {
return Build.SUPPORTED_ABIS[0].equals("arm64-v8a");
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public static Autofill fromJson(@NonNull JSONObject json)

@NonNull
private static String translateAutofillHint(@NonNull String hint) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT < 26) {
return hint;
}
switch (hint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public TextInputPlugin(
// Create a default object.
mEditable = new ListenableEditingState(null, mView);
mImm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= 26) {
afm = view.getContext().getSystemService(AutofillManager.class);
} else {
afm = null;
Expand All @@ -78,7 +78,7 @@ public TextInputPlugin(
// Sets up syncing ime insets with the framework, allowing
// the Flutter view to grow and shrink to accommodate Android
// controlled keyboard animations.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT >= 30) {
imeSyncCallback = new ImeSyncDeferringInsetsCallback(view);
imeSyncCallback.install();
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public void requestAutofill() {

@Override
public void finishAutofillContext(boolean shouldSave) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || afm == null) {
if (Build.VERSION.SDK_INT < 26 || afm == null) {
return;
}
if (shouldSave) {
Expand Down Expand Up @@ -312,8 +312,7 @@ public InputConnection createInputConnection(
configuration.textCapitalization);
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& !configuration.enableIMEPersonalizedLearning) {
if (Build.VERSION.SDK_INT >= 26 && !configuration.enableIMEPersonalizedLearning) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING;
}

Expand Down Expand Up @@ -676,7 +675,7 @@ private boolean needsAutofill() {
}

private void notifyViewEntered() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || afm == null || !needsAutofill()) {
if (Build.VERSION.SDK_INT < 26 || afm == null || !needsAutofill()) {
return;
}

Expand All @@ -689,7 +688,7 @@ private void notifyViewEntered() {
}

private void notifyViewExited() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O
if (Build.VERSION.SDK_INT < 26
|| afm == null
|| configuration == null
|| configuration.autofill == null
Expand All @@ -702,7 +701,7 @@ private void notifyViewExited() {
}

private void notifyValueChanged(String newValue) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || afm == null || !needsAutofill()) {
if (Build.VERSION.SDK_INT < 26 || afm == null || !needsAutofill()) {
return;
}

Expand All @@ -711,7 +710,7 @@ private void notifyValueChanged(String newValue) {
}

private void updateAutofillConfigurationIfNeeded(TextInputChannel.Configuration configuration) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT < 26) {
return;
}

Expand Down Expand Up @@ -741,7 +740,7 @@ private void updateAutofillConfigurationIfNeeded(TextInputChannel.Configuration
}

public void onProvideAutofillVirtualStructure(@NonNull ViewStructure structure, int flags) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || !needsAutofill()) {
if (Build.VERSION.SDK_INT < 26 || !needsAutofill()) {
return;
}

Expand Down Expand Up @@ -789,7 +788,7 @@ public void onProvideAutofillVirtualStructure(@NonNull ViewStructure structure,
}

public void autofill(@NonNull SparseArray<AutofillValue> values) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT < 26) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Locale resolveNativeLocale(@Nullable List<Locale> supportedLocales) {
//
// LanguageRange and Locale.lookup was added in API 26 and is the preferred way to
// select a locale. Pre-API 26, we implement a manual locale resolution.
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= 26) {
// Modern locale resolution using LanguageRange
// https://developer.android.com/guide/topics/resources/multilingual-support#postN
List<Locale.LanguageRange> languageRanges = new ArrayList<>();
Expand All @@ -104,7 +104,7 @@ public Locale resolveNativeLocale(@Nullable List<Locale> supportedLocales) {
return platformResolvedLocale;
}
return supportedLocales.get(0);
} else if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
} else if (Build.VERSION.SDK_INT >= 24) {
// Modern locale resolution without languageRange
// https://developer.android.com/guide/topics/resources/multilingual-support#postN
LocaleList localeList = context.getResources().getConfiguration().getLocales();
Expand Down Expand Up @@ -160,7 +160,7 @@ public Locale resolveNativeLocale(@Nullable List<Locale> supportedLocales) {
@SuppressWarnings("deprecation")
public void sendLocalesToFlutter(@NonNull Configuration config) {
List<Locale> locales = new ArrayList<>();
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
if (Build.VERSION.SDK_INT >= 24) {
LocaleList localeList = config.getLocales();
int localeCount = localeList.size();
for (int index = 0; index < localeCount; ++index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
package io.flutter.plugin.mouse;

import android.annotation.TargetApi;
import android.os.Build;
import android.view.PointerIcon;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import io.flutter.embedding.engine.systemchannels.MouseCursorChannel;
import java.util.HashMap;

/** A mandatory plugin that handles mouse cursor requests. */
@TargetApi(Build.VERSION_CODES.N)
@RequiresApi(Build.VERSION_CODES.N)
@TargetApi(24)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix here and below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lost track of what these were - I'll update them all.

@RequiresApi(24)
public class MouseCursorPlugin {
@NonNull private final MouseCursorViewDelegate mView;
@NonNull private final MouseCursorChannel mouseCursorChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void playSystemSound(@NonNull PlatformChannel.SoundType soundType) {
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
break;
case HEAVY_IMPACT:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= 23) {
view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK);
}
break;
Expand All @@ -217,7 +217,7 @@ private void setSystemChromePreferredOrientations(int androidOrientation) {
@SuppressWarnings("deprecation")
private void setSystemChromeApplicationSwitcherDescription(
PlatformChannel.AppSwitcherDescription description) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT < 28) {
activity.setTaskDescription(
new TaskDescription(description.label, /* icon= */ null, description.color));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void resize(final int width, final int height, final Runnable onNewSizeFr
getView().postDelayed(onNewSizeFrameAvailable, 0);
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (Build.VERSION.SDK_INT >= 31) {
resize31(getView(), width, height, onNewSizeFrameAvailable);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void processTextAction(
return;
}

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT < 23) {
result.error("error", "Android version not supported", null);
return;
}
Expand Down Expand Up @@ -105,14 +105,14 @@ public void processTextAction(
private void cacheResolveInfos() {
resolveInfosById = new HashMap<String, ResolveInfo>();

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT < 23) {
return;
}

Intent intent = new Intent().setAction(Intent.ACTION_PROCESS_TEXT).setType("text/plain");

List<ResolveInfo> infos;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (Build.VERSION.SDK_INT >= 33) {
infos = packageManager.queryIntentActivities(intent, PackageManager.ResolveInfoFlags.of(0));
} else {
infos = packageManager.queryIntentActivities(intent, 0);
Expand All @@ -134,8 +134,8 @@ private void cacheResolveInfos() {
* <p>When an activity does not return a value. the request is completed successfully and returns
* null.
*/
@TargetApi(Build.VERSION_CODES.M)
@RequiresApi(Build.VERSION_CODES.M)
@TargetApi(23)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix here and below

@RequiresApi(23)
public boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent intent) {
// Return early if the result is not related to a request sent by this plugin.
if (!requestsByCode.containsKey(requestCode)) {
Expand Down
18 changes: 9 additions & 9 deletions shell/platform/android/io/flutter/view/AccessibilityBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void onTooltip(@NonNull String message) {
//
// To reproduce native behavior, see
// https://developer.android.com/guide/topics/ui/tooltips.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= 28) {
return;
}
AccessibilityEvent e =
Expand Down Expand Up @@ -478,7 +478,7 @@ public void onTouchExplorationStateChanged(boolean isTouchExplorationEnabled) {

// 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.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (Build.VERSION.SDK_INT >= 31) {
setBoldTextFlag();
}

Expand Down Expand Up @@ -616,7 +616,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
if (flutterSemanticsTree.containsKey(ROOT_NODE_ID)) {
result.addChild(rootAccessibilityView, ROOT_NODE_ID);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (Build.VERSION.SDK_INT >= 24) {
result.setImportantForAccessibility(false);
}
return result;
Expand Down Expand Up @@ -652,7 +652,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {

// Accessibility Scanner uses isImportantForAccessibility to decide whether to check
// or skip this node.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (Build.VERSION.SDK_INT >= 24) {
result.setImportantForAccessibility(isImportant(semanticsNode));
}

Expand Down Expand Up @@ -881,12 +881,12 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
// for non-scopes-routes semantics nodes.
if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) {
result.setText(semanticsNode.getValue());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= 28) {
result.setHintText(semanticsNode.getTextFieldHint());
}
} else if (!semanticsNode.hasFlag(Flag.SCOPES_ROUTE)) {
CharSequence content = semanticsNode.getValueLabelHint();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT < 28) {
if (semanticsNode.tooltip != null) {
// For backward compatibility with Flutter SDK before Android API
// level 28, the tooltip is appended at the end of content description.
Expand All @@ -899,7 +899,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= 28) {
if (semanticsNode.tooltip != null) {
result.setTooltipText(semanticsNode.tooltip);
}
Expand All @@ -925,7 +925,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
result.setSelected(semanticsNode.hasFlag(Flag.IS_SELECTED));

// Heading support
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= 28) {
result.setHeading(semanticsNode.hasFlag(Flag.IS_HEADER));
}

Expand Down Expand Up @@ -1911,7 +1911,7 @@ private void onWindowNameChange(@NonNull SemanticsNode route) {
// next.
routeName = " ";
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= 28) {
setAccessibilityPaneTitle(routeName);
} else {
AccessibilityEvent event =
Expand Down
Loading