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] Not implemented: Window.select_folder_dialog() #1810

Closed
rem3228 opened this issue Mar 11, 2023 · 4 comments
Closed

[Android] Not implemented: Window.select_folder_dialog() #1810

rem3228 opened this issue Mar 11, 2023 · 4 comments
Labels
bug A crash or error in behavior.

Comments

@rem3228
Copy link

rem3228 commented Mar 11, 2023

Describe the bug

I built an application for android, and used a command in it, by clicking on which, I want to select a folder with files, but in the log I see the following:
03-11 07:59:02.231 11776 11776 I python.stdout: [Android] Not implemented: Window.select_folder_dialog()
Dialog box does not open.
Code that fires when a command is clicked:

def open_folder(self, widget):
        self.main_window.select_folder_dialog("Выберите папку", initial_directory=os.path.dirname(os.path.realpath(__file__)), on_result=self.set_folders)

Steps to reproduce

  1. briefcase create android
  2. briefcase build android
  3. briefcase run android
  4. Click on the command
  5. See log

Expected behavior

[Android] Not implemented: Window.select_folder_dialog()

Screenshots

image

Environment

  • Operating System: Windows 11
  • Python version: 3.10.6
  • Software versions:
    • Briefcase: 0.3.13
    • Toga: 0.3.0

Logs

03-11 07:59:02.231 11776 11776 I python.stdout: [Android] Not implemented: Window.select_folder_dialog()
03-11 07:59:02.231 11776 11776 D MainActivity: onOptionsItemSelected() complete

Additional context

No response

@rem3228 rem3228 added the bug A crash or error in behavior. label Mar 11, 2023
@proneon267
Copy link
Contributor

As the error indicates, that function is currently not implemented for Android.

See Pull Request: #1158
See issues: #1171

@rem3228
Copy link
Author

rem3228 commented Mar 11, 2023

As the error indicates, that function is currently not implemented for Android.

See Pull Request: #1158 See issues: #1171

Thanks for the answer. Is this solution? Where to get these libraries? Pip doesnt find them.

from com.chaquo.python import Python
from java import jclass

Intent = jclass('android.content.Intent')

context = Python.getPlatform().getApplication()  # Could also be widget.app._impl.native
fileChose = Intent(Intent.ACTION_GET_CONTENT)
fileChose.addCategory(Intent.CATEGORY_OPENABLE)
fileChose.setType("text/plain")
results = await widget.app._impl.intent_result(Intent.createChooser(fileChose, "Choose a file"))
data = results['resultData'].getData()
bytesJarray = bytes((context.getContentResolver().openInputStream(data).readAllBytes()))

@mhsmith
Copy link
Member

mhsmith commented Mar 11, 2023

You don't need to install any additional libraries: those imports are from Chaquopy, which is installed automatically on Android.

@rem3228
Copy link
Author

rem3228 commented Mar 11, 2023

Ok thanks everyone for the help

@rem3228 rem3228 closed this as completed Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

3 participants