Skip to content

Commit 9ccc7ef

Browse files
author
Iain McGinniss
committed
Checkstyle fixes and cleanup
Change-Id: I74de5db2673f71f4700fe4bc44a009bd9be58626
1 parent 44bf349 commit 9ccc7ef

File tree

7 files changed

+58
-57
lines changed

7 files changed

+58
-57
lines changed

auth/src/main/java/com/firebase/ui/auth/api/CredentialsAPI.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@ public String getPasswordFromCredential() {
126126
}
127127

128128
@Override
129-
public void onConnected(@Nullable Bundle bundle) {
130-
}
129+
public void onConnected(@Nullable Bundle bundle) {}
131130

132131
@Override
133-
public void onConnectionSuspended(int i) {
134-
}
132+
public void onConnectionSuspended(int cause) {}
135133

136134
private void initGoogleApiClient(String accountName) {
137135
GoogleSignInOptions.Builder gsoBuilder = new GoogleSignInOptions

auth/src/main/java/com/firebase/ui/auth/api/FirebaseAuthWrapperImpl.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public class FirebaseAuthWrapperImpl
5252

5353
private final FirebaseAuth mFirebaseAuth;
5454

55-
private long timeoutMs = DEFAULT_TIMEOUT;
55+
private long mTimeoutMs = DEFAULT_TIMEOUT;
5656

5757
public FirebaseAuthWrapperImpl(@NonNull FirebaseAuth firebaseAuth) {
58-
if(firebaseAuth == null) {
58+
if (firebaseAuth == null) {
5959
throw new IllegalArgumentException("firebaseAuth must not be null");
6060
}
6161
this.mFirebaseAuth = firebaseAuth;
@@ -78,10 +78,10 @@ public List<String> getProvidersForEmail(@Nullable String emailAddress) {
7878
return Collections.emptyList();
7979
}
8080

81-
ProviderQueryResult mProviderQueryResult =
81+
ProviderQueryResult result =
8282
await(mFirebaseAuth.fetchProvidersForEmail(emailAddress));
83-
if (hasProviders(mProviderQueryResult)) {
84-
return mProviderQueryResult.getProviders();
83+
if (hasProviders(result)) {
84+
return result.getProviders();
8585
}
8686

8787
return Collections.emptyList();
@@ -106,7 +106,7 @@ public boolean resetPasswordForEmail(@NonNull String emailAddress) {
106106
public FirebaseUser signInWithEmailPassword(
107107
@NonNull String emailAddress,
108108
@NonNull String password) {
109-
AuthResult authResult=
109+
AuthResult authResult =
110110
await(mFirebaseAuth.signInWithEmailAndPassword(emailAddress, password));
111111
return authResult == null ? null : authResult.getUser();
112112
}
@@ -158,12 +158,12 @@ public PendingIntent getEmailHintIntent(Context context) {
158158
return null;
159159
}
160160

161-
GoogleApiClient mCredentialsClient = new GoogleApiClient.Builder(context)
161+
GoogleApiClient client = new GoogleApiClient.Builder(context)
162162
.addConnectionCallbacks(this)
163163
.addApi(Auth.CREDENTIALS_API)
164164
.build();
165165

166-
mCredentialsClient.connect();
166+
client.connect();
167167

168168
HintRequest hintRequest = new HintRequest.Builder()
169169
.setHintPickerConfig(new CredentialPickerConfig.Builder()
@@ -172,12 +172,12 @@ public PendingIntent getEmailHintIntent(Context context) {
172172
.setEmailAddressIdentifierSupported(true)
173173
.build();
174174

175-
return Auth.CredentialsApi.getHintPickerIntent(mCredentialsClient, hintRequest);
175+
return Auth.CredentialsApi.getHintPickerIntent(client, hintRequest);
176176
}
177177

178178
@Override
179179
public void setTimeOut(long timeoutMs) {
180-
this.timeoutMs = timeoutMs;
180+
this.mTimeoutMs = timeoutMs;
181181
}
182182

183183
@Override
@@ -192,18 +192,14 @@ public FirebaseUser linkWithCredential(
192192
}
193193

194194
@Override
195-
public void onConnected(@Nullable Bundle bundle) {
196-
197-
}
195+
public void onConnected(@Nullable Bundle bundle) {}
198196

199197
@Override
200-
public void onConnectionSuspended(int i) {
201-
202-
}
198+
public void onConnectionSuspended(int cause) {}
203199

204200
private <T> T await(@NonNull Task<T> curTask) {
205201
try {
206-
Tasks.await(curTask, timeoutMs, TimeUnit.MILLISECONDS);
202+
Tasks.await(curTask, mTimeoutMs, TimeUnit.MILLISECONDS);
207203
return curTask.getResult();
208204
} catch (ExecutionException | InterruptedException | TimeoutException e) {
209205
if (BuildConfig.DEBUG) {

auth/src/main/java/com/firebase/ui/auth/api/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
/**
1616
* TODO: javadoc
1717
*/
18-
package com.firebase.ui.auth.api;
18+
package com.firebase.ui.auth.api;

auth/src/main/java/com/firebase/ui/auth/choreographer/Action.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ public static Action finish(int resultCode, Intent data) {
5555
}
5656

5757
/**
58-
* Block the flow at the current activity without doing anything. Information regarding the block
59-
* is contained in the Intent.
60-
*
58+
* Block the flow at the current activity without doing anything. Information regarding the
59+
* block is contained in the Intent.
6160
* @param data Data contains updated status for the current activity.
62-
* @return
6361
*/
6462
public static Action block(Intent data) {
6563
return new Action(Controller.BLOCK_AT_CURRENT_ACTIVITY_ID, data, 0, null);

auth/src/main/java/com/firebase/ui/auth/choreographer/Controller.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
package com.firebase.ui.auth.choreographer;
1616

1717
public interface Controller {
18-
public static final int DEFAULT_INIT_FLOW_ID = -1;
19-
public static final int BLOCK_AT_CURRENT_ACTIVITY_ID = -2;
20-
public static final int FINISH_FLOW_ID = -3;
21-
public static final int START_NEW_FLOW_ID = -4;
18+
int DEFAULT_INIT_FLOW_ID = -1;
19+
int BLOCK_AT_CURRENT_ACTIVITY_ID = -2;
20+
int FINISH_FLOW_ID = -3;
21+
int START_NEW_FLOW_ID = -4;
2222

2323
Action next(Result result);
2424
}

auth/src/main/java/com/firebase/ui/auth/choreographer/account_link/AccountLinkController.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import android.support.annotation.VisibleForTesting;
2121
import android.util.Log;
2222

23-
import com.firebase.ui.auth.api.FirebaseAuthWrapperFactory;
2423
import com.firebase.ui.auth.api.FirebaseAuthWrapper;
24+
import com.firebase.ui.auth.api.FirebaseAuthWrapperFactory;
2525
import com.firebase.ui.auth.choreographer.Action;
2626
import com.firebase.ui.auth.choreographer.Controller;
2727
import com.firebase.ui.auth.choreographer.ControllerConstants;
@@ -54,8 +54,7 @@ public class AccountLinkController implements Controller {
5454

5555
private Context mContext;
5656
private String mAppName;
57-
58-
57+
5958
public AccountLinkController(Context context, String appName) {
6059
mContext = context;
6160
mAppName = appName;
@@ -71,12 +70,13 @@ public Action next(Result result) {
7170

7271
IDPResponse idpResponse = data.getParcelableExtra(ControllerConstants.EXTRA_IDP_RESPONSE);
7372
FirebaseUser currentUser;
74-
FirebaseAuthWrapper apiWrapper = FirebaseAuthWrapperFactory.getFirebaseAuthWrapper(mAppName);
73+
FirebaseAuthWrapper apiWrapper =
74+
FirebaseAuthWrapperFactory.getFirebaseAuthWrapper(mAppName);
7575

7676
switch (result.getId()) {
7777
case ID_INIT:
7878
if (email == null) {
79-
finishAction(Activity.RESULT_OK);
79+
finishAction(Activity.RESULT_OK);
8080
}
8181
List<String> providers = apiWrapper.getProvidersForEmail(email);
8282

@@ -191,8 +191,10 @@ public Action next(Result result) {
191191
}
192192
case ID_CREDENTIALS_SAVE:
193193
return finishAction(Activity.RESULT_OK);
194+
default:
195+
Log.w(TAG, "No handler defined for state " + result.getId());
196+
return finishAction(Activity.RESULT_FIRST_USER);
194197
}
195-
return finishAction(Activity.RESULT_FIRST_USER);
196198
}
197199

198200
private Action finishAction(int resultCode) {

auth/src/main/java/com/firebase/ui/auth/choreographer/credentials/CredentialsController.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
public class CredentialsController implements Controller {
4141
private static final String TAG = "CredentialsController";
4242
private Context mContext;
43-
private CredentialsAPI mCredentialsAPI;
43+
private CredentialsAPI mCredentialsApi;
4444

4545
// states
4646
public static final int ID_INIT = 10;
4747
public static final int ID_CHOOSE_ACCOUNT = 20;
4848
private String mAppName;
4949

50-
public CredentialsController(Context context, CredentialsAPI credentialsAPI, String appName) {
51-
mCredentialsAPI = credentialsAPI;
50+
public CredentialsController(Context context, CredentialsAPI credentialsApi, String appName) {
51+
mCredentialsApi = credentialsApi;
5252
mContext = context;
5353
mAppName = appName;
5454
}
@@ -57,19 +57,19 @@ public CredentialsController(Context context, CredentialsAPI credentialsAPI, Str
5757
public Action next(Result result) {
5858
Intent data = result.getData();
5959

60-
String email = mCredentialsAPI.getEmailFromCredential();
61-
String password = mCredentialsAPI.getPasswordFromCredential();
62-
String accountType = mCredentialsAPI.getAccountTypeFromCredential();
60+
String email = mCredentialsApi.getEmailFromCredential();
61+
String password = mCredentialsApi.getPasswordFromCredential();
62+
String accountType = mCredentialsApi.getAccountTypeFromCredential();
6363

6464
ArrayList<IDPProviderParcel> providers =
6565
data.getParcelableArrayListExtra(ControllerConstants.EXTRA_PROVIDERS);
6666

6767
switch (result.getId()) {
6868
case ID_INIT:
69-
if (mCredentialsAPI.isPlayServicesAvailable()
70-
&& mCredentialsAPI.isCredentialsAvailable()) {
71-
if (mCredentialsAPI.isAutoSignInAvailable()) {
72-
mCredentialsAPI.googleSilentSignIn();
69+
if (mCredentialsApi.isPlayServicesAvailable()
70+
&& mCredentialsApi.isCredentialsAvailable()) {
71+
if (mCredentialsApi.isAutoSignInAvailable()) {
72+
mCredentialsApi.googleSilentSignIn();
7373
// TODO: (serikb) authenticate Firebase user and continue to application
7474
FirebaseUser loggedInUser;
7575
if (password != null && !password.isEmpty()) {
@@ -78,22 +78,23 @@ public Action next(Result result) {
7878
.signInWithEmailPassword(email, password);
7979
return finishAction(Activity.RESULT_OK, loggedInUser);
8080
} else {
81-
return redirectToIDPSignIn(email, accountType, providers);
81+
return redirectToIdpSignIn(email, accountType, providers);
8282
}
83-
} else if (mCredentialsAPI.isSignInResolutionNeeded()) {
83+
} else if (mCredentialsApi.isSignInResolutionNeeded()) {
8484
return Action.next(
8585
ID_CHOOSE_ACCOUNT,
8686
new Intent(mContext, ChooseAccountActivity.class)
8787
.putParcelableArrayListExtra(
88-
ControllerConstants.EXTRA_PROVIDERS, providers));
88+
ControllerConstants.EXTRA_PROVIDERS,
89+
providers));
8990
}
9091
}
9192
break;
9293
case ID_CHOOSE_ACCOUNT:
9394
Log.e(TAG, "email: " + email);
94-
if (email != null &&
95-
mCredentialsAPI.isCredentialsAvailable() &&
96-
!mCredentialsAPI.isSignInResolutionNeeded()) {
95+
if (email != null
96+
&& mCredentialsApi.isCredentialsAvailable()
97+
&& !mCredentialsApi.isSignInResolutionNeeded()) {
9798
// TODO: (serikb) authenticate Firebase user and continue to application
9899
FirebaseUser loggedInUser;
99100
if (password != null && !password.isEmpty()) {
@@ -102,18 +103,22 @@ public Action next(Result result) {
102103
.signInWithEmailPassword(email, password);
103104
return finishAction(Activity.RESULT_OK, loggedInUser);
104105
} else {
105-
return redirectToIDPSignIn(email, accountType, providers);
106+
return redirectToIdpSignIn(email, accountType, providers);
106107
}
107108
}
109+
break;
110+
default:
111+
Log.w(TAG, "No handler defined for state " + result.getId());
108112
}
113+
109114
return Action.startFlow(
110115
AuthMethodPickerActivity.createIntent(
111116
mContext,
112117
mAppName,
113118
providers));
114119
}
115120

116-
private Action redirectToIDPSignIn(
121+
private Action redirectToIdpSignIn(
117122
String email, String accountType, ArrayList<IDPProviderParcel> providers) {
118123
switch (accountType) {
119124
case IdentityProviders.GOOGLE:
@@ -132,15 +137,17 @@ private Action redirectToIDPSignIn(
132137
email,
133138
providers,
134139
mAppName));
140+
default:
141+
Log.w(TAG, "unknown provider: " + accountType);
142+
return Action.startFlow(
143+
AuthMethodPickerActivity.createIntent(mContext, mAppName, providers));
135144
}
136-
return Action.startFlow(
137-
AuthMethodPickerActivity.createIntent(mContext, mAppName, providers));
138145
}
139146

140147
private Action finishAction(int resultCode, FirebaseUser firebaseUser) {
141148
Bundle finishingData = new Bundle();
142149

143-
if(firebaseUser != null) {
150+
if (firebaseUser != null) {
144151
finishingData.putString(ControllerConstants.EXTRA_EMAIL, firebaseUser.getEmail());
145152
}
146153

0 commit comments

Comments
 (0)