-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Add Firebase Data Connect quickstart #1671
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 44 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
2648e40
Initial commit for dataconnect sample app
thatfiredev 2e242ff
chore: add Firebase dependencies
thatfiredev bc89f0b
add first schema
thatfiredev 441033f
update with new schema
thatfiredev 3c99916
add kotlin serialization and androidx.lifecycle
thatfiredev 44a274d
firebase init
thatfiredev 08a034c
setup bottom navigation
thatfiredev 1273149
feat: create movies screen
thatfiredev 30d6298
add firebase data connect logo
thatfiredev 6bb2988
add top 10 movies and latest to the MoviesScreen
thatfiredev 84bf1b0
create GenresScreen
thatfiredev 0b156e2
create GenreDetailScreen
thatfiredev d288623
create MovieDetailScreen
thatfiredev 7d7170e
Merge branch 'master' of github.com:firebase/quickstart-android into …
thatfiredev bdcd7e8
chore: bump gradle plugins
thatfiredev 27aa537
test: delete test modules
thatfiredev 24ca051
chore: add compose compiler
thatfiredev ab176f6
chore: move location from firebase.json to dataconnect.yaml
thatfiredev de4b232
feat: create an auth screen
thatfiredev d6de3cc
create user profile favorites list and sign out button
thatfiredev acc78fc
ellipsize text in Movie Tile
thatfiredev f37f21e
refactor: reuse MovieTile UI component
thatfiredev afe7d69
delete UserRepository
thatfiredev e3dd016
refactor: delete MovieRepository
thatfiredev eb76c92
refactor: delete the data package
thatfiredev 6a29c55
feat: list actors in the movie details screen
thatfiredev 0b9ef77
refactor: movie review list to bottom of profile screen
thatfiredev 1af90a7
feat: add reviews to movie detail screen
thatfiredev d9293ae
refactor: dateformat for reviews
thatfiredev a309c17
feat: mark movies as watched and/or favorite
thatfiredev 7fa7803
refactor: move AuthScreen into its own file
thatfiredev 609e504
docs: add a README file
thatfiredev 30a904b
feat: support reviewing movies :)
thatfiredev 14034c6
feat: create actor details screen
thatfiredev dff9533
refactor: make actor list reusable
thatfiredev 155d7a5
refactor: make movies list reusable
thatfiredev b15d0ab
refactor: make error and loading reusable components
thatfiredev 49a20a1
refactor: make toggle button reusable
thatfiredev 8546e34
refactor: make actor details screen stateless
thatfiredev a45c5d4
refactor: move UserReviews into its own dedicated file
thatfiredev f0f5ce4
refactor: turn actor tile into a card
thatfiredev bca483a
docs: update the getting started
thatfiredev a24417e
docs: update README.md
thatfiredev a8b2bf5
docs: update README.md
thatfiredev c06b22c
add data_seed.gql and useEmulator()
thatfiredev 2912f29
Update README.md
thatfiredev 142dcb9
refactor: use Navigation type safety
thatfiredev 3e0b914
refactor: delete extra uiState
thatfiredev 496af82
refactor favoriteActor for readability
thatfiredev 287adb1
refactor: make error messages nullable and add default error message
thatfiredev 01e072a
refactor: ensure a user is logged in before marking as favorite
thatfiredev 6077294
update GenreDetailScreen
thatfiredev 4a4401b
chore: use v1beta
thatfiredev 172e457
ci: remove Data Connect from build
thatfiredev 68b2595
chore: upgrade to 16.0.0-beta01
thatfiredev 8dc1a40
ci: remove -i parameter
thatfiredev 782010b
ci: output file
thatfiredev f76a395
Merge branch 'master' of github.com:firebase/quickstart-android into …
thatfiredev 851252f
ci: overwrite instead of append
thatfiredev 922c940
chore: agp 8.7.0
thatfiredev 85f1fb9
testing
thatfiredev a2e39b7
revert ci changes
thatfiredev d7fcb93
ci: add python script to remove fdc
thatfiredev d4249df
docs: update README.md
thatfiredev 83c7a3d
docs: remove deploy step
thatfiredev 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
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 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
.dataconnect/ | ||
.firebaserc |
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,97 @@ | ||
# Firebase Data Connect Quickstart | ||
|
||
## Introduction | ||
|
||
This quickstart is a movie review app to demonstrate the use of Firebase Data Connect | ||
with a Cloud SQL database. | ||
For more information about Firebase Data Connect visit [the docs](https://firebase.google.com/docs/data-connect/). | ||
|
||
## Getting Started | ||
|
||
Follow these steps to get up and running with Firebase Data Connect. For more detailed instructions, | ||
check out the [official documentation](https://firebase.google.com/docs/data-connect/quickstart). | ||
|
||
### 1. Connect to your Firebase project | ||
|
||
1. If you haven't already, create a Firebase project. | ||
1. In the [Firebase console](https://console.firebase.google.com), click | ||
**Add project**, then follow the on-screen instructions. | ||
|
||
2. Upgrade your project to the Blaze plan. This lets you create a Cloud SQL | ||
for PostgreSQL instance. | ||
|
||
> Note: Though you set up billing in your Blaze upgrade, you won't be | ||
charged for usage of Firebase Data Connect or the | ||
[default Cloud SQL for PostgreSQL configuration](https://firebase.google.com/docs/data-connect/#pricing) | ||
during the preview. | ||
|
||
3. Navigate to the [Data Connect section](https://console.firebase.google.com/u/0/project/_/dataconnect) | ||
of the Firebase console and follow the setup workflow: | ||
- Select a location for your Cloud SQL for PostgreSQL database (this sample uses `us-central1`). If you choose a different location, you'll also need to change the `quickstart-android/dataconnect/dataconnect/dataconnect.yaml` file. | ||
- Fill in the following fields: | ||
thatfiredev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Service ID: `dataconnect` | ||
- Cloud SQL Instance: `fdc-sql` | ||
thatfiredev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Database name: `fdcdb` | ||
4. Allow some time for the Cloud SQL instance to be provisioned. After it's provisioned, the instance | ||
can be managed in the [Cloud Console](https://console.cloud.google.com/sql). | ||
|
||
5. Download and then add the Firebase Android configuration file (`google-services.json`) to your app: | ||
thatfiredev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1. Click **Download google-services.json** to obtain your Firebase Android config file. | ||
2. Move your config file into the `quickstart-android/dataconnect/app` directory. | ||
|
||
### 2. Set Up Firebase CLI | ||
|
||
Ensure the Firebase CLI is installed and up to date: | ||
|
||
```bash | ||
npm install -g firebase-tools | ||
``` | ||
|
||
thatfiredev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### 3. Cloning the repository | ||
This repository contains the quickstart to get started with the functionalities of Data Connect. | ||
|
||
1. Clone this repository to your local machine: | ||
```sh | ||
git clone https://github.com/firebase/quickstart-android.git | ||
``` | ||
|
||
2. (Private Preview only) Checkout the `fdc-quickstart` branch (`git checkout fdc-quickstart`) | ||
and open the project in Android Studio. | ||
thatfiredev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### 4. Deploy the service to Firebase and generate SDKs | ||
|
||
1. Open the `quickstart-android/dataconnect/dataconnect` directory and deploy the schema with | ||
the following command: | ||
```bash | ||
firebase deploy | ||
``` | ||
2. Once the deploy is complete, you should be able to see the movie schema in the | ||
[Data Connect section](https://console.firebase.google.com/u/0/project/_/dataconnect) | ||
of the Firebase console. | ||
|
||
3. Generate the Kotlin SDK by running: | ||
```bash | ||
firebase dataconnect:sdk:generate | ||
``` | ||
|
||
### 5. Populating the database | ||
1. Run `1_movie_insert.gql`, `2_actor_insert.gql`, `3_movie_actor_insert.gql`, and `4_user_favorites_review_insert.gql` files in the `./dataconnect` directory in order using the VS code extension, | ||
|
||
### 6. Running the app | ||
|
||
Press the Run button in Android Studio to run the sample app on your device. | ||
|
||
## 🚧 Work in Progress | ||
|
||
This app is still missing some features which will be added before Public Preview: | ||
|
||
- [ ] Search | ||
- [ ] Movie review | ||
- [x] Add a new review | ||
- [ ] Update a review | ||
- [ ] Delete a review | ||
- [x] Actors | ||
- [x] Show actor profile | ||
- [x] Mark actor as favorite | ||
- [ ] Error handling | ||
Some errors may cause the app to crash, especially if there's no user logged in. |
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 @@ | ||
/build |
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,84 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
alias(libs.plugins.kotlin.serialization) | ||
alias(libs.plugins.google.services) | ||
alias(libs.plugins.compose.compiler) | ||
} | ||
|
||
android { | ||
namespace = "com.google.firebase.example.dataconnect" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.google.firebase.example.dataconnect" | ||
minSdk = 23 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.13" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
sourceSets.getByName("main") { | ||
java.srcDirs("build/generated/sources") | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.lifecycle.viewmodel.android) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.androidx.material3) | ||
implementation(libs.compose.navigation) | ||
implementation(libs.androidx.lifecycle.runtime.compose.android) | ||
implementation(libs.coil.compose) | ||
|
||
// Firebase dependencies | ||
implementation(libs.firebase.auth) | ||
implementation(libs.firebase.dataconnect) | ||
|
||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
androidTestImplementation(libs.androidx.ui.test.junit4) | ||
debugImplementation(libs.androidx.ui.tooling) | ||
debugImplementation(libs.androidx.ui.test.manifest) | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.FirebaseDataConnect" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.FirebaseDataConnect"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.