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

updated to latest stable versions #225

Open
wants to merge 1 commit 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
14 changes: 7 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ group 'carnegietechnologies.gallery_saver'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.5.20'
ext.kotlinCoroutinesVersion = '1.3.8'
ext.kotlin_version = '1.9.10' // Update to latest Kotlin version
ext.kotlinCoroutinesVersion = '1.7.3' // Update to latest Kotlin Coroutines version
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:8.1.1' // Update to latest Gradle plugin version
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,7 +26,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 30
compileSdkVersion 34 // Update to latest SDK version

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -41,10 +41,10 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api 'androidx.core:core-ktx:1.5.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" // Use `jdk8` version for Kotlin stdlib
api 'androidx.core:core-ktx:1.12.0' // Latest Core KTX
api 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.2'
implementation 'androidx.exifinterface:exifinterface:1.4.0' // Latest ExifInterface
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesVersion"
}
63 changes: 34 additions & 29 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _MyAppState extends State<MyApp> {
child: SizedBox.expand(
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.blue),
backgroundColor: WidgetStateProperty.all(Colors.blue),
),
onPressed: _takePhoto,
child: Text(firstButtonText,
Expand All @@ -58,7 +58,7 @@ class _MyAppState extends State<MyApp> {
child: SizedBox.expand(
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
backgroundColor: WidgetStateProperty.all(Colors.white),
),
onPressed: _recordVideo,
child: Text(secondButtonText,
Expand All @@ -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 All @@ -153,7 +153,7 @@ class _ScreenshotWidgetState extends State<ScreenshotWidget> {
child: SizedBox.expand(
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.pink),
backgroundColor: WidgetStateProperty.all(Colors.pink),
),
onPressed: _saveScreenshot,
child: Text(screenshotButtonText,
Expand All @@ -171,25 +171,30 @@ 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();

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

await GallerySaver.saveImage(capturedFile.path).then((value) {
setState(() {
screenshotButtonText = 'screenshot saved!';
final RenderRepaintBoundary? boundary = _globalKey.currentContext
?.findRenderObject() as RenderRepaintBoundary?;
if (boundary != null) {
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);
print(capturedFile.path);

await GallerySaver.saveImage(capturedFile.path).then((value) {
setState(() {
screenshotButtonText = 'screenshot saved!';
});
});
});
} else {
print("Render object is not a RenderRepaintBoundary or is null");
}
} catch (e) {
print(e);
}
Expand Down
Loading