@@ -55,42 +55,49 @@ const ConnectedDeviceInfo: React.FC<ConnectedDeviceInfoProps> = ({ isDarkTheme }
5555 }
5656
5757 // Request permissions on Android
58- if ( Platform . OS === 'android' && Platform . Version >= 23 ) {
59- PermissionsAndroid . requestMultiple ( [
60- PermissionsAndroid . PERMISSIONS . BLUETOOTH_SCAN ,
61- PermissionsAndroid . PERMISSIONS . BLUETOOTH_CONNECT ,
62- PermissionsAndroid . PERMISSIONS . ACCESS_FINE_LOCATION ,
63- ] ) . then ( async ( result ) => {
64- console . log ( 'Permissions granted:' , result ) ;
58+ if ( Platform . OS === 'android' && Platform . Version >= 23 ) {
59+ PermissionsAndroid . requestMultiple ( [
60+ PermissionsAndroid . PERMISSIONS . BLUETOOTH_SCAN ,
61+ PermissionsAndroid . PERMISSIONS . BLUETOOTH_CONNECT ,
62+ PermissionsAndroid . PERMISSIONS . ACCESS_FINE_LOCATION ,
63+ ] ) . then ( async ( result ) => {
64+ console . log ( 'Permissions granted:' , result ) ;
6565
66- const allGranted = Object . values ( result ) . every (
67- ( value ) => value === PermissionsAndroid . RESULTS . GRANTED
68- ) ;
66+ const allGranted = Object . values ( result ) . every (
67+ ( value ) => value === PermissionsAndroid . RESULTS . GRANTED
68+ ) ;
6969
70- if ( allGranted ) {
71- try {
72- await checkAndRequestNotificationAccessSpecialPermission ( ) ;
73- } catch ( error ) {
74- console . warn ( 'Notification permission request error:' , error ) ;
75- }
76- } else {
77- console . warn ( 'Some permissions were denied:' , result ) ;
78- // Optionally handle partial denial here
79- }
80- } )
81- . catch ( ( error ) => {
82- console . error ( 'Error requesting permissions:' , error ) ;
83- } ) ;
84- }
70+ if ( allGranted ) {
71+ try {
72+ await checkAndRequestNotificationAccessSpecialPermission ( ) ;
73+ } catch ( error ) {
74+ console . warn ( 'Notification permission request error:' , error ) ;
75+ }
76+ } else {
77+ console . warn ( 'Some permissions were denied:' , result ) ;
78+ // Optionally handle partial denial here
79+ Alert . alert (
80+ 'Permissions Required' ,
81+ 'Some permissions were denied. Please go to Settings and enable all required permissions for the app to function properly.' ,
82+ [
83+ { text : 'OK' , style : 'default' }
84+ ]
85+ ) ;
86+ }
87+ } )
88+ . catch ( ( error ) => {
89+ console . error ( 'Error requesting permissions:' , error ) ;
90+ } ) ;
91+ }
8592
86- // Cleanup function
87- return ( ) => {
88- fadeAnim . stopAnimation ( ) ;
89- scaleAnim . stopAnimation ( ) ;
90- slideAnim . stopAnimation ( ) ;
91- } ;
92- } , [ status . puck_connected , fadeAnim , scaleAnim , slideAnim ] )
93- ) ;
93+ // Cleanup function
94+ return ( ) => {
95+ fadeAnim . stopAnimation ( ) ;
96+ scaleAnim . stopAnimation ( ) ;
97+ slideAnim . stopAnimation ( ) ;
98+ } ;
99+ } , [ status . puck_connected , fadeAnim , scaleAnim , slideAnim ] )
100+ ) ;
94101
95102 const handleConnectToPuck = async ( ) => {
96103 try {
@@ -173,31 +180,31 @@ const ConnectedDeviceInfo: React.FC<ConnectedDeviceInfoProps> = ({ isDarkTheme }
173180 < >
174181 < Animated . View style = { [ styles . statusBar , { opacity : fadeAnim } ] } >
175182 < View style = { styles . statusInfo } >
176- { status . glasses_info ?. battery_life &&
183+ { status . glasses_info ?. battery_life != null && status . glasses_info ?. battery_life >= 0 &&
177184 < >
178185 < Text style = { [ styles . statusLabel , { color : themeStyles . statusLabelColor } ] } > Battery</ Text >
179186 < View style = { styles . batteryContainer } >
180187 < Icon name = { batteryIcon } size = { 16 } color = { batteryColor } style = { styles . batteryIcon } />
181188 < Text style = { [ styles . batteryValue , { color : batteryColor } ] } >
182- { status . glasses_info . battery_life == - 1
183- ? "?"
184- : `${ status . glasses_info . battery_life } %` }
189+ { status . glasses_info . battery_life == - 1
190+ ? "-"
191+ : `${ status . glasses_info . battery_life } %` }
185192 </ Text >
186193 </ View >
187194 </ >
188195 }
189196 </ View >
190197
191198 < View style = { styles . statusInfo } >
192- { status . glasses_info ?. brightness &&
193- < >
194- < Text style = { [ styles . statusLabel , { color : themeStyles . statusLabelColor } ] } > Brightness</ Text >
195- < Text style = { [ styles . statusValue , { color : themeStyles . statusValueColor } ] } >
196- { status . glasses_info
197- ? `${ status . glasses_info . brightness } `
198- : "? " }
199- </ Text >
200- </ >
199+ { status . glasses_info ?. brightness != null &&
200+ < >
201+ < Text style = { [ styles . statusLabel , { color : themeStyles . statusLabelColor } ] } > Brightness</ Text >
202+ < Text style = { [ styles . statusValue , { color : themeStyles . statusValueColor } ] } >
203+ { status . glasses_info
204+ ? `${ status . glasses_info . brightness } `
205+ : "- " }
206+ </ Text >
207+ </ >
201208 }
202209 </ View >
203210 < TouchableOpacity
@@ -210,19 +217,19 @@ const ConnectedDeviceInfo: React.FC<ConnectedDeviceInfoProps> = ({ isDarkTheme }
210217 </ Animated . View >
211218 </ >
212219 ) : (
213- < View style = { styles . statusInfoNotConnected } >
214- { status . glasses_info ?. is_searching ? (
215- < View style = { styles . disconnectedContent } >
216- < ActivityIndicator size = "small" color = "#2196F3" />
217- </ View >
218- ) : (
219- < View style = { styles . noGlassesContent } >
220- < TouchableOpacity style = { styles . connectButton } onPress = { connectGlasses } >
221- < Text style = { styles . buttonText } > Connect</ Text >
222- </ TouchableOpacity >
223- </ View >
224- ) }
225- </ View >
220+ < View style = { styles . statusInfoNotConnected } >
221+ { status . glasses_info ?. is_searching ? (
222+ < View style = { styles . disconnectedContent } >
223+ < ActivityIndicator size = "small" color = "#2196F3" />
224+ </ View >
225+ ) : (
226+ < View style = { styles . noGlassesContent } >
227+ < TouchableOpacity style = { styles . connectButton } onPress = { connectGlasses } >
228+ < Text style = { styles . buttonText } > Connect</ Text >
229+ </ TouchableOpacity >
230+ </ View >
231+ ) }
232+ </ View >
226233 ) }
227234 </ View >
228235 ) : (
@@ -307,7 +314,7 @@ const styles = StyleSheet.create({
307314 statusInfoNotConnected : {
308315 alignItems : 'center' ,
309316 flex : 1 ,
310- width :'100%'
317+ width : '100%'
311318 } ,
312319 statusInfo : {
313320 alignItems : 'center' ,
0 commit comments