@@ -8,35 +8,6 @@ class About(Activity):
88 logger = logging .getLogger (__file__ )
99 logger .setLevel (logging .INFO )
1010
11- def _add_label (self , parent , text , is_header = False , margin_top = DisplayMetrics .pct_of_height (5 )):
12- """Helper to create and add a label with text."""
13- label = lv .label (parent )
14- label .set_text (text )
15- if is_header :
16- primary_color = lv .theme_get_color_primary (None )
17- label .set_style_text_color (primary_color , lv .PART .MAIN )
18- label .set_style_text_font (lv .font_montserrat_14 , lv .PART .MAIN )
19- label .set_style_margin_top (margin_top , lv .PART .MAIN )
20- label .set_style_margin_bottom (DisplayMetrics .pct_of_height (2 ), lv .PART .MAIN )
21- else :
22- label .set_style_text_font (lv .font_montserrat_12 , lv .PART .MAIN )
23- label .set_style_margin_bottom (2 , lv .PART .MAIN )
24- return label
25-
26- def _add_disk_info (self , screen , path ):
27- """Helper to add disk usage info for a given path."""
28- import os
29- try :
30- stat = os .statvfs (path )
31- total_space = stat [0 ] * stat [2 ]
32- free_space = stat [0 ] * stat [3 ]
33- used_space = total_space - free_space
34- self ._add_label (screen , f"Total space { path } : { total_space } bytes" )
35- self ._add_label (screen , f"Free space { path } : { free_space } bytes" )
36- self ._add_label (screen , f"Used space { path } : { used_space } bytes" )
37- except Exception as e :
38- self .logger .warning (f"About app could not get info on { path } filesystem: { e } " )
39-
4011 def onCreate (self ):
4112 screen = lv .obj ()
4213 screen .set_style_border_width (0 , lv .PART .MAIN )
@@ -183,3 +154,50 @@ def onCreate(self):
183154 self ._add_disk_info (screen , '/sdcard' )
184155
185156 self .setContentView (screen )
157+
158+ @staticmethod
159+ def _focus_obj (event ):
160+ target = event .get_target_obj ()
161+ target .set_style_border_color (lv .theme_get_color_primary (None ),lv .PART .MAIN )
162+ target .set_style_border_width (1 , lv .PART .MAIN )
163+ target .scroll_to_view (True )
164+
165+ @staticmethod
166+ def _defocus_obj (event ):
167+ target = event .get_target_obj ()
168+ target .set_style_border_width (0 , lv .PART .MAIN )
169+
170+ def _add_label (self , parent , text , is_header = False , margin_top = DisplayMetrics .pct_of_height (5 )):
171+ """Helper to create and add a label with text."""
172+ label = lv .label (parent )
173+ label .set_text (text )
174+ # Make labels focusable to allow scroll on devices without touch screen
175+ label .add_event_cb (self ._focus_obj , lv .EVENT .FOCUSED , None )
176+ label .add_event_cb (self ._defocus_obj , lv .EVENT .DEFOCUSED , None )
177+ focusgroup = lv .group_get_default ()
178+ if focusgroup :
179+ focusgroup .add_obj (label )
180+ if is_header :
181+ primary_color = lv .theme_get_color_primary (None )
182+ label .set_style_text_color (primary_color , lv .PART .MAIN )
183+ label .set_style_text_font (lv .font_montserrat_14 , lv .PART .MAIN )
184+ label .set_style_margin_top (margin_top , lv .PART .MAIN )
185+ label .set_style_margin_bottom (DisplayMetrics .pct_of_height (2 ), lv .PART .MAIN )
186+ else :
187+ label .set_style_text_font (lv .font_montserrat_12 , lv .PART .MAIN )
188+ label .set_style_margin_bottom (2 , lv .PART .MAIN )
189+ return label
190+
191+ def _add_disk_info (self , screen , path ):
192+ """Helper to add disk usage info for a given path."""
193+ import os
194+ try :
195+ stat = os .statvfs (path )
196+ total_space = stat [0 ] * stat [2 ]
197+ free_space = stat [0 ] * stat [3 ]
198+ used_space = total_space - free_space
199+ self ._add_label (screen , f"Total space { path } : { total_space } bytes" )
200+ self ._add_label (screen , f"Free space { path } : { free_space } bytes" )
201+ self ._add_label (screen , f"Used space { path } : { used_space } bytes" )
202+ except Exception as e :
203+ self .logger .warning (f"About app could not get info on { path } filesystem: { e } " )
0 commit comments