Skip to content

Commit

Permalink
On touch double click fix and other
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanbobrowski committed Sep 6, 2024
1 parent 0607d40 commit 643cc54
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 20 deletions.
Binary file added assets/blog2epub_splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions assets/blog2epub_splash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 20 additions & 10 deletions blog2epub/blog2epub_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import webbrowser
import math
import time
import subprocess
from datetime import datetime
from itertools import cycle
from threading import Thread
Expand All @@ -29,7 +30,7 @@

from kivy.config import Config # type: ignore

Config.set("input", "mouse", "mouse,multitouch_on_demand")
# Config.set("input", "mouse", "mouse,multitouch_on_demand")
Config.set("graphics", "resizable", False)

from kivy.utils import platform # type: ignore
Expand All @@ -46,7 +47,7 @@
from kivymd.uix.dropdownitem import MDDropDownItem # type: ignore # noqa

from blog2epub import Blog2Epub
from blog2epub.common.assets import asset_path, open_file
from blog2epub.common.assets import asset_path
from blog2epub.common.crawler import prepare_url
from blog2epub.common.exceptions import BadUrlException
from blog2epub.common.interfaces import EmptyInterface
Expand Down Expand Up @@ -94,8 +95,10 @@ def __init__(self, **kwargs):
self.articles_data = []
self.blog2epub_settings = Blog2EpubSettings(path=USER_DATA_DIR)
if platform == "android":
from android.storage import primary_external_storage_path # type: ignore

self.blog2epub_settings.data.destination_folder = os.path.join(
os.environ["ANDROID_STORAGE"], "emulated", "0", "Download"
primary_external_storage_path(), "Download"
)
self.blog2epub = None
self.download_thread = None
Expand Down Expand Up @@ -449,11 +452,12 @@ def _download_ebook(self, blog2epub: Blog2Epub):
self._update_tab_generate()
if not blog2epub.crawler.cancelled:
self.interface.print("Download completed.")
notification.notify(
title="blog2epub - download completed",
message=f"{blog2epub.crawler.url}",
timeout=2,
)
if platform != "android":
notification.notify(
title="blog2epub - download completed",
message=f"{blog2epub.crawler.url}",
timeout=2,
)
self._switch_tab("Select")

@mainthread
Expand Down Expand Up @@ -520,7 +524,7 @@ def _get_articles_rows(self):
)
return temp_data

def download(self, *args, **kwargs):
def download(self, button_instance):
global USER_DATA_DIR
self.url_entry.error = False
self.interface.clear()
Expand Down Expand Up @@ -592,7 +596,13 @@ def success(self, ebook: Book):
success_content.add_widget(epub_cover_image_widget)

def open_ebook_in_default_viewer(inst):
open_file(ebook.file_full_path)
if platform == "win":
os.startfile(ebook.file_full_path)
elif platform == "android":
webbrowser.open(f"xdg-open://{ebook.file_full_path}")
else:
opener = "open" if sys.platform == "osx" else "xdg-open"
subprocess.call([opener, ebook.file_full_path])

def send_ebook_via_email(inst):
email.send(
Expand Down
9 changes: 0 additions & 9 deletions blog2epub/common/assets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import subprocess
import sys


Expand All @@ -12,11 +11,3 @@ def asset_path(filename: str) -> str:
return os.path.join(base_path, filename)
# if there is no given file i'm guessing that blog2epub is run from sources
return os.path.join(os.path.abspath("../assets/"), filename)


def open_file(filename):
if sys.platform == "win32":
os.startfile(filename)
else:
opener = "open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, filename])
2 changes: 1 addition & 1 deletion buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ requirements = python3,kivy==2.3.0,kivymd==1.2.0,pydantic,pydantic_core,lxml==5.
# requirements.source.kivy = ../../kivy

# (str) Presplash of the application
presplash.filename = ./assets/blog2epub_256px.png
presplash.filename = ./assets/blog2epub_splash.png

# (str) Icon of the application
icon.filename = ./assets/blog2epub_256px.png
Expand Down

0 comments on commit 643cc54

Please sign in to comment.