Skip to content

Commit d322f0e

Browse files
committed
Merge pull request #62 from danielkutik/gradle-appcompat-wip
Updated for AndroidStudio
2 parents c5af070 + be3f859 commit d322f0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+707
-1007
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ local.properties
1919
# Eclipse project files
2020
.classpath
2121
.project
22+
.settings/
23+
*/.classpath
24+
*/.project
25+
*/.settings/
2226

2327
# Proguard folder generated by Eclipse
2428
proguard/
@@ -50,4 +54,4 @@ temp-testng-customsuite.xml
5054
release.properties
5155
project.properties
5256
*/seed.txt
53-
gen-external-apklibs
57+
gen-external-apklibs

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repositories {
1717
}
1818

1919
dependencies {
20-
compile 'com.android.support:appcompat-v7:18.0.+'
20+
compile 'com.android.support:appcompat-v7:19.0.+'
2121
compile 'com.google.code.gson:gson:2.2.4'
2222
compile 'com.squareup.dagger:dagger:1.0.1'
2323
compile 'com.squareup.dagger:dagger-compiler:1.0.1'
@@ -36,12 +36,12 @@ dependencies {
3636
}
3737

3838
android {
39-
compileSdkVersion 18
40-
buildToolsVersion '18.0.1'
39+
compileSdkVersion 19
40+
buildToolsVersion '19.0.0'
4141

4242
defaultConfig {
4343
minSdkVersion 8
44-
targetSdkVersion 18
44+
targetSdkVersion 19
4545
versionCode 102
4646
versionName '1.0'
4747
}

app/default.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22
# Project target.
3-
target=android-18
3+
target=android-19

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<uses-sdk
99
android:minSdkVersion="8"
10-
android:targetSdkVersion="18" />
10+
android:targetSdkVersion="19" />
1111

1212
<uses-permission android:name="android.permission.INTERNET" />
1313
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
@@ -67,4 +67,4 @@
6767

6868
</application>
6969

70-
</manifest>
70+
</manifest>

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

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,41 @@
1919
/**
2020
* Module for all Android related provisions
2121
*/
22-
@Module
23-
(
24-
complete = false,
25-
library = true
26-
)
22+
@Module(complete = false, library = true)
2723
public class AndroidModule {
2824

2925
@Provides
3026
@Singleton
31-
Context provideAppContext()
32-
{
27+
Context provideAppContext() {
3328
return BootstrapApplication.getInstance().getApplicationContext();
3429
}
3530

3631
@Provides
37-
SharedPreferences provideDefaultSharedPreferences(final Context context)
38-
{
32+
SharedPreferences provideDefaultSharedPreferences(final Context context) {
3933
return PreferenceManager.getDefaultSharedPreferences(context);
4034
}
4135

4236
@Provides
43-
PackageInfo providePackageInfo(Context context)
44-
{
45-
try
46-
{
37+
PackageInfo providePackageInfo(Context context) {
38+
try {
4739
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
48-
}
49-
catch (PackageManager.NameNotFoundException e)
50-
{
40+
} catch (PackageManager.NameNotFoundException e) {
5141
throw new RuntimeException(e);
5242
}
5343
}
5444

5545
@Provides
56-
TelephonyManager provideTelephonyManager(Context context)
57-
{
46+
TelephonyManager provideTelephonyManager(Context context) {
5847
return getSystemService(context, Context.TELEPHONY_SERVICE);
5948
}
6049

6150
@SuppressWarnings("unchecked")
62-
public <T> T getSystemService(Context context, String serviceConstant)
63-
{
51+
public <T> T getSystemService(Context context, String serviceConstant) {
6452
return (T) context.getSystemService(serviceConstant);
6553
}
6654

6755
@Provides
68-
InputMethodManager provideInputMethodManager(final Context context)
69-
{
56+
InputMethodManager provideInputMethodManager(final Context context) {
7057
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
7158
}
7259

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
package com.donnfelker.android.bootstrap;
44

5-
import static android.os.Build.VERSION.SDK_INT;
6-
import static android.os.Build.VERSION_CODES.FROYO;
75
import android.app.Application;
86
import android.app.Instrumentation;
97
import android.content.Context;
108

119
import com.github.kevinsawicki.http.HttpRequest;
1210

13-
import dagger.ObjectGraph;
11+
import static android.os.Build.VERSION.SDK_INT;
12+
import static android.os.Build.VERSION_CODES.FROYO;
1413

1514
/**
1615
* Android Bootstrap application

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

Lines changed: 16 additions & 20 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;
@@ -26,25 +24,23 @@
2624
* Dagger module for setting up provides statements.
2725
* Register all of your entry points below.
2826
*/
29-
@Module
30-
(
31-
complete = false,
32-
33-
injects = {
34-
BootstrapApplication.class,
35-
BootstrapAuthenticatorActivity.class,
36-
CarouselActivity.class,
37-
BootstrapTimerActivity.class,
38-
CheckInsListFragment.class,
39-
NewsActivity.class,
40-
NewsListFragment.class,
41-
UserActivity.class,
42-
UserListFragment.class,
43-
TimerService.class
44-
}
45-
27+
@Module(
28+
complete = false,
29+
30+
injects = {
31+
BootstrapApplication.class,
32+
BootstrapAuthenticatorActivity.class,
33+
CarouselActivity.class,
34+
BootstrapTimerActivity.class,
35+
CheckInsListFragment.class,
36+
NewsActivity.class,
37+
NewsListFragment.class,
38+
UserActivity.class,
39+
UserListFragment.class,
40+
TimerService.class
41+
}
4642
)
47-
public class BootstrapModule {
43+
public class BootstrapModule {
4844

4945
@Singleton
5046
@Provides

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import com.donnfelker.android.bootstrap.authenticator.ApiKeyProvider;
88
import com.donnfelker.android.bootstrap.core.BootstrapService;
99
import com.donnfelker.android.bootstrap.core.UserAgentProvider;
10-
import javax.inject.Inject;
1110

1211
import java.io.IOException;
1312

13+
import javax.inject.Inject;
14+
1415
/**
1516
* Provider for a {@link com.donnfelker.android.bootstrap.core.BootstrapService} instance
1617
*/
@@ -21,7 +22,7 @@ public class BootstrapServiceProvider {
2122

2223
/**
2324
* Get service for configured key provider
24-
* <p>
25+
* <p/>
2526
* This method gets an auth key and so it blocks and shouldn't be called on the main thread.
2627
*
2728
* @return bootstrap service

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
import dagger.ObjectGraph;
44

5-
public final class Injector
6-
{
5+
public final class Injector {
76
public static ObjectGraph objectGraph = null;
87

98

109
public static void init(final Object rootModule) {
1110

12-
if(objectGraph == null)
13-
{
11+
if (objectGraph == null) {
1412
objectGraph = ObjectGraph.create(rootModule);
15-
}
16-
else
17-
{
13+
} else {
1814
objectGraph = objectGraph.plus(rootModule);
1915
}
2016

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

2420
}
2521

26-
public static void init(final Object rootModule, final Object target)
27-
{
22+
public static void init(final Object rootModule, final Object target) {
2823
init(rootModule);
2924
inject(target);
3025
}
3126

32-
public static final void inject(final Object target)
33-
{
27+
public static void inject(final Object target) {
3428
objectGraph.inject(target);
3529
}
3630

37-
public static <T> T resolve(Class<T> type)
38-
{
31+
public static <T> T resolve(Class<T> type) {
3932
return objectGraph.get(type);
4033
}
4134
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
/**
66
* Add all the other modules to this one.
77
*/
8-
@Module
9-
(
8+
@Module(
109
includes = {
11-
AndroidModule.class,
12-
BootstrapModule.class
10+
AndroidModule.class,
11+
BootstrapModule.class
1312
}
1413
)
1514
public class RootModule {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

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

4-
import static android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT;
54
import android.app.Service;
65
import android.content.Intent;
76
import android.os.IBinder;
87

8+
import static android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT;
9+
910
/**
1011
* Authenticator service that returns a subclass of AbstractAccountAuthenticator in onBind()
1112
*/
@@ -15,7 +16,7 @@ public class AccountAuthenticatorService extends Service {
1516

1617
@Override
1718
public IBinder onBind(Intent intent) {
18-
return intent.getAction().equals(ACTION_AUTHENTICATOR_INTENT) ? getAuthenticator().getIBinder() : null;
19+
return ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction()) ? getAuthenticator().getIBinder() : null;
1920
}
2021

2122
private BootstrapAccountAuthenticator getAuthenticator() {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
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

1311
import com.donnfelker.android.bootstrap.core.Constants;
14-
import javax.inject.Inject;
1512

1613
import java.io.IOException;
1714

15+
import javax.inject.Inject;
16+
17+
import static android.accounts.AccountManager.KEY_AUTHTOKEN;
18+
1819
/**
1920
* Bridge class that obtains a API key for the currently configured account
2021
*/

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11

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

4-
import static android.accounts.AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE;
5-
import static android.accounts.AccountManager.KEY_ACCOUNT_NAME;
6-
import static android.accounts.AccountManager.KEY_ACCOUNT_TYPE;
7-
import static android.accounts.AccountManager.KEY_AUTHTOKEN;
8-
import static android.accounts.AccountManager.KEY_BOOLEAN_RESULT;
9-
import static android.accounts.AccountManager.KEY_INTENT;
10-
import static com.donnfelker.android.bootstrap.authenticator.BootstrapAuthenticatorActivity.PARAM_AUTHTOKEN_TYPE;
114
import android.accounts.AbstractAccountAuthenticator;
125
import android.accounts.Account;
136
import android.accounts.AccountAuthenticatorResponse;
@@ -16,9 +9,18 @@
169
import android.content.Context;
1710
import android.content.Intent;
1811
import android.os.Bundle;
12+
1913
import com.donnfelker.android.bootstrap.core.Constants;
2014
import com.donnfelker.android.bootstrap.util.Ln;
2115

16+
import static android.accounts.AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE;
17+
import static android.accounts.AccountManager.KEY_ACCOUNT_NAME;
18+
import static android.accounts.AccountManager.KEY_ACCOUNT_TYPE;
19+
import static android.accounts.AccountManager.KEY_AUTHTOKEN;
20+
import static android.accounts.AccountManager.KEY_BOOLEAN_RESULT;
21+
import static android.accounts.AccountManager.KEY_INTENT;
22+
import static com.donnfelker.android.bootstrap.authenticator.BootstrapAuthenticatorActivity.PARAM_AUTHTOKEN_TYPE;
23+
2224
class BootstrapAccountAuthenticator extends AbstractAccountAuthenticator {
2325

2426
private static final String DESCRIPTION_CLIENT = "Bootstrap for Android";
@@ -38,7 +40,7 @@ public BootstrapAccountAuthenticator(Context context) {
3840
*/
3941
@Override
4042
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
41-
String[] requiredFeatures, Bundle options) throws NetworkErrorException {
43+
String[] requiredFeatures, Bundle options) throws NetworkErrorException {
4244
final Intent intent = new Intent(context, BootstrapAuthenticatorActivity.class);
4345
intent.putExtra(PARAM_AUTHTOKEN_TYPE, authTokenType);
4446
intent.putExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
@@ -61,6 +63,7 @@ public Bundle editProperties(AccountAuthenticatorResponse response, String accou
6163
* This method gets called when the
6264
* {@link com.donnfelker.android.bootstrap.authenticator.ApiKeyProvider#getAuthKey()} methods gets invoked.
6365
* This happens on a different process, so debugging it can be a beast.
66+
*
6467
* @param response
6568
* @param account
6669
* @param authTokenType
@@ -70,7 +73,7 @@ public Bundle editProperties(AccountAuthenticatorResponse response, String accou
7073
*/
7174
@Override
7275
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
73-
Bundle options) throws NetworkErrorException {
76+
Bundle options) throws NetworkErrorException {
7477

7578
Ln.d("Attempting to get authToken");
7679

@@ -97,7 +100,7 @@ public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account
97100

98101
@Override
99102
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType,
100-
Bundle options) {
103+
Bundle options) {
101104
return null;
102105
}
103106
}

0 commit comments

Comments
 (0)