This file contains 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
for (file in files) { | |
val gfile = com.google.api.services.drive.model.File() | |
val fileContent = FileContent("your_mime", file) | |
gfile.name = file.name | |
val parents: MutableList<String> = ArrayList(1) | |
parents.add("folder_id") // Here you need to get the parent folder id | |
gfile.parents = parents |
This file contains 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
viewModelScope.launch(Dispatchers.IO) { | |
// Define a Folder | |
val gFolder = com.google.api.services.drive.model.File() | |
// Set file name and MIME | |
gFolder.name = "My Cool Folder Name" | |
gFolder.mimeType = "application/vnd.google-apps.folder" | |
// You can also specify where to create the new Google folder | |
// passing a parent Folder Id | |
val parents: MutableList<String> = ArrayList(1) |
This file contains 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
GoogleSignIn.getLastSignedInAccount(context)?.let { googleAccount -> | |
// get credentials | |
val credential = GoogleAccountCredential.usingOAuth2( | |
context, listOf(DriveScopes.DRIVE, DriveScopes.DRIVE_FILE) | |
) | |
credential.selectedAccount = googleAccount.account!! | |
// get Drive Instance | |
val drive = Drive |
This file contains 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
fun getGoogleSignInClient(context: Context): GoogleSignInClient { | |
val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) | |
.requestEmail() | |
.requestScopes(Scope(DriveScopes.DRIVE_FILE), Scope(DriveScopes.DRIVE)) | |
.build() | |
return GoogleSignIn.getClient(context, signInOptions) | |
} |
This file contains 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
Button( | |
onClick = { | |
startForResult.launch(getGoogleSignInClient(ctx).signInIntent) | |
}, | |
modifier = Modifier() | |
) { | |
Text(text = "Sign in with Google") | |
} |
This file contains 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
val startForResult = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult -> | |
if (result.resultCode == Activity.RESULT_OK) { | |
val intent = result.data | |
if (result.data != null) { | |
val task: Task<GoogleSignInAccount> = | |
GoogleSignIn.getSignedInAccountFromIntent(intent) | |
/** | |
* handle [task] result | |
*/ |
This file contains 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
// ... | |
// coroutines | |
// Guava | |
implementation "com.google.guava:guava:24.1-jre" | |
// Guava fix | |
implementation "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" | |
//Drive | |
implementation('com.google.api-client:google-api-client-android:1.23.0') { |
This file contains 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
function createHomeCard() { | |
const imgLogoUri = "http://your.home.page.image.link"; | |
const imgLogo = CardService.newImage() | |
.setImageUrl(imgLogoUri) | |
.setAltText("Digit-Atoms"); | |
const footer = CardService.newFixedFooter().setPrimaryButton( | |
CardService.newTextButton() | |
.setTextButtonStyle(CardService.TextButtonStyle.FILLED) |
This file contains 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
const txtInsertId = | |
CardService.newTextParagraph().setText("<b>Bold text</b><br/> -Can you read this?"); | |
const textInput = CardService.newTextInput() | |
.setFieldName("txt_input_id_to_process") | |
.setTitle("Write something here..."); | |
const ico = CardService.newIconImage().setIconUrl( | |
"ico link" | |
); |
This file contains 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
/** | |
* Callback for rendering the homepage card. | |
* @return The card to show to the user. | |
*/ | |
function onHomepage(e) { | |
return createHomeCard(); | |
} | |
/** | |
* Build the home card |
NewerOlder