def __init__(self, config_handler, **kwargs): """ Creates a MoonWidget object :param kwargs: Kwargs for MDGridLayout """ super(MoonWidget, self).__init__(**kwargs) self.cols = 1 self.rows = 2 self.config_handler = config_handler moon_phase = self.update_moon_phase() self.size_hint = (0.8, 0.8) self.orientation = "horizontal" self.moon_text = Label( text=moon_phase, color=DARK_THEME_TEXT_COLOR if self.config_handler.get_setting(CONFIG_ENABLE_DARK_MODE_KEY) else LIGHT_THEME_TEXT_COLOR, font_name="RobotoMono-Regular", size_hint=(1, 1), font_size="15sp", ) self.image = Image(source=moon_phase_images[moon_phase.lower()]) self.add_widget(self.moon_text) self.add_widget(self.image) self.moon_schedule = Clock.schedule_once( self.update, (get_tomorrow_date() - datetime.datetime.now()).seconds + 60)
def __init__(self, config_handler, **kwargs): """ Create a CalendarBox object :param kwargs: Kwargs for MDGridLayout """ super(CalendarBox, self).__init__(**kwargs) self.cols = 3 self.rows = 1 self.config_handler = config_handler gregorian_date = getter.get_gregorian_date() self.gregorian_widget = WrappedLabel( text=gregorian_date["formatted_string"], color=DARK_THEME_TEXT_COLOR if self.config_handler.get_setting(CONFIG_ENABLE_DARK_MODE_KEY) else LIGHT_THEME_TEXT_COLOR, font_name="Roboto-Bold", font_size="16sp", size_hint=(0.5, 1), padding=("10sp", "0sp"), ) self.hijri_widget = WrappedLabel( text="14 Ramadan 1440 AH", color=DARK_THEME_TEXT_COLOR if self.config_handler.get_setting(CONFIG_ENABLE_DARK_MODE_KEY) else LIGHT_THEME_TEXT_COLOR, font_name="Roboto-Bold", font_size="16sp", size_hint=(0.5, 1), padding=("10sp", "0sp"), ) self.update_hijri() # Logo courtesy of flaticon if self.config_handler.get_setting(CONFIG_ENABLE_DARK_MODE_KEY): self.add_widget( Image( source="res/mosque_white.png", keep_ratio=True, size_hint_x=0.1, pos=(0, 0), )) else: self.add_widget( Image( source="res/mosque_dark.png", keep_ratio=True, size_hint_x=0.1, pos=(0, 0), )) self.add_widget(self.gregorian_widget) self.add_widget(self.hijri_widget) Clock.schedule_once( self.update_gregorian, (get_tomorrow_date() - datetime.datetime.now()).seconds, )
def update_gregorian(self, *args): """ Schedules a Clock schedule to update Gregorian date at midnight. :param args: Args given by Kivy :return: None """ gregorian_date = getter.get_gregorian_date() self.gregorian_widget.text = gregorian_date["formatted_string"] Clock.schedule_once( self.update_gregorian, (get_tomorrow_date() - datetime.datetime.now()).seconds, )
def update(self, *args): """ Updates moon phase text and moon phase image and schedules daily updates. :param args: Args given by Kivy :return: None """ moon_phase = self.update_moon_phase() self.moon_text.text = moon_phase self.image.source = moon_phase_images[moon_phase.lower()] self.moon_schedule.cancel() self.moon_schedule = Clock.schedule_once( self.update, (get_tomorrow_date() - datetime.datetime.now()).seconds + 60)
def __init__(self, audio_player, config_handler, **kwargs): """ Create a PrayerPane object :param kwargs: Kwargs for MDGridLayout """ super(PrayerPane, self).__init__(**kwargs) self.cols = 1 self.rows = 6 self.todays_times = { "Fajr": "12:00 am", "Duha": "12:00 am", "Dhuhr": "12:00 am", "Asr": "12:00 am", "Maghrib": "12:00 am", "Isha": "12:00 am", } self.tomorrow_times = { "Fajr": "12:00 am", "Duha": "12:00 am", "Dhuhr": "12:00 am", "Asr": "12:00 am", "Maghrib": "12:00 am", "Isha": "12:00 am", } self.audio_player = audio_player self.config_handler = config_handler self.prayer_time_widgets = dict() for prayer_time in ["Fajr", "Duha", "Dhuhr", "Asr", "Maghrib", "Isha"]: self.prayer_time_widgets[prayer_time] = PrayerTimeLayout( audio_player, config_handler, prayer_time, self.todays_times, self.tomorrow_times, ) self.add_widget(self.prayer_time_widgets[prayer_time]) self.get_prayer_times() self.alarm_popup_service = AlarmDismissPopup(audio_player, config_handler) self.alarm_schedule = None Clock.schedule_once( self.update, (get_tomorrow_date() - datetime.datetime.now()).seconds + 60)
def update(self, *args): """ Updates all child PrayerTimeLayout widgets and schedules tahajjud alarm if applicable. :param args: Args given by Kivy :return: None """ self.get_prayer_times() for prayer_time in ["Fajr", "Duha", "Dhuhr", "Asr", "Maghrib", "Isha"]: self.prayer_time_widgets[prayer_time].update( self.todays_times, self.tomorrow_times) Clock.schedule_once( self.update, (get_tomorrow_date() - datetime.datetime.now()).seconds + 60) if self.config_handler.get_setting( constants.CONFIG_TAHAJJUD_ALARM_KEY): self.schedule_alarm_tahajjud()