From 1555347e76de7409635883686f3173795ba01651 Mon Sep 17 00:00:00 2001 From: Muqheet Date: Wed, 30 May 2018 17:12:06 +0530 Subject: [PATCH] connected app to firebase --- build.gradle | 1 + uhabits-android/build.gradle | 7 +- uhabits-android/google-services.json | 59 +++++++++++ uhabits-android/src/main/AndroidManifest.xml | 100 +++++++++--------- .../activities/login/LoginActivity.java | 46 ++++++++ .../src/main/res/layout/activity_login.xml | 9 ++ .../src/main/res/values/strings.xml | 5 +- 7 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 uhabits-android/google-services.json create mode 100644 uhabits-android/src/main/java/org/isoron/uhabits/activities/login/LoginActivity.java create mode 100644 uhabits-android/src/main/res/layout/activity_login.xml diff --git a/build.gradle b/build.gradle index 6692adb1e..00692e91f 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" classpath 'org.ajoberstar:grgit:1.5.0' classpath 'com.github.triplet.gradle:play-publisher:1.2.0' + classpath 'com.google.gms:google-services:3.1.1' } } diff --git a/uhabits-android/build.gradle b/uhabits-android/build.gradle index 5acaf1c1d..abd915fe5 100644 --- a/uhabits-android/build.gradle +++ b/uhabits-android/build.gradle @@ -16,7 +16,7 @@ android { compileSdkVersion COMPILE_SDK_VERSION as Integer buildToolsVersion BUILD_TOOLS_VERSION - if(project.hasProperty("LOOP_STORE_FILE")) { + if (project.hasProperty("LOOP_STORE_FILE")) { signingConfigs { release { storeFile file(LOOP_STORE_FILE) @@ -108,6 +108,9 @@ dependencies { implementation "com.google.code.findbugs:jsr305:3.0.2" implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$KOTLIN_VERSION" + implementation 'com.google.firebase:firebase-auth:11.6.0' + implementation 'com.firebaseui:firebase-ui-auth:4.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.0' compileOnly "javax.annotation:jsr250-api:1.0" compileOnly "com.google.auto.factory:auto-factory:1.0-beta3" kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" @@ -188,3 +191,5 @@ task coverageReport(type: JacocoReport) { play { track = 'alpha' } + +apply plugin: 'com.google.gms.google-services' diff --git a/uhabits-android/google-services.json b/uhabits-android/google-services.json new file mode 100644 index 000000000..f79ff9d61 --- /dev/null +++ b/uhabits-android/google-services.json @@ -0,0 +1,59 @@ +{ + "project_info": { + "project_number": "1070387411684", + "firebase_url": "https://uhabits-60f5c.firebaseio.com", + "project_id": "uhabits-60f5c", + "storage_bucket": "uhabits-60f5c.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:1070387411684:android:c24ac74afee79412", + "android_client_info": { + "package_name": "org.isoron.uhabits" + } + }, + "oauth_client": [ + { + "client_id": "1070387411684-62dgqp208udgiql8k3nk9nnsj99tps2n.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "org.isoron.uhabits", + "certificate_hash": "f7ade3b34bad8aadad38b28645d32ff5674a96a5" + } + }, + { + "client_id": "1070387411684-sinls84quiqltb6t9mlok2cg1qaqu4hk.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "1070387411684-sinls84quiqltb6t9mlok2cg1qaqu4hk.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyA_FuA7_lt1HQ6yG39YDHykKa5B9Bngs6s" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 2, + "other_platform_oauth_client": [ + { + "client_id": "1070387411684-sinls84quiqltb6t9mlok2cg1qaqu4hk.apps.googleusercontent.com", + "client_type": 3 + } + ] + }, + "ads_service": { + "status": 2 + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/uhabits-android/src/main/AndroidManifest.xml b/uhabits-android/src/main/AndroidManifest.xml index be3dff213..d0ee59db9 100644 --- a/uhabits-android/src/main/AndroidManifest.xml +++ b/uhabits-android/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - - - - - - - - - + + + + + android:value="AEdPqrEAAAAI6aeWncbnMNo8E5GWeZ44dlc5cQ7tCROwFhOtiw" /> + android:launchMode="singleTop" /> + + android:value=".activities.habits.list.ListHabitsActivity" /> + android:value=".activities.habits.list.ListHabitsActivity" /> + android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> - + + android:value=".activities.habits.list.ListHabitsActivity" /> - - + android:theme="@android:style/Theme.Translucent.NoTitleBar"> - + + android:resource="@xml/widget_checkmark_info" /> - + + android:resource="@xml/widget_history_info" /> - + + android:resource="@xml/widget_score_info" /> - + + android:resource="@xml/widget_streak_info" /> - + + android:resource="@xml/widget_frequency_info" /> - + - + - + + android:scheme="content" /> - + - + + android:scheme="content" /> - + - + + android:scheme="content" /> @@ -194,7 +191,7 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name"> - + @@ -203,7 +200,7 @@ android:name=".automation.FireSettingReceiver" android:exported="true"> - + @@ -214,14 +211,21 @@ android:grantUriPermissions="true"> + android:resource="@xml/file_paths" /> - + android:exported="false"> + + + + + + + + \ No newline at end of file diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/activities/login/LoginActivity.java b/uhabits-android/src/main/java/org/isoron/uhabits/activities/login/LoginActivity.java new file mode 100644 index 000000000..755cde1f5 --- /dev/null +++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/login/LoginActivity.java @@ -0,0 +1,46 @@ +package org.isoron.uhabits.activities.login; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +import com.firebase.ui.auth.AuthUI; + +import org.isoron.uhabits.R; + +import java.util.Arrays; +import java.util.List; + +public class LoginActivity extends AppCompatActivity { + + private static final int RC_SIGN_IN = 123; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + + signin(); + } + + private void signin() { +// ... + +// Choose authentication providers + List providers = Arrays.asList( + new AuthUI.IdpConfig.EmailBuilder().build(), + new AuthUI.IdpConfig.PhoneBuilder().build(), + new AuthUI.IdpConfig.GoogleBuilder().build(), + new AuthUI.IdpConfig.FacebookBuilder().build(), + new AuthUI.IdpConfig.TwitterBuilder().build()); + +// Create and launch sign-in intent + startActivityForResult( + AuthUI.getInstance() + .createSignInIntentBuilder() + .setAvailableProviders(providers) + .build(), + RC_SIGN_IN); + } + + +} diff --git a/uhabits-android/src/main/res/layout/activity_login.xml b/uhabits-android/src/main/res/layout/activity_login.xml new file mode 100644 index 000000000..3566532a1 --- /dev/null +++ b/uhabits-android/src/main/res/layout/activity_login.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/uhabits-android/src/main/res/values/strings.xml b/uhabits-android/src/main/res/values/strings.xml index 5c043b111..64213e0eb 100644 --- a/uhabits-android/src/main/res/values/strings.xml +++ b/uhabits-android/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ - -