Skip to content

Commit

Permalink
Merge pull request #1444 from firebase/version-4.2.0
Browse files Browse the repository at this point in the history
Version 4.2.0
  • Loading branch information
samtstern authored Sep 12, 2018
2 parents 0d1e22c + 780e744 commit a045fb9
Show file tree
Hide file tree
Showing 182 changed files with 1,031 additions and 418 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ libraries.
```groovy
dependencies {
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
implementation 'com.firebaseui:firebase-ui-database:4.2.0'
// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:4.2.0'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
// FirebaseUI for Firebase Auth (GitHub provider)
implementation 'com.firebaseui:firebase-ui-auth-github:4.2.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:4.1.0'
implementation 'com.firebaseui:firebase-ui-storage:4.2.0'
}
```

Expand Down Expand Up @@ -102,15 +105,15 @@ versions. This means that FirebaseUI has independent dependencies on each of the
For best results, your app should depend on a version of each dependency with the same major
version number as the version used by FirebaseUI.

As of version `4.1.0`, FirebaseUI has the following dependency versions:
As of version `4.2.0`, FirebaseUI has the following dependency versions:

| Library | Version |
|----------------------|--------------------------------|
| `firebase-auth` | 16.0.1 |
| `play-services-auth` | 15.0.1 |
| `firebase-database` | 16.0.1 |
| `firebase-firestore` | 17.0.1 |
| `firebase-storage` | 16.0.1 |
| `firebase-auth` | 16.0.3 |
| `play-services-auth` | 16.0.0 |
| `firebase-database` | 16.0.2 |
| `firebase-firestore` | 17.1.0 |
| `firebase-storage` | 16.0.2 |

### Upgrading dependencies

Expand Down
4 changes: 3 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
}

