@@ -67,7 +67,9 @@ class BaseView(UserControl):
6767 def __init__ (self , state : AppState , image : str = "placeholder.png" ):
6868 super ().__init__ ()
6969 self .state = state
70+ # right part of the display, add content here.
7071 self .right_view = Column (expand = True )
72+ # left part of the display: used for displaying the images
7173 self .left_view = Column (
7274 width = 600 ,
7375 controls = [Image (src = f"/assets/imgs/{ image } " )],
@@ -81,6 +83,140 @@ def __init__(self, state: AppState, image: str = "placeholder.png"):
8183 )
8284
8385
86+ class RequirementsView (BaseView ):
87+ """View to display requirements and ask for confirmation."""
88+
89+ def __init__ (
90+ self ,
91+ state : AppState ,
92+ on_confirm : Callable ,
93+ ):
94+ super ().__init__ (state = state )
95+ self .on_confirm = on_confirm
96+
97+ def build (self ):
98+ self .continue_button = ElevatedButton (
99+ "Continue" ,
100+ on_click = self .on_confirm ,
101+ icon = icons .NEXT_PLAN_OUTLINED ,
102+ disabled = True ,
103+ expand = True ,
104+ )
105+
106+ # build up the main view
107+ self .right_view .controls .extend (
108+ [
109+ get_title ("Check the Requirements" ),
110+ Text (
111+ "Before continuing you need to check some requirements to progress. Please read the instructions and check the boxes if everything is fine."
112+ ),
113+ Divider (),
114+ ]
115+ )
116+ self .checkboxes = []
117+
118+ def enable_continue_button (e ):
119+ """Enable the continue button if all checkboxes are ticked."""
120+ for checkbox in self .checkboxes :
121+ if not checkbox .value :
122+ logger .info (checkbox )
123+ self .continue_button .disabled = True
124+ return
125+ logger .info ("All requirements ticked. Allow to continue" )
126+ self .continue_button .disabled = False
127+ self .right_view .update ()
128+
129+ # check if there are additional requirements given in the config
130+ if self .state .config .requirements :
131+ # android version
132+ required_android_version = self .state .config .requirements .get ("android" )
133+ if required_android_version :
134+ android_checkbox = Checkbox (
135+ label = "The required android version is installed. (Or I know the risk of continuing)" ,
136+ on_change = enable_continue_button ,
137+ )
138+ android_version_check = Column (
139+ [
140+ Markdown (
141+ f"""
142+ #### Android Version { required_android_version } :
143+ Before following these instructions please ensure that the device is currently using Android { required_android_version } firmware.
144+ If the vendor provided multiple updates for that version, e.g. security updates, make sure you are on the latest!
145+ If your current installation is newer or older than Android { required_android_version } , please upgrade or downgrade to the required
146+ version before proceeding (guides can be found on the internet!).
147+ """
148+ ),
149+ android_checkbox ,
150+ ]
151+ )
152+ self .checkboxes .append (android_checkbox )
153+ self .right_view .controls .append (android_version_check )
154+
155+ # firmware version
156+ required_firmware_version = self .state .config .requirements .get ("firmware" )
157+ if required_firmware_version :
158+ firmware_checkbox = Checkbox (
159+ label = "The required firmware version is installed. (Or I know the risk of continuing)" ,
160+ on_change = enable_continue_button ,
161+ )
162+ firmware_version_check = Column (
163+ [
164+ Markdown (
165+ f"""
166+ #### Firmware Version { required_firmware_version } :
167+ Before following these instructions please ensure that the device is on firmware version { required_firmware_version } .
168+ To discern this, you can run the command `adb shell getprop ro.build.display.id` on the stock ROM.
169+ If the device is not on the specified version, please follow the instructions below to install it.
170+ """
171+ ),
172+ firmware_checkbox ,
173+ ]
174+ )
175+ self .checkboxes .append (firmware_checkbox )
176+ self .right_view .controls .append (firmware_version_check )
177+
178+ # default requirements: battery level
179+ battery_checkbox = Checkbox (
180+ label = "The battery level is over 80%." ,
181+ on_change = enable_continue_button ,
182+ )
183+ battery_version_check = Column (
184+ [
185+ Markdown (
186+ f"""
187+ #### Battery level over 80%
188+ Before continuing make sure your device battery level is above 80%.
189+ """
190+ ),
191+ battery_checkbox ,
192+ ]
193+ )
194+ self .checkboxes .append (battery_checkbox )
195+ self .right_view .controls .append (battery_version_check )
196+
197+ # default requirement: disable lock code and fingerprint
198+ lock_checkbox = Checkbox (
199+ label = "No lock code or fingerprint lock enabled." ,
200+ on_change = enable_continue_button ,
201+ )
202+ lock_check = Column (
203+ [
204+ Markdown (
205+ f"""
206+ #### Disable all device lock codes and fingerprint locks.
207+ """
208+ ),
209+ lock_checkbox ,
210+ ]
211+ )
212+ self .checkboxes .append (lock_checkbox )
213+ self .right_view .controls .append (lock_check )
214+
215+ # add the final confirm and continue button
216+ self .right_view .controls .append (Row ([self .continue_button ], alignment = "center" ))
217+ return self .view
218+
219+
84220class WelcomeView (BaseView ):
85221 def __init__ (
86222 self ,
0 commit comments