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/habits/edit/EditHabitDialog.java b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java index 6ff2bfa6b..bd10fd433 100644 --- a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java +++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java @@ -20,11 +20,16 @@ package org.isoron.uhabits.activities.habits.edit; import android.content.*; +import android.content.res.Resources; import android.os.*; import android.support.annotation.*; import android.support.v7.app.*; import android.text.format.*; +import android.util.Log; import android.view.*; +import android.widget.AdapterView; +import android.widget.Spinner; +import android.widget.TextView; import com.android.datetimepicker.time.*; @@ -180,7 +185,13 @@ public class EditHabitDialog extends AppCompatDialogFragment habit.setFrequency(frequencyPanel.getFrequency()); habit.setUnit(targetPanel.getUnit()); habit.setTargetValue(targetPanel.getTargetValue()); - habit.setType(type); +// habit.setType(type); //removing +// adding below lines + Log.d("habit-typeNum",String.valueOf(habit.getType())); + if (targetPanel.getVisibility() == View.VISIBLE) + habit.setType(Habit.NUMBER_HABIT); + else + habit.setType(Habit.YES_NO_HABIT); saveHabit(habit); dismiss(); @@ -201,14 +212,74 @@ public class EditHabitDialog extends AppCompatDialogFragment return habit; } + @BindView(R.id.spHabitType) + Spinner spHabitType; + + @BindView(R.id.tvSpinnerHabitType) + TextView tvSpinnerHabitType; + + @BindView(R.id.tvDescription) + ExampleEditText tvDescription; + + private void setupHabitTypeController(Habit habit){ + + spHabitType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + + Log.d("spinner-position", String.valueOf(i)); + Resources res = getResources(); + + if (i == Habit.NUMBER_HABIT){ + habit.setType(Habit.NUMBER_HABIT); + }else { + habit.setType(Habit.YES_NO_HABIT); + } + + if(i == Habit.NUMBER_HABIT) + tvDescription.setExample(res.getString(R.string.example_question_numerical)); + else + tvDescription.setExample(res.getString(R.string.example_question_boolean)); + + // Copied from populateform() + if (habit.isNumerical()) { + frequencyPanel.setVisibility(GONE); + targetPanel.setVisibility(View.VISIBLE); + } + else { + targetPanel.setVisibility(GONE); + frequencyPanel.setVisibility(View.VISIBLE); + } + + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + + } + }); + } + private void populateForm() { Habit habit = modelFactory.buildHabit(); habit.setFrequency(Frequency.DAILY); habit.setColor(prefs.getDefaultHabitColor(habit.getColor())); - habit.setType(getTypeFromArguments()); + habit.setType(getTypeFromArguments());//commenting this line for test purpose +// habit.setType(Habit.NUMBER_HABIT);//To be deleted later + + if (originalHabit != null) {//edit habit + + Log.d("isEditHabit", "true"); + habit.copyFrom(originalHabit); + + //Hide the 'type of habit' question on edit habit + spHabitType.setVisibility(GONE); + tvSpinnerHabitType.setVisibility(GONE); + } - if (originalHabit != null) habit.copyFrom(originalHabit); + //setting own habit controller + setupHabitTypeController(habit); if (habit.isNumerical()) frequencyPanel.setVisibility(GONE); else targetPanel.setVisibility(GONE); 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/layout/edit_habit_name.xml b/uhabits-android/src/main/res/layout/edit_habit_name.xml index 70ad45cdc..ca61ecb8a 100644 --- a/uhabits-android/src/main/res/layout/edit_habit_name.xml +++ b/uhabits-android/src/main/res/layout/edit_habit_name.xml @@ -54,6 +54,19 @@ + + + diff --git a/uhabits-android/src/main/res/values/constants.xml b/uhabits-android/src/main/res/values/constants.xml index 34e8136a5..e4e7f4073 100644 --- a/uhabits-android/src/main/res/values/constants.xml +++ b/uhabits-android/src/main/res/values/constants.xml @@ -89,6 +89,10 @@ @string/uncheck @string/toggle + + With a simple yes or no + With a number + @string/day 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 @@ - -