Skip to content

Commit

Permalink
remove references to v1 embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
Gray Mackall committed Jun 7, 2024
1 parent 7b3eebf commit 7c5ff40
Showing 1 changed file with 5 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;

/**
* FilePickerPlugin
Expand Down Expand Up @@ -116,29 +115,6 @@ public void onActivityStopped(final Activity activity) {
private static boolean withData = false;
private static int compressionQuality;

/**
* Plugin registration.
*/
public static void registerWith(final io.flutter.plugin.common.PluginRegistry.Registrar registrar) {

if (registrar.activity() == null) {
// If a background flutter view tries to register the plugin, there will be no activity from the registrar,
// we stop the registering process immediately because the ImagePicker requires an activity.
return;
}

final Activity activity = registrar.activity();
Application application = null;
if (registrar.context() != null) {
application = (Application) (registrar.context().getApplicationContext());
}

final FilePickerPlugin plugin = new FilePickerPlugin();
plugin.setup(registrar.messenger(), application, activity, registrar, null);

}


@SuppressWarnings("unchecked")
@Override
public void onMethodCall(final MethodCall call, final MethodChannel.Result rawResult) {
Expand Down Expand Up @@ -258,7 +234,6 @@ private void setup(
final BinaryMessenger messenger,
final Application application,
final Activity activity,
final PluginRegistry.Registrar registrar,
final ActivityPluginBinding activityBinding) {

this.activity = activity;
Expand All @@ -278,18 +253,11 @@ public void onCancel(final Object arguments) {
}
});
this.observer = new LifeCycleObserver(activity);
if (registrar != null) {
// V1 embedding setup for activity listeners.
application.registerActivityLifecycleCallbacks(this.observer);
registrar.addActivityResultListener(this.delegate);
registrar.addRequestPermissionsResultListener(this.delegate);
} else {
// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(this.delegate);
activityBinding.addRequestPermissionsResultListener(this.delegate);
this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
this.lifecycle.addObserver(this.observer);
}
// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(this.delegate);
activityBinding.addRequestPermissionsResultListener(this.delegate);
this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
this.lifecycle.addObserver(this.observer);
}

private void tearDown() {
Expand Down Expand Up @@ -325,7 +293,6 @@ public void onAttachedToActivity(final ActivityPluginBinding binding) {
this.pluginBinding.getBinaryMessenger(),
(Application) this.pluginBinding.getApplicationContext(),
this.activityBinding.getActivity(),
null,
this.activityBinding);
}

Expand Down

0 comments on commit 7c5ff40

Please sign in to comment.