Skip to content

Commit e20ae06

Browse files
committed
Code Style
Lint CheckStyle FindBugs
1 parent aa25561 commit e20ae06

36 files changed

+590
-559
lines changed

app/src/main/java/com/donnfelker/android/bootstrap/BootstrapApplication.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@
1010

1111
import com.github.kevinsawicki.http.HttpRequest;
1212

13-
import dagger.ObjectGraph;
14-
1513
/**
1614
* Android Bootstrap application
1715
*/
1816
public class BootstrapApplication extends Application {
1917

20-
private static BootstrapApplication instance;
18+
private static BootstrapApplication sInstance;
2119

2220
/**
2321
* Create main application
2422
*/
2523
public BootstrapApplication() {
26-
2724
// Disable http.keepAlive on Froyo and below
28-
if (SDK_INT <= FROYO)
25+
if (SDK_INT <= FROYO) {
2926
HttpRequest.keepAlive(false);
27+
}
3028
}
3129

3230
/**
@@ -37,14 +35,13 @@ public BootstrapApplication() {
3735
public BootstrapApplication(final Context context) {
3836
this();
3937
attachBaseContext(context);
40-
4138
}
4239

4340
@Override
4441
public void onCreate() {
4542
super.onCreate();
4643

47-
instance = this;
44+
sInstance = this;
4845

4946
// Perform injection
5047
Injector.init(getRootModule(), this);
@@ -67,6 +64,6 @@ public BootstrapApplication(final Instrumentation instrumentation) {
6764
}
6865

6966
public static BootstrapApplication getInstance() {
70-
return instance;
67+
return sInstance;
7168
}
7269
}

app/src/main/java/com/donnfelker/android/bootstrap/BootstrapModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
import com.donnfelker.android.bootstrap.authenticator.BootstrapAuthenticatorActivity;
77
import com.donnfelker.android.bootstrap.authenticator.LogoutService;
8-
import com.donnfelker.android.bootstrap.core.CheckIn;
98
import com.donnfelker.android.bootstrap.core.TimerService;
109
import com.donnfelker.android.bootstrap.ui.BootstrapTimerActivity;
1110
import com.donnfelker.android.bootstrap.ui.CarouselActivity;
1211
import com.donnfelker.android.bootstrap.ui.CheckInsListFragment;
13-
import com.donnfelker.android.bootstrap.ui.ItemListFragment;
1412
import com.donnfelker.android.bootstrap.ui.NewsActivity;
1513
import com.donnfelker.android.bootstrap.ui.NewsListFragment;
1614
import com.donnfelker.android.bootstrap.ui.UserActivity;

app/src/main/java/com/donnfelker/android/bootstrap/BootstrapServiceProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
public class BootstrapServiceProvider {
1818

19-
@Inject ApiKeyProvider keyProvider;
20-
@Inject UserAgentProvider userAgentProvider;
19+
@Inject ApiKeyProvider mKeyProvider;
20+
@Inject UserAgentProvider mUserAgentProvider;
2121

2222
/**
2323
* Get service for configured key provider
@@ -29,6 +29,6 @@ public class BootstrapServiceProvider {
2929
* @throws AccountsException
3030
*/
3131
public BootstrapService getService(Activity activity) throws IOException, AccountsException {
32-
return new BootstrapService(keyProvider.getAuthKey(activity), userAgentProvider);
32+
return new BootstrapService(mKeyProvider.getAuthKey(activity), mUserAgentProvider);
3333
}
3434
}

app/src/main/java/com/donnfelker/android/bootstrap/Injector.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
import dagger.ObjectGraph;
44

