Skip to content

Commit

Permalink
[many] Remove references to v1 embedding (#6494)
Browse files Browse the repository at this point in the history
I have a WIP effort to remove the v1 embedding entirely (flutter/flutter#146523 is the latest pr).

`registerWith` references the v1 embedding, which has been deprecated for many years, so this PR removes it from all plugins.

Also removes some additional references, see in particular these three commits:

1. Modifies private `ActivityState` class to remove `PluginRegistry.Registrar` member in `image_picker`: c2e4c87
2. Replaces `FlutterMain.getLookupKeyForAsset()` with `FlutterLoader.getLookupKeyForAsset()` in `google_maps` plugin: 73c3de3
3. Removes deprecated `RegistrarFlutterAssetManager` class in `webview_flutter`: cc842c6

Fixes flutter/flutter#70923
  • Loading branch information
gmackall committed May 28, 2024
1 parent b4d134e commit b16a7e3
Show file tree
Hide file tree
Showing 61 changed files with 140 additions and 435 deletions.
5 changes: 3 additions & 2 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 0.10.9+3

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* Removes support for apps using the v1 Android embedding.

## 0.10.9+2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*
* <p>Instantiate this in an add to app scenario to gracefully handle activity and context changes.
* See {@code io.flutter.plugins.camera.MainActivity} for an example.
*
* <p>Call {@link #registerWith(io.flutter.plugin.common.PluginRegistry.Registrar)} to register an
* implementation of this that uses the stable {@code io.flutter.plugin.common} package.
*/
public final class CameraPlugin implements FlutterPlugin, ActivityAware {

Expand All @@ -36,24 +33,6 @@ public final class CameraPlugin implements FlutterPlugin, ActivityAware {
*/
public CameraPlugin() {}

/**
* Registers a plugin implementation that uses the stable {@code io.flutter.plugin.common}
* package.
*
* <p>Calling this automatically initializes the plugin. However plugins initialized this way
* won't react to changes in activity or context, unlike {@link CameraPlugin}.
*/
@SuppressWarnings("deprecation")
public static void registerWith(
@NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
CameraPlugin plugin = new CameraPlugin();
plugin.maybeStartListening(
registrar.activity(),
registrar.messenger(),
registrar::addRequestPermissionsResultListener,
registrar.view());
}

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
this.flutterPluginBinding = binding;
Expand Down
4 changes: 2 additions & 2 deletions packages/camera/camera_android/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ description: Demonstrates how to use the camera plugin.
publish_to: none

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

dependencies:
camera_android:
Expand Down
6 changes: 3 additions & 3 deletions packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ description: Android implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22

version: 0.10.9+2
version: 0.10.9+3

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

flutter:
plugin:
Expand Down
5 changes: 3 additions & 2 deletions packages/espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 0.3.0+9

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* Removes support for apps using the v1 Android embedding.

## 0.3.0+8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
channel.setMethodCallHandler(new EspressoPlugin());
}

// This static function is optional and equivalent to onAttachedToEngine. It supports the old
// pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
// plugin registration via this function while apps migrate to use the new Android APIs
// post-flutter-1.12 via https://flutter.dev/go/android-project-migration.
//
// It is encouraged to share logic between onAttachedToEngine and registerWith to keep
// them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
// depending on the user's project. onAttachedToEngine or registerWith must both be defined
// in the same class.
@SuppressWarnings("deprecation")
public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "espresso");
channel.setMethodCallHandler(new EspressoPlugin());
}

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
if (call.method.equals("getPlatformVersion")) {
Expand Down
4 changes: 2 additions & 2 deletions packages/espresso/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ description: Demonstrates how to use the espresso plugin.
publish_to: none

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions packages/espresso/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ description: Java classes for testing Flutter apps using Espresso.
Allows driving Flutter widgets from a native Espresso test.
repository: https://github.com/flutter/packages/tree/main/packages/espresso
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22
version: 0.3.0+8
version: 0.3.0+9

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

flutter:
plugin:
Expand Down
5 changes: 3 additions & 2 deletions packages/flutter_plugin_android_lifecycle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 2.0.20

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* Removes support for apps using the v1 Android embedding.

## 2.0.19

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
* <p><strong>DO NOT USE THIS CLASS.</strong>
*/
public class FlutterAndroidLifecyclePlugin implements FlutterPlugin {
@SuppressWarnings("deprecation")
public static void registerWith(
@NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
// no-op
}

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ description: Demonstrates how to use the flutter_plugin_android_lifecycle plugin
publish_to: none

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter_plugin_android_lifecycle/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: flutter_plugin_android_lifecycle
description: Flutter plugin for accessing an Android Lifecycle within other plugins.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_plugin_android_lifecycle%22
version: 2.0.19
version: 2.0.20

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

flutter:
plugin:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 2.8.1

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* Removes support for apps using the v1 Android embedding.

## 2.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.android.gms.maps.model.SquareCap;
import com.google.android.gms.maps.model.Tile;
import com.google.maps.android.clustering.Cluster;
import io.flutter.FlutterInjector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -36,9 +37,6 @@
/** Conversions between JSON-like values and GoogleMaps data types. */
class Convert {

// TODO(hamdikahloun): FlutterMain has been deprecated and should be replaced with FlutterLoader
// when it's available in Stable channel: https://github.com/flutter/flutter/issues/70923.
@SuppressWarnings("deprecation")
private static BitmapDescriptor toBitmapDescriptor(Object o) {
final List<?> data = toList(o);
switch (toString(data.get(0))) {
Expand All @@ -51,16 +49,21 @@ private static BitmapDescriptor toBitmapDescriptor(Object o) {
case "fromAsset":
if (data.size() == 2) {
return BitmapDescriptorFactory.fromAsset(
io.flutter.view.FlutterMain.getLookupKeyForAsset(toString(data.get(1))));
FlutterInjector.instance()
.flutterLoader()
.getLookupKeyForAsset(toString(data.get(1))));
} else {
return BitmapDescriptorFactory.fromAsset(
io.flutter.view.FlutterMain.getLookupKeyForAsset(
toString(data.get(1)), toString(data.get(2))));
FlutterInjector.instance()
.flutterLoader()
.getLookupKeyForAsset(toString(data.get(1)), toString(data.get(2))));
}
case "fromAssetImage":
if (data.size() == 3) {
return BitmapDescriptorFactory.fromAsset(
io.flutter.view.FlutterMain.getLookupKeyForAsset(toString(data.get(1))));
FlutterInjector.instance()
.flutterLoader()
.getLookupKeyForAsset(toString(data.get(1))));
} else {
throw new IllegalArgumentException(
"'fromAssetImage' Expected exactly 3 arguments, got: " + data.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,6 @@ public class GoogleMapsPlugin implements FlutterPlugin, ActivityAware {

private static final String VIEW_TYPE = "plugins.flutter.dev/google_maps_android";

@SuppressWarnings("deprecation")
public static void registerWith(
@NonNull final io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
final Activity activity = registrar.activity();
if (activity == null) {
// When a background flutter view tries to register the plugin, the registrar has no activity.
// We stop the registration process as this plugin is foreground only.
return;
}
if (activity instanceof LifecycleOwner) {
registrar
.platformViewRegistry()
.registerViewFactory(
VIEW_TYPE,
new GoogleMapFactory(
registrar.messenger(),
registrar.context(),
new LifecycleProvider() {
@Override
public Lifecycle getLifecycle() {
return ((LifecycleOwner) activity).getLifecycle();
}
}));
} else {
registrar
.platformViewRegistry()
.registerViewFactory(
VIEW_TYPE,
new GoogleMapFactory(
registrar.messenger(),
registrar.context(),
new ProxyLifecycleProvider(activity)));
}
}

public GoogleMapsPlugin() {}

// FlutterPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ description: Demonstrates how to use the google_maps_flutter plugin.
publish_to: none

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

dependencies:
cupertino_icons: ^1.0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: google_maps_flutter_android
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.8.0
version: 2.8.1

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

flutter:
plugin:
Expand Down
5 changes: 3 additions & 2 deletions packages/google_sign_in/google_sign_in_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 6.1.24

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* Removes support for apps using the v1 Android embedding.

## 6.1.23

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ public class GoogleSignInPlugin implements FlutterPlugin, ActivityAware {
private @Nullable BinaryMessenger messenger;
private ActivityPluginBinding activityPluginBinding;

@SuppressWarnings("deprecation")
public static void registerWith(
@NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
GoogleSignInPlugin instance = new GoogleSignInPlugin();
instance.initInstance(registrar.messenger(), registrar.context(), new GoogleSignInWrapper());
instance.setUpRegistrar(registrar);
}

@VisibleForTesting
public void initInstance(
@NonNull BinaryMessenger messenger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ description: Example of Google Sign-In plugin.
publish_to: none

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions packages/google_sign_in/google_sign_in_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: google_sign_in_android
description: Android implementation of the google_sign_in plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 6.1.23
version: 6.1.24

environment:
sdk: ^3.2.0
flutter: ">=3.16.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

flutter:
plugin:
Expand Down
5 changes: 5 additions & 0 deletions packages/image_picker/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.8.12+2

* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* Removes support for apps using the v1 Android embedding.

## 0.8.12+1

* Fixes another app crash case on Android 12+, and refactors getting of paths from intents.
Expand Down
Loading

0 comments on commit b16a7e3

Please sign in to comment.