diff --git a/flockompass.kv b/flockompass.kv index a806a02..7c9f61e 100644 --- a/flockompass.kv +++ b/flockompass.kv @@ -144,24 +144,24 @@ cols: 2 BackgroundLabel: text: "Dark theme" - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) font_size: '14sp' BgSwitch: id: dark_theme active: True - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) on_active: app.set_dark_theme(self.active) BackgroundLabel: text: "Compas smoothing" - background_color: rgba("#f3e8d2") + background_color: rgba(app.theme['bgcolor']) color: rgba("#346645") font_size: '14sp' BgSlider: id: slider_smoothing - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) min: 0.05 max: 0.99 step: 0.05 @@ -171,13 +171,13 @@ BackgroundLabel: text: "Compas update frequency" - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) font_size: '14sp' BgSlider: id: slider_compass_update - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) min: 0.1 max: 0.9 step: 0.05 @@ -187,13 +187,13 @@ BackgroundLabel: text: "Update frequency" - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) font_size: '14sp' BgSlider: id: slider_update_freq - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) min: 0 max: 1 step: 0.1 @@ -201,13 +201,13 @@ value: 0.5 BackgroundLabel: text: "Local altruism" - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) font_size: '14sp' BgSlider: id: slider_local_altruism - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) min: 0 max: 1 step: 0.1 @@ -215,13 +215,13 @@ value: 0.1 BackgroundLabel: text: "Destination altruism" - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) font_size: '14sp' BgSlider: id: slider_dest_altruism - background_color: rgba("#f3e8d2") - color: rgba("#346645") + background_color: rgba(app.theme['bgcolor']) + color: rgba(app.theme['fgcolor']) min: 0 max: 1 step: 0.2 diff --git a/main.py b/main.py index 3c0742c..ff2401e 100644 --- a/main.py +++ b/main.py @@ -79,13 +79,20 @@ class FlockompassApp(App): settings = pickle.load(f) else: settings = {'settings_smoothing': 0.88, - 'settings_compass_update': 0.777 + 'settings_compass_update': 0.777, + 'settings_theme': "dark" } with open(pickle_path, 'wb') as f: pickle.dump(settings, f) self.session_data.update(settings) + if self.session_data['settings_theme'] == "dark": + self.set_dark_theme(True) + else: + self.set_dark_theme(False) + + def save_settings(self): app_folder = os.path.dirname(os.path.abspath(__file__)) pickle_path = path.join(app_folder, 'settings.pickle') @@ -114,16 +121,23 @@ class FlockompassApp(App): self.ms.ids.mapview.center_on(self.session_data['dest_lat'], self.session_data['dest_lon']) - def set_dark_theme(self, active): if active: self.theme = {'needle': "assets/needle_dark.png", 'to_map': "assets/to_map_dark.png", - 'bgcolor': "#336645"} + 'bgcolor': "#336645", + 'fgcolor': "#f3e8d2" + } + self.session_data['settings_theme'] = 'dark' else: self.theme = {'needle': "assets/needle_bright.png", 'to_map': "assets/to_map_bright.png", - 'bgcolor': "#f3e8d2"} + 'bgcolor': "#f3e8d2", + 'fgcolor': "#346645" + } + self.session_data['settings_theme'] = 'bright' + self.save_settings() + def request_android_permissions(self): from android.permissions import request_permissions, Permission