diff --git a/.gitignore b/.gitignore index e9dc58d..bdf834e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,63 @@ -.DS_Store +# https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub .dart_tool/ +.packages +.pub/ +build/ +pubspec.lock + +# Directory created by dartdoc +/doc/api/ + +# IDE +*.iml // IntelliJ +*.ipr // IntelliJ +*.iws // IntelliJ +.idea/ // IntelliJ +.DS_Store // Mac + +# copied from https://github.com/flutter/plugins/blob/master/.gitignore +.DS_Store +.atom/ +.idea/ +.vscode/ .packages .pub/ +.dart_tool/ +pubspec.lock +flutter_export_environment.sh + +examples/all_plugins/pubspec.yaml +Podfile +Podfile.lock +Pods/ +.symlinks/ +**/Flutter/App.framework/ +**/Flutter/Flutter.framework/ +**/Flutter/Generated.xcconfig +**/Flutter/flutter_assets/ +ServiceDefinitions.json +xcuserdata/ +**/DerivedData/ + +local.properties +keystore.properties +.gradle/ +gradlew +gradlew.bat +gradle-wrapper.jar +.flutter-plugins-dependencies +*.iml + +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m +GeneratedPluginRegistrant.java build/ +.flutter-plugins + +.project +.classpath +.settings diff --git a/android/build.gradle b/android/build.gradle index b211d53..a7de000 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 + compileSdkVersion 29 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..4d3226a 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/android/gradlew b/android/gradlew old mode 100644 new mode 100755 diff --git a/android/src/main/kotlin/com/kasem/flutter_absolute_path/FileDirectory.kt b/android/src/main/kotlin/com/kasem/flutter_absolute_path/FileDirectory.kt index 47b955b..190b895 100644 --- a/android/src/main/kotlin/com/kasem/flutter_absolute_path/FileDirectory.kt +++ b/android/src/main/kotlin/com/kasem/flutter_absolute_path/FileDirectory.kt @@ -67,6 +67,12 @@ object FileDirectory { }// MediaProvider // DownloadsProvider } else if ("content".equals(uri.scheme, ignoreCase = true)) { + + // Return the remote address + // source: https://gist.github.com/chauhan-tarun/15eb908a778ac77835d7433e04f71c16 + if (isGooglePhotosUri(uri)) + return uri.getLastPathSegment(); + return getDataColumn(context, uri, null, null) } @@ -86,15 +92,18 @@ object FileDirectory { private fun getDataColumn(context: Context, uri: Uri, selection: String?, selectionArgs: Array?): String? { - if (uri.authority != null) { - val targetFile = File(context.cacheDir, "IMG_${Date().time}.png") - context.contentResolver.openInputStream(uri)?.use { input -> - FileOutputStream(targetFile).use { fileOut -> - input.copyTo(fileOut) - } - } - return targetFile.path - } + // This is old code that needs revision. Aprently are connected to d983bd8 'Fix getting path from google photos' + // But it just copy a file on the cache (independently if is from google fotos) + // So, if we realy need to make a cache copy, do it in other way!! +// if (uri.authority != null) { +// val targetFile = File(context.cacheDir, "IMG_${Date().time}.png") +// context.contentResolver.openInputStream(uri)?.use { input -> +// FileOutputStream(targetFile).use { fileOut -> +// input.copyTo(fileOut) +// } +// } +// return targetFile.path +// } var cursor: Cursor? = null val column = "_data" @@ -136,4 +145,12 @@ object FileDirectory { fun isMediaDocument(uri: Uri): Boolean { return "com.android.providers.media.documents" == uri.authority } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is Google Photos. + */ + fun isGooglePhotosUri(uri: Uri): Boolean { + return "com.google.android.apps.photos.content" == uri.authority + } } diff --git a/example/.gitignore b/example/.gitignore index 07488ba..bdf834e 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,70 +1,63 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp +# https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub +.dart_tool/ +.packages +.pub/ +build/ +pubspec.lock + +# Directory created by dartdoc +/doc/api/ + +# IDE +*.iml // IntelliJ +*.ipr // IntelliJ +*.iws // IntelliJ +.idea/ // IntelliJ +.DS_Store // Mac + +# copied from https://github.com/flutter/plugins/blob/master/.gitignore .DS_Store .atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws .idea/ - -# Visual Studio Code related .vscode/ -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins .packages -.pub-cache/ .pub/ -/build/ +.dart_tool/ +pubspec.lock +flutter_export_environment.sh -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java +examples/all_plugins/pubspec.yaml -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +Podfile +Podfile.lock +Pods/ +.symlinks/ +**/Flutter/App.framework/ +**/Flutter/Flutter.framework/ +**/Flutter/Generated.xcconfig +**/Flutter/flutter_assets/ +ServiceDefinitions.json +xcuserdata/ +**/DerivedData/ + +local.properties +keystore.properties +.gradle/ +gradlew +gradlew.bat +gradle-wrapper.jar +.flutter-plugins-dependencies +*.iml + +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m +GeneratedPluginRegistrant.java +build/ +.flutter-plugins -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +.project +.classpath +.settings diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 782ae58..71e33f3 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 29 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -39,8 +39,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.kasem.flutter_absolute_path_example" - minSdkVersion 16 - targetSdkVersion 28 + minSdkVersion 19 + targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 5bf86b4..b8b007e 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,11 @@ + + + + +