├── .gitignore ├── LICENSE ├── README.md ├── dagger2-demo ├── .gitignore ├── README.md ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── net │ │ │ └── gouline │ │ │ └── dagger2demo │ │ │ └── ApplicationTest.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── net │ │ │ └── gouline │ │ │ └── dagger2demo │ │ │ ├── DemoApplication.java │ │ │ ├── activity │ │ │ └── AlbumSearchActivity.java │ │ │ ├── di │ │ │ ├── component │ │ │ │ └── DemoApplicationComponent.java │ │ │ └── module │ │ │ │ └── ApplicationModule.java │ │ │ ├── model │ │ │ ├── ITunesResult.java │ │ │ └── ITunesResultSet.java │ │ │ └── rest │ │ │ └── ITunesService.java │ │ └── res │ │ ├── drawable-hdpi │ │ ├── ic_action_search.png │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ ├── ic_action_search.png │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ ├── ic_action_search.png │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ ├── ic_action_search.png │ │ └── ic_launcher.png │ │ ├── layout │ │ └── activity_album_search.xml │ │ ├── menu │ │ └── activity_album_search.xml │ │ ├── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── searchable.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── drawable-sources ├── README.md ├── app │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── net │ │ │ └── gouline │ │ │ └── drawablesources │ │ │ ├── app │ │ │ └── MainActivity.java │ │ │ ├── model │ │ │ ├── Contact.java │ │ │ ├── Profile.java │ │ │ └── User.java │ │ │ ├── util │ │ │ └── DrawableSource.java │ │ │ └── widget │ │ │ └── ProfileView.java │ │ └── res │ │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ └── ic_profile.png │ │ ├── drawable-mdpi │ │ ├── ic_launcher.png │ │ └── ic_profile.png │ │ ├── drawable-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_profile.png │ │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ │ ├── layout │ │ └── view_profile.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── gradle-eclipse ├── AndroidManifest.xml ├── README.md ├── build.gradle ├── build.xml ├── ic_launcher-web.png ├── libs │ └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── activity_main.xml │ ├── menu │ │ └── main.xml │ ├── values-sw600dp │ │ └── dimens.xml │ ├── values-sw720dp-land │ │ └── dimens.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ ├── debug │ └── java │ │ └── net │ │ └── gouline │ │ └── android │ │ └── gradle │ │ └── EnvironmentConfig.java │ ├── main │ └── java │ │ └── net │ │ └── gouline │ │ └── android │ │ └── gradle │ │ └── MainActivity.java │ └── release │ └── java │ └── net │ └── gouline │ └── android │ └── gradle │ └── EnvironmentConfig.java ├── jacoco ├── .gitignore ├── README.md ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── net │ │ │ └── gouline │ │ │ └── jacoco │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── net │ │ │ │ └── gouline │ │ │ │ └── jacoco │ │ │ │ ├── activity │ │ │ │ └── MainActivity.java │ │ │ │ └── util │ │ │ │ └── UsefulUtils.java │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── net │ │ └── gouline │ │ └── jacoco │ │ └── UsefulUtilsTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jacoco.gradle └── settings.gradle └── kotlin-demo ├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules-debug.pro ├── proguard-rules-test.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── net │ │ └── gouline │ │ └── kotlindemo │ │ ├── ApplicationTest.kt │ │ └── WifiStationTest.kt │ ├── debug │ └── java │ │ └── net │ │ └── gouline │ │ └── kotlindemo │ │ └── BuildTypeConfig.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── net │ │ │ └── gouline │ │ │ └── kotlindemo │ │ │ ├── app │ │ │ ├── MainActivity.kt │ │ │ ├── WifiActivity.kt │ │ │ ├── WifiDetailFragment.kt │ │ │ └── WifiListFragment.kt │ │ │ └── model │ │ │ └── WifiStation.kt │ └── res │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_wifi.xml │ │ ├── fragment_wifi_detail.xml │ │ ├── fragment_wifi_list.xml │ │ └── list_item_wifi.xml │ │ ├── menu │ │ ├── main.xml │ │ └── wifi.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── release │ └── java │ └── net │ └── gouline │ └── kotlindemo │ └── BuildTypeConfig.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | build/ 15 | 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | 19 | # Eclipse project files 20 | .classpath 21 | .project 22 | .settings/ 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Intellij project files 28 | *.iml 29 | *.ipr 30 | *.iws 31 | .idea/ 32 | 33 | # Build 34 | .gradle/ 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Mike Gouline 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Android Samples 2 | =============== 3 | 4 | Sample Android code for the tutorials on my [blog][1]. 5 | 6 | Developed By 7 | ------------ 8 | * Mike Gouline 9 | 10 | The MIT License (MIT) 11 | --------------------- 12 | 13 | Copyright (c) 2015 Mike Gouline 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 19 | the Software, and to permit persons to whom the Software is furnished to do so, 20 | subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 27 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 28 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 29 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | 32 | [1]: http://blog.gouline.net/tag/android/ 33 | -------------------------------------------------------------------------------- /dagger2-demo/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .DS_Store 3 | *.iml 4 | /.idea 5 | /local.properties 6 | /build 7 | -------------------------------------------------------------------------------- /dagger2-demo/README.md: -------------------------------------------------------------------------------- 1 | Dagger 2 Demo 2 | ============= 3 | 4 | Sample Android application using [Dagger 2](http://google.github.io/dagger/). 5 | 6 | Read the full article [here](http://blog.gouline.net/2015/05/04/dagger-2-even-sharper-less-square/). 7 | 8 | -------------------------------------------------------------------------------- /dagger2-demo/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /dagger2-demo/app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 7 | } 8 | } 9 | 10 | apply plugin: 'com.android.application' 11 | apply plugin: 'com.neenbedankt.android-apt' 12 | 13 | android { 14 | compileSdkVersion 22 15 | buildToolsVersion "22.0.1" 16 | 17 | defaultConfig { 18 | applicationId "net.gouline.dagger2demo" 19 | minSdkVersion 15 20 | targetSdkVersion 22 21 | versionCode 1 22 | versionName "1.0" 23 | } 24 | buildTypes { 25 | debug { 26 | minifyEnabled true 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_7 33 | targetCompatibility JavaVersion.VERSION_1_7 34 | } 35 | } 36 | 37 | dependencies { 38 | // Support 39 | compile 'com.android.support:appcompat-v7:22.0.0' 40 | 41 | // Injection 42 | compile 'javax.annotation:jsr250-api:1.0' 43 | compile 'com.google.dagger:dagger:2.0' 44 | apt 'com.google.dagger:dagger-compiler:2.0' 45 | compile 'com.jakewharton:butterknife:6.1.0' 46 | 47 | // Network 48 | compile 'com.squareup.retrofit:retrofit:1.9.0' 49 | } 50 | -------------------------------------------------------------------------------- /dagger2-demo/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # NOTE: Nothing to configure for Dagger! 20 | 21 | # Support 22 | -dontwarn android.support.v7.** 23 | -keep class android.support.v7.** { *; } 24 | -keep interface android.support.v7.** { *; } 25 | 26 | # Retrofit (with OkHttp) 27 | -keepattributes Signature 28 | -keepattributes *Annotation* 29 | -keep class com.squareup.okhttp.** { *; } 30 | -keep interface com.squareup.okhttp.** { *; } 31 | -dontwarn com.squareup.okhttp.** 32 | 33 | -dontwarn rx.** 34 | -dontwarn retrofit.** 35 | -keep class retrofit.** { *; } 36 | -keepclasseswithmembers class * { 37 | @retrofit.http.* ; 38 | } 39 | 40 | -keep class sun.misc.Unsafe { *; } 41 | -keep class net.gouline.dagger2demo.model.** { *; } 42 | 43 | -dontwarn okio.** 44 | 45 | # Butter Knife 46 | -keep class butterknife.** { *; } 47 | -dontwarn butterknife.internal.** 48 | -keep class **$$ViewInjector { *; } 49 | 50 | -keepclasseswithmembernames class * { 51 | @butterknife.* ; 52 | } 53 | 54 | -keepclasseswithmembernames class * { 55 | @butterknife.* ; 56 | } 57 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/androidTest/java/net/gouline/dagger2demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.support.annotation.NonNull; 6 | 7 | import net.gouline.dagger2demo.di.component.DaggerDemoApplicationComponent; 8 | import net.gouline.dagger2demo.di.component.DemoApplicationComponent; 9 | import net.gouline.dagger2demo.di.module.ApplicationModule; 10 | 11 | /** 12 | * Custom application definition. 13 | *

