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

Remove v1 Flutter Android embedding references #223

Open
wants to merge 2 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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.3.3
* Removes references to Flutter v1 android embedding classes.

## 2.3.2
*Fixed - fix url error with query #146

Expand Down Expand Up @@ -97,4 +100,4 @@

## 0.0.1

* Initial release. Image and video from provided temp path get saved to device(Gallery and Photos).
* Initial release. Image and video from provided temp path get saved to device(Gallery and Photos).
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import io.flutter.plugin.common.MethodCall
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.Registrar

class GallerySaverPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
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 @@ -17,7 +17,7 @@


<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="gallery_saver_example">
<activity
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.5.20'
ext.kotlin_version = '2.0.21'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Thu Oct 31 14:06:34 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
30 changes: 15 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ class _MyAppState extends State<MyApp> {

void _takePhoto() async {
ImagePicker()
.getImage(source: ImageSource.camera)
.then((PickedFile recordedImage) {
.pickImage(source: ImageSource.camera)
.then((XFile? recordedImage) {
if (recordedImage != null && recordedImage.path != null) {
setState(() {
firstButtonText = 'saving in progress...';
});
GallerySaver.saveImage(recordedImage.path, albumName: albumName)
.then((bool success) {
.then((bool? success) {
setState(() {
firstButtonText = 'image saved!';
});
Expand All @@ -95,14 +95,14 @@ class _MyAppState extends State<MyApp> {

void _recordVideo() async {
ImagePicker()
.getVideo(source: ImageSource.camera)
.then((PickedFile recordedVideo) {
.pickVideo(source: ImageSource.camera)
.then((XFile? recordedVideo) {
if (recordedVideo != null && recordedVideo.path != null) {
setState(() {
secondButtonText = 'saving in progress...';
});
GallerySaver.saveVideo(recordedVideo.path, albumName: albumName)
.then((bool success) {
.then((bool? success) {
setState(() {
secondButtonText = 'video saved!';
});
Expand All @@ -115,7 +115,7 @@ class _MyAppState extends State<MyApp> {
void _saveNetworkVideo() async {
String path =
'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4';
GallerySaver.saveVideo(path, albumName: albumName).then((bool success) {
GallerySaver.saveVideo(path, albumName: albumName).then((bool? success) {
setState(() {
print('Video is saved');
});
Expand All @@ -126,7 +126,7 @@ class _MyAppState extends State<MyApp> {
void _saveNetworkImage() async {
String path =
'https://image.shutterstock.com/image-photo/montreal-canada-july-11-2019-600w-1450023539.jpg';
GallerySaver.saveImage(path, albumName: albumName).then((bool success) {
GallerySaver.saveImage(path, albumName: albumName).then((bool? success) {
setState(() {
print('Image is saved');
});
Expand Down Expand Up @@ -171,18 +171,18 @@ class _ScreenshotWidgetState extends State<ScreenshotWidget> {
});
try {
//extract bytes
final RenderRepaintBoundary boundary =
_globalKey.currentContext.findRenderObject();
final ui.Image image = await boundary.toImage(pixelRatio: 3.0);
final ByteData byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
final Uint8List pngBytes = byteData.buffer.asUint8List();
final RenderRepaintBoundary? boundary =
_globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;
final ui.Image? image = await boundary?.toImage(pixelRatio: 3.0);
final ByteData? byteData =
await image?.toByteData(format: ui.ImageByteFormat.png);
final Uint8List? pngBytes = byteData?.buffer.asUint8List();

//create file
final String dir = (await getApplicationDocumentsDirectory()).path;
final String fullPath = '$dir/${DateTime.now().millisecond}.png';
File capturedFile = File(fullPath);
await capturedFile.writeAsBytes(pngBytes);
await capturedFile.writeAsBytes(pngBytes!);
print(capturedFile.path);

await GallerySaver.saveImage(capturedFile.path).then((value) {
Expand Down
Loading