-
Notifications
You must be signed in to change notification settings - Fork 0
Request all platform permissions and add Android permission demos for CodeBuilder Admin #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bfa686e
Initial plan
Copilot 06595ea
Declare comprehensive permissions
Copilot 6f4302d
Add permissions demos and merge main
Copilot 70d5883
Polish permission demos
Copilot 624d6dc
Clarify permission handling
Copilot 140afa6
Merge Conflicts + Organized / De-Duped Permissions Lists.
digitalnomad91 6ebeb93
Removed typo.
digitalnomad91 2cbbfa5
Updated .env.example.
digitalnomad91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import CameraMicrophonePermissionDemo from '@/components/permissions/CameraMicrophonePermissionDemo'; | ||
|
|
||
| export default function CameraMicScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Camera & Microphone" showBackButton /> | ||
| <CameraMicrophonePermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import BluetoothNearbyPermissionDemo from '@/components/permissions/BluetoothNearbyPermissionDemo'; | ||
|
|
||
| export default function ConnectivityScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Bluetooth & Nearby" showBackButton /> | ||
| <BluetoothNearbyPermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { Link } from 'expo-router'; | ||
| import React from 'react'; | ||
| import { View, Text, StyleSheet, ScrollView, Pressable } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
|
|
||
| const routes = [ | ||
| { href: '/permissions/location', title: 'Location (foreground/background)' }, | ||
| { href: '/permissions/camera-mic', title: 'Camera & Microphone' }, | ||
| { href: '/permissions/notifications', title: 'Notifications' }, | ||
| { href: '/permissions/media-storage', title: 'Media Library' }, | ||
| { href: '/permissions/storage', title: 'Storage & File Access' }, | ||
| { href: '/permissions/telephony-sms', title: 'Telephony & SMS' }, | ||
| { href: '/permissions/connectivity', title: 'Bluetooth & Nearby' }, | ||
| ]; | ||
|
|
||
| export default function PermissionsHub() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Permissions Hub" /> | ||
| <ScrollView contentContainerStyle={styles.content}> | ||
| <Text style={styles.lead}> | ||
| Explore Android permission demos. Each link opens a focused screen that requests the associated runtime permissions and | ||
| performs a small capability check. | ||
| </Text> | ||
| {routes.map((route) => ( | ||
| <View style={styles.card} key={route.href}> | ||
| <Text style={styles.cardTitle}>{route.title}</Text> | ||
| <Link href={route.href} asChild> | ||
| <Pressable style={styles.button}> | ||
| <Text style={styles.buttonText}>Open demo</Text> | ||
| </Pressable> | ||
| </Link> | ||
| </View> | ||
| ))} | ||
| </ScrollView> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| content: { padding: 16, gap: 12 }, | ||
| lead: { color: '#ccc', fontSize: 14, lineHeight: 20, marginBottom: 6 }, | ||
| card: { | ||
| backgroundColor: '#111', | ||
| padding: 16, | ||
| borderRadius: 10, | ||
| gap: 8, | ||
| borderWidth: 1, | ||
| borderColor: '#222', | ||
| }, | ||
| cardTitle: { color: '#fff', fontSize: 16, fontWeight: '600' }, | ||
| button: { | ||
| backgroundColor: '#1e88e5', | ||
| paddingVertical: 10, | ||
| borderRadius: 8, | ||
| alignItems: 'center', | ||
| }, | ||
| buttonText: { color: '#fff', fontWeight: '600' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import LocationPermissionDemo from '@/components/permissions/LocationPermissionDemo'; | ||
|
|
||
| export default function LocationScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Location permissions" showBackButton /> | ||
| <LocationPermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import MediaLibraryPermissionDemo from '@/components/permissions/MediaLibraryPermissionDemo'; | ||
|
|
||
| export default function MediaStorageScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Media Library" showBackButton /> | ||
| <MediaLibraryPermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import NotificationsPermissionDemo from '@/components/permissions/NotificationsPermissionDemo'; | ||
|
|
||
| export default function NotificationsScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Notifications" showBackButton /> | ||
| <NotificationsPermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import StoragePermissionDemo from '@/components/permissions/StoragePermissionDemo'; | ||
|
|
||
| export default function StorageScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Storage" showBackButton /> | ||
| <StoragePermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { View, StyleSheet } from 'react-native'; | ||
| import CustomHeader from '@/components/CustomHeader'; | ||
| import TelephonySmsPermissionDemo from '@/components/permissions/TelephonySmsPermissionDemo'; | ||
|
|
||
| export default function TelephonySmsScreen() { | ||
| return ( | ||
| <View style={styles.container}> | ||
| <CustomHeader title="Telephony & SMS" showBackButton /> | ||
| <TelephonySmsPermissionDemo /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| }); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import React, { useState } from 'react'; | ||
| import { View, Text, Button, StyleSheet, ScrollView, PermissionsAndroid, Platform } from 'react-native'; | ||
|
|
||
| const REQUESTS = [ | ||
| PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, | ||
| PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, | ||
| PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE, | ||
| PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, | ||
| PermissionsAndroid.PERMISSIONS.NEARBY_WIFI_DEVICES, | ||
| ]; | ||
|
|
||
| export default function BluetoothNearbyPermissionDemo() { | ||
| const [statuses, setStatuses] = useState<Record<string, string>>({}); | ||
|
|
||
| const request = async () => { | ||
| if (Platform.OS !== 'android') { | ||
| setStatuses({ platform: 'Only relevant on Android' }); | ||
| return; | ||
| } | ||
| const results = await PermissionsAndroid.requestMultiple(REQUESTS); | ||
| setStatuses(results); | ||
| }; | ||
|
|
||
| return ( | ||
| <ScrollView style={styles.container} contentContainerStyle={styles.content}> | ||
| <Text style={styles.title}>Bluetooth & Nearby</Text> | ||
| <Text style={styles.copy}> | ||
| Requests BLUETOOTH_CONNECT / SCAN / ADVERTISE along with NEARBY_WIFI_DEVICES and fine location to showcase nearby device | ||
| discovery prerequisites. | ||
| </Text> | ||
| <Button title="Request nearby permissions" onPress={request} /> | ||
| <View style={styles.statusBox}> | ||
| {Object.keys(statuses).length === 0 ? ( | ||
| <Text style={styles.statusText}>No results yet</Text> | ||
| ) : ( | ||
| Object.entries(statuses).map(([key, value]) => ( | ||
| <Text style={styles.statusText} key={key}> | ||
| {key.split('.').pop()}: {value} | ||
| </Text> | ||
| )) | ||
| )} | ||
| </View> | ||
| </ScrollView> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| content: { padding: 16, gap: 12 }, | ||
| title: { color: '#fff', fontSize: 18, fontWeight: '700' }, | ||
| copy: { color: '#ccc', fontSize: 14, lineHeight: 20 }, | ||
| statusBox: { backgroundColor: '#111', padding: 12, borderRadius: 8, marginTop: 12 }, | ||
| statusText: { color: '#fff', marginBottom: 4 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import React, { useState } from 'react'; | ||
| import { View, Text, Button, StyleSheet, ScrollView } from 'react-native'; | ||
| import { Camera } from 'expo-camera'; | ||
|
|
||
| export default function CameraMicrophonePermissionDemo() { | ||
| const [cameraStatus, setCameraStatus] = useState<string>('unknown'); | ||
| const [micStatus, setMicStatus] = useState<string>('unknown'); | ||
| const [availableTypes, setAvailableTypes] = useState<string>('not queried'); | ||
|
|
||
| const requestPermissions = async () => { | ||
| const camera = await Camera.requestCameraPermissionsAsync(); | ||
| const mic = await Camera.requestMicrophonePermissionsAsync(); | ||
| setCameraStatus(camera.status); | ||
| setMicStatus(mic.status); | ||
|
|
||
| if (camera.status === 'granted') { | ||
| const types = await Camera.getAvailableCameraTypesAsync(); | ||
| setAvailableTypes(types.join(', ') || 'none reported'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <ScrollView style={styles.container} contentContainerStyle={styles.content}> | ||
| <Text style={styles.title}>Camera & Microphone</Text> | ||
| <Text style={styles.copy}> | ||
| Requests CAMERA and RECORD_AUDIO plus microphone access via expo-camera. Queries available camera types once granted. | ||
| </Text> | ||
| <Button title="Request camera & mic permissions" onPress={requestPermissions} /> | ||
| <View style={styles.statusBox}> | ||
| <Text style={styles.statusText}>Camera: {cameraStatus}</Text> | ||
| <Text style={styles.statusText}>Microphone: {micStatus}</Text> | ||
| <Text style={styles.statusText}>Available cameras: {availableTypes}</Text> | ||
| </View> | ||
| </ScrollView> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| content: { padding: 16, gap: 12 }, | ||
| title: { color: '#fff', fontSize: 18, fontWeight: '700' }, | ||
| copy: { color: '#ccc', fontSize: 14, lineHeight: 20 }, | ||
| statusBox: { backgroundColor: '#111', padding: 12, borderRadius: 8, marginTop: 12 }, | ||
| statusText: { color: '#fff', marginBottom: 4 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import React, { useState } from 'react'; | ||
| import { View, Text, Button, StyleSheet, ScrollView, Platform } from 'react-native'; | ||
| import * as Location from 'expo-location'; | ||
|
|
||
| export default function LocationPermissionDemo() { | ||
| const [status, setStatus] = useState<Location.PermissionStatus | null>(null); | ||
| const [backgroundStatus, setBackgroundStatus] = useState<Location.PermissionStatus | null>(null); | ||
| const [coords, setCoords] = useState<string>(''); | ||
| const [error, setError] = useState<string>(''); | ||
|
|
||
| const requestPermissions = async () => { | ||
| setError(''); | ||
| const fg = await Location.requestForegroundPermissionsAsync(); | ||
| setStatus(fg.status); | ||
|
|
||
| if (Platform.OS === 'android') { | ||
| const bg = await Location.requestBackgroundPermissionsAsync(); | ||
| setBackgroundStatus(bg.status); | ||
| } | ||
| }; | ||
|
|
||
| const fetchLocation = async () => { | ||
| try { | ||
| const loc = await Location.getCurrentPositionAsync({}); | ||
| setCoords(`${loc.coords.latitude.toFixed(5)}, ${loc.coords.longitude.toFixed(5)}`); | ||
| } catch (e) { | ||
| setError(e instanceof Error ? e.message : String(e)); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <ScrollView style={styles.container} contentContainerStyle={styles.content}> | ||
| <Text style={styles.title}>Location (foreground & background)</Text> | ||
| <Text style={styles.copy}> | ||
| Requests ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, ACCESS_BACKGROUND_LOCATION and demonstrates fetching a single | ||
| location fix via expo-location. | ||
| </Text> | ||
|
|
||
| <Button title="Request location permissions" onPress={requestPermissions} /> | ||
| <View style={styles.gap} /> | ||
| <Button title="Fetch current location" onPress={fetchLocation} /> | ||
|
|
||
| <View style={styles.statusBox}> | ||
| <Text style={styles.statusText}>Foreground: {status ?? 'unknown'}</Text> | ||
| {Platform.OS === 'android' && <Text style={styles.statusText}>Background: {backgroundStatus ?? 'unknown'}</Text>} | ||
| {coords ? <Text style={styles.statusText}>Last fix: {coords}</Text> : null} | ||
| {error ? <Text style={[styles.statusText, styles.error]}>{error}</Text> : null} | ||
| </View> | ||
| </ScrollView> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { flex: 1, backgroundColor: '#000' }, | ||
| content: { padding: 16, gap: 12 }, | ||
| title: { color: '#fff', fontSize: 18, fontWeight: '700' }, | ||
| copy: { color: '#ccc', fontSize: 14, lineHeight: 20 }, | ||
| statusBox: { backgroundColor: '#111', padding: 12, borderRadius: 8, marginTop: 12 }, | ||
| statusText: { color: '#fff', marginBottom: 4 }, | ||
| error: { color: '#ff6b6b' }, | ||
| gap: { height: 10 }, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env.exampleincludes a specific LAN IP forREACT_NATIVE_PACKAGER_HOSTNAME. Keeping a machine-specific address in an example file is likely to break other developers’ setups if copied verbatim; use a placeholder value (or omit it and document when/why to set it).