Skip to content

Commit

Permalink
Struggling with opening damn epub file after generation on android
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanbobrowski committed Oct 31, 2024
1 parent fc82f6f commit 64a3d18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions blog2epub/blog2epub_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,14 @@ def save_settings(self):
def popup_success(self, ebook: Book):
self.success(ebook)

def _open_ebook_in_default_viewer(self, file_full_path, inst):
print("===LOL===")
@mainthread
def _open_epub(self, file_full_path, inst):
file_path_urlencoded = urllib.parse.quote(file_full_path)
self.interface.print(f"Opening file: {file_full_path} ({platform})")
if platform == "win":
os.startfile(file_path_urlencoded) # type: ignore
elif platform == "android":
pass
# webbrowser.open(f"file://{file_path_urlencoded}")
webbrowser.open(f"file:/{file_path_urlencoded}")
else:
opener = "open" if sys.platform == "osx" else "xdg-open"
subprocess.call([opener, file_path_urlencoded])
Expand Down Expand Up @@ -606,9 +605,7 @@ def success(self, ebook: Book):
font_size=sp(16),
font_name=UI_FONT_NAME,
size_hint=(0.5, 1),
on_press=partial(
self._open_ebook_in_default_viewer, ebook.file_full_path
),
on_press=partial(self._open_epub, ebook.file_full_path),
)
)
success_content.add_widget(buttons_row)
Expand Down
4 changes: 2 additions & 2 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fullscreen = 0
# (list) Permissions
# (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties)
# android.permissions = android.permission.INTERNET, (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)
android.permissions = android.permission.INTERNET, android.permission.READ_EXTERNAL_STORAGE, android.permission.WRITE_EXTERNAL_STORAGE
android.permissions = android.permission.INTERNET, android.permission.READ_EXTERNAL_STORAGE, android.permission.WRITE_EXTERNAL_STORAGE, android.permission.FLAG_GRANT_READ_URI_PERMISSION

# (list) features (adds uses-feature -tags to manifest)
#android.features = android.hardware.usb.host
Expand All @@ -108,7 +108,7 @@ android.permissions = android.permission.INTERNET, android.permission.READ_EXTER
#android.minapi = 21

# (int) Android SDK version to use
#android.sdk = 20
android.sdk = 20

# (str) Android NDK version to use
#android.ndk = 23b
Expand Down

0 comments on commit 64a3d18

Please sign in to comment.