Skip to content

Commit

Permalink
version 1.1.0
Browse files Browse the repository at this point in the history
Added Sticky Hours functionality: stay longer or come earlyer to benefit an otherwise of schedule common free hour of someone else
New gap finding method
  • Loading branch information
MrStickyPiston committed Oct 5, 2024
1 parent 56a04c5 commit 73144c1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 40 deletions.
4 changes: 2 additions & 2 deletions build/stickyhours/android/gradle/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {

defaultConfig {
applicationId "io.github.mrstickypiston.stickyhours"
versionCode 100
versionName "1.0.6"
versionCode 010100
versionName "1.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// Briefcase currently requires API Level 24 for the `pidof` command, and the `--pid`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[tool.briefcase]
project_name = "StickyHours"
bundle = "io.github.mrstickypiston"
version = "1.0.6"
version = "1.1.0"
url = "https://mrstickypiston.is-a.dev/projects/sticky-hours"
license.file = "LICENSE"
author = "MrStickyPiston"
Expand Down
10 changes: 10 additions & 0 deletions src/io.github.mrstickypiston.stickyhours.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@

# Releases
<releases>
<release version="1.1.0" date="2024-10-05">
<url type="details">https://github.com/MrStickyPiston/StickyHours/releases/tag/1.1.0</url>
<description>
<p> Sticky Hours 1.1.0</p>
<ul>
<li>New gap finding method</li>
<li>Added Sticky Hours functionality: stay longer or come earlyer to benefit an otherwise of schedule common free hour of someone else</li>
</ul>
</description>
</release>
<release version="1.0.6" date="2024-10-03">
<url type="details">https://github.com/MrStickyPiston/StickyHours/releases/tag/1.0.6</url>
<description>
Expand Down
50 changes: 25 additions & 25 deletions src/stickyhours/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,28 @@ def main_setup(self):

add_entry_button = toga.Button(_('main.button.add_entry'), on_press=self.add_entry, style=utils.button_style)

weeks_amount_label = toga.Label(text=_('main.label.weeks_amount'), style=Pack(font_size=FontSize.xl.value))
self.weeks_amount_input = toga.Selection(items=[1, 2, 3, 4, 5])

sticky_amount_label = toga.Label(text=_('main.label.sticky_amount'), style=Pack(font_size=FontSize.xl.value))
self.sticky_amount_input = toga.Selection(items=[0, 1, 2, 3, 4])
weeks_amount_label = toga.Label(text=_('main.label.options'), style=Pack(font_size=FontSize.xl.value))
self.weeks_amount_input = toga.Selection(
items=[
{'amount': 1, 'text': _('main.selection.weeks_amount.current')},
{'amount': 2, 'text': _('main.selection.weeks_amount').format(2)},
{'amount': 3, 'text': _('main.selection.weeks_amount').format(3)},
{'amount': 4, 'text': _('main.selection.weeks_amount').format(4)},
{'amount': 5, 'text': _('main.selection.weeks_amount').format(5)},
],
accessor='text')

self.sticky_amount_input = toga.Selection(
items=[
{'amount': 0, 'text': _('main.selection.sticky_amount.none')},
{'amount': 1, 'text': _('main.selection.sticky_amount.one')},
{'amount': 2, 'text': _('main.selection.sticky_amount').format(2)},
{'amount': 3, 'text': _('main.selection.sticky_amount').format(3)},
{'amount': 4, 'text': _('main.selection.sticky_amount').format(4)},
{'amount': 5, 'text': _('main.selection.sticky_amount').format(5)},
],
accessor='text'
)

self.compute_button = toga.Button(_('main.button.idle'), on_press=self.compute, style=utils.button_style)

Expand All @@ -220,7 +237,6 @@ def main_setup(self):
main_box.add(weeks_amount_label)
main_box.add(self.weeks_amount_input)

main_box.add(sticky_amount_label)
main_box.add(self.sticky_amount_input)

main_box.add(self.compute_button)
Expand Down Expand Up @@ -469,7 +485,7 @@ def done():

a = await asyncio.wait_for(
self.loop.run_in_executor(None, self.zermelo.get_current_weeks_appointments, v.id, v.teacher,
int(self.weeks_amount_input.value), True), timeout=20)
int(self.weeks_amount_input.value.amount), True), timeout=20)

