Skip to content

Commit 8d50f21

Browse files
authored
1.1 update release
1 parent 5fe4bcb commit 8d50f21

6 files changed

Lines changed: 99 additions & 30 deletions

File tree

list_cb_a.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Example element.png": {
2+
"Example element A.png": {
33
"link": "https://files.catbox.moe/8ht3zw.png"
44
}
55
}

list_cb_b.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
{}
1+
{
2+
"Example element B.png": {
3+
"link": "https://files.catbox.moe/8ht3zw.png"
4+
}
5+
}

list_lb.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Example element.png": {
2+
"Example element L.png": {
33
"link": "https://files.catbox.moe/8ht3zw.png"
44
}
55
}

main.py

Lines changed: 88 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,19 @@ def save_hash(self):
210210
settings = load_settings()
211211
current_hash = settings['userhash']
212212
new_hash = self.root.ids.entry.text.strip()
213+
clear_hash = new_hash.replace(" ", "")
213214

214-
if new_hash == current_hash:
215+
if clear_hash == current_hash:
216+
self.show_hash("same")
215217
return
216218

217-
if new_hash == "":
219+
if clear_hash == "":
220+
self.show_hash("invalid")
218221
return
219222

220-
settings['userhash'] = new_hash
223+
settings['userhash'] = clear_hash
221224
save_settings(settings)
225+
self.show_hash("update")
222226

223227
# Copy userhash
224228
def copy_hash(self):
@@ -243,10 +247,15 @@ def period_upd(self, option):
243247
def list_choice_upd(self, option):
244248
global list_to_show
245249

250+
if option == list_to_show:
251+
return
252+
246253
if option == "anon":
247254
list_to_show = "anon"
255+
self.add_cb_a()
248256
else:
249257
list_to_show = "auth"
258+
self.add_cb_b()
250259

251260
print("List to show updated:", list_to_show)
252261

@@ -381,7 +390,6 @@ def upl_lb(self):
381390
# Call Catbox uploads
382391
def upload_cb(self):
383392
global method
384-
global list_to_show
385393
global file_cb
386394

387395
if file_cb == "":
@@ -729,28 +737,87 @@ def back(self):
729737
### === Notifications === ###
730738

731739
# Show current userhash
732-
def show_hash(self):
740+
def show_hash(self, option):
733741
settings = load_settings()
734742
current_hash = settings['userhash']
735743

736-
if current_hash == "":
737-
support_text = "No userhash provided"
738-
else:
744+
if option == "show":
745+
if current_hash == "":
746+
support_text = "No userhash provided"
747+
else:
748+
support_text = current_hash
749+
750+
show = MDSnackbar(
751+
MDSnackbarText(
752+
text = "Current userhash:",
753+
),
754+
MDSnackbarSupportingText(
755+
text = support_text,
756+
),
757+
y=dp(10),
758+
orientation="horizontal",
759+
pos_hint={"center_x": 0.5},
760+
size_hint_x=0.8,
761+
)
762+
show.open()
763+
764+
if option == "update":
765+
up_text = "New userhash"
739766
support_text = current_hash
740767

741-
show = MDSnackbar(
742-
MDSnackbarText(
743-
text = "Current userhash:",
744-
),
745-
MDSnackbarSupportingText(
746-
text = support_text,
747-
),
748-
y=dp(10),
749-
orientation="horizontal",
750-
pos_hint={"center_x": 0.5},
751-
size_hint_x=0.8,
752-
)
753-
show.open()
768+
show = MDSnackbar(
769+
MDSnackbarText(
770+
text = up_text,
771+
),
772+
MDSnackbarSupportingText(
773+
text = support_text,
774+
),
775+
y=dp(10),
776+
orientation="horizontal",
777+
pos_hint={"center_x": 0.5},
778+
size_hint_x=0.8,
779+
)
780+
show.open()
781+
782+
783+
if option == "invalid":
784+
up_text = "Userhash was not updated!"
785+
support_text = "Provided userhash is invalid."
786+
787+
show = MDSnackbar(
788+
MDSnackbarText(
789+
text = up_text,
790+
),
791+
MDSnackbarSupportingText(
792+
text = support_text,
793+
),
794+
y=dp(10),
795+
orientation="horizontal",
796+
pos_hint={"center_x": 0.5},
797+
size_hint_x=0.8,
798+
)
799+
show.open()
800+
801+
802+
if option == "same":
803+
up_text = "Userhash was not updated!"
804+
support_text = "Provided userhash is the same."
805+
806+
show = MDSnackbar(
807+
MDSnackbarText(
808+
text = up_text,
809+
),
810+
MDSnackbarSupportingText(
811+
text = support_text,
812+
),
813+
y=dp(10),
814+
orientation="horizontal",
815+
pos_hint={"center_x": 0.5},
816+
size_hint_x=0.8,
817+
)
818+
show.open()
819+
820+
754821

755822

756823
MainApp().run()

settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"theme": "Light",
2+
"theme": "Dark",
33
"userhash": ""
44
}

ui.kv

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@ MDScreenManager:
156156
active: True
157157
on_release:
158158
app.list_choice_upd('anon'),
159-
app.add_cb_a()
160159
MDSegmentButtonLabel:
161160
text: 'Anonymous'
162161
MDSegmentedButtonItem:
163162
on_release:
164-
app.list_choice_upd('anon'),
165-
app.add_cb_b()
163+
app.list_choice_upd('auth'),
166164
MDSegmentButtonLabel:
167165
text: 'Authorized'
168166

@@ -413,7 +411,7 @@ MDScreenManager:
413411
MDButton:
414412
style: "tonal"
415413
pos_hint: {"center_x": 0.5, "center_y": 0.6}
416-
on_release: app.show_hash()
414+
on_release: app.show_hash('show')
417415
MDButtonText:
418416
text: "See current userhash"
419417

@@ -427,7 +425,7 @@ MDScreenManager:
427425
role: 'large'
428426

429427
MDLabel:
430-
text: 'v 1.0'
428+
text: 'v 1.1'
431429
padding: dp(10)
432430
halign: 'center'
433431
pos_hint: {"center_x": 0.5, "center_y": 0.02}

0 commit comments

Comments
 (0)