Skip to content

Commit

Permalink
Bump minSdk to 19 for tests
Browse files Browse the repository at this point in the history
Signed-off-by: utzcoz <[email protected]>
  • Loading branch information
utzcoz committed Dec 15, 2023
1 parent 9524a18 commit ec1270a
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 214 deletions.
2 changes: 1 addition & 1 deletion shell/platform/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.flutter.app" android:versionCode="1" android:versionName="0.0.1">

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="34" />
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="34" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -194,7 +192,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ public FlutterView(@NonNull Context context, @NonNull FlutterTextureView flutter
* <p>{@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);
}
Expand Down Expand Up @@ -357,7 +356,6 @@ private FlutterView(
init();
}

@TargetApi(19)
private FlutterView(
@NonNull Context context,
@Nullable AttributeSet attrs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,17 +167,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ public long id() {
}

@Override
@TargetApi(19)
public void release() {
if (released) {
return;
Expand All @@ -658,7 +657,6 @@ public void release() {
}

@Override
@TargetApi(19)
public void pushImage(Image image) {
if (released) {
return;
Expand Down Expand Up @@ -725,7 +723,6 @@ public Image acquireLatestImage() {
}

@Override
@TargetApi(19)
protected void finalize() throws Throwable {
try {
if (released) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,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
Expand Down Expand Up @@ -417,7 +416,6 @@ public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) {
view.dispatchTouchEvent(event);
}

@TargetApi(17)
@Override
public void setDirection(int viewId, int direction) {
if (!validateDirection(direction)) {
Expand Down Expand Up @@ -502,7 +500,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) {
Expand Down Expand Up @@ -1082,7 +1079,6 @@ private void initializeRootImageViewIfNeeded() {
* testing.
*/
@VisibleForTesting
@TargetApi(Build.VERSION_CODES.KITKAT)
void initializePlatformViewIfNeeded(int viewId) {
final PlatformView platformView = platformViews.get(viewId);
if (platformView == null) {
Expand Down Expand Up @@ -1294,7 +1290,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++;
Expand All @@ -1309,7 +1304,6 @@ public FlutterOverlaySurface createOverlaySurface(@NonNull PlatformOverlayView i
*
* <p>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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
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;
import android.content.ContextWrapper;
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;
Expand Down Expand Up @@ -51,7 +49,6 @@
* EmbeddedView
*/
@Keep
@TargetApi(Build.VERSION_CODES.KITKAT)
class SingleViewPresentation extends Presentation {
private static final String TAG = "PlatformViewsController";

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

/**
Expand Down
6 changes: 1 addition & 5 deletions shell/platform/android/io/flutter/util/ViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down
Loading

0 comments on commit ec1270a

Please sign in to comment.