@@ -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
756823MainApp ().run ()
0 commit comments