14 | * Created by mgouline on 23/04/15. 15 | */ 16 | public class DemoApplication extends Application { 17 | private DemoApplicationComponent mComponent; 18 | 19 | @Override 20 | public void onCreate() { 21 | super.onCreate(); 22 | mComponent = DaggerDemoApplicationComponent.builder() 23 | .applicationModule(new ApplicationModule(this)) 24 | .build(); 25 | mComponent.inject(this); 26 | } 27 | 28 | public DemoApplicationComponent getComponent() { 29 | return mComponent; 30 | } 31 | 32 | /** 33 | * Extracts application from support context types. 34 | * 35 | * @param context Source context. 36 | * @return Application instance or {@code null}. 37 | */ 38 | public static DemoApplication from(@NonNull Context context) { 39 | return (DemoApplication) context.getApplicationContext(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/activity/AlbumSearchActivity.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo.activity; 2 | 3 | import android.app.ProgressDialog; 4 | import android.app.SearchManager; 5 | import android.content.Context; 6 | import android.os.Bundle; 7 | import android.support.v7.app.ActionBarActivity; 8 | import android.support.v7.widget.SearchView; 9 | import android.util.Log; 10 | import android.view.Menu; 11 | import android.view.View; 12 | import android.widget.ArrayAdapter; 13 | import android.widget.ListView; 14 | 15 | import net.gouline.dagger2demo.DemoApplication; 16 | import net.gouline.dagger2demo.R; 17 | import net.gouline.dagger2demo.model.ITunesResult; 18 | import net.gouline.dagger2demo.model.ITunesResultSet; 19 | import net.gouline.dagger2demo.rest.ITunesService; 20 | 21 | import javax.inject.Inject; 22 | 23 | import butterknife.ButterKnife; 24 | import butterknife.InjectView; 25 | import retrofit.Callback; 26 | import retrofit.RetrofitError; 27 | import retrofit.client.Response; 28 | 29 | /** 30 | * Activity for search iTunes albums by artist name. 31 | *

32 | * Created by mgouline on 23/04/15. 33 | */ 34 | public class AlbumSearchActivity extends ActionBarActivity implements SearchView.OnQueryTextListener { 35 | private static final String TAG = AlbumSearchActivity.class.getSimpleName(); 36 | 37 | @Inject 38 | ITunesService mITunesService; 39 | 40 | @InjectView(android.R.id.list) 41 | ListView mListView; 42 | @InjectView(R.id.empty_view) 43 | View mEmptyView; 44 | 45 | private ProgressDialog mProgressDialog; 46 | 47 | private ArrayAdapter mListAdapter; 48 | 49 | @Override 50 | public void onCreate(Bundle savedInstanceState) { 51 | super.onCreate(savedInstanceState); 52 | setContentView(R.layout.activity_album_search); 53 | ButterKnife.inject(this); 54 | 55 | // Actual injection, now performed via the component 56 | DemoApplication.from(this).getComponent().inject(this); 57 | 58 | mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); 59 | mListView.setEmptyView(mEmptyView); 60 | mListView.setAdapter(mListAdapter); 61 | } 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | getMenuInflater().inflate(R.menu.activity_album_search, menu); 66 | 67 | SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); 68 | SearchView searchView = (SearchView) menu.findItem(R.id.menu_item_search).getActionView(); 69 | searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); 70 | searchView.setOnQueryTextListener(this); 71 | 72 | return true; 73 | } 74 | 75 | @Override 76 | public boolean onQueryTextSubmit(String s) { 77 | fetchResults(s); 78 | return true; 79 | } 80 | 81 | @Override 82 | public boolean onQueryTextChange(String s) { 83 | return false; 84 | } 85 | 86 | private void fetchResults(String term) { 87 | if (mProgressDialog != null && mProgressDialog.isShowing()) { 88 | mProgressDialog.dismiss(); 89 | } 90 | mProgressDialog = ProgressDialog.show(this, null, getString(R.string.search_progress)); 91 | 92 | // Properly injected Retrofit service 93 | mITunesService.search(term, "album", new Callback() { 94 | @Override 95 | public void success(ITunesResultSet iTunesResultSet, Response response) { 96 | mListAdapter.addAll(iTunesResultSet.getResults()); 97 | mListAdapter.notifyDataSetChanged(); 98 | mProgressDialog.dismiss(); 99 | } 100 | 101 | @Override 102 | public void failure(RetrofitError error) { 103 | Log.w(TAG, "Failed to retrieve albums", error); 104 | mProgressDialog.dismiss(); 105 | } 106 | }); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/di/component/DemoApplicationComponent.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo.di.component; 2 | 3 | import net.gouline.dagger2demo.DemoApplication; 4 | import net.gouline.dagger2demo.activity.AlbumSearchActivity; 5 | import net.gouline.dagger2demo.di.module.ApplicationModule; 6 | 7 | import javax.inject.Singleton; 8 | 9 | import dagger.Component; 10 | 11 | /** 12 | * Component for {@link DemoApplication}. 13 | *

14 | * This acts as pairing between the module and injection targets, each of which 15 | * has to have a corresponding inject method in this component. 16 | *

17 | * Created by mgouline on 23/04/15. 18 | */ 19 | @Singleton 20 | @Component(modules = ApplicationModule.class) 21 | public interface DemoApplicationComponent { 22 | void inject(DemoApplication application); 23 | 24 | void inject(AlbumSearchActivity activity); 25 | } 26 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/di/module/ApplicationModule.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo.di.module; 2 | 3 | import android.content.Context; 4 | 5 | import net.gouline.dagger2demo.DemoApplication; 6 | import net.gouline.dagger2demo.rest.ITunesService; 7 | 8 | import javax.inject.Singleton; 9 | 10 | import dagger.Module; 11 | import dagger.Provides; 12 | import retrofit.RestAdapter; 13 | 14 | /** 15 | * Application-wide dependencies. 16 | *

17 | * Now it only contains the injectable objects and has no direct pairing 18 | * to the injection targets - that's what components are now for. 19 | *

20 | * Created by mgouline on 23/04/15. 21 | */ 22 | @Module 23 | public class ApplicationModule { 24 | private final DemoApplication mApplication; 25 | 26 | private ITunesService mITunesService; 27 | 28 | public ApplicationModule(DemoApplication application) { 29 | mApplication = application; 30 | mITunesService = new RestAdapter.Builder() 31 | .setEndpoint("https://itunes.apple.com") 32 | .build() 33 | .create(ITunesService.class); 34 | } 35 | 36 | @Provides 37 | @Singleton 38 | Context provideApplicationContext() { 39 | return mApplication; 40 | } 41 | 42 | @Provides 43 | @Singleton 44 | ITunesService provideITunesService() { 45 | return mITunesService; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/model/ITunesResult.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo.model; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Single iTunes result contained in {@link ITunesResultSet}. 9 | *

10 | * Created by mgouline on 23/04/15. 11 | */ 12 | @SuppressWarnings("unused") 13 | public class ITunesResult implements Serializable { 14 | @SerializedName("collectionName") 15 | private String mCollectionName; 16 | 17 | public String getCollectionName() { 18 | return mCollectionName; 19 | } 20 | 21 | public void setCollectionName(String collectionName) { 22 | mCollectionName = collectionName; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return mCollectionName; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/model/ITunesResultSet.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo.model; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Result set as returned from the iTunes API. 10 | *

11 | * Created by mgouline on 23/04/15. 12 | */ 13 | @SuppressWarnings("unused") 14 | public class ITunesResultSet implements Serializable { 15 | @SerializedName("results") 16 | private List mResults; 17 | 18 | public List getResults() { 19 | return mResults; 20 | } 21 | 22 | public void setResults(List results) { 23 | mResults = results; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/java/net/gouline/dagger2demo/rest/ITunesService.java: -------------------------------------------------------------------------------- 1 | package net.gouline.dagger2demo.rest; 2 | 3 | import net.gouline.dagger2demo.model.ITunesResultSet; 4 | 5 | import retrofit.Callback; 6 | import retrofit.http.GET; 7 | import retrofit.http.Query; 8 | 9 | /** 10 | * iTunes service. 11 | *

12 | * Created by mgouline on 23/04/15. 13 | */ 14 | public interface ITunesService { 15 | @GET("/search") 16 | void search(@Query("term") String term, @Query("entity") String entity, Callback callback); 17 | } 18 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-hdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-hdpi/ic_action_search.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-mdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-mdpi/ic_action_search.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-xhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-xhdpi/ic_action_search.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-xxhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-xxhdpi/ic_action_search.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/dagger2-demo/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/layout/activity_album_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/menu/activity_album_search.xml: -------------------------------------------------------------------------------- 1 | 2 |

4 | 10 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20dp 5 | 6 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dagger2 Demo 4 | Albums 5 | 6 | Search 7 | 8 | Artist 9 | Search for artists names to see albums 10 | Searching… 11 | 12 | -------------------------------------------------------------------------------- /dagger2-demo/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /drawable-sources/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /drawable-sources/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /drawable-sources/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/drawable-sources/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /drawable-sources/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 01 20:01:16 EST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /drawable-sources/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /drawable-sources/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /drawable-sources/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /gradle-eclipse/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /gradle-eclipse/README.md: -------------------------------------------------------------------------------- 1 | Gradle Eclipse Sample 2 | =================== 3 | 4 | Basic structure for an Android project on Eclipse generated by Gradle. 5 | 6 | Read the full tutorial [here][1]. 7 | 8 | ## Deprecated 9 | Since Android Studio is now the official IDE for Android, this sample is deprecated and is only kept for archival purposes. Stop using Eclipse already! 10 | 11 | [1]: http://blog.gouline.net/2013/10/21/new-build-system-for-android-with-eclipse 12 | -------------------------------------------------------------------------------- /gradle-eclipse/build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/build.gradle -------------------------------------------------------------------------------- /gradle-eclipse/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /gradle-eclipse/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle-eclipse/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/libs/android-support-v4.jar -------------------------------------------------------------------------------- /gradle-eclipse/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /gradle-eclipse/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | -------------------------------------------------------------------------------- /gradle-eclipse/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle-eclipse/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle-eclipse/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle-eclipse/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/gradle-eclipse/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle-eclipse/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /gradle-eclipse/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GradleBasic 5 | Settings 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle-eclipse/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /gradle-eclipse/src/debug/java/net/gouline/android/gradle/EnvironmentConfig.java: -------------------------------------------------------------------------------- 1 | package net.gouline.android.gradle; 2 | 3 | /** 4 | * Environment-specific configuration. 5 | * 6 | * @author Mike Gouline 7 | * 8 | */ 9 | public interface EnvironmentConfig { 10 | 11 | public static final String ENVIRONMENT = "debug"; 12 | } 13 | -------------------------------------------------------------------------------- /gradle-eclipse/src/main/java/net/gouline/android/gradle/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.gouline.android.gradle; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import android.app.Activity; 6 | import android.os.Bundle; 7 | import android.view.Menu; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Sample main activity. 12 | * 13 | * @author Mike Gouline 14 | * 15 | */ 16 | public class MainActivity extends Activity { 17 | 18 | private TextView mTextViewEnvironment; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | String environmentShort = StringUtils.abbreviate(EnvironmentConfig.ENVIRONMENT, 3); 26 | 27 | mTextViewEnvironment = (TextView) findViewById(R.id.textViewEnvironment); 28 | mTextViewEnvironment.setText(environmentShort); 29 | } 30 | 31 | @Override 32 | public boolean onCreateOptionsMenu(Menu menu) { 33 | getMenuInflater().inflate(R.menu.main, menu); 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gradle-eclipse/src/release/java/net/gouline/android/gradle/EnvironmentConfig.java: -------------------------------------------------------------------------------- 1 | package net.gouline.android.gradle; 2 | 3 | /** 4 | * Environment-specific configuration. 5 | * 6 | * @author Mike Gouline 7 | * 8 | */ 9 | public interface EnvironmentConfig { 10 | 11 | public static final String ENVIRONMENT = "release"; 12 | } 13 | -------------------------------------------------------------------------------- /jacoco/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .DS_Store 3 | *.iml 4 | /.idea 5 | /local.properties 6 | /build 7 | -------------------------------------------------------------------------------- /jacoco/README.md: -------------------------------------------------------------------------------- 1 | JaCoCo 2 | ====== 3 | 4 | Sample Android application using [JaCoCo](http://www.eclemma.org/jacoco/). 5 | 6 | Read the full article [here](http://blog.gouline.net/2015/06/23/code-coverage-on-android-with-jacoco/). 7 | 8 | -------------------------------------------------------------------------------- /jacoco/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /jacoco/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply from: '../jacoco.gradle' 4 | 5 | android { 6 | compileSdkVersion 23 7 | buildToolsVersion "23.0.1" 8 | 9 | defaultConfig { 10 | applicationId "net.gouline.jacoco" 11 | minSdkVersion 15 12 | targetSdkVersion 23 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | buildTypes { 17 | debug { 18 | testCoverageEnabled = true 19 | } 20 | } 21 | productFlavors { 22 | blue {} 23 | 24 | red {} 25 | } 26 | 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_7 29 | targetCompatibility JavaVersion.VERSION_1_7 30 | } 31 | } 32 | 33 | dependencies { 34 | // Support 35 | compile 'com.android.support:appcompat-v7:22.2.0' 36 | 37 | // Injection 38 | compile 'com.jakewharton:butterknife:6.1.0' 39 | 40 | // Unit testing 41 | testCompile "org.robolectric:robolectric:3.0-rc3" 42 | testCompile "junit:junit:4.12" 43 | testCompile "org.assertj:assertj-core:1.7.0" 44 | } 45 | -------------------------------------------------------------------------------- /jacoco/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /jacoco/app/src/androidTest/java/net/gouline/jacoco/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.gouline.jacoco; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /jacoco/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /jacoco/app/src/main/java/net/gouline/jacoco/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.gouline.jacoco.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.TextView; 6 | 7 | import net.gouline.jacoco.R; 8 | import net.gouline.jacoco.util.UsefulUtils; 9 | 10 | import butterknife.ButterKnife; 11 | import butterknife.InjectView; 12 | 13 | /** 14 | * Main entry activity. 15 | *

16 | * Created by mgouline on 24/05/15. 17 | */ 18 | public class MainActivity extends AppCompatActivity { 19 | private static final String TAG = MainActivity.class.getSimpleName(); 20 | 21 | @InjectView(R.id.txt_status) 22 | TextView mStatusTextView; 23 | 24 | @Override 25 | public void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_main); 28 | ButterKnife.inject(this); 29 | 30 | // Display the result to ensure it works 31 | mStatusTextView.setText(String.valueOf(UsefulUtils.sum(1, 2, 3, 4, 5))); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jacoco/app/src/main/java/net/gouline/jacoco/util/UsefulUtils.java: -------------------------------------------------------------------------------- 1 | package net.gouline.jacoco.util; 2 | 3 | /** 4 | * Supposedly useful utilities. 5 | *

6 | * Created by mgouline on 24/06/15. 7 | */ 8 | public final class UsefulUtils { 9 | 10 | private UsefulUtils() { 11 | } 12 | 13 | /** 14 | * Calculates the sum of integers. Wow, much useful! 15 | */ 16 | public static int sum(int... nums) { 17 | int result = 0; 18 | for (int num : nums) { 19 | result += num; 20 | } 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jacoco/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/jacoco/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /jacoco/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/jacoco/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /jacoco/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/jacoco/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /jacoco/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gouline/android-samples/5a1bc7b30282b2463b7d1a63971bce3728010ea8/jacoco/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /jacoco/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | -------------------------------------------------------------------------------- /jacoco/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | JaCoCo 4 | 5 | -------------------------------------------------------------------------------- /jacoco/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |