Skip to content
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

Add Firebase Data Connect quickstart #1671

Merged
merged 65 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2648e40
Initial commit for dataconnect sample app
thatfiredev May 8, 2024
2e242ff
chore: add Firebase dependencies
thatfiredev May 10, 2024
bc89f0b
add first schema
thatfiredev May 13, 2024
441033f
update with new schema
thatfiredev May 13, 2024
3c99916
add kotlin serialization and androidx.lifecycle
thatfiredev May 31, 2024
44a274d
firebase init
thatfiredev May 31, 2024
08a034c
setup bottom navigation
thatfiredev Jun 3, 2024
1273149
feat: create movies screen
thatfiredev Jun 3, 2024
30d6298
add firebase data connect logo
thatfiredev Jun 3, 2024
6bb2988
add top 10 movies and latest to the MoviesScreen
thatfiredev Jun 5, 2024
84bf1b0
create GenresScreen
thatfiredev Jun 5, 2024
0b156e2
create GenreDetailScreen
thatfiredev Jun 5, 2024
d288623
create MovieDetailScreen
thatfiredev Jun 7, 2024
7d7170e
Merge branch 'master' of github.com:firebase/quickstart-android into …
thatfiredev Sep 13, 2024
bdcd7e8
chore: bump gradle plugins
thatfiredev Sep 13, 2024
27aa537
test: delete test modules
thatfiredev Sep 13, 2024
24ca051
chore: add compose compiler
thatfiredev Sep 13, 2024
ab176f6
chore: move location from firebase.json to dataconnect.yaml
thatfiredev Sep 13, 2024
de4b232
feat: create an auth screen
thatfiredev Sep 13, 2024
d6de3cc
create user profile favorites list and sign out button
thatfiredev Sep 17, 2024
acc78fc
ellipsize text in Movie Tile
thatfiredev Sep 17, 2024
f37f21e
refactor: reuse MovieTile UI component
thatfiredev Sep 17, 2024
afe7d69
delete UserRepository
thatfiredev Sep 17, 2024
e3dd016
refactor: delete MovieRepository
thatfiredev Sep 17, 2024
eb76c92
refactor: delete the data package
thatfiredev Sep 17, 2024
6a29c55
feat: list actors in the movie details screen
thatfiredev Sep 18, 2024
0b9ef77
refactor: movie review list to bottom of profile screen
thatfiredev Sep 18, 2024
1af90a7
feat: add reviews to movie detail screen
thatfiredev Sep 18, 2024
d9293ae
refactor: dateformat for reviews
thatfiredev Sep 18, 2024
a309c17
feat: mark movies as watched and/or favorite
thatfiredev Sep 18, 2024
7fa7803
refactor: move AuthScreen into its own file
thatfiredev Sep 18, 2024
609e504
docs: add a README file
thatfiredev Sep 19, 2024
30a904b
feat: support reviewing movies :)
thatfiredev Sep 19, 2024
14034c6
feat: create actor details screen
thatfiredev Sep 20, 2024
dff9533
refactor: make actor list reusable
thatfiredev Sep 20, 2024
155d7a5
refactor: make movies list reusable
thatfiredev Sep 20, 2024
b15d0ab
refactor: make error and loading reusable components
thatfiredev Sep 20, 2024
49a20a1
refactor: make toggle button reusable
thatfiredev Sep 20, 2024
8546e34
refactor: make actor details screen stateless
thatfiredev Sep 20, 2024
a45c5d4
refactor: move UserReviews into its own dedicated file
thatfiredev Sep 20, 2024
f0f5ce4
refactor: turn actor tile into a card
thatfiredev Sep 20, 2024
bca483a
docs: update the getting started
thatfiredev Sep 20, 2024
a24417e
docs: update README.md
thatfiredev Sep 23, 2024
a8b2bf5
docs: update README.md
thatfiredev Sep 23, 2024
c06b22c
add data_seed.gql and useEmulator()
thatfiredev Sep 30, 2024
2912f29
Update README.md
thatfiredev Sep 30, 2024
142dcb9
refactor: use Navigation type safety
thatfiredev Sep 30, 2024
3e0b914
refactor: delete extra uiState
thatfiredev Sep 30, 2024
496af82
refactor favoriteActor for readability
thatfiredev Sep 30, 2024
287adb1
refactor: make error messages nullable and add default error message
thatfiredev Sep 30, 2024
01e072a
refactor: ensure a user is logged in before marking as favorite
thatfiredev Sep 30, 2024
6077294
update GenreDetailScreen
thatfiredev Oct 1, 2024
4a4401b
chore: use v1beta
thatfiredev Oct 2, 2024
172e457
ci: remove Data Connect from build
thatfiredev Oct 2, 2024
68b2595
chore: upgrade to 16.0.0-beta01
thatfiredev Oct 2, 2024
8dc1a40
ci: remove -i parameter
thatfiredev Oct 2, 2024
782010b
ci: output file
thatfiredev Oct 2, 2024
f76a395
Merge branch 'master' of github.com:firebase/quickstart-android into …
thatfiredev Oct 2, 2024
851252f
ci: overwrite instead of append
thatfiredev Oct 2, 2024
922c940
chore: agp 8.7.0
thatfiredev Oct 2, 2024
85f1fb9
testing
thatfiredev Oct 2, 2024
a2e39b7
revert ci changes
thatfiredev Oct 2, 2024
d7fcb93
ci: add python script to remove fdc
thatfiredev Oct 2, 2024
d4249df
docs: update README.md
thatfiredev Oct 2, 2024
83c7a3d
docs: remove deploy step
thatfiredev Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("com.google.firebase.firebase-perf") version "1.4.2" apply false
id("androidx.navigation.safeargs") version "2.8.0" apply false
id("com.github.ben-manes.versions") version "0.51.0" apply true
id("org.jetbrains.kotlin.plugin.compose") version "2.0.20" apply false
}

allprojects {
Expand Down
1 change: 1 addition & 0 deletions copy_mock_google_services_json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cp mock-google-services.json auth/app/google-services.json
cp mock-google-services.json config/app/google-services.json
cp mock-google-services.json crash/app/google-services.json
cp mock-google-services.json database/app/google-services.json
cp mock-google-services.json dataconnect/app/google-services.json
cp mock-google-services.json dynamiclinks/app/google-services.json
cp mock-google-services.json firestore/app/google-services.json
cp mock-google-services.json functions/app/google-services.json
Expand Down
17 changes: 17 additions & 0 deletions dataconnect/.gitignore
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
97 changes: 97 additions & 0 deletions dataconnect/README.md
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, click on the "Get Started" button 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.
- Select the option to create a new Cloud SQL instance and fill in the following fields:
- Service ID: `dataconnect`
- Cloud SQL Instance ID: `fdc-sql`
- 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. If you haven’t already, add an Android app to your Firebase project, with the android package name `com.google.firebase.example.dataconnect`. Download and then add the Firebase Android configuration file (`google-services.json`) to your app:
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.
1 change: 1 addition & 0 deletions dataconnect/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
84 changes: 84 additions & 0 deletions dataconnect/app/build.gradle.kts
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.compose)
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)
}
21 changes: 21 additions & 0 deletions dataconnect/app/proguard-rules.pro
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
31 changes: 31 additions & 0 deletions dataconnect/app/src/main/AndroidManifest.xml
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>
Loading
Loading