5-
public final class Injector
6-
{
7-
public static ObjectGraph objectGraph = null;
5+
public final class Injector {
6+
7+
public static ObjectGraph objectGraph = null; //TODO why is this public?
88

99

1010
public static void init(final Object rootModule) {
1111

12-
if(objectGraph == null)
13-
{
12+
if(objectGraph == null) {
1413
objectGraph = ObjectGraph.create(rootModule);
15-
}
16-
else
17-
{
14+
} else {
1815
objectGraph = objectGraph.plus(rootModule);
1916
}
2017

@@ -23,19 +20,16 @@ public static void init(final Object rootModule) {
2320

2421
}
2522

26-
public static void init(final Object rootModule, final Object target)
27-
{
23+
public static void init(final Object rootModule, final Object target) {
2824
init(rootModule);
2925
inject(target);
3026
}
3127

32-
public static final void inject(final Object target)
33-
{
28+
public static void inject(final Object target) {
3429
objectGraph.inject(target);
3530
}
3631

37-
public static <T> T resolve(Class<T> type)
38-
{
32+
public static <T> T resolve(Class<T> type) {
3933
return objectGraph.get(type);
4034
}
4135
}

app/src/main/java/com/donnfelker/android/bootstrap/authenticator/AccountAuthenticatorService.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
/**
1010
* Authenticator service that returns a subclass of AbstractAccountAuthenticator in onBind()
1111
*/
12-
public class AccountAuthenticatorService extends Service {
12+
class AccountAuthenticatorService extends Service {
1313

14-
private static BootstrapAccountAuthenticator AUTHENTICATOR = null;
14+
private static BootstrapAccountAuthenticator sAuthenticator = null;
1515

1616
@Override
17-
public IBinder onBind(Intent intent) {
18-
return intent.getAction().equals(ACTION_AUTHENTICATOR_INTENT) ? getAuthenticator().getIBinder() : null;
17+
public IBinder onBind(final Intent intent) {
18+
if (intent != null && ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) {
19+
return getAuthenticator().getIBinder();
20+
}
21+
return null;
1922
}
2023

2124
private BootstrapAccountAuthenticator getAuthenticator() {
22-
if (AUTHENTICATOR == null)
23-
AUTHENTICATOR = new BootstrapAccountAuthenticator(this);
24-
return AUTHENTICATOR;
25+
if (sAuthenticator == null) {
26+
sAuthenticator = new BootstrapAccountAuthenticator(this);
27+
}
28+
return sAuthenticator;
2529
}
2630
}

app/src/main/java/com/donnfelker/android/bootstrap/authenticator/ApiKeyProvider.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
package com.donnfelker.android.bootstrap.authenticator;
44

5-
import static android.accounts.AccountManager.KEY_AUTHTOKEN;
6-
75
import android.accounts.AccountManager;
86
import android.accounts.AccountManagerFuture;
97
import android.accounts.AccountsException;
108
import android.app.Activity;
119
import android.os.Bundle;
1210

13-
import com.donnfelker.android.bootstrap.core.Constants;
11+
import java.io.IOException;
12+
1413
import javax.inject.Inject;
1514

16-
import java.io.IOException;
15+
import static android.accounts.AccountManager.KEY_AUTHTOKEN;
16+
import static com.donnfelker.android.bootstrap.core.Constants.Auth.AUTHTOKEN_TYPE;
17+
import static com.donnfelker.android.bootstrap.core.Constants.Auth.BOOTSTRAP_ACCOUNT_TYPE;
1718

1819
/**
1920
* Bridge class that obtains a API key for the currently configured account
2021
*/
2122
public class ApiKeyProvider {
2223

23-
@Inject AccountManager accountManager;
24+
@Inject protected AccountManager mAccountManager;
2425

2526
/**
2627
* This call blocks, so shouldn't be called on the UI thread
@@ -29,9 +30,10 @@ public class ApiKeyProvider {
2930
* @throws AccountsException
3031
* @throws IOException
3132
*/
32-
public String getAuthKey(Activity activity) throws AccountsException, IOException {
33-
AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthTokenByFeatures(Constants.Auth.BOOTSTRAP_ACCOUNT_TYPE,
34-
Constants.Auth.AUTHTOKEN_TYPE, new String[0], activity, null, null, null, null);
33+
public String getAuthKey(final Activity activity) throws AccountsException, IOException {
34+
final AccountManagerFuture<Bundle> accountManagerFuture
35+
= mAccountManager.getAuthTokenByFeatures(BOOTSTRAP_ACCOUNT_TYPE,
36+
AUTHTOKEN_TYPE, new String[0], activity, null, null, null, null);
3537

3638
return accountManagerFuture.getResult().getString(KEY_AUTHTOKEN);
3739
}

app/src/main/java/com/donnfelker/android/bootstrap/authenticator/BootstrapAccountAuthenticator.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class BootstrapAccountAuthenticator extends AbstractAccountAuthenticator {
2323

2424
private static final String DESCRIPTION_CLIENT = "Bootstrap for Android";
2525

26-
private final Context context;
26+
private final Context mContext;
2727

28-
public BootstrapAccountAuthenticator(Context context) {
28+
public BootstrapAccountAuthenticator(final Context context) {
2929
super(context);
3030

31-
this.context = context;
31+
mContext = context;
3232
}
3333

3434
/*
@@ -37,23 +37,28 @@ public BootstrapAccountAuthenticator(Context context) {
3737
* manager.
3838
*/
3939
@Override
40-
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
41-
String[] requiredFeatures, Bundle options) throws NetworkErrorException {
42-
final Intent intent = new Intent(context, BootstrapAuthenticatorActivity.class);
40+
public Bundle addAccount(final AccountAuthenticatorResponse response, final String accountType,
41+
final String authTokenType, final String[] requiredFeatures,
42+
final Bundle options) throws NetworkErrorException {
43+
final Intent intent = new Intent(mContext, BootstrapAuthenticatorActivity.class);
4344
intent.putExtra(PARAM_AUTHTOKEN_TYPE, authTokenType);
4445
intent.putExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
46+
4547
final Bundle bundle = new Bundle();
4648
bundle.putParcelable(KEY_INTENT, intent);
49+
4750
return bundle;
4851
}
4952

5053
@Override
51-
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
54+
public Bundle confirmCredentials(final AccountAuthenticatorResponse response,
55+
final Account account, final Bundle options) {
5256
return null;
5357
}
5458

5559
@Override
56-
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
60+
public Bundle editProperties(final AccountAuthenticatorResponse response,
61+
final String accountType) {
5762
return null;
5863
}
5964

@@ -69,35 +74,39 @@ public Bundle editProperties(AccountAuthenticatorResponse response, String accou
6974
* @throws NetworkErrorException
7075
*/
7176
@Override
72-
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
73-
Bundle options) throws NetworkErrorException {
77+
public Bundle getAuthToken(final AccountAuthenticatorResponse response,
78+
final Account account, final String authTokenType,
79+
final Bundle options) throws NetworkErrorException {
7480

7581
Ln.d("Attempting to get authToken");
7682

77-
String authToken = AccountManager.get(context).peekAuthToken(account, authTokenType);
78-
Bundle bundle = new Bundle();
83+
final String authToken = AccountManager.get(mContext).peekAuthToken(account, authTokenType);
84+
85+
final Bundle bundle = new Bundle();
7986
bundle.putString(KEY_ACCOUNT_NAME, account.name);
8087
bundle.putString(KEY_ACCOUNT_TYPE, Constants.Auth.BOOTSTRAP_ACCOUNT_TYPE);
8188
bundle.putString(KEY_AUTHTOKEN, authToken);
89+
8290
return bundle;
8391
}
8492

8593
@Override
86-
public String getAuthTokenLabel(String authTokenType) {
94+
public String getAuthTokenLabel(final String authTokenType) {
8795
return authTokenType.equals(Constants.Auth.AUTHTOKEN_TYPE) ? authTokenType : null;
8896
}
8997

9098
@Override
91-
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)
92-
throws NetworkErrorException {
99+
public Bundle hasFeatures(final AccountAuthenticatorResponse response, final Account account,
100+
final String[] features) throws NetworkErrorException {
93101
final Bundle result = new Bundle();
94102
result.putBoolean(KEY_BOOLEAN_RESULT, false);
95103
return result;
96104
}
97105

98106
@Override
99-
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType,
100-
Bundle options) {
107+
public Bundle updateCredentials(final AccountAuthenticatorResponse response,
108+
final Account account, final String authTokenType,
109+
final Bundle options) {
101110
return null;
102111
}
103112
}

0 commit comments

Comments
 (0)