Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes v1 Flutter Android embedding #366

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.1

* Removes references to Flutter v1 android embedding classes.

## 2.0.0

* Android: Fixes #137 and #132
Expand Down Expand Up @@ -101,4 +105,4 @@ Now you can pass text of your choice and your language choice.

## 0.0.1

* Initial release.
* Initial release.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.ActivityResultListener;
import io.flutter.plugin.common.EventChannel.StreamHandler;
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
Expand Down Expand Up @@ -68,26 +67,6 @@ public class FlutterBarcodeScannerPlugin implements MethodCallHandler, ActivityR
public FlutterBarcodeScannerPlugin() {
}

private FlutterBarcodeScannerPlugin(FlutterActivity activity, final PluginRegistry.Registrar registrar) {
FlutterBarcodeScannerPlugin.activity = activity;
}

/**
* Plugin registration.
*/
public static void registerWith(final PluginRegistry.Registrar registrar) {
if (registrar.activity() == null) {
return;
}
Activity activity = registrar.activity();
Application applicationContext = null;
if (registrar.context() != null) {
applicationContext = (Application) (registrar.context().getApplicationContext());
}
FlutterBarcodeScannerPlugin instance = new FlutterBarcodeScannerPlugin((FlutterActivity) registrar.activity(), registrar);
instance.createPluginSetup(registrar.messenger(), applicationContext, activity, registrar, null);
}

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
try {
Expand Down Expand Up @@ -234,14 +213,12 @@ public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding
* @param messenger
* @param applicationContext
* @param activity
* @param registrar
* @param activityBinding
*/
private void createPluginSetup(
final BinaryMessenger messenger,
final Application applicationContext,
final Activity activity,
final PluginRegistry.Registrar registrar,
final ActivityPluginBinding activityBinding) {


Expand All @@ -254,19 +231,11 @@ private void createPluginSetup(
this.applicationContext = applicationContext;
channel = new MethodChannel(messenger, CHANNEL);
channel.setMethodCallHandler(this);
if (registrar != null) {
// V1 embedding setup for activity listeners.
observer = new LifeCycleObserver(activity);
applicationContext.registerActivityLifecycleCallbacks(
observer); // Use getApplicationContext() to avoid casting failures.
registrar.addActivityResultListener(this);
} else {
// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(this);
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
observer = new LifeCycleObserver(activity);
lifecycle.addObserver(observer);
}
// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(this);
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
observer = new LifeCycleObserver(activity);
lifecycle.addObserver(observer);
}

@Override
Expand All @@ -276,7 +245,6 @@ public void onAttachedToActivity(ActivityPluginBinding binding) {
pluginBinding.getBinaryMessenger(),
(Application) pluginBinding.getApplicationContext(),
activityBinding.getActivity(),
null,
activityBinding);
}

Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
compileSdkVersion 34

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,7 +34,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.amolg.flutterbarcodescannerexample"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</intent-filter>
</activity>
<activity
android:name=".EmbeddingV1Activity"
android:name=".MainActivity"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
android:hardwareAccelerated="true"
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:7.1.0'
}
}

Expand All @@ -24,6 +24,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
3 changes: 1 addition & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Apr 20 02:13:11 IST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
10 changes: 5 additions & 5 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Volumes/MyData/Flutter_SDK/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/admin/Desktop/FlutterBarcodeScanner/flutter_barcode_scanner/example"
export "FLUTTER_ROOT=/Users/schectman/src/flutter/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/schectman/src/v1er/flutter_barcode_scanner/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_BUILD_NAME=2.0.0.0"
export "FLUTTER_BUILD_NUMBER=2.0.0.0"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_barcode_scanner
description: A plugin for barcode scanning support on Android and iOS. Supports barcodes, QR codes, etc.
version: 2.0.0
version: 2.0.1
author: Amol Gangadhare <[email protected]>
homepage: https://github.com/AmolGangadhare/flutter_barcode_scanner

Expand All @@ -27,4 +27,4 @@ flutter:
package: com.amolg.flutterbarcodescanner
pluginClass: FlutterBarcodeScannerPlugin
ios:
pluginClass: SwiftFlutterBarcodeScannerPlugin
pluginClass: SwiftFlutterBarcodeScannerPlugin