Skip to content

Instantly share code, notes, and snippets.

View AZKZero's full-sized avatar
🏠
Working from home

Abdullah Zowad Khan AZKZero

🏠
Working from home
View GitHub Profile
@ianhanniballake
ianhanniballake / PickImageContracts.kt
Last active September 10, 2022 18:03
Gist showing how to write backward compatible ActivityResultContracts for supporting Android 13's new Photo Picker: https://developer.android.com/about/versions/13/features/photopicker
/**
* Use this [ActivityResultContract] to seamlessly switch between
* the new [MediaStore.ACTION_PICK_IMAGES] and [Intent.ACTION_GET_CONTENT]
* based on the availability of the Photo Picker.
*
* Use [PickMultipleImages] if you'd like the user to be able to select multiple
* photos/videos.
*
* Input: the mimeType you'd like to receive. This should generally be
* either `image/\*` or `video/\*` for requesting only images or only videos
export const covid19UserResponse = functions.https.onCall(async (data, context) => {
try {
// https://docs.google.com/spreadsheets/d/13x-6koKiqRnIK6_trJX-abLJyi65OzqV621u9iwM1qw/edit#gid=2008915096
await admin.firestore().collection('corona-user-responses').add(data);
// tslint:disable-next-line:radix
let is_elder = parseInt(data['age']['answer']) > 60 ? '1' : '0';
let has_diseases_history = data['high_risk']['answer'] === 'true' ? '1' : '0';