Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
66 changes: 33 additions & 33 deletions BlockStore/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,21 @@
* limitations under the License.
*/
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'dagger.hilt.android.plugin'
id 'kotlin-kapt'
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.hilt.android)
alias(libs.plugins.kotlin.kapt)
}

android {
compileSdkVersion 31
buildToolsVersion "30.0.3"

compileSdk 35
namespace "com.google.android.gms.identity.sample.blockstore"
defaultConfig {
applicationId "com.google.android.gms.identity.sample.blockstore"
minSdkVersion 21
targetSdkVersion 31
minSdk 21
targetSdk 35
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -44,42 +42,44 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.gms:play-services-auth-blockstore:16.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.test.espresso:espresso-idling-resource:3.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation libs.kotlin.stdlib
implementation libs.play.services.auth.blockstore
implementation libs.material.design
implementation libs.androidx.core.ktx
implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout
implementation libs.androidx.work.runtime

// Hilt
implementation 'com.google.dagger:hilt-android:2.37'
kapt 'com.google.dagger:hilt-android-compiler:2.37'
implementation 'androidx.hilt:hilt-work:1.0.0'
kapt 'androidx.hilt:hilt-compiler:1.0.0'
implementation libs.hilt.android
kapt libs.hilt.android.compiler
implementation libs.hilt.work
kapt libs.hilt.compiler

// Lifecycle
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0-alpha03"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
implementation libs.bundles.androidx.lifecycle

// Activity
implementation "androidx.activity:activity-ktx:1.3.1"
implementation libs.androidx.activity.ktx

// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.4.3"
implementation libs.kotlinx.coroutines.play.services

// jUnit
testImplementation libs.junit
debugImplementation libs.androidx.test.monitor
androidTestImplementation libs.bundles.androidx.test
implementation libs.androidx.test.espresso.idling.resource
}
7 changes: 4 additions & 3 deletions BlockStore/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms.identity.sample.blockstore">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="false"
Expand All @@ -22,7 +22,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.BlockStore">
<activity android:name=".MainActivity"
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ class AppModule {
@Provides
fun provideBlockStoreClient(@ApplicationContext context: Context): BlockstoreClient =
Blockstore.getClient(context)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.google.android.gms.identity.sample.blockstore

import com.google.android.gms.auth.blockstore.BlockstoreClient
import com.google.android.gms.auth.blockstore.RetrieveBytesRequest
import com.google.android.gms.auth.blockstore.RetrieveBytesResponse
import com.google.android.gms.auth.blockstore.StoreBytesData
import com.google.android.gms.tasks.Task
import kotlinx.coroutines.tasks.await
import javax.inject.Inject

Expand All @@ -13,20 +16,29 @@ class BlockStoreRepository @Inject constructor(
private val blockStoreClient: BlockstoreClient
) {

// This function saves the authentication token to Block Store.
/** This function saves the authentication token to Block Store. */
suspend fun storeBytes(inputString: String) {
val data: StoreBytesData =
StoreBytesData.Builder().setBytes(inputString.toByteArray()).build()
blockStoreClient.storeBytes(data).await()
}

// This function retrieves your Block Store data.
/** This function retrieves your Block Store data. */
@Deprecated(message = "retrieveBytes() now requires argument RetrieveBytesRequest")
suspend fun retrieveBytes(): String {
return String(blockStoreClient.retrieveBytes().await())
}

// This function clears your Block Store data.
/** This function retrieves your Block Store data with RetrieveBytesRequest. */
suspend fun retrieveBytes(bytesRequest: RetrieveBytesRequest) {
val response: Task<RetrieveBytesResponse?> = blockStoreClient
.retrieveBytes(bytesRequest)
.addOnSuccessListener {}
.addOnFailureListener {}
}

/** This function clears your Block Store data. */
suspend fun clearBytes() {
storeBytes("")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ class MainActivity : AppCompatActivity() {
viewModel.clearBytes()
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ import dagger.hilt.android.HiltAndroidApp
* Application class, needed to enable dependency injection with Hilt.
*/
@HiltAndroidApp
class MainApplication : Application()
class MainApplication : Application()
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class MainViewModel @Inject constructor(
_state.value = State(bytes = null)
}
}
}
}
31 changes: 7 additions & 24 deletions BlockStore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,13 @@
* limitations under the License.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.21"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.hilt.android) apply false
}

allprojects {
repositories {
google()
mavenCentral()
}
tasks.register('clean', Delete) {
delete rootProject.fileTree("build")
}

task clean(type: Delete) {
delete rootProject.buildDir
}
4 changes: 3 additions & 1 deletion BlockStore/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.code.style=official

kapt.use.k2=true
53 changes: 53 additions & 0 deletions BlockStore/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[versions]
android_gradle_plugin = '8.6.0'
hilt_android = '2.52'
hilt = '1.2.0'
kotlin = '2.0.20'
kotlinx_coroutines = '1.7.3'
junit = '4.13.2'
material_design = '1.12.0'
androidx_core = '1.13.1'
androidx_activity = '1.9.2'
androidx_appcompat = '1.7.0'
androidx_constraintlayout = '2.1.4'
androidx_lifecycle = '2.8.5'
androidx_work = '2.9.1'
androidx_test_ext_junit = '1.2.1'
androidx_test_monitor = '1.7.2'
androidx_test_espresso = '3.6.1'
play_services_auth_blockstore = '16.4.0'

[plugins]
android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" }
android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }
kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin_kapt = { id = "org.jetbrains.kotlin.kapt" }
hilt_android = { id = "com.google.dagger.hilt.android", version.ref = "hilt_android" }

[libraries]
hilt_compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hilt" }
hilt_work = { module = "androidx.hilt:hilt-work", version.ref = "hilt" }
hilt_android = { module = "com.google.dagger:hilt-android", version.ref = "hilt_android" }
hilt_android_compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt_android" }
junit = { module = "junit:junit", version.ref = "junit" }
kotlin_stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlinx_coroutines_play_services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx_coroutines" }
material_design = { module = "com.google.android.material:material", version.ref = "material_design" }
androidx_core_ktx = { module = "androidx.core:core-ktx", version.ref = "androidx_core" }
androidx_activity_ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidx_activity" }
androidx_appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx_appcompat" }
androidx_constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx_constraintlayout" }
play_services_auth_blockstore = { module = "com.google.android.gms:play-services-auth-blockstore", version.ref = "play_services_auth_blockstore" }
androidx_lifecycle_common_java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "androidx_lifecycle" }
androidx_lifecycle_livedata_ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "androidx_lifecycle" }
androidx_lifecycle_viewmodel_ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx_lifecycle" }
androidx_work_runtime = { module = "androidx.work:work-runtime", version.ref = "androidx_work" }
androidx_work_runtime_ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "androidx_work" }
androidx_test_monitor = { module = "androidx.test:monitor", version.ref = "androidx_test_monitor" }
androidx_test_ext_junit = { module = "androidx.test.ext:junit", version.ref = "androidx_test_ext_junit" }
androidx_test_espresso_core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx_test_espresso" }
androidx_test_espresso_idling_resource = { module = "androidx.test.espresso:espresso-idling-resource", version.ref = "androidx_test_espresso" }

[bundles]
androidx_lifecycle = ["androidx_lifecycle_common_java8", "androidx_lifecycle_livedata_ktx", "androidx_lifecycle_viewmodel_ktx"]
androidx_test = ["androidx_test_ext_junit", "androidx_test_espresso_core"]
2 changes: 1 addition & 1 deletion BlockStore/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
#Thu Aug 19 16:25:07 EDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
20 changes: 20 additions & 0 deletions BlockStore/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
}
}
rootProject.name = "BlockStore"
include ':app'
Loading