if not a or a == {}:
done()
Expand All @@ -486,7 +502,7 @@ def done():
break
processed_appointments.append(g)

self.common_gaps_cache = get_common_gaps(processed_appointments, sticky_hours=self.sticky_amount_input.value)
self.common_gaps_cache = get_common_gaps(processed_appointments, sticky_hours=self.sticky_amount_input.value.amount)

except asyncio.TimeoutError:
# Handle timeout
Expand All @@ -503,23 +519,7 @@ def done():
self.result_box.clear()

self.result_box.add(
toga.Label(_('main.results.header'), style=Pack(font_size=FontSize.xl.value)),
toga.Label(
"\n" + _('main.results.options.header'),
style=Pack(font_size=FontSize.l.value)
),
toga.Label(
"\n" + _('main.results.weeks_amount').format(self.weeks_amount_input.value),
style=Pack(font_size=FontSize.s.value)
),
toga.Label(
_('main.results.sticky_amount').format(self.sticky_amount_input.value),
style=Pack(font_size=FontSize.s.value)
),
toga.Label(
"\n" + _('main.results.users.header'),
style=Pack(font_size=FontSize.l.value)
)
toga.Label(_('main.results.header'), style=Pack(font_size=FontSize.xl.value))
)

for entry in entries:
Expand Down
25 changes: 13 additions & 12 deletions src/stickyhours/lang.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import string
from pathlib import Path
from pprint import pprint

from stickyhours import utils
Expand Down Expand Up @@ -78,18 +79,18 @@ def __init__(self):
'main.button.processing.user': 'Processing user {}',
'main.button.remove_entry': 'Remove user',
'main.label.entries': 'Users',
'main.label.sticky_amount': 'Amount of sticky hours',
'main.label.weeks_amount': 'Amount of weeks',
'main.label.options': 'Options',
'main.message.no_schedule_user.message': 'User {} has no schedule '
'available.',
'main.message.no_schedule_user.title': 'No schedule found for user.',
'main.placeholder.filter_entry': 'Filter users...',
'main.results.header': 'Common free hours',
'main.results.none': 'No common free hours found.',
'main.results.options.header': 'Options',
'main.results.sticky_amount': 'Amount of sticky hours: {}',
'main.results.users.header': 'Users',
'main.results.weeks_amount': 'Amount of weeks in future: {}'},
'main.selection.sticky_amount': '{} Sticky Hours',
'main.selection.sticky_amount.none': 'No Sticky Hours',
'main.selection.sticky_amount.one': '1 Sticky Hour',
'main.selection.weeks_amount': 'Up to {} weeks in the future',
'main.selection.weeks_amount.current': 'Only this week'},
'nl': {'auth.button.help': 'Hulp met inloggen',
'auth.button.idle': 'Log in',
'auth.button.progress': 'Aan het inloggen...',
Expand Down Expand Up @@ -144,18 +145,18 @@ def __init__(self):
'main.button.processing.user': 'Gebruiker {} verwerken',
'main.button.remove_entry': 'Gebruiker verwijderen',
'main.label.entries': 'Gebruikers',
'main.label.sticky_amount': 'Aantal sticky hours',
'main.label.weeks_amount': 'Aantal weken',
'main.label.options': 'Instellingen',
'main.message.no_schedule_user.message': 'Geen rooster gevonden voor '
'gebruiker {}.',
'main.message.no_schedule_user.title': 'Geen rooster gevonden',
'main.placeholder.filter_entry': 'Gebruikers filteren...',
'main.results.header': 'Gezamelijke tussenuren',
'main.results.none': 'Geen gezamelijke tussenuren.',
'main.results.options.header': 'Opties',
'main.results.sticky_amount': 'Aantal sticky hours: {}',
'main.results.users.header': 'Gebruikers',
'main.results.weeks_amount': 'Aantal weken in de toekomst: {}'}}
'main.selection.sticky_amount': '{} Sticky Hours',
'main.selection.sticky_amount.none': 'Geen Sticky Hours',
'main.selection.sticky_amount.one': '1 Sticky Hour',
'main.selection.weeks_amount': 'Tot {} weken in de toekomst',
'main.selection.weeks_amount.current': 'Alleen deze week'}}

print(f'Detected language {self.lang}')

Expand Down

0 comments on commit 73144c1

Please sign in to comment.