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

Add an ability to turn off the notification #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions kivy_reloader/compile_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,19 @@ def compile_app():
sys.exit(0)

logging.info("Starting compilation")

notify(
f"Compiling {app_name}",
f"Compilation started at {time.strftime('%H:%M:%S')}",
)
if config.NOTIFY_ON_COMPILE_START:
notify(
f"Compiling {app_name}",
f"Compilation started at {time.strftime('%H:%M:%S')}",
)
t1 = time.time()
subprocess.run(["buildozer", "-v", "android", "debug", "deploy", "run"], check=True)
t2 = time.time()
notify(
f"Compiled {app_name} successfully",
f"Compilation finished in {round(t2 - t1, 2)} seconds",
)
if config.NOTIFY_ON_COMPILE_FINISH:
notify(
f"Compiled {app_name} successfully",
f"Compilation finished in {round(t2 - t1, 2)} seconds",
)
logging.info("Finished compilation")


Expand Down Expand Up @@ -328,17 +329,19 @@ def start_scrcpy():

def create_aab():
print(f"{yellow} Started creating aab")
notify(
f"Compile production: {app_name}",
if config.NOTIFY_ON_COMPILE_START:
notify(
f"Compile production: {app_name}",
f"Compilation started at {time.strftime('%H:%M:%S')}",
)
)
t1 = time.time()
os.system("buildozer -v android release")
t2 = time.time()
notify(
f"Compiled {app_name} successfully",
f"Compilation finished in {round(t2 - t1, 2)} seconds",
)
if config.NOTIFY_ON_COMPILE_FINISH:
notify(
f"Compiled {app_name} successfully",
f"Compilation finished in {round(t2 - t1, 2)} seconds",
)
print(f"{green} Finished compilation")
sys.exit(0)

Expand Down
9 changes: 9 additions & 0 deletions kivy_reloader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(self):
"SERVICE_FILES",
"SERVICE_NAMES",
"NO_AUDIO",
"NOTIFY_ON_COMPILE_START",
"NOTIFY_ON_COMPILE_FINISH",
]
self._load_config()

Expand Down Expand Up @@ -170,5 +172,12 @@ def FOLDERS_AND_FILES_TO_EXCLUDE_FROM_PHONE(self) -> List[str]:
def NO_AUDIO(self) -> str:
return self.get("NO_AUDIO", True)

@property
def NOTIFY_ON_COMPILE_START(self) -> bool:
return self.get("NOTIFY_ON_COMPILE_START",False)

@property
def NOTIFY_ON_COMPILE_FINISH(self) -> bool:
return self.get("NOTIFY_ON_COMPILE_FINISH",True)

config = Config()
6 changes: 6 additions & 0 deletions kivy_reloader/kivy-reloader.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ STREAM_USING = "USB"
# It can be any port
PORT = 5555

# Whether to send a system notification whenever kivy-reloader begins compiling
NOTIFY_ON_COMPILE_START = false

# Whether to send a system notification whenever kivy-reloader finishes compiling compiling
NOTIFY_ON_COMPILE_FINISH = true

# Add the python files you want to watch here, i.e., if they change, the app will be reloaded
WATCHED_FILES = ["main.py"]

Expand Down