Ejemplo n.º 1
0
 def _on_music_folder_press(self) -> None:
     from bastd.ui import fileselector
     ba.containerwidget(edit=self._root_widget, transition='out_left')
     base_path = _ba.android_get_external_storage_path()
     ba.app.main_menu_window = (fileselector.FileSelectorWindow(
         base_path,
         callback=self._music_folder_selector_cb,
         show_base_path=False,
         valid_file_extensions=[],
         allow_folders=True).get_root_widget())
Ejemplo n.º 2
0
def supports_soundtrack_entry_type(entry_type: str) -> bool:
    """Return whether the provided soundtrack entry type is supported here."""
    uas = _ba.app.user_agent_string
    if entry_type == 'iTunesPlaylist':
        return 'Mac' in uas
    if entry_type in ('musicFile', 'musicFolder'):
        return ('android' in uas
                and _ba.android_get_external_storage_path() is not None)
    if entry_type == 'default':
        return True
    return False
Ejemplo n.º 3
0
 def _on_music_file_press(self) -> None:
     from ba.osmusic import OSMusicPlayer
     from bastd.ui.fileselector import FileSelectorWindow
     ba.containerwidget(edit=self._root_widget, transition='out_left')
     base_path = _ba.android_get_external_storage_path()
     ba.app.ui.set_main_menu_window(
         FileSelectorWindow(
             base_path,
             callback=self._music_file_selector_cb,
             show_base_path=False,
             valid_file_extensions=(
                 OSMusicPlayer.get_valid_music_file_extensions()),
             allow_folders=False).get_root_widget())
Ejemplo n.º 4
0
    def supports_soundtrack_entry_type(self, entry_type: str) -> bool:
        """Return whether provided soundtrack entry type is supported here."""
        uas = _ba.env()['user_agent_string']
        assert isinstance(uas, str)

        # FIXME: Generalize this.
        if entry_type == 'iTunesPlaylist':
            return 'Mac' in uas
        if entry_type in ('musicFile', 'musicFolder'):
            return ('android' in uas
                    and _ba.android_get_external_storage_path() is not None)
        if entry_type == 'default':
            return True
        return False
Ejemplo n.º 5
0
def get_human_readable_user_scripts_path() -> str:
    """Return a human readable location of user-scripts.

    This is NOT a valid filesystem path; may be something like "(SD Card)".
    """
    from ba import _language
    app = _ba.app
    path: Optional[str] = app.python_directory_user
    if path is None:
        return '<Not Available>'

    # On newer versions of android, the user's external storage dir is probably
    # only visible to the user's processes and thus not really useful printed
    # in its entirety; lets print it as <External Storage>/myfilepath.
    if app.platform == 'android':
        ext_storage_path: Optional[str] = (
            _ba.android_get_external_storage_path())
        if (ext_storage_path is not None
                and app.python_directory_user.startswith(ext_storage_path)):
            path = ('<' +
                    _language.Lstr(resource='externalStorageText').evaluate() +
                    '>' + app.python_directory_user[len(ext_storage_path):])
    return path