Skip to content

Commit 6aeafd4

Browse files
SUPERCILEXsamtstern
authored andcommitted
Code inspect cleanup (#785)
1 parent f34f5ab commit 6aeafd4

24 files changed

+58
-143
lines changed

app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void onCreate(Bundle savedInstanceState) {
156156
return;
157157
}
158158

159-
if (!isGoogleConfigured()) {
159+
if (isGoogleMisconfigured()) {
160160
mUseGoogleProvider.setChecked(false);
161161
mUseGoogleProvider.setEnabled(false);
162162
mUseGoogleProvider.setText(R.string.google_label_missing_config);
@@ -171,7 +171,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
171171
});
172172
}
173173

174-
if (!isFacebookConfigured()) {
174+
if (isFacebookMisconfigured()) {
175175
mUseFacebookProvider.setChecked(false);
176176
mUseFacebookProvider.setEnabled(false);
177177
mUseFacebookProvider.setText(R.string.facebook_label_missing_config);
@@ -186,13 +186,13 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
186186
});
187187
}
188188

189-
if (!isTwitterConfigured()) {
189+
if (isTwitterMisconfigured()) {
190190
mUseTwitterProvider.setChecked(false);
191191
mUseTwitterProvider.setEnabled(false);
192192
mUseTwitterProvider.setText(R.string.twitter_label_missing_config);
193193
}
194194

195-
if (!isGoogleConfigured() || !isFacebookConfigured() || !isTwitterConfigured()) {
195+
if (isGoogleMisconfigured() || isFacebookMisconfigured() || isTwitterMisconfigured()) {
196196
showSnackbar(R.string.configuration_required);
197197
}
198198
}
@@ -365,25 +365,23 @@ private String getSelectedPrivacyPolicyUrl() {
365365
}
366366

367367
@MainThread
368-
private boolean isGoogleConfigured() {
369-
return !UNCHANGED_CONFIG_VALUE.equals(
370-
getString(R.string.default_web_client_id));
368+
private boolean isGoogleMisconfigured() {
369+
return UNCHANGED_CONFIG_VALUE.equals(getString(R.string.default_web_client_id));
371370
}
372371

373372
@MainThread
374-
private boolean isFacebookConfigured() {
375-
return !UNCHANGED_CONFIG_VALUE.equals(
376-
getString(R.string.facebook_application_id));
373+
private boolean isFacebookMisconfigured() {
374+
return UNCHANGED_CONFIG_VALUE.equals(getString(R.string.facebook_application_id));
377375
}
378376

379377
@MainThread
380-
private boolean isTwitterConfigured() {
378+
private boolean isTwitterMisconfigured() {
381379
List<String> twitterConfigs = Arrays.asList(
382380
getString(R.string.twitter_consumer_key),
383381
getString(R.string.twitter_consumer_secret)
384382
);
385383

386-
return !twitterConfigs.contains(UNCHANGED_CONFIG_VALUE);
384+
return twitterConfigs.contains(UNCHANGED_CONFIG_VALUE);
387385
}
388386

389387
@MainThread

auth/src/main/java/com/firebase/ui/auth/AuthUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public class AuthUI {
9797
public static final String TWITTER_PROVIDER = TwitterAuthProvider.PROVIDER_ID;
9898

9999
/**
100-
* Provider identifier for Phone, for use with {@link SignInIntentBuilder#setProviders}.
100+
* Provider identifier for Phone, for use with {@link SignInIntentBuilder#setAvailableProviders(List)}.
101101
*/
102102
public static final String PHONE_VERIFICATION_PROVIDER = PhoneAuthProvider.PROVIDER_ID;
103103

auth/src/main/java/com/firebase/ui/auth/provider/EmailProvider.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
import android.content.Intent;
66
import android.support.annotation.LayoutRes;
77

8-
import com.firebase.ui.auth.AuthUI;
98
import com.firebase.ui.auth.R;
109
import com.firebase.ui.auth.ResultCodes;
1110
import com.firebase.ui.auth.ui.FlowParameters;
1211
import com.firebase.ui.auth.ui.email.RegisterEmailActivity;
13-
import com.google.firebase.auth.EmailAuthProvider;
1412

1513
public class EmailProvider implements Provider {
1614
private static final int RC_EMAIL_FLOW = 2;
@@ -28,12 +26,6 @@ public String getName(Context context) {
2826
return context.getString(R.string.provider_name_email);
2927
}
3028

31-
@Override
32-
@AuthUI.SupportedProvider
33-
public String getProviderId() {
34-
return EmailAuthProvider.PROVIDER_ID;
35-
}
36-
3729
@Override
3830
@LayoutRes
3931
public int getButtonLayout() {

auth/src/main/java/com/firebase/ui/auth/provider/FacebookProvider.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public class FacebookProvider implements IdpProvider, FacebookCallback<LoginResu
4848
private static final String TAG = "FacebookProvider";
4949
private static final String EMAIL = "email";
5050
private static final String PUBLIC_PROFILE = "public_profile";
51-
private static final String ERROR = "err";
52-
private static final String ERROR_MSG = "err_msg";
5351

5452
private static CallbackManager sCallbackManager;
5553

@@ -79,12 +77,6 @@ public String getName(Context context) {
7977
return context.getString(R.string.idp_name_facebook);
8078
}
8179

82-
@Override
83-
@AuthUI.SupportedProvider
84-
public String getProviderId() {
85-
return FacebookAuthProvider.PROVIDER_ID;
86-
}
87-
8880
@Override
8981
@LayoutRes
9082
public int getButtonLayout() {
@@ -134,12 +126,12 @@ public void onCompleted(JSONObject object, GraphResponse response) {
134126
FacebookRequestError requestError = response.getError();
135127
if (requestError != null) {
136128
Log.e(TAG, "Received Facebook error: " + requestError.getErrorMessage());
137-
onFailure(new Bundle());
129+
onFailure();
138130
return;
139131
}
140132
if (object == null) {
141133
Log.w(TAG, "Received null response from Facebook GraphRequest");
142-
onFailure(new Bundle());
134+
onFailure();
143135
} else {
144136
try {
145137
String email = object.getString("email");
@@ -160,18 +152,13 @@ public void onCompleted(JSONObject object, GraphResponse response) {
160152

161153
@Override
162154
public void onCancel() {
163-
Bundle extra = new Bundle();
164-
extra.putString(ERROR, "cancelled");
165-
onFailure(extra);
155+
onFailure();
166156
}
167157

168158
@Override
169159
public void onError(FacebookException error) {
170160
Log.e(TAG, "Error logging in with Facebook. " + error.getMessage());
171-
Bundle extra = new Bundle();
172-
extra.putString(ERROR, "error");
173-
extra.putString(ERROR_MSG, error.getMessage());
174-
onFailure(extra);
161+
onFailure();
175162
}
176163

177164
private void onSuccess(@Nullable String email, LoginResult loginResult) {
@@ -185,9 +172,9 @@ private IdpResponse createIdpResponse(@Nullable String email, LoginResult loginR
185172
.build();
186173
}
187174

188-
private void onFailure(Bundle bundle) {
175+
private void onFailure() {
189176
gcCallbackManager();
190-
mCallbackObject.onFailure(bundle);
177+
mCallbackObject.onFailure();
191178
}
192179

193180
private void gcCallbackManager() {

auth/src/main/java/com/firebase/ui/auth/provider/GoogleProvider.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import android.app.Activity;
1818
import android.content.Context;
1919
import android.content.Intent;
20-
import android.os.Bundle;
2120
import android.support.annotation.LayoutRes;
2221
import android.support.annotation.NonNull;
2322
import android.support.annotation.Nullable;
@@ -26,7 +25,6 @@
2625
import android.util.Log;
2726
import android.widget.Toast;
2827

29-
import com.firebase.ui.auth.AuthUI;
3028
import com.firebase.ui.auth.AuthUI.IdpConfig;
3129
import com.firebase.ui.auth.IdpResponse;
3230
import com.firebase.ui.auth.R;
@@ -46,7 +44,6 @@
4644
public class GoogleProvider implements IdpProvider, GoogleApiClient.OnConnectionFailedListener {
4745
private static final String TAG = "GoogleProvider";
4846
private static final int RC_SIGN_IN = 20;
49-
private static final String ERROR_KEY = "error";
5047

5148
private GoogleApiClient mGoogleApiClient;
5249
private FragmentActivity mActivity;
@@ -97,12 +94,6 @@ public String getName(Context context) {
9794
return context.getString(R.string.idp_name_google);
9895
}
9996

100-
@Override
101-
@AuthUI.SupportedProvider
102-
public String getProviderId() {
103-
return GoogleAuthProvider.PROVIDER_ID;
104-
}
105-
10697
@Override
10798
@LayoutRes
10899
public int getButtonLayout() {
@@ -175,9 +166,7 @@ private void onError(GoogleSignInResult result) {
175166

176167
private void onError(String errorMessage) {
177168
Log.e(TAG, "Error logging in with Google. " + errorMessage);
178-
Bundle extra = new Bundle();
179-
extra.putString(ERROR_KEY, errorMessage);
180-
mIdpCallback.onFailure(extra);
169+
mIdpCallback.onFailure();
181170
}
182171

183172
@Override

auth/src/main/java/com/firebase/ui/auth/provider/IdpProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
package com.firebase.ui.auth.provider;
1616

17-
import android.os.Bundle;
18-
1917
import com.firebase.ui.auth.IdpResponse;
2018

2119
public interface IdpProvider extends Provider {
2220
interface IdpCallback {
2321
void onSuccess(IdpResponse idpResponse);
2422

25-
void onFailure(Bundle extra);
23+
void onFailure();
2624
}
2725

2826
void setAuthenticationCallback(IdpCallback callback);

auth/src/main/java/com/firebase/ui/auth/provider/PhoneProvider.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
import android.content.Intent;
66
import android.support.annotation.LayoutRes;
77

8-
import com.firebase.ui.auth.AuthUI;
98
import com.firebase.ui.auth.R;
109
import com.firebase.ui.auth.ResultCodes;
1110
import com.firebase.ui.auth.ui.FlowParameters;
1211
import com.firebase.ui.auth.ui.phone.PhoneVerificationActivity;
13-
import com.google.firebase.auth.PhoneAuthProvider;
1412

1513
public class PhoneProvider implements Provider {
1614

@@ -29,12 +27,6 @@ public String getName(Context context) {
2927
return context.getString(R.string.provider_name_phone);
3028
}
3129

32-
@Override
33-
@AuthUI.SupportedProvider
34-
public String getProviderId() {
35-
return PhoneAuthProvider.PROVIDER_ID;
36-
}
37-
3830
@Override
3931
@LayoutRes
4032
public int getButtonLayout() {

auth/src/main/java/com/firebase/ui/auth/provider/Provider.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
import android.content.Intent;
66
import android.support.annotation.LayoutRes;
77

8-
import com.google.firebase.auth.GoogleAuthProvider;
9-
108
public interface Provider {
119
/** Retrieves the name of the IDP, for display on-screen. */
1210
String getName(Context context);
1311

14-
/** Retrieves the id of the IDP, e.g. {@link GoogleAuthProvider#PROVIDER_ID}. */
15-
String getProviderId();
16-
1712
/** Retrieves the layout id of the button to inflate and/or set a click listener. */
1813
@LayoutRes
1914
int getButtonLayout();

auth/src/main/java/com/firebase/ui/auth/provider/TwitterProvider.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import android.app.Activity;
44
import android.content.Context;
55
import android.content.Intent;
6-
import android.os.Bundle;
76
import android.support.annotation.LayoutRes;
87
import android.util.Log;
98

10-
import com.firebase.ui.auth.AuthUI;
119
import com.firebase.ui.auth.IdpResponse;
1210
import com.firebase.ui.auth.R;
1311
import com.google.firebase.auth.AuthCredential;
@@ -43,7 +41,7 @@ public static AuthCredential createAuthCredential(IdpResponse response) {
4341
return TwitterAuthProvider.getCredential(response.getIdpToken(), response.getIdpSecret());
4442
}
4543

46-
public static void initialize(Context context) {
44+
private static void initialize(Context context) {
4745
TwitterAuthConfig authConfig = new TwitterAuthConfig(
4846
context.getString(R.string.twitter_consumer_key),
4947
context.getString(R.string.twitter_consumer_secret));
@@ -72,12 +70,6 @@ public String getName(Context context) {
7270
return context.getString(R.string.idp_name_twitter);
7371
}
7472

75-
@Override
76-
@AuthUI.SupportedProvider
77-
public String getProviderId() {
78-
return TwitterAuthProvider.PROVIDER_ID;
79-
}
80-
8173
@Override
8274
@LayoutRes
8375
public int getButtonLayout() {
@@ -108,7 +100,7 @@ public void success(Result<TwitterSession> result) {
108100
@Override
109101
public void failure(TwitterException exception) {
110102
Log.e(TAG, "Failure logging in to Twitter. " + exception.getMessage());
111-
mCallbackObject.onFailure(new Bundle());
103+
mCallbackObject.onFailure();
112104
}
113105

114106
private static class EmailCallback extends Callback<String> {

auth/src/main/java/com/firebase/ui/auth/ui/ProgressDialogHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ProgressDialogHolder(Context context) {
1616
mContext = context;
1717
}
1818

19-
public void showLoadingDialog(String message) {
19+
private void showLoadingDialog(String message) {
2020
dismissDialog();
2121

2222
if (mProgressDialog == null) {

auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackIdpPrompt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void onFailure(@NonNull Exception e) {
187187
}
188188

189189
@Override
190-
public void onFailure(Bundle extra) {
190+
public void onFailure() {
191191
finishWithError();
192192
}
193193

auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackPasswordPrompt.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ protected void onCreate(Bundle savedInstanceState) {
8989
mIdpResponse = IdpResponse.fromResultIntent(getIntent());
9090
mEmail = mIdpResponse.getEmail();
9191

92-
TextView welcomeBackHeader = (TextView) findViewById(R.id.welcome_back_email_header);
9392
mPasswordLayout = (TextInputLayout) findViewById(R.id.password_layout);
9493
mPasswordField = (EditText) findViewById(R.id.password);
9594

auth/src/main/java/com/firebase/ui/auth/ui/idp/AuthMethodPickerActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void onSuccess(final IdpResponse response) {
163163
}
164164

165165
@Override
166-
public void onFailure(Bundle extra) {
166+
public void onFailure() {
167167
// stay on this screen
168168
getDialogHolder().dismissDialog();
169169
}

auth/src/main/java/com/firebase/ui/auth/ui/phone/BucketedTextChangeListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void onTextChanged(CharSequence s, int ignoredParam1, int ignoredParam2,
8686
final String enteredContent = numericContents.substring(0, enteredContentLength);
8787

8888
// 3) Reset the text to be the content + required hyphens. The SET automatically inserts
89-
// spaces requires for aesthetics. This requires removing and reseting the listener to
89+
// spaces requires for aesthetics. This requires removing and resetting the listener to
9090
// avoid recursion.
9191
editText.removeTextChangedListener(this);
9292
editText.setText(enteredContent + postFixes[expectedContentLength - enteredContentLength]);
@@ -106,12 +106,12 @@ public void afterTextChanged(Editable s) {
106106
}
107107

108108
/**
109-
* {@link #generatePostfixArray(CharSequence, int)} with params ("-", 6) returns
109+
* For example, passing in ("-", 6) would return the following result:
110110
* {"", "-", "--", "---", "----", "-----", "------"}
111111
*
112-
* @param repeatableChar
113-
* @param length
114-
* @return
112+
* @param repeatableChar the char to repeat to the specified length
113+
* @param length the maximum length of repeated chars
114+
* @return an increasing sequence array of chars up the specified length
115115
*/
116116
private String[] generatePostfixArray(CharSequence repeatableChar, int length) {
117117
final String[] ret = new String[length + 1];

auth/src/main/java/com/firebase/ui/auth/ui/phone/CompletableProgressDialog.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ protected void onCreate(Bundle savedInstanceState) {
5252
}
5353
}
5454

55-
@Override
56-
public void show() {
57-
super.show();
58-
}
59-
6055
public void complete(String msg) {
6156
setMessage(msg);
6257
mProgress.setVisibility(View.GONE);

0 commit comments

Comments
 (0)