Skip to content
Browse files

Various tweaks from feedback

  • Loading branch information...
1 parent 9d61550 commit 5a08bbabae2716e57d078c741af3c344ac40ba07 @abehaskins abehaskins committed
View
8 app/src/main/java/com/firebase/uidemo/RecyclerViewDemoActivity.java
@@ -21,7 +21,7 @@
import com.firebase.client.FirebaseError;
import com.firebase.client.Query;
import com.firebase.ui.auth.core.FirebaseLoginBaseActivity;
-import com.firebase.ui.FirebaseRecyclerViewAdapter;
+import com.firebase.ui.FirebaseRecyclerAdapter;
import com.firebase.ui.auth.core.FirebaseLoginError;
import com.firebase.ui.auth.core.SocialProvider;
@@ -37,7 +37,7 @@
private EditText mMessageEdit;
private RecyclerView mMessages;
- private FirebaseRecyclerViewAdapter<Chat, ChatHolder> mRecycleViewAdapter;
+ private FirebaseRecyclerAdapter<Chat, ChatHolder> mRecycleViewAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -81,7 +81,7 @@ public void onComplete(FirebaseError firebaseError, Firebase firebase) {
mMessages.setHasFixedSize(false);
mMessages.setLayoutManager(manager);
- mRecycleViewAdapter = new FirebaseRecyclerViewAdapter<Chat, ChatHolder>(Chat.class, R.layout.message, ChatHolder.class, mChatRef) {
+ mRecycleViewAdapter = new FirebaseRecyclerAdapter<Chat, ChatHolder>(Chat.class, R.layout.message, ChatHolder.class, mChatRef) {
@Override
public void populateViewHolder(ChatHolder chatView, Chat chat) {
chatView.setName(chat.getName());
@@ -208,7 +208,7 @@ public String getText() {
}
public static class ChatHolder extends RecyclerView.ViewHolder {
- public View mView;
+ View mView;
public ChatHolder(View itemView) {
super(itemView);
View
2 build.gradle
@@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
- classpath 'com.google.gms:google-services:1.5.0-beta2'
+ classpath 'com.google.gms:google-services:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
View
2 library/pom.xml
@@ -6,7 +6,7 @@
<name>FirebaseUI-Android</name>
<description>FirebaseUI library for Android applications</description>
<url>https://github.com/firebase/FirebaseUI-Android</url>
- <version>0.2.2</version>
+ <version>0.3.0</version>
<packaging>aar</packaging>
<scm>
<url>scm:git@github.com/firebase/FirebaseUI-Android</url>
View
5 library/src/main/AndroidManifest.xml
@@ -1,9 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.firebase.ui">
-
- <uses-permission android:name="android.permission.INTERNET" />
-
<application android:allowBackup="true" android:label="@string/app_name">
-
</application>
-
</manifest>
View
1 library/src/main/java/com/firebase/ui/FirebaseListAdapter.java
@@ -162,6 +162,7 @@ protected void populateView(View v, T model, int position) {
* @param v The view to populate
* @param model The object containing the data used to populate the view
*/
+ @Deprecated
protected void populateView(View v, T model) {
}
View
15 ...ebase/ui/FirebaseRecyclerViewAdapter.java → .../firebase/ui/FirebaseRecyclerAdapter.java
@@ -60,14 +60,14 @@
* }
* }
*
- * FirebaseRecyclerViewAdapter<ChatMessage, ChatMessageViewHolder> adapter;
+ * FirebaseRecyclerAdapter<ChatMessage, ChatMessageViewHolder> adapter;
* ref = new Firebase("https://<yourapp>.firebaseio.com");
*
* RecyclerView recycler = (RecyclerView) findViewById(R.id.messages_recycler);
* recycler.setHasFixedSize(true);
* recycler.setLayoutManager(new LinearLayoutManager(this));
*
- * adapter = new FirebaseRecyclerViewAdapter<ChatMessage, ChatMessageViewHolder>(ChatMessage.class, android.R.layout.two_line_list_item, ChatMessageViewHolder.class, mRef) {
+ * adapter = new FirebaseRecyclerAdapter<ChatMessage, ChatMessageViewHolder>(ChatMessage.class, android.R.layout.two_line_list_item, ChatMessageViewHolder.class, mRef) {
* public void populateViewHolder(ChatMessageViewHolder chatMessageViewHolder, ChatMessage chatMessage) {
* chatMessageViewHolder.nameText.setText(chatMessage.getName());
* chatMessageViewHolder.messageText.setText(chatMessage.getMessage());
@@ -80,7 +80,7 @@
* @param <T> The Java class that maps to the type of objects stored in the Firebase location.
* @param <VH> The ViewHolder class that contains the Views in the layout that is shown for each object.
*/
-public abstract class FirebaseRecyclerViewAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
+public abstract class FirebaseRecyclerAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
Class<T> mModelClass;
protected int mModelLayout;
@@ -95,7 +95,7 @@
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location, using some
* combination of <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>
*/
- public FirebaseRecyclerViewAdapter(Class<T> modelClass, int modelLayout, Class<VH> viewHolderClass, Query ref) {
+ public FirebaseRecyclerAdapter(Class<T> modelClass, int modelLayout, Class<VH> viewHolderClass, Query ref) {
mModelClass = modelClass;
mModelLayout = modelLayout;
mViewHolderClass = viewHolderClass;
@@ -132,7 +132,7 @@ public void onChanged(EventType type, int index, int oldIndex) {
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location, using some
* combination of <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>
*/
- public FirebaseRecyclerViewAdapter(Class<T> modelClass, int modelLayout, Class<VH> viewHolderClass, Firebase ref) {
+ public FirebaseRecyclerAdapter(Class<T> modelClass, int modelLayout, Class<VH> viewHolderClass, Firebase ref) {
this(modelClass, modelLayout, viewHolderClass, (Query) ref);
}
@@ -186,7 +186,7 @@ public void onBindViewHolder(VH viewHolder, int position) {
* this class. The third argument is the item's position in the list.
* <p>
* Your implementation should populate the view using the data contained in the model.
- * You should implement either this method or the other FirebaseRecyclerViewAdapter#populateViewHolder(VH, Object) method
+ * You should implement either this method or the other FirebaseRecyclerAdapter#populateViewHolder(VH, Object) method
* but not both.
*
* @param viewHolder The view to populate
@@ -199,7 +199,7 @@ protected void populateViewHolder(VH viewHolder, T model, int position) {
/**
* This is a backwards compatible version of populateViewHolder.
* <p>
- * You should implement either this method or the other FirebaseRecyclerViewAdapter#populateViewHolder(VH, T, int) method
+ * You should implement either this method or the other FirebaseRecyclerAdapter#populateViewHolder(VH, T, int) method
* but not both.
*
* @see FirebaseListAdapter#populateView(View, Object, int)
@@ -207,6 +207,7 @@ protected void populateViewHolder(VH viewHolder, T model, int position) {
* @param viewHolder The view to populate
* @param model The object containing the data used to populate the view
*/
+ @Deprecated
protected void populateViewHolder(VH viewHolder, T model) {
};
View
8 ...base/ui/auth/core/FirebaseAuthHelper.java → ...se/ui/auth/core/FirebaseAuthProvider.java
@@ -9,16 +9,17 @@
import java.util.HashMap;
import java.util.Map;
-public abstract class FirebaseAuthHelper {
+public abstract class FirebaseAuthProvider {
public abstract void logout();
public abstract String getProviderName();
public abstract Firebase getFirebaseRef();
+ public abstract SocialProvider getProviderType();
public void login() {
- Log.d("FirebaseAuthHelper", "Login() is not supported for provider type " + getProviderName());
+ Log.d("FirebaseAuthProvider", "Login() is not supported for provider type " + getProviderName());
};
public void login(String email, String password) {
- Log.d("FirebaseAuthHelper", "Login(String email, String password) is not supported for provider type " + getProviderName());
+ Log.d("FirebaseAuthProvider", "Login(String email, String password) is not supported for provider type " + getProviderName());
};
public void onFirebaseTokenReceived(FirebaseOAuthToken token, TokenAuthHandler handler) {
@@ -26,7 +27,6 @@ public void onFirebaseTokenReceived(FirebaseOAuthToken token, TokenAuthHandler h
}
private void authenticateRefWithOAuthFirebasetoken(FirebaseOAuthToken token, final TokenAuthHandler handler) {
- Log.d("Got a token", token.token);
Firebase.AuthResultHandler authResultHandler = new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
View
25 library/src/main/java/com/firebase/ui/auth/core/FirebaseLoginBaseActivity.java
@@ -14,13 +14,34 @@
private FirebaseLoginDialog mDialog;
private TokenAuthHandler mHandler;
- /* Abstract methods for Login Events */
+ /**
+ * Subclasses of this activity may implement this method to handle when a user logs in.
+ *
+ * @return void
+ */
protected abstract void onFirebaseLoggedIn(AuthData authData);
+ /**
+ * Subclasses of this activity may implement this method to handle when a user logs out.
+ *
+ * @return void
+ */
protected abstract void onFirebaseLoggedOut();
+ /**
+ * Subclasses of this activity may implement this method to handle any potential provider errors
+ * like OAuth or other internal errors.
+ *
+ * @return void
+ */
protected abstract void onFirebaseLoginProviderError(FirebaseLoginError firebaseError);
+ /**
+ * Subclasses of this activity may implement this method to handle any potential user errors
+ * like entering an incorrect password or closing the login dialog.
+ *
+ * @return void
+ */
protected abstract void onFirebaseLoginUserError(FirebaseLoginError firebaseError);
/**
@@ -93,7 +114,7 @@ public void onAuthStateChanged(AuthData authData) {
}
public void setEnabledAuthProvider(SocialProvider provider) {
- mDialog.setProviderEnabled(provider);
+ mDialog.setEnabledProvider(provider);
}
protected void onStop() {
View
38 library/src/main/java/com/firebase/ui/auth/core/FirebaseLoginDialog.java
@@ -25,6 +25,7 @@
GoogleAuthProvider mGoogleAuthProvider;
PasswordAuthProvider mPasswordAuthProvider;
TokenAuthHandler mHandler;
+ SocialProvider mActiveProvider;
Firebase mRef;
Context mContext;
View mView;
@@ -34,6 +35,12 @@ public void onStart() {
if (mGoogleAuthProvider != null) mGoogleAuthProvider.onStart();
}
+
+ /*
+ We need to be extra aggressive about building / destroying mGoogleauthProviders so we don't
+ end up with two clients connected at the same time.
+ */
+
public void onStop() {
super.onStop();
if (mGoogleAuthProvider != null) mGoogleAuthProvider.onStop();
@@ -45,15 +52,15 @@ public void onDestroy() {
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (mFacebookAuthProvider != null) {
+ if (mFacebookAuthProvider != null && mActiveProvider == SocialProvider.facebook) {
mFacebookAuthProvider.mCallbackManager.onActivityResult(requestCode, resultCode, data);
}
- if (mTwitterAuthProvider != null) {
+ if (mTwitterAuthProvider != null && mActiveProvider == SocialProvider.twitter) {
mTwitterAuthProvider.onActivityResult(requestCode, resultCode, data);
}
- if (mGoogleAuthProvider != null) {
+ if (mGoogleAuthProvider != null && mActiveProvider == SocialProvider.google) {
mGoogleAuthProvider.onActivityResult(requestCode, resultCode, data);
}
}
@@ -103,10 +110,20 @@ public void reset() {
}
public void logout() {
- if (mFacebookAuthProvider != null) mFacebookAuthProvider.logout();
- if (mGoogleAuthProvider != null) mGoogleAuthProvider.logout();
- if (mTwitterAuthProvider != null) mTwitterAuthProvider.logout();
- if (mPasswordAuthProvider != null) mPasswordAuthProvider.logout();
+ switch (mActiveProvider) {
+ case twitter:
+ mTwitterAuthProvider.logout();
+ break;
+ case facebook:
+ mFacebookAuthProvider.logout();
+ break;
+ case google:
+ mGoogleAuthProvider.logout();
+ break;
+ case password:
+ mPasswordAuthProvider.logout();
+ break;
+ }
mRef.unauth();
}
@@ -133,7 +150,7 @@ public void onProviderError(FirebaseLoginError err) {
return this;
}
- public FirebaseLoginDialog setProviderEnabled(SocialProvider provider) {
+ public FirebaseLoginDialog setEnabledProvider(SocialProvider provider) {
switch (provider) {
case facebook:
if (mFacebookAuthProvider == null)
@@ -156,11 +173,11 @@ public FirebaseLoginDialog setProviderEnabled(SocialProvider provider) {
return this;
}
- private void showLoginOption(final FirebaseAuthHelper helper, int id) {
+ private void showLoginOption(final FirebaseAuthProvider helper, int id) {
mView.findViewById(id).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if (helper.getProviderName().equals("password")) {
+ if (helper.getProviderType() == SocialProvider.password) {
EditText emailText = (EditText) mView.findViewById(R.id.email);
EditText passwordText = (EditText) mView.findViewById(R.id.password);
helper.login(emailText.getText().toString(), passwordText.getText().toString());
@@ -169,6 +186,7 @@ public void onClick(View view) {
} else {
helper.login();
}
+ mActiveProvider = helper.getProviderType();
mView.findViewById(R.id.login_section).setVisibility(View.GONE);
mView.findViewById(R.id.loading_section).setVisibility(View.VISIBLE);
}
View
12 library/src/main/java/com/firebase/ui/auth/facebook/FacebookAuthProvider.java
@@ -15,18 +15,20 @@
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.firebase.client.Firebase;
-import com.firebase.ui.auth.core.FirebaseAuthHelper;
+import com.firebase.ui.auth.core.FirebaseAuthProvider;
import com.firebase.ui.auth.core.FirebaseResponse;
import com.firebase.ui.auth.core.FirebaseLoginError;
import com.firebase.ui.auth.core.FirebaseOAuthToken;
+import com.firebase.ui.auth.core.SocialProvider;
import com.firebase.ui.auth.core.TokenAuthHandler;
import java.util.Arrays;
import java.util.Collection;
-public class FacebookAuthProvider extends FirebaseAuthHelper {
+public class FacebookAuthProvider extends FirebaseAuthProvider {
public static final String PROVIDER_NAME = "facebook";
+ public static final SocialProvider PROVIDER_TYPE = SocialProvider.facebook;
private final String TAG = "FacebookAuthProvider";
public CallbackManager mCallbackManager;
private LoginManager mLoginManager;
@@ -102,10 +104,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
}
- public String getProviderName() {
- return PROVIDER_NAME;
- }
-
+ public String getProviderName() { return PROVIDER_NAME; }
+ public SocialProvider getProviderType() { return PROVIDER_TYPE; };
public Firebase getFirebaseRef() {return mRef; }
public void logout() {
View
8 library/src/main/java/com/firebase/ui/auth/google/GoogleAuthProvider.java
@@ -7,13 +7,13 @@
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
-import android.util.Log;
import com.firebase.client.Firebase;
-import com.firebase.ui.auth.core.FirebaseAuthHelper;
+import com.firebase.ui.auth.core.FirebaseAuthProvider;
import com.firebase.ui.auth.core.FirebaseLoginError;
import com.firebase.ui.auth.core.FirebaseOAuthToken;
import com.firebase.ui.auth.core.FirebaseResponse;
+import com.firebase.ui.auth.core.SocialProvider;
import com.firebase.ui.auth.core.TokenAuthHandler;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
@@ -24,11 +24,12 @@
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
-public class GoogleAuthProvider extends FirebaseAuthHelper implements
+public class GoogleAuthProvider extends FirebaseAuthProvider implements
GoogleApiClient.OnConnectionFailedListener,
GoogleOAuthTaskHandler {
public final static String PROVIDER_NAME = "google";
+ public static final SocialProvider PROVIDER_TYPE = SocialProvider.google;
private static final int RC_SIGN_IN = 9001;
private final String TAG = "GoogleAuthProvider";
private GoogleApiClient mGoogleApiClient;
@@ -79,6 +80,7 @@ public GoogleAuthProvider(Context context, Firebase ref, TokenAuthHandler handle
public String getProviderName() { return PROVIDER_NAME; }
public Firebase getFirebaseRef() { return mRef; }
+ public SocialProvider getProviderType() { return PROVIDER_TYPE; };
public void logout() {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
View
7 library/src/main/java/com/firebase/ui/auth/password/PasswordAuthProvider.java
@@ -6,16 +6,18 @@
import com.firebase.client.AuthData;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
-import com.firebase.ui.auth.core.FirebaseAuthHelper;
+import com.firebase.ui.auth.core.FirebaseAuthProvider;
import com.firebase.ui.auth.core.FirebaseResponse;
import com.firebase.ui.auth.core.FirebaseLoginError;
+import com.firebase.ui.auth.core.SocialProvider;
import com.firebase.ui.auth.core.TokenAuthHandler;
-public class PasswordAuthProvider extends FirebaseAuthHelper {
+public class PasswordAuthProvider extends FirebaseAuthProvider {
private final String LOG_TAG = "PasswordAuthProvider";
public final static String PROVIDER_NAME = "password";
+ public final static SocialProvider PROVIDER_TYPE = SocialProvider.password;
private TokenAuthHandler mHandler;
private Activity mActivity;
@@ -42,5 +44,6 @@ public void onAuthenticationError(FirebaseError firebaseError) {
public String getProviderName() { return PROVIDER_NAME; }
public Firebase getFirebaseRef() { return mRef; }
+ public SocialProvider getProviderType() { return PROVIDER_TYPE; };
public void logout() {}
}
View
7 library/src/main/java/com/firebase/ui/auth/twitter/TwitterAuthProvider.java
@@ -5,15 +5,17 @@
import android.content.Intent;
import com.firebase.client.Firebase;
-import com.firebase.ui.auth.core.FirebaseAuthHelper;
+import com.firebase.ui.auth.core.FirebaseAuthProvider;
import com.firebase.ui.auth.core.FirebaseLoginError;
import com.firebase.ui.auth.core.FirebaseOAuthToken;
+import com.firebase.ui.auth.core.SocialProvider;
import com.firebase.ui.auth.core.TokenAuthHandler;
-public class TwitterAuthProvider extends FirebaseAuthHelper {
+public class TwitterAuthProvider extends FirebaseAuthProvider {
public static final String TAG = "TwitterAuthProvider";
public static final String PROVIDER_NAME = "twitter";
+ public static final SocialProvider PROVIDER_TYPE = SocialProvider.twitter;
private Activity mActivity;
private TokenAuthHandler mHandler;
@@ -35,6 +37,7 @@ public void logout() {
public String getProviderName() { return PROVIDER_NAME; }
public Firebase getFirebaseRef() { return mRef; }
+ public SocialProvider getProviderType() { return PROVIDER_TYPE; };
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == TwitterActions.SUCCESS) {

0 comments on commit 5a08bba

Please sign in to comment.
Something went wrong with that request. Please try again.