Skip to content

Commit

Permalink
Implement google picker (#120)
Browse files Browse the repository at this point in the history
* Implement google picker

* Disable workflows

* Disable workflows
  • Loading branch information
cp-pratik-k authored Feb 26, 2025
1 parent 3117a21 commit 70caa64
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build

on: push
on:
workflow_dispatch:

jobs:
build:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/android_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Publish to Google Play Store

on:
push:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ios_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Publish to App Store Connect

on:
push:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
12 changes: 8 additions & 4 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions docs/pickers/google_picker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cloud Gallery - Google Picker</title>
<script>
let accessToken = null;
let appId = null;
let apiKey = null;

function onApiLoad() {
gapi.load('picker', onPickerApiLoad);
}

function onPickerApiLoad() {
console.log("Google Picker API Loaded");
}

function createPicker() {
if (!accessToken || !appId || !apiKey) {
console.error("Authentication Failed");
return;
}

const picker = new google.picker.PickerBuilder()
.addView(google.picker.ViewId.DOCS_IMAGES_AND_VIDEOS)
.addView(google.picker.ViewId.FOLDERS)
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.setOAuthToken(accessToken)
.setDeveloperKey(apiKey)
.setCallback(pickerCallback)
.setAppId(appId)
.build();
picker.setVisible(true);
}

function pickerCallback(data) {
if (data.action === google.picker.Action.PICKED) {
console.log("Picked:", data.docs);
window.flutterWebView.postMessage(JSON.stringify(data.docs));
}
}

function receiveAccessToken(token, key, id) {
accessToken = token;
appId = id;
apiKey = key;
console.log("Authentication with", accessToken, appId, apiKey);
}
</script>
<script async defer src="https://apis.google.com/js/api.js" onload="onApiLoad()"></script>
</head>
<body>
<center>
<h1>Grant Access</h1>
<br>
<p>Click the button below to grant access to your Google Drive</p>
<br>
<button onclick="createPicker()">Show Picker</button>
</center>
</body>
</html>

0 comments on commit 70caa64

Please sign in to comment.