buildTypes {
getByName("release") {
named("release").configure {
// For the purposes of the sample, allow testing of a proguarded release build
// using the debug key
signingConfig = signingConfigs["debug"]
Expand All @@ -32,6 +32,7 @@ dependencies {
implementation(Config.Libs.Support.multidex)

implementation(project(":auth"))
implementation(project(":auth-github"))
implementation(project(":firestore"))
implementation(project(":database"))
implementation(project(":storage"))
Expand All @@ -55,6 +56,7 @@ dependencies {
implementation(Config.Libs.Misc.butterKnife)
annotationProcessor(Config.Libs.Misc.butterKnifeCompiler)
debugImplementation(Config.Libs.Misc.leakCanary)
debugImplementation(Config.Libs.Misc.leakCanaryFragments)
releaseImplementation(Config.Libs.Misc.leakCanaryNoop)
testImplementation(Config.Libs.Misc.leakCanaryNoop)
}
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/com/firebase/uidemo/FirebaseUIDemo.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package com.firebase.uidemo;

import android.content.Context;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.AppCompatDelegate;

import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

public class FirebaseUIDemo extends MultiDexApplication {
private RefWatcher mRefWatcher;

static {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
}

public static RefWatcher getRefWatcher(Context context) {
return ((FirebaseUIDemo) context.getApplicationContext()).mRefWatcher;
}

@Override
public void onCreate() {
super.onCreate();
Expand All @@ -26,6 +18,6 @@ public void onCreate() {
// You should not init your app in this process.
return;
}
mRefWatcher = LeakCanary.install(this);
LeakCanary.install(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
Expand Down Expand Up @@ -52,7 +53,7 @@ public class AnonymousUpgradeActivity extends AppCompatActivity {
private AuthCredential mPendingCredential;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_anonymous_upgrade);
ButterKnife.bind(this);
Expand Down Expand Up @@ -82,7 +83,6 @@ public void startAuthUI() {
Intent intent = AuthUI.getInstance().createSignInIntentBuilder()
.setLogo(R.drawable.firebase_auth_120dp)
.setAvailableProviders(providers)
.setIsSmartLockEnabled(false)
.enableAnonymousUsersAutoUpgrade()
.build();
startActivityForResult(intent, RC_SIGN_IN);
Expand Down Expand Up @@ -127,7 +127,7 @@ public void onComplete(@NonNull Task<Void> task) {
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
Expand All @@ -137,12 +137,13 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
if (resultCode == RESULT_OK) {
setStatus("Signed in as " + getUserIdentifier(FirebaseAuth.getInstance().getCurrentUser()));
} else if (response.getError().getErrorCode() == ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
setStatus("Merge conflict: user already exists.");
mResolveMergeButton.setEnabled(true);
mPendingCredential = response.getCredentialForLinking();
} else {
if (response.getError().getErrorCode() == ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
setStatus("Merge conflict: user already exists.");
mResolveMergeButton.setEnabled(true);
mPendingCredential = response.getCredentialForLinking();
}
Toast.makeText(this, "Auth error, see logs", Toast.LENGTH_SHORT).show();
Log.w(TAG, "Error: " + response.getError().getMessage(), response.getError());
}

updateUI();
Expand Down
20 changes: 13 additions & 7 deletions app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class AuthUiActivity extends AppCompatActivity {
@BindView(R.id.github_provider) CheckBox mUseGitHubProvider;
@BindView(R.id.email_provider) CheckBox mUseEmailProvider;
@BindView(R.id.phone_provider) CheckBox mUsePhoneProvider;
@BindView(R.id.anonymous_provider) CheckBox mUseAnonymousProvider;

@BindView(R.id.default_theme) RadioButton mDefaultTheme;
@BindView(R.id.green_theme) RadioButton mGreenTheme;
Expand Down Expand Up @@ -103,7 +104,8 @@ public class AuthUiActivity extends AppCompatActivity {
@BindView(R.id.allow_new_email_accounts) CheckBox mAllowNewEmailAccounts;
@BindView(R.id.require_name) CheckBox mRequireName;

public static Intent createIntent(Context context) {
@NonNull
public static Intent createIntent(@NonNull Context context) {
return new Intent(context, AuthUiActivity.class);
}

Expand Down Expand Up @@ -177,7 +179,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
}

@OnClick(R.id.sign_in)
public void signIn(View view) {
public void signIn() {
startActivityForResult(
AuthUI.getInstance().createSignInIntentBuilder()
.setTheme(getSelectedTheme())
Expand All @@ -192,7 +194,7 @@ public void signIn(View view) {
}

@OnClick(R.id.sign_in_silent)
public void silentSignIn(View view) {
public void silentSignIn() {
AuthUI.getInstance().silentSignIn(this, getSelectedProviders())
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
Expand All @@ -207,7 +209,7 @@ public void onComplete(@NonNull Task<AuthResult> task) {
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
handleSignInResponse(resultCode, data);
Expand All @@ -224,8 +226,8 @@ protected void onResume() {
}
}

private void handleSignInResponse(int resultCode, Intent data) {
final IdpResponse response = IdpResponse.fromResultIntent(data);
private void handleSignInResponse(int resultCode, @Nullable Intent data) {
IdpResponse response = IdpResponse.fromResultIntent(data);

// Successfully signed in
if (resultCode == RESULT_OK) {
Expand All @@ -249,7 +251,7 @@ private void handleSignInResponse(int resultCode, Intent data) {
}
}

private void startSignedInActivity(IdpResponse response) {
private void startSignedInActivity(@Nullable IdpResponse response) {
startActivity(SignedInActivity.createIntent(this, response));
}

Expand Down Expand Up @@ -319,6 +321,10 @@ private List<IdpConfig> getSelectedProviders() {
selectedProviders.add(new IdpConfig.PhoneBuilder().build());
}

if (mUseAnonymousProvider.isChecked()) {
selectedProviders.add(new IdpConfig.AnonymousBuilder().build());
}

return selectedProviders;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ public class SignedInActivity extends AppCompatActivity {
@BindView(R.id.user_enabled_providers) TextView mEnabledProviders;
@BindView(R.id.user_is_new) TextView mIsNewUser;

public static Intent createIntent(Context context, IdpResponse idpResponse) {
@NonNull
public static Intent createIntent(@NonNull Context context, @Nullable IdpResponse response) {
return new Intent().setClass(context, SignedInActivity.class)
.putExtra(ExtraConstants.IDP_RESPONSE, idpResponse);
.putExtra(ExtraConstants.IDP_RESPONSE, response);
}

@Override
Expand Down Expand Up @@ -164,7 +165,7 @@ private void populateProfile(@Nullable IdpResponse response) {

List<String> providers = new ArrayList<>();
if (user.getProviderData().isEmpty()) {
providers.add("Anonymous");
providers.add(getString(R.string.providers_anonymous));
} else {
for (UserInfo info : user.getProviderData()) {
switch (info.getProviderId()) {
Expand Down
16 changes: 14 additions & 2 deletions app/src/main/java/com/firebase/uidemo/database/AbstractChat.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
package com.firebase.uidemo.database;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

/**
* Common interface for chat messages, helps share code between RTDB and Firestore examples.
*/
public abstract class AbstractChat {

@Nullable
public abstract String getName();

public abstract void setName(@Nullable String name);

@Nullable
public abstract String getMessage();

public abstract void setMessage(@Nullable String message);

@NonNull
public abstract String getUid();

public abstract void setUid(@NonNull String uid);

@Override
public abstract int hashCode();
public abstract boolean equals(@Nullable Object obj);

@Override
public abstract boolean equals(Object obj);
public abstract int hashCode();

}
12 changes: 7 additions & 5 deletions app/src/main/java/com/firebase/uidemo/database/ChatHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RotateDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
Expand All @@ -26,7 +28,7 @@ public class ChatHolder extends RecyclerView.ViewHolder {
private final int mGreen300;
private final int mGray300;

public ChatHolder(View itemView) {
public ChatHolder(@NonNull View itemView) {
super(itemView);
mNameField = itemView.findViewById(R.id.name_text);
mTextField = itemView.findViewById(R.id.message_text);
Expand All @@ -38,19 +40,19 @@ public ChatHolder(View itemView) {
mGray300 = ContextCompat.getColor(itemView.getContext(), R.color.material_gray_300);
}

public void bind(AbstractChat chat) {
public void bind(@NonNull AbstractChat chat) {
setName(chat.getName());
setText(chat.getMessage());
setMessage(chat.getMessage());

FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
setIsSender(currentUser != null && chat.getUid().equals(currentUser.getUid()));
}

private void setName(String name) {
private void setName(@Nullable String name) {
mNameField.setText(name);
}

private void setText(String text) {
private void setMessage(@Nullable String text) {
mTextField.setText(text);
}

Expand Down
Loading

0 comments on commit a045fb9

Please sign in to comment.