EMF_Camp_Badge/settings/main.py

56 lines
1.7 KiB
Python
Raw Normal View History

2018-08-27 05:02:16 -04:00
"""Settings app for common or shared settings
Currently supports
* Setting name
* Setting wifi
* Pick default app
* Change badgestore repo/branch
2018-08-27 17:20:51 -04:00
Todo:
* timezone
2018-08-27 05:02:16 -04:00
"""
2018-07-15 06:53:48 -04:00
2018-09-03 09:59:37 -04:00
___title___ = "Settings"
2018-08-27 05:02:16 -04:00
___license___ = "MIT"
2018-08-27 17:20:51 -04:00
___dependencies___ = ["dialogs", "ugfx_helper", "database", "app", "stack_nav", "wifi"]
2018-07-15 06:53:48 -04:00
___categories___ = ["System"]
___bootstrapped___ = True
2018-08-27 05:02:16 -04:00
import ugfx_helper, os, wifi, app, database
2018-08-27 17:20:51 -04:00
from settings.badge_store_settings import settings_badge_store
from dialogs import *
from stack_nav import *
2018-08-27 05:02:16 -04:00
2018-08-27 17:20:51 -04:00
### SCREENS ###
2018-08-27 05:02:16 -04:00
def settings_startup_app(state):
2018-08-27 17:20:51 -04:00
apps = app.get_apps()
print(apps)
selection = prompt_option([{"title": a.title, "app": a} for a in apps], text="Select App:", none_text="Back", title="Set startup app")
if selection:
2018-09-02 05:23:30 -04:00
app.write_launch_file(selection["app"].name, "default_app.txt")
2018-08-27 05:02:16 -04:00
def settings_wifi(state):
2018-08-27 17:20:51 -04:00
wifi.choose_wifi()
2018-08-27 05:02:16 -04:00
def settings_launcher(state):
apps = app.get_apps("Launcher")
selection = prompt_option([{"title": a.title, "app": a} for a in apps], text="Select App:", none_text="Back", title="Set default launcher")
if selection:
app.write_launch_file(selection["app"].name, "default_launcher.txt")
2018-08-27 05:02:16 -04:00
def settings_main(state):
2018-08-27 17:20:51 -04:00
return selection({
2018-08-30 13:37:47 -04:00
"Homescreen Name": change_database_string("Set your name", "homescreen.name"),
2018-09-01 17:37:27 -04:00
"Homescreen Callsign": change_database_string("Set your callsign", "homescreen.callsign"),
2018-08-27 17:20:51 -04:00
"Wifi": settings_wifi,
"Startup app": settings_startup_app,
"Default Launcher": settings_launcher,
2018-08-27 17:20:51 -04:00
"Badge Store": settings_badge_store
}, none_text="Exit")
### ENTRY POINT ###
ugfx_helper.init()
2018-08-27 05:02:16 -04:00
nav(settings_main)
2018-08-31 12:05:14 -04:00
app.restart_to_default()