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

[Android] No return value when use saveAs and press back #78

Closed
deandreamatias-worldline opened this issue Sep 26, 2023 · 5 comments
Closed

Comments

@deandreamatias-worldline

Plugin version: 0.2.8
Platform: Android

Flutter doctor
[✓] Flutter (Channel stable, 3.13.5, on macOS 13.6 22G120 darwin-arm64, locale en-ES)
    • Flutter version 3.13.5 on channel stable at /Users/matias/fvm/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12fccda598 (6 days ago), 2023-09-19 13:56:11 -0700
    • Engine revision bd986c5ed2
    • Dart version 3.1.2
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/matias/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/matias/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.82.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.72.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 13 (API 33) (emulator)
    • iPhone 14 Pro (mobile)      • 0A5FA2A3-EBD5-4C77-AC22-80F3782F7034 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 13.6 22G120 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 117.0.5938.92

[✓] Network resources
    • All expected network resources are available.

Minimal code example: example of repo

Current Behavior:

When try save a file with method saveAs on Android and press on back button, the method doesn't return anything. This not allow that developer control this use case.

Desired Behavior:

When try save a file with method saveAs on Android and press on back button, the method should be return something to allow developer control this use case.

Steps To Reproduce:

  1. Execute example code from repo
  2. Press on button Open file manager
  3. Press Android back button
  4. Error: doesn't return anything

Aditional information:

I think in two ways to solve this: Add a custom Exception like EmptyException or return success with null/empty path.
Code related:

    private fun completeFileOperation(uri: Uri) {
        CoroutineScope(Dispatchers.Main).launch {
            try {
                saveFile(uri)
                val fileUtils = FileUtils(activity)
                result?.success(fileUtils.getPath(uri));
                //result?.success(getRealPathFromUri(activity, uri))
            } catch (e: SecurityException) {
                Log.d(TAG, "Security Exception while saving file" + e.message)

                result?.error("Security Exception", e.localizedMessage, e)
            } catch (e: Exception) {
                Log.d(TAG, "Exception while saving file" + e.message)
                result?.error("Error", e.localizedMessage, e)
            }
        }
    }
@incrediblezayed
Copy link
Owner

It'll be huge help if you add it and create a PR, I'm unfortunately extremely busy these days🥲

@deandreamatias-worldline
Copy link
Author

It'll be huge help if you add it and create a PR, I'm unfortunately extremely busy these days🥲

From Worldline, we will try to implemented a solution for this. Do you have any advise or recommendation?

@incrediblezayed
Copy link
Owner

@deandreamatias-worldline go with your latter solution (result.success with an empty path)

@Javidroid
Copy link

Just made a proposal for the solution, but returning null instead of empty path.

The important change is in Dialog.kt (explained in PR). Other changes are merely format and indentation corrections, so feel free to pick or not as many changes as you will

#79

@incrediblezayed
Copy link
Owner

Hi, merged, thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants