From ac8cd44a8144ea0bf5296d3644a3e51d30cdc15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Cotta?= Date: Fri, 30 Aug 2019 11:37:46 -0300 Subject: [PATCH 1/2] Fixed AndroidX migration, updated libraries and small nits. --- android/build.gradle | 7 +++---- .../kotlin/com/ko2ic/imagedownloader/Downloader.kt | 2 +- ...istener.kt => ImageDownloaderPermissionListener.kt} | 2 +- .../com/ko2ic/imagedownloader/ImageDownloaderPlugin.kt | 10 +++++----- example/android/build.gradle | 4 ++-- .../android/gradle/wrapper/gradle-wrapper.properties | 4 ++-- example/ios/Flutter/flutter_export_environment.sh | 8 ++++++++ 7 files changed, 22 insertions(+), 15 deletions(-) rename android/src/main/kotlin/com/ko2ic/imagedownloader/{ImageDownloderPermissionListener.kt => ImageDownloaderPermissionListener.kt} (95%) create mode 100755 example/ios/Flutter/flutter_export_environment.sh diff --git a/android/build.gradle b/android/build.gradle index 800940a..d809405 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,16 +2,15 @@ group 'com.ko2ic.imagedownloader' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.android.support:support-compat:28.0.0' } } @@ -33,7 +32,7 @@ android { } defaultConfig { minSdkVersion 16 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { disable 'InvalidPackage' diff --git a/android/src/main/kotlin/com/ko2ic/imagedownloader/Downloader.kt b/android/src/main/kotlin/com/ko2ic/imagedownloader/Downloader.kt index 7a78b8f..f7aa7e1 100644 --- a/android/src/main/kotlin/com/ko2ic/imagedownloader/Downloader.kt +++ b/android/src/main/kotlin/com/ko2ic/imagedownloader/Downloader.kt @@ -28,7 +28,7 @@ class Downloader(private val context: Context, private val request: Request) { receiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { intent ?: return - if (ACTION_DOWNLOAD_COMPLETE.equals(intent.action)) { + if (ACTION_DOWNLOAD_COMPLETE == intent.action) { val id = intent.getLongExtra(EXTRA_DOWNLOAD_ID, -1) resolveDownloadStatus(id, onNext, onError, onComplete) } diff --git a/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloderPermissionListener.kt b/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPermissionListener.kt similarity index 95% rename from android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloderPermissionListener.kt rename to android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPermissionListener.kt index 0e44718..0d53acf 100644 --- a/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloderPermissionListener.kt +++ b/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPermissionListener.kt @@ -7,7 +7,7 @@ import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import io.flutter.plugin.common.PluginRegistry -class ImageDownloderPermissionListener(private val activity: Activity) : +class ImageDownloaderPermissionListener(private val activity: Activity) : PluginRegistry.RequestPermissionsResultListener { private val permissionRequestId: Int = 2578166 diff --git a/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPlugin.kt b/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPlugin.kt index 328eed7..e179400 100644 --- a/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPlugin.kt +++ b/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPlugin.kt @@ -33,14 +33,14 @@ import java.util.* class ImageDownloaderPlugin( private val registrar: Registrar, private val channel: MethodChannel, - private val permissionListener: ImageDownloderPermissionListener + private val permissionListener: ImageDownloaderPermissionListener ) : MethodCallHandler { companion object { @JvmStatic fun registerWith(registrar: Registrar) { val channel = MethodChannel(registrar.messenger(), "plugins.ko2ic.com/image_downloader") - val listener = ImageDownloderPermissionListener(registrar.activity()) + val listener = ImageDownloaderPermissionListener(registrar.activity()) registrar.addRequestPermissionsResultListener(listener) channel.setMethodCallHandler(ImageDownloaderPlugin(registrar, channel, listener)) @@ -167,7 +167,7 @@ class ImageDownloaderPlugin( arrayOf(imageId), null ).use { - if (it == null) throw IllegalStateException("$imageId is an imageId that does not exist.") + checkNotNull(it) { "$imageId is an imageId that does not exist." } it.moveToFirst() val path = it.getString(it.getColumnIndex(MediaStore.Images.Media.DATA)) val name = it.getString(it.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME)) @@ -204,7 +204,7 @@ class ImageDownloaderPlugin( private val channel: MethodChannel, private val context: Context ) : - ImageDownloderPermissionListener.Callback { + ImageDownloaderPermissionListener.Callback { var downloader: Downloader? = null @@ -344,7 +344,7 @@ class ImageDownloaderPlugin( arrayOf(file.absolutePath), null ).use { - if (it == null) throw java.lang.IllegalStateException("${file.absolutePath} is not found.") + checkNotNull(it) { "${file.absolutePath} is not found." } it.moveToFirst() it.getString(it.getColumnIndex(MediaStore.Images.Media._ID)) } diff --git a/example/android/build.gradle b/example/android/build.gradle index fb3bb63..3100ad2 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 22710a8..506439c 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Apr 18 16:54:42 JST 2019 +#Fri Aug 30 11:33:54 BRT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 0000000..cfa154a --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/juliocotta/flutter/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/juliocotta/git/androidx/image_downloader/example" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_FRAMEWORK_DIR=/Users/juliocotta/flutter/flutter/bin/cache/artifacts/engine/ios" From aa6f8946ffe67c57e88d55d8cf59dd39f98eefdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Cotta?= Date: Fri, 30 Aug 2019 11:40:39 -0300 Subject: [PATCH 2/2] remove file from git --- .gitignore | 1 + example/ios/Flutter/flutter_export_environment.sh | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100755 example/ios/Flutter/flutter_export_environment.sh diff --git a/.gitignore b/.gitignore index 765d213..b03685b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +example/ios/Flutter/flutter_export_environment.sh .DS_Store .atom/ .idea/ diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh deleted file mode 100755 index cfa154a..0000000 --- a/example/ios/Flutter/flutter_export_environment.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/juliocotta/flutter/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/juliocotta/git/androidx/image_downloader/example" -export "FLUTTER_TARGET=lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" -export "FLUTTER_FRAMEWORK_DIR=/Users/juliocotta/flutter/flutter/bin/cache/artifacts/engine/ios"