├── .gitignore ├── .travis.yml ├── LICENSE-2.0.txt ├── README.md ├── YourAppIdea ├── build.gradle ├── google-services.json ├── lint.xml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── michenux │ │ └── yourappidea │ │ └── ApplicationTest.java │ ├── debug │ └── res │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ │ ├── drawable-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── strings.xml │ │ ├── strings_aroundme.xml │ │ ├── strings_friends.xml │ │ └── strings_tutorial.xml │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── EULA │ │ └── sql │ │ │ ├── create.sql │ │ │ ├── upgrade-0102.sql │ │ │ ├── upgrade-0130.sql │ │ │ ├── upgrade-0140.sql │ │ │ ├── upgrade-0141.sql │ │ │ └── upgrade-0142.sql │ ├── java │ │ └── org │ │ │ └── michenux │ │ │ └── yourappidea │ │ │ ├── FixedSwipeRefreshLayout.java │ │ │ ├── NavigationController.java │ │ │ ├── YourAppModule.java │ │ │ ├── YourApplication.java │ │ │ ├── airport │ │ │ ├── AirportInfoService.java │ │ │ ├── AirportInfoServiceFactory.java │ │ │ ├── AirportListFragment.java │ │ │ ├── AirportRecyclerAdapter.java │ │ │ ├── AirportRestResponse.java │ │ │ ├── Flight.java │ │ │ └── FlightEtaComparator.java │ │ │ ├── aroundme │ │ │ ├── AroundMeFragment.java │ │ │ ├── CityActivity.java │ │ │ ├── CityContentProvider.java │ │ │ ├── CityListFragment.java │ │ │ ├── CityRecyclerAdapter.java │ │ │ ├── MongolabPlaceService.java │ │ │ ├── MongolabPlaceServiceFactory.java │ │ │ ├── Place.java │ │ │ ├── PlaceContentProvider.java │ │ │ ├── PlaceLocalProvider.java │ │ │ ├── PlaceProvider.java │ │ │ ├── PlaceRecyclerAdapter.java │ │ │ ├── PlaceRemoteProvider.java │ │ │ ├── PlaceRestResponse.java │ │ │ └── RecyclerViewPauseOnScrollListener.java │ │ │ ├── donations │ │ │ └── DonateFragment.java │ │ │ ├── facebook │ │ │ ├── FacebookDelegate.java │ │ │ └── FbLoginFragment.java │ │ │ ├── friends │ │ │ ├── FriendContentProvider.java │ │ │ ├── FriendDetailFragment.java │ │ │ ├── FriendListFragment.java │ │ │ ├── FriendMainFragment.java │ │ │ └── FriendRecyclerAdapter.java │ │ │ ├── home │ │ │ ├── LoginActivity.java │ │ │ ├── MainFragment.java │ │ │ ├── YourAppMainActivity.java │ │ │ └── YourAppNavigationFragment.java │ │ │ ├── map │ │ │ └── SimpleMapFragment.java │ │ │ ├── receivers │ │ │ ├── BatteryLevelReceiver.java │ │ │ ├── ConnectivityChangeReceiver.java │ │ │ └── PowerConnectionReceiver.java │ │ │ ├── settings │ │ │ └── SettingsFragment.java │ │ │ └── tutorial │ │ │ ├── TutorialListFragment.java │ │ │ ├── TutorialRecyclerAdapter.java │ │ │ └── sync │ │ │ ├── TutorialAuthenticator.java │ │ │ ├── TutorialAuthenticatorService.java │ │ │ ├── TutorialContentProvider.java │ │ │ ├── TutorialSyncAdapter.java │ │ │ ├── TutorialSyncHelper.java │ │ │ ├── TutorialSyncService.java │ │ │ ├── WordpressService.java │ │ │ └── WordpressServiceFactory.java │ └── res │ │ ├── color │ │ └── navdrawer_item.xml │ │ ├── drawable-hdpi-v11 │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-mdpi-v11 │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_menu_refresh.png │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-xhdpi-v11 │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-xhdpi │ │ ├── airport_landing.png │ │ ├── airport_takeoff.png │ │ ├── android.png │ │ ├── face01.png │ │ ├── face02.png │ │ ├── face03.png │ │ ├── face04.png │ │ ├── face05.png │ │ ├── face06.png │ │ ├── face07.png │ │ ├── face08.png │ │ ├── face09.png │ │ ├── ic_launcher.png │ │ ├── ic_stat_notify_newtuto.png │ │ ├── navdrawer_airport.png │ │ ├── navdrawer_aroundme.png │ │ ├── navdrawer_changelog.png │ │ ├── navdrawer_donations.png │ │ ├── navdrawer_eula.png │ │ ├── navdrawer_friends.png │ │ ├── navdrawer_logout.png │ │ ├── navdrawer_map.png │ │ ├── navdrawer_ratings.png │ │ ├── navdrawer_settings.png │ │ └── navdrawer_tutorial.png │ │ ├── drawable-xxhdpi-v11 │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_stat_notify_newtuto.png │ │ ├── drawable-xxxhdpi │ │ └── ic_launcher.png │ │ ├── drawable │ │ ├── button_drawable.xml │ │ ├── city_background_selector.xml │ │ └── navdrawer_header_bg.xml │ │ ├── layout-land │ │ ├── frienddetail_icon.xml │ │ └── friends.xml │ │ ├── layout │ │ ├── airport_listfragment.xml │ │ ├── airport_listitem.xml │ │ ├── airport_mode.xml │ │ ├── aroundme_fragment.xml │ │ ├── aroundme_listitem.xml │ │ ├── city.xml │ │ ├── city_fragment.xml │ │ ├── city_listitem.xml │ │ ├── donations_button.xml │ │ ├── donations_fragment.xml │ │ ├── frienddetail.xml │ │ ├── frienddetail_icon.xml │ │ ├── friendlist.xml │ │ ├── friendlistitem.xml │ │ ├── friends.xml │ │ ├── login.xml │ │ ├── login_facebook.xml │ │ ├── main.xml │ │ ├── main_fragment.xml │ │ ├── navdrawer.xml │ │ ├── navdrawer_loginheader.xml │ │ ├── simplemap_fragment.xml │ │ ├── toolbar.xml │ │ ├── tutorial_list.xml │ │ └── tutorial_listitem.xml │ │ ├── menu │ │ ├── airport_menu.xml │ │ ├── aroundme_menu.xml │ │ ├── friends_menu.xml │ │ ├── navigation_drawer_menu.xml │ │ ├── navigation_drawer_secondarymenu.xml │ │ ├── simplemap_menu.xml │ │ └── tutorial_menu.xml │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ ├── strings_airport.xml │ │ ├── strings_aroundme.xml │ │ ├── strings_changelog.xml │ │ ├── strings_donations.xml │ │ ├── strings_eula.xml │ │ ├── strings_friends.xml │ │ ├── strings_login.xml │ │ ├── strings_menu.xml │ │ ├── strings_navdrawer.xml │ │ ├── strings_simplemap.xml │ │ ├── strings_tutorial.xml │ │ └── styles.xml │ │ └── xml │ │ ├── changelog.xml │ │ ├── preferences.xml │ │ ├── tutorial_authenticator.xml │ │ └── tutorial_syncadapter.xml │ └── test │ └── java │ └── org │ └── michenux │ └── yourappidea │ ├── airport │ └── AirportServiceInfoTest.java │ ├── aroundme │ └── MongolabPlaceServiceTest.java │ └── tutorial │ └── WordpressServiceTest.java ├── build.gradle ├── dependencies.gradle ├── drodrolib ├── build.gradle ├── lint.xml ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── michenux │ │ └── drodrolib │ │ ├── MCXApplication.java │ │ ├── MCXModule.java │ │ ├── accounts │ │ ├── AccountUtils.java │ │ └── DumbAccountAuthenticator.java │ │ ├── battery │ │ └── BatteryUtils.java │ │ ├── content │ │ ├── ContentProviderUtils.java │ │ ├── IntentUtils.java │ │ └── ReceiverUtils.java │ │ ├── db │ │ ├── AbstractContentProvider.java │ │ ├── CursorRecyclerViewAdapter.java │ │ ├── sqlite │ │ │ ├── SQLiteDatabaseFactory.java │ │ │ └── SQLiteDatabaseHelper.java │ │ └── utils │ │ │ ├── CursorUtils.java │ │ │ └── SqlParser.java │ │ ├── geoloc │ │ ├── DistanceComparator.java │ │ ├── DistanceHolder.java │ │ ├── Localizable.java │ │ └── LocalizableComparator.java │ │ ├── gms │ │ ├── GmsUtils.java │ │ └── auth │ │ │ ├── GoogleAuthDelegate.java │ │ │ └── GoogleAuthFragment.java │ │ ├── info │ │ ├── AppUsageUtils.java │ │ └── VersionUtils.java │ │ ├── lang │ │ └── DateUtils.java │ │ ├── network │ │ ├── connectivity │ │ │ └── ConnectivityUtils.java │ │ ├── gson │ │ │ ├── LocationDeserializer.java │ │ │ └── TimestampDeserializer.java │ │ ├── okhttp │ │ │ └── LoggingInterceptor.java │ │ ├── ssl │ │ │ ├── TrustAllManager.java │ │ │ └── TrustAllSSLSocketFactory.java │ │ └── sync │ │ │ └── AbstractSyncHelper.java │ │ ├── resources │ │ ├── AssetUtils.java │ │ └── ResourceUtils.java │ │ ├── security │ │ ├── SecurityUtils.java │ │ ├── User.java │ │ ├── UserHelper.java │ │ └── UserSessionCallback.java │ │ ├── ui │ │ ├── animation │ │ │ ├── LiveButton.java │ │ │ └── SquashAndStretch.java │ │ ├── changelog │ │ │ ├── ChangeLogDialogFragment.java │ │ │ ├── ChangeLogHelper.java │ │ │ └── EulaChangeLogChainHelper.java │ │ ├── eula │ │ │ └── EulaHelper.java │ │ ├── fragment │ │ │ ├── FragmentHelper.java │ │ │ ├── MasterDetailFragmentHelper.java │ │ │ └── MasterDetailFragments.java │ │ ├── navdrawer │ │ │ ├── NavDrawerActivityConfiguration.java │ │ │ ├── NavdrawerHeaderArrowView.java │ │ │ └── NavigationDrawerFragment.java │ │ ├── recyclerview │ │ │ ├── DividerItemDecoration.java │ │ │ └── ItemClickSupport.java │ │ └── snackbar │ │ │ └── SnackbarHelper.java │ │ └── wordpress │ │ └── json │ │ ├── WPAttachment.java │ │ ├── WPAuthor.java │ │ ├── WPCustomFields.java │ │ ├── WPJsonPost.java │ │ ├── WPJsonResponse.java │ │ ├── WPThumbnailImage.java │ │ └── WPThumbnailImages.java │ └── res │ ├── drawable-v21 │ └── expander_group.xml │ ├── drawable-xhdpi-v21 │ ├── expander_close_mtrl_alpha.9.png │ └── expander_open_mtrl_alpha.9.png │ ├── drawable-xhdpi │ ├── expander_close_holo_dark.9.png │ ├── expander_open_holo_dark.9.png │ └── navdrawer_profile.png │ ├── drawable │ ├── expander_group.xml │ └── preferences_listselector.xml │ ├── layout │ ├── login_googleplus.xml │ └── preference_list_content.xml │ └── values │ ├── ids.xml │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle files 2 | .gradle/ 3 | build/ 4 | 5 | # Local configuration file (sdk path, etc) 6 | local.properties 7 | 8 | # IntelliJ project files 9 | *.iml 10 | .idea/ 11 | 12 | # Android Studio captures folder 13 | captures/ 14 | 15 | # Misc 16 | .DS_Store 17 | 18 | YourAppIdea/google-services.json 19 | YourAppIdea/src/release/google-services.json 20 | 21 | work 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | jdk: 4 | - oraclejdk8 5 | 6 | before_cache: 7 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 8 | 9 | cache: 10 | directories: 11 | - $HOME/.gradle/caches/ 12 | - $HOME/.gradle/wrapper/ 13 | 14 | android: 15 | components: 16 | - tools 17 | - build-tools-25.0.2 18 | - android-25 19 | - platform-tools 20 | - extra-google-m2repository 21 | - extra-android-m2repository 22 | 23 | script: 24 | ./gradlew build 25 | -------------------------------------------------------------------------------- /YourAppIdea/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "me.tatarka.retrolambda" version "3.3.0" 3 | } 4 | 5 | apply plugin: 'com.android.application' 6 | apply plugin: 'me.tatarka.retrolambda' 7 | 8 | android { 9 | compileSdkVersion 25 10 | buildToolsVersion "25.0.2" 11 | 12 | defaultConfig { 13 | applicationId "org.michenux.yourappidea" 14 | minSdkVersion 16 15 | targetSdkVersion 25 16 | versionCode 320 17 | versionName "3.2.0" 18 | 19 | multiDexEnabled true 20 | } 21 | 22 | compileOptions { 23 | sourceCompatibility JavaVersion.VERSION_1_8 24 | targetCompatibility JavaVersion.VERSION_1_8 25 | } 26 | 27 | signingConfigs { 28 | release { 29 | if (project.hasProperty('yourappidea.keystore')) { 30 | storeFile file(project.property("yourappidea.keystore")) 31 | storePassword project.property("yourappidea.keystore.password") 32 | keyAlias project.property("yourappidea.keystore.keyAlias") 33 | keyPassword project.property("yourappidea.keystore.keyPassword") 34 | } 35 | } 36 | } 37 | 38 | buildTypes { 39 | debug { 40 | applicationIdSuffix ".debug" 41 | } 42 | 43 | release { 44 | minifyEnabled false 45 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 46 | if (project.hasProperty('yourappidea.keystore')) { 47 | signingConfig signingConfigs.release 48 | } 49 | } 50 | } 51 | 52 | testOptions { 53 | unitTests.returnDefaultValues = true 54 | } 55 | } 56 | 57 | dependencies { 58 | compile supportDependencies.appcompat 59 | compile supportDependencies.design 60 | compile supportDependencies.cardview 61 | compile supportDependencies.preferences 62 | compile otherDependencies.universalImageLoader 63 | compile otherDependencies.facebookSdk 64 | compile otherDependencies.retrofit 65 | compile otherDependencies.retrofitGsonConverter 66 | compile playServicesDependencies.maps 67 | compile playServicesDependencies.auth 68 | compile playServicesDependencies.ads 69 | compile playServicesDependencies.location 70 | 71 | compile rx.rxPermission 72 | compile rx.rxbinding 73 | compile rx.rxAndroid 74 | compile rx.retrofitRxJava 75 | 76 | compile project(':drodrolib') 77 | 78 | testCompile testDependencies.junit 79 | testCompile testDependencies.mockito 80 | testCompile testDependencies.hamcrest 81 | } 82 | 83 | apply plugin: 'com.google.gms.google-services' 84 | -------------------------------------------------------------------------------- /YourAppIdea/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "193514795353", 4 | "project_id": "spartan-archive-826" 5 | }, 6 | "client": [ 7 | { 8 | "client_info": { 9 | "mobilesdk_app_id": "1:193514795353:android:15aa1f29225ea454", 10 | "android_client_info": { 11 | "package_name": "org.michenux.yourappidea" 12 | } 13 | }, 14 | "oauth_client": [ 15 | { 16 | "client_id": "193514795353-qi3g4ih08rj0piovd52pmqqu87trbndo.apps.googleusercontent.com", 17 | "client_type": 1, 18 | "android_info": { 19 | "package_name": "org.michenux.yourappidea", 20 | "certificate_hash": "F2C661510F42912A013240DE0A0E51619EB83AC5" 21 | } 22 | } 23 | ], 24 | "api_key": [ 25 | { 26 | "current_key": "AIzaSyBKkkIK5NB71DD72hBKCN9lpGzs9v8afkQ" 27 | } 28 | ], 29 | "services": { 30 | "analytics_service": { 31 | "status": 1 32 | }, 33 | "appinvite_service": { 34 | "status": 1, 35 | "other_platform_oauth_client": [] 36 | }, 37 | "ads_service": { 38 | "status": 1 39 | } 40 | } 41 | }, 42 | { 43 | "client_info": { 44 | "mobilesdk_app_id": "1:193514795353:android:637251afd7d1dc41", 45 | "android_client_info": { 46 | "package_name": "org.michenux.yourappidea.debug" 47 | } 48 | }, 49 | "oauth_client": [ 50 | { 51 | "client_id": "193514795353-a4mgk4uo6oglr6q7h1j5p2dmramjtaba.apps.googleusercontent.com", 52 | "client_type": 1, 53 | "android_info": { 54 | "package_name": "org.michenux.yourappidea.debug", 55 | "certificate_hash": "2E0894D69AE30ED284EAE8CDC5807B7463EF54AA" 56 | } 57 | } 58 | ], 59 | "api_key": [ 60 | { 61 | "current_key": "AIzaSyAFbVzLpEHRU37f8dJcqmqEgcXB1vofvP4" 62 | } 63 | ], 64 | "services": { 65 | "analytics_service": { 66 | "status": 1 67 | }, 68 | "appinvite_service": { 69 | "status": 1, 70 | "other_platform_oauth_client": [] 71 | }, 72 | "ads_service": { 73 | "status": 1 74 | } 75 | } 76 | } 77 | ], 78 | "configuration_version": "1" 79 | } 80 | -------------------------------------------------------------------------------- /YourAppIdea/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YourAppIdea/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 ${sdk.dir}/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 | -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault,*Annotation* 20 | 21 | # Dagger 22 | -dontwarn dagger.internal.codegen.** 23 | -keepclassmembers,allowobfuscation class * { 24 | @javax.inject.* *; 25 | @dagger.* *; 26 | (); 27 | } 28 | -keep class dagger.* { *; } 29 | -keep class javax.inject.* { *; } 30 | -keep class * extends dagger.internal.Binding 31 | -keep class * extends dagger.internal.ModuleAdapter 32 | -keep class * extends dagger.internal.StaticInjection 33 | 34 | # Guava 35 | -keep class com.google.common.** 36 | -dontwarn com.google.common.collect.MinMaxPriorityQueue 37 | 38 | # facebook 39 | -keep class com.facebook.** { *; } 40 | -keepattributes Signature 41 | -------------------------------------------------------------------------------- /YourAppIdea/src/androidTest/java/org/michenux/yourappidea/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea; 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 | } 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/debug/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/debug/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/debug/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/debug/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/debug/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Your App Idea Dev 4 | 5 | 6 | AIzaSyAFbVzLpEHRU37f8dJcqmqEgcXB1vofvP4 7 | 8 | 9 | 1592621560969472 10 | 11 | -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/values/strings_aroundme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.michenux.yourappidea.debug.places 5 | org.michenux.yourappidea.debug.cities 6 | 7 | 8 | -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/values/strings_friends.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.michenux.yourappidea.debug.friends 5 | 6 | 7 | -------------------------------------------------------------------------------- /YourAppIdea/src/debug/res/values/strings_tutorial.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.michenux.yourappidea.debug.tutorials 5 | michenux.net.debug 6 | 7 | 8 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/assets/EULA: -------------------------------------------------------------------------------- 1 | Write your EULA here. 2 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/assets/sql/upgrade-0102.sql: -------------------------------------------------------------------------------- 1 | insert into T_FRIEND(_id, NAME, JOB) values (null, 'Nicolas', 'Taxi driver'); 2 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/assets/sql/upgrade-0130.sql: -------------------------------------------------------------------------------- 1 | create table T_TUTORIAL ( 2 | _id integer primary key autoincrement, 3 | TITLE TEXT not null, 4 | DESCRIPTION TEXT not null, 5 | URL TEXT not null, 6 | DATECREATION INTEGER not null ); 7 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/assets/sql/upgrade-0141.sql: -------------------------------------------------------------------------------- 1 | create table T_CITY ( 2 | _id integer primary key autoincrement, 3 | NAME TEXT not null, 4 | COUNTRY TEXT not null, 5 | LONGITUDE REAL not null, 6 | LATITUDE REAL not null ); 7 | 8 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Tokyo','Japan', 139.7513889, 35.685); 9 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Shanghai','China', 121.4086111, 31.005); 10 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Jakarta','Indonesia', 106.8294444, -6.1744444); 11 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Seoul','Korea', 126.9788888889, 37.5658333333); 12 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Delhi','India', 77.216667, 28.666667); 13 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Mexico','Mexico', -99.138611, 19.434167); 14 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Manila','Philippines', 120.9822222, 14.6041667); 15 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'New York','United State', -74.0063889, 40.7141667); 16 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Sao Paulo','Brazil', -46.6166667, -23.5333333); 17 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Moscow','Russia', 37.6155556, 55.7522222); 18 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Cairo','Egypt', 31.25, 30.05 ); 19 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'London','Great Britain', -0.116667, 51.5 ); 20 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Buenos Aires','Argentina', -58.3816666667, -34.6033333333); 21 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Bangkok','Thailand', 100.516667, 13.75); 22 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Istanbul','Turkey', 28.9647222, 41.0186111); 23 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Paris','France', 2.333333, 48.866667); 24 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Lagos','Nigeria', 3.3958333, 6.4530556); 25 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Bogota','Colombia', -74.0833333, 4.6 ); 26 | insert into T_CITY(_id, NAME, COUNTRY, LONGITUDE, LATITUDE) values (null,'Berlin','Germany', 13.4, 52.5166667); 27 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/assets/sql/upgrade-0142.sql: -------------------------------------------------------------------------------- 1 | drop table T_TUTORIAL; 2 | 3 | create table T_TUTORIAL ( 4 | _id integer primary key autoincrement, 5 | POSTID INTEGER not null, 6 | TITLE TEXT not null, 7 | DESCRIPTION TEXT not null, 8 | THUMBNAIL TEXT not null, 9 | URL TEXT not null, 10 | CONTENT TEXT not null, 11 | AUTHOR TEXT not null, 12 | DATECREATION INTEGER not null, 13 | DATEMODIFICATION INTEGER not null); 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/FixedSwipeRefreshLayout.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea; 2 | 3 | import android.content.Context; 4 | import android.os.Parcelable; 5 | import android.support.v4.widget.SwipeRefreshLayout; 6 | import android.util.AttributeSet; 7 | 8 | /** 9 | * Created by lmichenaud on 31/12/2015. 10 | */ 11 | public class FixedSwipeRefreshLayout extends SwipeRefreshLayout { 12 | public FixedSwipeRefreshLayout(Context context) { 13 | super(context); 14 | } 15 | 16 | public FixedSwipeRefreshLayout(Context context, AttributeSet attrs) { 17 | super(context, attrs); 18 | } 19 | 20 | @Override 21 | protected Parcelable onSaveInstanceState() { 22 | clearAnimation(); 23 | return super.onSaveInstanceState(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/YourAppModule.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea; 2 | 3 | import org.michenux.drodrolib.MCXModule; 4 | import org.michenux.yourappidea.aroundme.AroundMeFragment; 5 | import org.michenux.yourappidea.aroundme.CityContentProvider; 6 | import org.michenux.yourappidea.aroundme.PlaceContentProvider; 7 | import org.michenux.yourappidea.donations.DonateFragment; 8 | import org.michenux.yourappidea.facebook.FbLoginFragment; 9 | import org.michenux.yourappidea.friends.FriendContentProvider; 10 | import org.michenux.yourappidea.home.LoginActivity; 11 | import org.michenux.yourappidea.home.MainFragment; 12 | import org.michenux.yourappidea.home.YourAppMainActivity; 13 | import org.michenux.yourappidea.home.YourAppNavigationFragment; 14 | import org.michenux.yourappidea.settings.SettingsFragment; 15 | import org.michenux.yourappidea.tutorial.TutorialListFragment; 16 | import org.michenux.yourappidea.tutorial.sync.TutorialContentProvider; 17 | import org.michenux.yourappidea.tutorial.sync.TutorialSyncAdapter; 18 | 19 | import dagger.Module; 20 | 21 | @Module( 22 | injects = { 23 | YourApplication.class, 24 | 25 | YourAppMainActivity.class, 26 | LoginActivity.class, 27 | 28 | FriendContentProvider.class, 29 | TutorialContentProvider.class, 30 | PlaceContentProvider.class, 31 | CityContentProvider.class, 32 | YourAppNavigationFragment.class, 33 | 34 | MainFragment.class, 35 | DonateFragment.class, 36 | SettingsFragment.class, 37 | TutorialListFragment.class, 38 | AroundMeFragment.class, 39 | FbLoginFragment.class, 40 | 41 | TutorialSyncAdapter.class 42 | }, 43 | includes = { 44 | MCXModule.class 45 | }, 46 | overrides = true 47 | ) 48 | public class YourAppModule { 49 | } 50 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/airport/AirportInfoService.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.airport; 2 | 3 | import retrofit2.http.GET; 4 | import retrofit2.http.Query; 5 | import rx.Observable; 6 | 7 | //http://www.flightradar24.com/AirportInfoService.php?airport=ORY&type=in 8 | //new API: https://api.flightradar24.com/common/v1/airport.json?code=ory 9 | //LFRS 10 | public interface AirportInfoService { 11 | @GET("/AirportInfoService.php") 12 | Observable getFlights(@Query("airport") String airportCode, @Query("type") String flightType); 13 | } 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/airport/AirportInfoServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.airport; 2 | 3 | import android.content.Context; 4 | import android.location.Location; 5 | 6 | import com.google.gson.GsonBuilder; 7 | 8 | import org.michenux.drodrolib.network.gson.LocationDeserializer; 9 | import org.michenux.drodrolib.network.gson.TimestampDeserializer; 10 | import org.michenux.drodrolib.network.okhttp.LoggingInterceptor; 11 | import org.michenux.yourappidea.R; 12 | 13 | import java.sql.Timestamp; 14 | 15 | import okhttp3.OkHttpClient; 16 | import retrofit2.Retrofit; 17 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 18 | import retrofit2.converter.gson.GsonConverterFactory; 19 | 20 | public class AirportInfoServiceFactory { 21 | public static AirportInfoService create(Context context) { 22 | GsonBuilder gsonBuilder = new GsonBuilder(); 23 | gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer()); 24 | gsonBuilder.registerTypeAdapter(Location.class, new LocationDeserializer()); 25 | 26 | OkHttpClient client = new OkHttpClient.Builder() 27 | .addInterceptor(new LoggingInterceptor()) 28 | .build(); 29 | 30 | Retrofit retrofit = new Retrofit.Builder() 31 | .baseUrl(context.getString(R.string.airport_rest_url)) 32 | .client(client) 33 | .addConverterFactory(GsonConverterFactory.create(gsonBuilder.create())) 34 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 35 | .build(); 36 | 37 | return retrofit.create(AirportInfoService.class); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/airport/AirportRestResponse.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.airport; 2 | 3 | import java.util.List; 4 | 5 | public class AirportRestResponse { 6 | private List flights; 7 | 8 | public List getFlights() { 9 | return flights; 10 | } 11 | 12 | public void setFlights(List flights) { 13 | this.flights = flights; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/airport/Flight.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.airport; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.sql.Timestamp; 6 | 7 | // {"callsign":"VLG1982","iata":"LIS","type":"A320","lat":39.379,"lon":-8.195,"spd":434,"alt":26175,"flight":"VY1982","name":"Lisbon Lisboa","eta":1364422653} 8 | public class Flight { 9 | @SerializedName("callsign") 10 | private String callSign; 11 | 12 | private String iata; 13 | 14 | private String type; 15 | 16 | @SerializedName("lat") 17 | private double latitude; 18 | 19 | @SerializedName("lon") 20 | private double longitude; 21 | 22 | @SerializedName("spd") 23 | private long speed; 24 | 25 | @SerializedName("alt") 26 | private long altitude; 27 | 28 | private String flight; 29 | 30 | private String name; 31 | 32 | @SerializedName("eta") 33 | private Timestamp eta; 34 | 35 | public String getCallSign() { 36 | return callSign; 37 | } 38 | 39 | public void setCallSign(String callSign) { 40 | this.callSign = callSign; 41 | } 42 | 43 | public String getIata() { 44 | return iata; 45 | } 46 | 47 | public void setIata(String iata) { 48 | this.iata = iata; 49 | } 50 | 51 | public String getType() { 52 | return type; 53 | } 54 | 55 | public void setType(String type) { 56 | this.type = type; 57 | } 58 | 59 | public double getLatitude() { 60 | return latitude; 61 | } 62 | 63 | public void setLatitude(double latitude) { 64 | this.latitude = latitude; 65 | } 66 | 67 | public double getLongitude() { 68 | return longitude; 69 | } 70 | 71 | public void setLongitude(double longitude) { 72 | this.longitude = longitude; 73 | } 74 | 75 | public long getSpeed() { 76 | return speed; 77 | } 78 | 79 | public void setSpeed(long speed) { 80 | this.speed = speed; 81 | } 82 | 83 | public long getAltitude() { 84 | return altitude; 85 | } 86 | 87 | public void setAltitude(long altitude) { 88 | this.altitude = altitude; 89 | } 90 | 91 | public String getFlight() { 92 | return flight; 93 | } 94 | 95 | public void setFlight(String flight) { 96 | this.flight = flight; 97 | } 98 | 99 | public String getName() { 100 | return name; 101 | } 102 | 103 | public void setName(String name) { 104 | this.name = name; 105 | } 106 | 107 | public Timestamp getEta() { 108 | return eta; 109 | } 110 | 111 | public void setEta(Timestamp eta) { 112 | this.eta = eta; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/airport/FlightEtaComparator.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.airport; 2 | 3 | import java.util.Comparator; 4 | 5 | public class FlightEtaComparator implements Comparator { 6 | public int compare(Flight f1, Flight f2) { 7 | if (f1.getEta() == null && f2.getEta() == null) { 8 | return 0; 9 | } 10 | 11 | if (f1.getEta() != null && f2.getEta() == null) { 12 | return 1; 13 | } 14 | 15 | if (f1.getEta() == null && f2.getEta() != null) { 16 | return -1; 17 | } 18 | 19 | return (int) f1.getEta().getTime() - (int) f2.getEta().getTime(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/CityActivity.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBar; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.MenuItem; 8 | 9 | import org.michenux.yourappidea.R; 10 | 11 | public class CityActivity extends AppCompatActivity { 12 | private Toolbar mToolBar; 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.city); 18 | 19 | mToolBar = (Toolbar) findViewById(R.id.toolbar); 20 | setSupportActionBar(mToolBar); 21 | ActionBar actionBar = getSupportActionBar(); 22 | if (actionBar != null) { 23 | actionBar.setDisplayHomeAsUpEnabled(true); 24 | } 25 | } 26 | 27 | @Override 28 | public boolean onOptionsItemSelected(MenuItem item) { 29 | switch (item.getItemId()) { 30 | case android.R.id.home: 31 | this.finish(); 32 | return true; 33 | } 34 | return super.onOptionsItemSelected(item); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/CityContentProvider.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.content.UriMatcher; 4 | import android.net.Uri; 5 | 6 | import org.michenux.drodrolib.content.ContentProviderUtils; 7 | import org.michenux.drodrolib.db.AbstractContentProvider; 8 | import org.michenux.yourappidea.BuildConfig; 9 | 10 | public class CityContentProvider extends AbstractContentProvider { 11 | public static final String TABLE_NAME = "T_CITY"; 12 | public static final String NAME_COLUMN = "NAME"; 13 | public static final String COUNTRY_COLUMN = "COUNTRY"; 14 | public static final String LONGITUDE_COLUMN = "LONGITUDE"; 15 | public static final String LATITUDE_COLUMN = "LATITUDE"; 16 | 17 | private static final String AUTHORITY = ContentProviderUtils.buildAuthority( 18 | BuildConfig.APPLICATION_ID, BuildConfig.FLAVOR, "cities"); 19 | 20 | private static final String BASE_PATH = "cities"; 21 | 22 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH); 23 | 24 | protected static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); 25 | 26 | static { 27 | uriMatcher.addURI(AUTHORITY, BASE_PATH, LIST); 28 | uriMatcher.addURI(AUTHORITY, BASE_PATH + "/#", ITEM_ID); 29 | } 30 | 31 | public CityContentProvider() { 32 | super(TABLE_NAME, uriMatcher, BASE_PATH); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/CityRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.database.Cursor; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | 10 | import org.michenux.drodrolib.db.CursorRecyclerViewAdapter; 11 | import org.michenux.drodrolib.db.utils.CursorUtils; 12 | import org.michenux.yourappidea.R; 13 | 14 | public class CityRecyclerAdapter extends CursorRecyclerViewAdapter { 15 | public CityRecyclerAdapter(Cursor cursor) { 16 | super(cursor); 17 | } 18 | 19 | @Override 20 | public CityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 21 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.city_listitem, parent, false); 22 | return new CityViewHolder(v); 23 | } 24 | 25 | @Override 26 | public void onBindViewHolder(CityViewHolder viewHolder, Cursor cursor) { 27 | String cityName = CursorUtils.getString(CityContentProvider.NAME_COLUMN, cursor); 28 | viewHolder.getNameView().setText(cityName); 29 | 30 | String countryName = CursorUtils.getString(CityContentProvider.COUNTRY_COLUMN, cursor); 31 | viewHolder.getCountryView().setText(countryName); 32 | } 33 | 34 | public static class CityViewHolder extends RecyclerView.ViewHolder { 35 | private TextView mNameView; 36 | private TextView mCountryView; 37 | 38 | public CityViewHolder(View itemView) { 39 | super(itemView); 40 | mNameView = (TextView) itemView.findViewById(R.id.city_name); 41 | mCountryView = (TextView) itemView.findViewById(R.id.city_country); 42 | } 43 | 44 | public TextView getNameView() { 45 | return mNameView; 46 | } 47 | 48 | public TextView getCountryView() { 49 | return mCountryView; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/MongolabPlaceService.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import java.util.List; 4 | 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Query; 7 | import rx.Observable; 8 | 9 | // https://api.mongolab.com/api/1/databases/michenuxdb/collections/Places?q={\'location\':{$near:{$geometry:{\'type\':\'Point\',\'coordinates\':[%1$s,%2$s]},$maxDistance:%3$s}}}&apiKey=50a2444ae4b0cd0bfc124248 10 | public interface MongolabPlaceService { 11 | @GET("/api/1/databases/michenuxdb/collections/Places") 12 | Observable> getPlaces(@Query("query") String query, @Query("apiKey") String apiKey); 13 | } 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/MongolabPlaceServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.content.Context; 4 | import android.location.Location; 5 | 6 | import com.google.gson.GsonBuilder; 7 | 8 | import org.michenux.drodrolib.network.gson.LocationDeserializer; 9 | import org.michenux.drodrolib.network.gson.TimestampDeserializer; 10 | import org.michenux.drodrolib.network.okhttp.LoggingInterceptor; 11 | import org.michenux.yourappidea.R; 12 | 13 | import java.sql.Timestamp; 14 | 15 | import okhttp3.OkHttpClient; 16 | import retrofit2.Retrofit; 17 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 18 | import retrofit2.converter.gson.GsonConverterFactory; 19 | 20 | public class MongolabPlaceServiceFactory { 21 | public static MongolabPlaceService create(Context context) { 22 | GsonBuilder gsonBuilder = new GsonBuilder(); 23 | gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer()); 24 | gsonBuilder.registerTypeAdapter(Location.class, new LocationDeserializer()); 25 | 26 | OkHttpClient client = new OkHttpClient.Builder() 27 | .addInterceptor(new LoggingInterceptor()) 28 | .build(); 29 | 30 | String url = context.getString(R.string.aroundme_placeremoteprovider_url); 31 | 32 | Retrofit retrofit = new Retrofit.Builder() 33 | .baseUrl(url) 34 | .client(client) 35 | .addConverterFactory(GsonConverterFactory.create(gsonBuilder.create())) 36 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 37 | .build(); 38 | 39 | return retrofit.create(MongolabPlaceService.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/Place.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.location.Location; 4 | 5 | import org.michenux.drodrolib.geoloc.DistanceHolder; 6 | 7 | public class Place implements DistanceHolder { 8 | private long id; 9 | private String name; 10 | private String country; 11 | private String image; 12 | private Location location; 13 | private float distance; 14 | 15 | public long getId() { 16 | return id; 17 | } 18 | 19 | public void setId(long id) { 20 | this.id = id; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public Location getLocation() { 32 | return location; 33 | } 34 | 35 | public void setLocation(Location location) { 36 | this.location = location; 37 | } 38 | 39 | public float getDistance() { 40 | return distance; 41 | } 42 | 43 | public void setDistance(float distance) { 44 | this.distance = distance; 45 | } 46 | 47 | public String getCountry() { 48 | return country; 49 | } 50 | 51 | public void setCountry(String country) { 52 | this.country = country; 53 | } 54 | 55 | public String getImage() { 56 | return image; 57 | } 58 | 59 | public void setImage(String image) { 60 | this.image = image; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/PlaceContentProvider.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.content.UriMatcher; 4 | import android.net.Uri; 5 | 6 | import org.michenux.drodrolib.content.ContentProviderUtils; 7 | import org.michenux.drodrolib.db.AbstractContentProvider; 8 | import org.michenux.yourappidea.BuildConfig; 9 | 10 | public class PlaceContentProvider extends AbstractContentProvider { 11 | public static final String TABLE_NAME = "T_PLACE"; 12 | public static final String NAME_COLUMN = "NAME"; 13 | public static final String COUNTRY_COLUMN = "COUNTRY"; 14 | public static final String URL_COLUMN = "URL"; 15 | public static final String LONGITUDE_COLUMN = "LONGITUDE"; 16 | public static final String LATITUDE_COLUMN = "LATITUDE"; 17 | 18 | private static final String AUTHORITY = ContentProviderUtils.buildAuthority( 19 | BuildConfig.APPLICATION_ID, BuildConfig.FLAVOR, "places"); 20 | 21 | private static final String BASE_PATH = "places"; 22 | 23 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH); 24 | 25 | private static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); 26 | 27 | static { 28 | uriMatcher.addURI(AUTHORITY, BASE_PATH, LIST); 29 | uriMatcher.addURI(AUTHORITY, BASE_PATH + "/#", ITEM_ID); 30 | } 31 | 32 | public PlaceContentProvider() { 33 | super(TABLE_NAME, uriMatcher, BASE_PATH); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/PlaceProvider.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.location.Location; 4 | 5 | import java.util.List; 6 | 7 | public interface PlaceProvider { 8 | public void onLocationChanged(Location location); 9 | 10 | public void onDestroy(); 11 | 12 | public interface PlaceLoaderCallback { 13 | public void onPlaceLoadFinished(List places); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/PlaceRestResponse.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class PlaceRestResponse extends ArrayList { 6 | } 7 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/aroundme/RecyclerViewPauseOnScrollListener.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | import com.nostra13.universalimageloader.core.ImageLoader; 6 | 7 | import static android.support.v7.widget.RecyclerView.OnScrollListener; 8 | 9 | public class RecyclerViewPauseOnScrollListener extends OnScrollListener { 10 | private ImageLoader mImageLoader; 11 | 12 | private final boolean mPauseOnScroll; 13 | private final boolean mPauseOnFling; 14 | private final OnScrollListener mExternalListener; 15 | 16 | public RecyclerViewPauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling) { 17 | this(imageLoader, pauseOnScroll, pauseOnFling, null); 18 | } 19 | 20 | public RecyclerViewPauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling, 21 | OnScrollListener customListener) { 22 | this.mImageLoader = imageLoader; 23 | this.mPauseOnScroll = pauseOnScroll; 24 | this.mPauseOnFling = pauseOnFling; 25 | mExternalListener = customListener; 26 | } 27 | 28 | @Override 29 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 30 | if (mExternalListener != null) { 31 | mExternalListener.onScrolled(recyclerView, dx, dy); 32 | } 33 | } 34 | 35 | @Override 36 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 37 | switch (newState) { 38 | case RecyclerView.SCROLL_STATE_IDLE: 39 | mImageLoader.resume(); 40 | break; 41 | case RecyclerView.SCROLL_STATE_DRAGGING: 42 | if (mPauseOnScroll) { 43 | mImageLoader.pause(); 44 | } 45 | break; 46 | case RecyclerView.SCROLL_STATE_SETTLING: 47 | if (mPauseOnFling) { 48 | mImageLoader.pause(); 49 | } 50 | break; 51 | } 52 | if (mExternalListener != null) { 53 | mExternalListener.onScrollStateChanged(recyclerView, newState); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/donations/DonateFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.donations; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.v4.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.View.OnClickListener; 10 | import android.view.ViewGroup; 11 | import android.widget.Button; 12 | 13 | import org.michenux.yourappidea.R; 14 | import org.michenux.yourappidea.YourApplication; 15 | 16 | public class DonateFragment extends Fragment implements OnClickListener { 17 | @Override 18 | public void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | ((YourApplication) getActivity().getApplication()).inject(this); 21 | } 22 | 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 25 | Bundle savedInstanceState) { 26 | final View view = inflater.inflate(R.layout.donations_fragment, container, false); 27 | final Button button = (Button) view.findViewById(R.id.donations_paypal_donate_button); 28 | button.setOnClickListener(this); 29 | return view; 30 | } 31 | 32 | @Override 33 | public void onClick(View v) { 34 | Uri.Builder uriBuilder = new Uri.Builder(); 35 | uriBuilder.scheme("https").authority("www.paypal.com").path("cgi-bin/webscr"); 36 | uriBuilder.appendQueryParameter("cmd", "_donations"); 37 | 38 | uriBuilder.appendQueryParameter("business", "lmichenaud@gmail.com"); 39 | uriBuilder.appendQueryParameter("lc", "US"); 40 | uriBuilder.appendQueryParameter("item_name", "yourappidea"); 41 | uriBuilder.appendQueryParameter("no_note", "1"); 42 | uriBuilder.appendQueryParameter("no_shipping", "1"); 43 | uriBuilder.appendQueryParameter("currency_code", "EUR"); 44 | Uri payPalUri = uriBuilder.build(); 45 | 46 | Intent viewIntent = new Intent(Intent.ACTION_VIEW, payPalUri); 47 | startActivity(viewIntent); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/facebook/FbLoginFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.facebook; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.facebook.login.widget.LoginButton; 11 | 12 | import org.michenux.drodrolib.security.UserHelper; 13 | import org.michenux.drodrolib.security.UserSessionCallback; 14 | import org.michenux.yourappidea.R; 15 | import org.michenux.yourappidea.YourApplication; 16 | 17 | import javax.inject.Inject; 18 | 19 | public class FbLoginFragment extends Fragment implements UserSessionCallback { 20 | @Inject 21 | UserHelper mUserHelper; 22 | 23 | private FacebookDelegate mFacebookDelegate; 24 | 25 | @Override 26 | public void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | ((YourApplication) getActivity().getApplication()).inject(this); 29 | 30 | mFacebookDelegate = new FacebookDelegate(mUserHelper, this.getActivity()); 31 | mFacebookDelegate.setUserSessionCallback(this); 32 | } 33 | 34 | @Override 35 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 36 | View view = inflater.inflate(R.layout.login_facebook, container, false); 37 | LoginButton loginButton = (LoginButton) view.findViewById(R.id.navmenufacebook_loginbutton); 38 | loginButton.setReadPermissions("public_profile", "email"); 39 | loginButton.setFragment(this); 40 | 41 | // Hide facebook login button if facebook app not installed 42 | if (!mFacebookDelegate.isFacebookInstalled()) { 43 | loginButton.setVisibility(View.GONE); 44 | } 45 | return view; 46 | } 47 | 48 | @Override 49 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 50 | super.onActivityResult(requestCode, resultCode, data); 51 | mFacebookDelegate.onActivityResult(requestCode, resultCode, data); 52 | } 53 | 54 | @Override 55 | public void onDestroy() { 56 | mFacebookDelegate.onDestroy(); 57 | super.onDestroy(); 58 | } 59 | 60 | @Override 61 | public void onLogin() { 62 | if (this.getActivity() != null) { 63 | this.getActivity().finish(); 64 | } 65 | } 66 | 67 | @Override 68 | public void onLogout() { 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/friends/FriendContentProvider.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.friends; 2 | 3 | import android.content.ContentResolver; 4 | import android.content.UriMatcher; 5 | import android.net.Uri; 6 | 7 | import org.michenux.drodrolib.content.ContentProviderUtils; 8 | import org.michenux.drodrolib.db.AbstractContentProvider; 9 | import org.michenux.yourappidea.BuildConfig; 10 | 11 | public class FriendContentProvider extends AbstractContentProvider { 12 | public static final String TABLE_NAME = "T_FRIEND"; 13 | public static final String NAME_COLUMN = "NAME"; 14 | public static final String JOB_COLUMN = "JOB"; 15 | public static final String FACE_COLUMN = "FACE"; 16 | 17 | private static final String AUTHORITY = ContentProviderUtils.buildAuthority( 18 | BuildConfig.APPLICATION_ID, BuildConfig.FLAVOR, "friends"); 19 | 20 | private static final String BASE_PATH = "friends"; 21 | 22 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY 23 | + "/" + BASE_PATH); 24 | 25 | public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE 26 | + "/friends"; 27 | public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE 28 | + "/friend"; 29 | 30 | private static final UriMatcher uriMatcher = new UriMatcher( 31 | UriMatcher.NO_MATCH); 32 | 33 | static { 34 | uriMatcher.addURI(AUTHORITY, BASE_PATH, LIST); 35 | uriMatcher.addURI(AUTHORITY, BASE_PATH + "/#", ITEM_ID); 36 | } 37 | 38 | public FriendContentProvider() { 39 | super(TABLE_NAME, uriMatcher, BASE_PATH); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/friends/FriendMainFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.friends; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.Menu; 7 | import android.view.MenuInflater; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | import com.afollestad.materialdialogs.MaterialDialog; 13 | 14 | import org.michenux.drodrolib.ui.fragment.MasterDetailFragmentHelper; 15 | import org.michenux.drodrolib.ui.fragment.MasterDetailFragments; 16 | import org.michenux.yourappidea.R; 17 | 18 | public class FriendMainFragment extends Fragment { 19 | @Override 20 | public void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setRetainInstance(false); 23 | setHasOptionsMenu(true); 24 | } 25 | 26 | @Override 27 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 28 | Bundle savedInstanceState) { 29 | View view = inflater.inflate(R.layout.friends, container, false); 30 | 31 | MasterDetailFragments currentFragments = MasterDetailFragmentHelper 32 | .getCurrentFragments(R.id.friendmain_fragment, 33 | R.id.frienddetail_fragment, FriendDetailFragment.class, 34 | getChildFragmentManager()); 35 | if (currentFragments.master == null) { 36 | currentFragments.master = FriendListFragment.newInstance(); 37 | } 38 | 39 | MasterDetailFragmentHelper.initFragments(currentFragments, R.id.friendmain_fragment, 40 | R.id.frienddetail_fragment, getResources().getConfiguration(), getChildFragmentManager()); 41 | 42 | return view; 43 | } 44 | 45 | @Override 46 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 47 | inflater.inflate(R.menu.friends_menu, menu); 48 | } 49 | 50 | @Override 51 | public boolean onOptionsItemSelected(MenuItem item) { 52 | switch (item.getItemId()) { 53 | case R.id.friends_menu_info: 54 | new MaterialDialog.Builder(this.getActivity()) 55 | .title(R.string.friends_info_title) 56 | .items(R.array.friends_info_details) 57 | .positiveText(R.string.close) 58 | .show(); 59 | return true; 60 | } 61 | return super.onOptionsItemSelected(item); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/friends/FriendRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.friends; 2 | 3 | import android.database.Cursor; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import org.michenux.drodrolib.db.CursorRecyclerViewAdapter; 12 | import org.michenux.drodrolib.db.utils.CursorUtils; 13 | import org.michenux.drodrolib.resources.ResourceUtils; 14 | import org.michenux.yourappidea.R; 15 | 16 | public class FriendRecyclerAdapter extends CursorRecyclerViewAdapter { 17 | public FriendRecyclerAdapter(Cursor cursor) { 18 | super(cursor); 19 | } 20 | 21 | @Override 22 | public FriendViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 23 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.friendlistitem, parent, false); 24 | return new FriendViewHolder(v); 25 | } 26 | 27 | @Override 28 | public void onBindViewHolder(FriendViewHolder viewHolder, Cursor cursor) { 29 | String faceName = CursorUtils.getString(FriendContentProvider.FACE_COLUMN, cursor); 30 | String friendName = CursorUtils.getString(FriendContentProvider.NAME_COLUMN, cursor); 31 | viewHolder.nameView.setText(friendName); 32 | viewHolder.imageView.setImageDrawable(ResourceUtils.getDrawableByName(faceName, viewHolder.itemView.getContext())); 33 | } 34 | 35 | public static class FriendViewHolder extends RecyclerView.ViewHolder { 36 | public TextView nameView; 37 | public ImageView imageView; 38 | 39 | public FriendViewHolder(View itemView) { 40 | super(itemView); 41 | nameView = (TextView) itemView.findViewById(R.id.friend_name); 42 | imageView = (ImageView) itemView.findViewById(R.id.friend_icon); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/home/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.home; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v7.app.ActionBar; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.Toolbar; 9 | import android.view.MenuItem; 10 | 11 | import org.michenux.yourappidea.R; 12 | 13 | public class LoginActivity extends AppCompatActivity { 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.login); 18 | 19 | Toolbar mToolBar = (Toolbar) findViewById(R.id.toolbar); 20 | setSupportActionBar(mToolBar); 21 | ActionBar actionBar = getSupportActionBar(); 22 | if (actionBar != null) { 23 | actionBar.setDisplayHomeAsUpEnabled(true); 24 | } 25 | } 26 | 27 | @Override 28 | public boolean onOptionsItemSelected(MenuItem item) { 29 | switch (item.getItemId()) { 30 | case android.R.id.home: 31 | this.finish(); 32 | return true; 33 | } 34 | return super.onOptionsItemSelected(item); 35 | } 36 | 37 | @Override 38 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 39 | super.onActivityResult(requestCode, resultCode, data); 40 | Fragment fragment = getSupportFragmentManager().findFragmentByTag("googlePlusFragment"); 41 | if (fragment != null) { 42 | fragment.onActivityResult(requestCode, resultCode, data); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/home/MainFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.home; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | 11 | import org.michenux.drodrolib.ui.navdrawer.NavigationDrawerFragment; 12 | import org.michenux.yourappidea.R; 13 | import org.michenux.yourappidea.YourApplication; 14 | 15 | public class MainFragment extends Fragment implements View.OnClickListener { 16 | @Override 17 | public void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | ((YourApplication) getActivity().getApplication()).inject(this); 20 | } 21 | 22 | @Override 23 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 24 | Bundle savedInstanceState) { 25 | View mainView = inflater 26 | .inflate(R.layout.main_fragment, container, false); 27 | 28 | Button button0 = (Button) mainView.findViewById(R.id.mainmenu_button0); 29 | button0.setOnClickListener(this); 30 | 31 | Button button1 = (Button) mainView.findViewById(R.id.mainmenu_button1); 32 | button1.setOnClickListener(this); 33 | 34 | Button button2 = (Button) mainView.findViewById(R.id.mainmenu_button2); 35 | button2.setOnClickListener(this); 36 | 37 | Button button3 = (Button) mainView.findViewById(R.id.mainmenu_button3); 38 | button3.setOnClickListener(this); 39 | 40 | Button button4 = (Button) mainView.findViewById(R.id.mainmenu_button4); 41 | button4.setOnClickListener(this); 42 | 43 | return mainView; 44 | } 45 | 46 | @Override 47 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 48 | super.onActivityCreated(savedInstanceState); 49 | } 50 | 51 | @Override 52 | public void onClick(View v) { 53 | NavigationDrawerFragment fragment = ((YourAppMainActivity) this.getActivity()).findNavDrawerFragment(); 54 | switch (v.getId()) { 55 | case R.id.mainmenu_button0: 56 | fragment.selectItem(R.id.navdrawer_tutorial, false); 57 | break; 58 | case R.id.mainmenu_button1: 59 | fragment.selectItem(R.id.navdrawer_friends, false); 60 | break; 61 | case R.id.mainmenu_button2: 62 | fragment.selectItem(R.id.navdrawer_airport, false); 63 | break; 64 | case R.id.mainmenu_button3: 65 | fragment.selectItem(R.id.navdrawer_map, false); 66 | break; 67 | case R.id.mainmenu_button4: 68 | fragment.selectItem(R.id.navdrawer_aroundme, false); 69 | break; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/receivers/BatteryLevelReceiver.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.receivers; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | public class BatteryLevelReceiver extends BroadcastReceiver { 8 | @Override 9 | public void onReceive(Context context, Intent intent) { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/receivers/ConnectivityChangeReceiver.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.receivers; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | 8 | import org.michenux.drodrolib.content.ReceiverUtils; 9 | import org.michenux.drodrolib.network.connectivity.ConnectivityUtils; 10 | import org.michenux.yourappidea.BuildConfig; 11 | import org.michenux.yourappidea.YourApplication; 12 | 13 | public class ConnectivityChangeReceiver extends BroadcastReceiver { 14 | @Override 15 | public void onReceive(Context context, Intent intent) { 16 | if (BuildConfig.DEBUG) { 17 | Log.d(YourApplication.LOG_TAG, "ConnectivityChangeReceiver.onReceive"); 18 | Log.d(YourApplication.LOG_TAG, " isConnected: " + ConnectivityUtils.isConnected(context)); 19 | Log.d(YourApplication.LOG_TAG, " isWifiConnected: " + ConnectivityUtils.isConnectedWifi(context)); 20 | } 21 | 22 | if (ConnectivityUtils.isConnected(context)) { 23 | // When connected, stop listening for changes of connectivity because consumes resource 24 | // When refreshing, test if connected, if not, enable the connectivity change listener 25 | ReceiverUtils.disableReceiver(this.getClass(), context); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/receivers/PowerConnectionReceiver.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.receivers; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | 8 | import org.michenux.drodrolib.battery.BatteryUtils; 9 | import org.michenux.yourappidea.BuildConfig; 10 | import org.michenux.yourappidea.YourApplication; 11 | 12 | public class PowerConnectionReceiver extends BroadcastReceiver { 13 | @Override 14 | public void onReceive(Context context, Intent intent) { 15 | if (BuildConfig.DEBUG) { 16 | Log.d(YourApplication.LOG_TAG, "PowerConnectionReceiver"); 17 | Log.d(YourApplication.LOG_TAG, " isChargingOrFull: " + BatteryUtils.isChargingOrFull(context)); 18 | Log.d(YourApplication.LOG_TAG, " charging mode: " + BatteryUtils.getChargingMode(context)); 19 | Log.d(YourApplication.LOG_TAG, " charge pct: " + BatteryUtils.getChargePct(context)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/settings/SettingsFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.settings; 2 | 3 | import android.content.SharedPreferences; 4 | import android.os.Bundle; 5 | import android.support.v7.preference.PreferenceFragmentCompat; 6 | import android.support.v7.preference.PreferenceManager; 7 | import android.util.Log; 8 | 9 | import org.michenux.yourappidea.BuildConfig; 10 | import org.michenux.yourappidea.R; 11 | import org.michenux.yourappidea.YourApplication; 12 | import org.michenux.yourappidea.tutorial.sync.TutorialSyncHelper; 13 | 14 | import javax.inject.Inject; 15 | 16 | public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { 17 | @Inject 18 | TutorialSyncHelper mTutorialSyncHelper; 19 | 20 | @Override 21 | public void onCreatePreferences(Bundle bundle, String rootKey) { 22 | ((YourApplication) getActivity().getApplication()).inject(this); 23 | addPreferencesFromResource(R.xml.preferences); 24 | PreferenceManager preferenceManager = getPreferenceManager(); 25 | preferenceManager.getSharedPreferences() 26 | .registerOnSharedPreferenceChangeListener(this); 27 | } 28 | 29 | @Override 30 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 31 | if (key.equals("notificationPref")) { 32 | if (sharedPreferences.getBoolean(key, true)) { 33 | if (BuildConfig.DEBUG) { 34 | Log.d(YourApplication.LOG_TAG, "settings notificationPref changed: addPeriodicSync()"); 35 | } 36 | mTutorialSyncHelper.enablePeriodicSync(this.getActivity()); 37 | } else { 38 | if (BuildConfig.DEBUG) { 39 | Log.d(YourApplication.LOG_TAG, "settings notificationPref changed: removePeriodicSync()"); 40 | } 41 | mTutorialSyncHelper.removePeriodicSync(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/TutorialRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial; 2 | 3 | import android.database.Cursor; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.text.Html; 6 | import android.text.format.DateUtils; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.TextView; 11 | 12 | import org.michenux.drodrolib.db.CursorRecyclerViewAdapter; 13 | import org.michenux.drodrolib.db.utils.CursorUtils; 14 | import org.michenux.yourappidea.R; 15 | import org.michenux.yourappidea.tutorial.sync.TutorialContentProvider; 16 | 17 | public class TutorialRecyclerAdapter extends CursorRecyclerViewAdapter { 18 | public TutorialRecyclerAdapter() { 19 | super(null); 20 | } 21 | 22 | public TutorialRecyclerAdapter(Cursor cursor) { 23 | super(cursor); 24 | } 25 | 26 | @Override 27 | public TutorialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 28 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.tutorial_listitem, parent, false); 29 | return new TutorialViewHolder(v); 30 | } 31 | 32 | @Override 33 | public void onBindViewHolder(TutorialViewHolder viewHolder, Cursor cursor) { 34 | String title = CursorUtils.getString(TutorialContentProvider.TITLE_COLUMN, cursor); 35 | viewHolder.getTitleView().setText(Html.fromHtml(title)); 36 | viewHolder.getDescriptionView().setText(Html.fromHtml(CursorUtils.getString(TutorialContentProvider.DESCRIPTION_COLUMN, cursor))); 37 | 38 | long date = CursorUtils.getLong(TutorialContentProvider.DATECREATION_COLUMN, cursor) * 1000; 39 | int flags = 0; 40 | flags |= DateUtils.FORMAT_SHOW_DATE; 41 | flags |= DateUtils.FORMAT_ABBREV_MONTH; 42 | flags |= DateUtils.FORMAT_SHOW_YEAR; 43 | 44 | viewHolder.getDateView().setText(DateUtils.formatDateTime(viewHolder.itemView.getContext(), date, flags)); 45 | } 46 | 47 | public static class TutorialViewHolder extends RecyclerView.ViewHolder { 48 | private TextView mTitleView; 49 | private TextView mDescriptionView; 50 | private TextView mDateView; 51 | 52 | public TutorialViewHolder(View itemView) { 53 | super(itemView); 54 | mTitleView = (TextView) itemView.findViewById(R.id.tutorial_title); 55 | mDescriptionView = (TextView) itemView.findViewById(R.id.tutorial_desc); 56 | mDateView = (TextView) itemView.findViewById(R.id.tutorial_date); 57 | } 58 | 59 | public TextView getTitleView() { 60 | return mTitleView; 61 | } 62 | 63 | public TextView getDescriptionView() { 64 | return mDescriptionView; 65 | } 66 | 67 | public TextView getDateView() { 68 | return mDateView; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/sync/TutorialAuthenticator.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial.sync; 2 | 3 | import android.accounts.AbstractAccountAuthenticator; 4 | import android.accounts.Account; 5 | import android.accounts.AccountAuthenticatorResponse; 6 | import android.accounts.NetworkErrorException; 7 | import android.content.Context; 8 | import android.os.Bundle; 9 | 10 | public class TutorialAuthenticator extends AbstractAccountAuthenticator { 11 | public TutorialAuthenticator(Context context) { 12 | super(context); 13 | } 14 | 15 | // Editing properties is not supported 16 | @Override 17 | public Bundle editProperties( 18 | AccountAuthenticatorResponse response, String accountType) { 19 | throw new UnsupportedOperationException(); 20 | } 21 | 22 | // Don't add additional accounts 23 | @Override 24 | public Bundle addAccount( 25 | AccountAuthenticatorResponse response, 26 | String accountType, 27 | String authTokenType, 28 | String[] requiredFeatures, 29 | Bundle bundle) throws NetworkErrorException { 30 | return null; 31 | } 32 | 33 | // Ignore attempts to confirm credentials 34 | @Override 35 | public Bundle confirmCredentials( 36 | AccountAuthenticatorResponse response, 37 | Account account, 38 | Bundle options) throws NetworkErrorException { 39 | return null; 40 | } 41 | 42 | // Getting an authentication token is not supported 43 | @Override 44 | public Bundle getAuthToken( 45 | AccountAuthenticatorResponse response, 46 | Account account, 47 | String authTokenType, 48 | Bundle options) throws NetworkErrorException { 49 | throw new UnsupportedOperationException(); 50 | } 51 | 52 | // Getting a label for the auth token is not supported 53 | @Override 54 | public String getAuthTokenLabel(String authTokenType) { 55 | throw new UnsupportedOperationException(); 56 | } 57 | 58 | // Updating user credentials is not supported 59 | @Override 60 | public Bundle updateCredentials( 61 | AccountAuthenticatorResponse response, 62 | Account account, 63 | String authTokenType, Bundle options) throws NetworkErrorException { 64 | throw new UnsupportedOperationException(); 65 | } 66 | 67 | // Checking features for the account is not supported 68 | @Override 69 | public Bundle hasFeatures( 70 | AccountAuthenticatorResponse response, 71 | Account account, String[] features) throws NetworkErrorException { 72 | throw new UnsupportedOperationException(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/sync/TutorialAuthenticatorService.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial.sync; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | import android.util.Log; 7 | 8 | import org.michenux.yourappidea.BuildConfig; 9 | import org.michenux.yourappidea.YourApplication; 10 | 11 | public class TutorialAuthenticatorService extends Service { 12 | // Instance field that stores the authenticator object 13 | private TutorialAuthenticator mAuthenticator; 14 | 15 | @Override 16 | public void onCreate() { 17 | // Create a new authenticator object 18 | if (BuildConfig.DEBUG) { 19 | Log.d(YourApplication.LOG_TAG, "TutorialAuthenticatorService.onCreate()"); 20 | } 21 | mAuthenticator = new TutorialAuthenticator(this); 22 | } 23 | 24 | /* 25 | * When the system binds to this Service to make the RPC call 26 | * return the authenticator's IBinder. 27 | */ 28 | @Override 29 | public IBinder onBind(Intent intent) { 30 | if (BuildConfig.DEBUG) { 31 | Log.d(YourApplication.LOG_TAG, "TutorialAuthenticatorService.onBind()"); 32 | } 33 | return mAuthenticator.getIBinder(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/sync/TutorialContentProvider.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial.sync; 2 | 3 | import android.content.UriMatcher; 4 | import android.net.Uri; 5 | 6 | import org.michenux.drodrolib.content.ContentProviderUtils; 7 | import org.michenux.drodrolib.db.AbstractContentProvider; 8 | import org.michenux.yourappidea.BuildConfig; 9 | 10 | public class TutorialContentProvider extends AbstractContentProvider { 11 | public static final String TABLE_NAME = "T_TUTORIAL"; 12 | public static final String POSTID_COLUMN = "POSTID"; 13 | public static final String TITLE_COLUMN = "TITLE"; 14 | public static final String DESCRIPTION_COLUMN = "DESCRIPTION"; 15 | public static final String URL_COLUMN = "URL"; 16 | public static final String THUMBNAIL_COLMUN = "THUMBNAIL"; 17 | public static final String AUTHOR_COLUMN = "AUTHOR"; 18 | public static final String CONTENT_COLUMN = "CONTENT"; 19 | public static final String DATECREATION_COLUMN = "DATECREATION"; 20 | public static final String DATEMODIFICATION_COLUMN = "DATEMODIFICATION"; 21 | 22 | public static final String AUTHORITY = ContentProviderUtils.buildAuthority( 23 | BuildConfig.APPLICATION_ID, BuildConfig.FLAVOR, "tutorials"); 24 | 25 | private static final String BASE_PATH = "tutorial"; 26 | 27 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH); 28 | 29 | private static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); 30 | 31 | static { 32 | uriMatcher.addURI(AUTHORITY, BASE_PATH, LIST); 33 | uriMatcher.addURI(AUTHORITY, BASE_PATH + "/#", ITEM_ID); 34 | } 35 | 36 | public TutorialContentProvider() { 37 | super(TABLE_NAME, uriMatcher, BASE_PATH); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/sync/TutorialSyncService.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial.sync; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | 7 | public class TutorialSyncService extends Service { 8 | private static final Object sSyncAdapterLock = new Object(); 9 | 10 | private static TutorialSyncAdapter sSyncAdapter = null; 11 | 12 | @Override 13 | public void onCreate() { 14 | synchronized (sSyncAdapterLock) { 15 | if (sSyncAdapter == null) { 16 | sSyncAdapter = new TutorialSyncAdapter(getApplicationContext(), true); 17 | } 18 | } 19 | } 20 | 21 | @Override 22 | public IBinder onBind(Intent intent) { 23 | return sSyncAdapter.getSyncAdapterBinder(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/sync/WordpressService.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial.sync; 2 | 3 | import org.michenux.drodrolib.wordpress.json.WPJsonResponse; 4 | 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Query; 7 | import rx.Observable; 8 | 9 | // "http://www.michenux.net/?json=get_recent_posts&count=1" 10 | // "http://www.michenux.net/?json=get_category_posts&slug=android&custom_fields=android_desc&categories=android&count=9999" 11 | // &include=id,title,custom_fields,url,date,modified,excerpt,author,thumbnail_images,content 12 | public interface WordpressService { 13 | @GET("/") 14 | Observable query( 15 | @Query("json") String command, 16 | @Query("slug") String slug, 17 | @Query("custom_fields") String customFields, 18 | @Query("categories") String categories, 19 | @Query("count") int count); 20 | } 21 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/java/org/michenux/yourappidea/tutorial/sync/WordpressServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial.sync; 2 | 3 | import android.content.Context; 4 | import android.location.Location; 5 | 6 | import com.google.gson.GsonBuilder; 7 | 8 | import org.michenux.drodrolib.network.gson.LocationDeserializer; 9 | import org.michenux.drodrolib.network.gson.TimestampDeserializer; 10 | import org.michenux.drodrolib.network.okhttp.LoggingInterceptor; 11 | import org.michenux.yourappidea.R; 12 | 13 | import java.sql.Timestamp; 14 | 15 | import okhttp3.OkHttpClient; 16 | import retrofit2.Retrofit; 17 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 18 | import retrofit2.converter.gson.GsonConverterFactory; 19 | 20 | public class WordpressServiceFactory { 21 | public static WordpressService create(Context context) { 22 | GsonBuilder gsonBuilder = new GsonBuilder(); 23 | gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer()); 24 | gsonBuilder.registerTypeAdapter(Location.class, new LocationDeserializer()); 25 | 26 | OkHttpClient client = new OkHttpClient.Builder() 27 | .addInterceptor(new LoggingInterceptor()) 28 | .build(); 29 | 30 | Retrofit retrofit = new Retrofit.Builder() 31 | .baseUrl(context.getString(R.string.tutorial_sync_url)) 32 | .client(client) 33 | .addConverterFactory(GsonConverterFactory.create(gsonBuilder.create())) 34 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 35 | .build(); 36 | 37 | return retrofit.create(WordpressService.class); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/color/navdrawer_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-hdpi-v11/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-hdpi-v11/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-hdpi/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-hdpi/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-mdpi-v11/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-mdpi-v11/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-mdpi/ic_menu_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-mdpi/ic_menu_refresh.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-mdpi/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-mdpi/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi-v11/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi-v11/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/airport_landing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/airport_landing.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/airport_takeoff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/airport_takeoff.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/android.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face01.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face02.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face03.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face04.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face05.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face06.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face07.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face08.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/face09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/face09.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_airport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_airport.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_aroundme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_aroundme.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_changelog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_changelog.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_donations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_donations.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_eula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_eula.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_friends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_friends.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_logout.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_map.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_ratings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_ratings.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_settings.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_tutorial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xhdpi/navdrawer_tutorial.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xxhdpi-v11/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xxhdpi-v11/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xxhdpi/ic_stat_notify_newtuto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xxhdpi/ic_stat_notify_newtuto.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/YourAppIdea/src/main/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable/button_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable/city_background_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/drawable/navdrawer_header_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout-land/frienddetail_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout-land/friends.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/airport_listfragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 21 | 22 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/airport_mode.xml: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/aroundme_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/city.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 23 | 24 | 25 | 29 | 30 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/city_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/city_listitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 20 | 21 | 28 | 29 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/donations_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/donations_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/frienddetail.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 23 | 24 | 33 | 34 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/frienddetail_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/friendlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 23 | 24 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/friendlistitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 26 | 27 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/friends.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/login.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 23 | 24 | 25 | 30 | 31 | 36 | 37 | 46 | 47 | 55 | 56 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/login_facebook.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 17 | 18 | 27 | 28 | 32 | 33 | 38 | 39 | 40 | 41 | 42 | 48 | 49 | 50 | 51 | 52 | 61 | 62 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/main_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 | 27 | 28 | 36 | 37 | 45 | 46 | 54 | 55 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/navdrawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/simplemap_fragment.xml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/tutorial_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/layout/tutorial_listitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 23 | 24 | 33 | 34 | 35 | 36 | 43 | 44 | 45 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/airport_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 19 | 20 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/aroundme_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 19 | 20 | 25 | 26 | 28 | 33 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/friends_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/navigation_drawer_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 14 | 18 | 22 | 26 | 30 | 31 | 32 | 35 | 39 | 44 | 48 | 53 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/navigation_drawer_secondarymenu.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/simplemap_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/menu/tutorial_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 24 | 25 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | @color/accent 4 | @color/primary_light 5 | @color/primary 6 | #802196F3 7 | @color/primary_dark 8 | #801976D2 9 | 10 | @color/primary 11 | @color/primary_dark 12 | @color/primary_light 13 | 14 | #3F51B5 15 | #303F9F 16 | #C5CAE9 17 | #FF4081 18 | #212121 19 | #727272 20 | #FFFFFF 21 | #B6B6B6 22 | 23 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 7 | 160dp 8 | 9 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Your App Idea 4 | 5 | 6 | AIzaSyDNPreInss5-Yua-nkAHq9qvy84Yqc1wnY 7 | 8 | 9 | 1445798595651770 10 | 11 | Preferences 12 | 13 | Info 14 | 15 | Error retrieving data 16 | RETRY 17 | 18 | 19 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_airport.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Arrivals to Paris 5 | Alt: %1$sm 6 | Speed: %1$skm/h 7 | Eta: %1$s 8 | http://www.flightradar24.com/ 9 | ORY 10 | 11 | Mode 12 | 13 | 14 | Arrivals 15 | Departures 16 | 17 | 18 | Info 19 | 20 | - Retrieve flight information of Orly Airport (Paris/France). 21 | - Use the spinner in action bar to choose between incoming and outgoing flights. 22 | - SwipeRefreshLayout (android support) to refresh the list by swiping down. 23 | - Retrofit and Gson libraries are used to query the remote web service. 24 | - Snackbar library to display errors. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_aroundme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.michenux.yourappidea.places 5 | org.michenux.yourappidea.cities 6 | 7 | Waiting for location updates... 8 | %1$d km 9 | https://api.mongolab.com/ 10 | Select city... 11 | Info 12 | 50a2444ae4b0cd0bfc124248 13 | 14 | My location 15 | My Loc 16 | Select city... 17 | City... 18 | Local database 19 | Local db 20 | Remote database 21 | Remote db 22 | 23 | 24 | - Use the actionbar menu to choose between loading the places from the local database, or loading the places from a remote webservice (mongolab). 25 | - Use the actionbar menu to select a city or to find your location. 26 | - Works in offline with configuration: Select a city and Local database. 27 | 28 | - ContentProvider/CursorLoader/LoaderManager are used to load the places from the database. 29 | - Retrofit and Gson libraries are used to query the remote web service. 30 | - Universal Image Loader library is used to load the images of the places. 31 | - Google Play Services are used to find the location of the user. 32 | - Geocoder is used to get the real address from the location. 33 | - Snackbar library to display errors. 34 | 35 | 36 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_changelog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ChangeLog v%1$s 4 | What\'s new in v%1$s 5 | Close 6 | 7 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_donations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Do you find this application useful?\nSupport its development by sending a donation to the developer! 5 | PayPal 6 | Donate ! 7 | 8 | 9 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_eula.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | End User License Agreement 5 | Accept 6 | Refuse 7 | Close 8 | Error reading eula 9 | 10 | 11 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_friends.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.michenux.yourappidea.friends 5 | 6 | No friends 7 | Name : 8 | Job : 9 | 10 | Info 11 | 12 | - List/detail screen. 13 | - In portrait orientation, detail is displayed above the list. 14 | - In landscape orientation, the screen is divided in two columns, one for the list, one for detail. 15 | - On rotation, the state of the screen is preserved. 16 | 17 | - Fragments. 18 | - ContentProvider for data. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sign in 5 | Connect via a social network 6 | 7 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tutorials 5 | List/Detail (Fragment) 6 | Airport (Volley) 7 | Simple Map 8 | Around me 9 | 10 | 11 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_navdrawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tutorials 5 | List detail 6 | Airport 7 | Simple map 8 | Around me 9 | Tutorials 10 | 11 | Logout 12 | 13 | Settings 14 | Rate this app 15 | Donate 16 | ChangeLog 17 | Eula 18 | 19 | Your app idea 20 | Amazing bootstrap 21 | Sign in 22 | 23 | 24 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_simplemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Connection failed 5 | Connection suspended 6 | Your location is required. 7 | 8 | Info 9 | 10 | - Just a simple map with a location button. 11 | - Google Map V2. 12 | - Google Play Service to find user location. 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/strings_tutorial.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.michenux.yourappidea.tutorials 5 | michenux.net 6 | 7 | http://www.michenux.net/ 8 | New android tutorial 9 | 10 | Info 11 | 12 | - Retrieve posts from a wordpress website. 13 | - Check every day for new posts and notify the user. 14 | - Works in offline mode : posts stored in local database. 15 | - Pull down to refresh the list. 16 | 17 | - RecyclerView with twowayview library. 18 | - SyncAdapter is used to retrieve the new posts. 19 | - Retrofit and Gson libraries are used to query the json feed of wordpress. 20 | - ContentProvider/CursorLoader/LoaderManager are used to load the posts from the database. 21 | - SwipeRefreshLayout (android support) to refresh the list by swiping down. 22 | - Snackbar to display errors. 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 23 | 24 | 26 | 27 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/xml/tutorial_authenticator.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | -------------------------------------------------------------------------------- /YourAppIdea/src/main/res/xml/tutorial_syncadapter.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /YourAppIdea/src/test/java/org/michenux/yourappidea/airport/AirportServiceInfoTest.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.airport; 2 | 3 | import android.content.Context; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Before; 7 | import org.junit.Ignore; 8 | import org.junit.Test; 9 | import org.michenux.yourappidea.R; 10 | import org.mockito.Mock; 11 | import org.mockito.MockitoAnnotations; 12 | 13 | import java.util.List; 14 | 15 | import rx.Observable; 16 | import rx.observers.TestSubscriber; 17 | 18 | import static org.mockito.Mockito.when; 19 | 20 | public class AirportServiceInfoTest { 21 | @Mock 22 | private Context mContext; 23 | 24 | @Before 25 | public void setup() { 26 | MockitoAnnotations.initMocks(this); 27 | when(mContext.getString(R.string.airport_rest_url)).thenReturn("http://www.flightradar24.com/"); 28 | } 29 | 30 | @Ignore //TODO: /AirportInfoService.php on flightradar24 returns 404 now 31 | @Test 32 | public void testArrivalFlight() throws Exception { 33 | AirportInfoService airportInfoService = AirportInfoServiceFactory.create(mContext); 34 | Observable observable = 35 | airportInfoService.getFlights("ORY", "in"); 36 | TestSubscriber testSubscriber = new TestSubscriber<>(); 37 | observable.subscribe(testSubscriber); 38 | testSubscriber.assertNoErrors(); 39 | 40 | List events = testSubscriber.getOnNextEvents(); 41 | Assert.assertNotNull(events); 42 | Assert.assertFalse(events.isEmpty()); 43 | 44 | AirportRestResponse response = events.get(0); 45 | 46 | List flights = response.getFlights(); 47 | Assert.assertNotNull(flights); 48 | Assert.assertFalse(flights.isEmpty()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /YourAppIdea/src/test/java/org/michenux/yourappidea/aroundme/MongolabPlaceServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.aroundme; 2 | 3 | import android.content.Context; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.michenux.yourappidea.R; 9 | import org.mockito.Mock; 10 | import org.mockito.MockitoAnnotations; 11 | 12 | import java.util.List; 13 | 14 | import rx.Observable; 15 | import rx.observers.TestSubscriber; 16 | 17 | import static org.mockito.Mockito.when; 18 | 19 | public class MongolabPlaceServiceTest { 20 | @Mock 21 | private Context mContext; 22 | 23 | @Before 24 | public void setup() { 25 | MockitoAnnotations.initMocks(this); 26 | when(mContext.getString(R.string.aroundme_placeremoteprovider_url)).thenReturn("https://api.mongolab.com/"); 27 | when(mContext.getString(R.string.aroundme_apiKey)).thenReturn("50a2444ae4b0cd0bfc124248"); 28 | } 29 | 30 | @Test 31 | public void testRemoteProvider() { 32 | MongolabPlaceService placeService = MongolabPlaceServiceFactory.create(mContext); 33 | 34 | String query = "{'location':{$near:{$geometry:{'type':'Point','coordinates':[" 35 | + 0 + "," + 0 + "]},$maxDistance:1000000000}}}"; 36 | 37 | Observable> observable = 38 | placeService.getPlaces(query, mContext.getString(R.string.aroundme_apiKey)); 39 | TestSubscriber> testSubscriber = new TestSubscriber<>(); 40 | observable.subscribe(testSubscriber); 41 | testSubscriber.assertNoErrors(); 42 | 43 | List> events = testSubscriber.getOnNextEvents(); 44 | Assert.assertNotNull(events); 45 | Assert.assertFalse(events.isEmpty()); 46 | 47 | List places = events.get(0); 48 | Assert.assertNotNull(places); 49 | Assert.assertFalse(places.isEmpty()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /YourAppIdea/src/test/java/org/michenux/yourappidea/tutorial/WordpressServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.michenux.yourappidea.tutorial; 2 | 3 | import android.content.Context; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.michenux.drodrolib.wordpress.json.WPJsonPost; 9 | import org.michenux.drodrolib.wordpress.json.WPJsonResponse; 10 | import org.michenux.yourappidea.R; 11 | import org.michenux.yourappidea.tutorial.sync.WordpressService; 12 | import org.michenux.yourappidea.tutorial.sync.WordpressServiceFactory; 13 | import org.mockito.Mock; 14 | import org.mockito.MockitoAnnotations; 15 | 16 | import java.util.List; 17 | 18 | import rx.Observable; 19 | import rx.observers.TestSubscriber; 20 | 21 | import static org.mockito.Mockito.when; 22 | 23 | public class WordpressServiceTest { 24 | @Mock 25 | private Context mContext; 26 | 27 | @Before 28 | public void setup() { 29 | MockitoAnnotations.initMocks(this); 30 | when(mContext.getString(R.string.tutorial_sync_url)).thenReturn("http://www.michenux.net/"); 31 | } 32 | 33 | @Test 34 | public void testQuery() throws Exception { 35 | WordpressService wordpressService = WordpressServiceFactory.create(mContext); 36 | Observable observable = 37 | wordpressService.query("get_recent_posts", "android", "android_desc", "android", 9999); 38 | TestSubscriber testSubscriber = new TestSubscriber<>(); 39 | observable.subscribe(testSubscriber); 40 | testSubscriber.assertNoErrors(); 41 | 42 | List jsonPosts = testSubscriber.getOnNextEvents(); 43 | Assert.assertNotNull(jsonPosts); 44 | Assert.assertFalse(jsonPosts.isEmpty()); 45 | 46 | WPJsonResponse response = jsonPosts.get(0); 47 | Assert.assertEquals(response.getStatus(), "ok"); 48 | 49 | List posts = response.getPosts(); 50 | Assert.assertNotNull(posts); 51 | Assert.assertFalse(posts.isEmpty()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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:2.2.3' 9 | classpath 'com.google.gms:google-services:3.0.0' 10 | } 11 | } 12 | 13 | apply from: 'dependencies.gradle' 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | maven { url "https://jitpack.io" } 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /drodrolib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile supportDependencies.multidex 24 | compile supportDependencies.appcompat 25 | compile supportDependencies.design 26 | compile supportDependencies.recyclerview 27 | compile supportDependencies.cardview 28 | compile playServicesDependencies.maps 29 | compile playServicesDependencies.auth 30 | compile playServicesDependencies.ads 31 | compile playServicesDependencies.location 32 | compile otherDependencies.daggerCompiler 33 | compile otherDependencies.dagger 34 | compile otherDependencies.gson 35 | compile otherDependencies.okhttp 36 | compile otherDependencies.circleImageView 37 | compile(otherDependencies.materialDialogs) { 38 | transitive = true 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /drodrolib/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /drodrolib/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in ${sdk.dir}/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 | -------------------------------------------------------------------------------- /drodrolib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/MCXApplication.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.content.AbstractThreadedSyncAdapter; 6 | import android.content.ContentProvider; 7 | import android.content.Context; 8 | import android.support.multidex.MultiDexApplication; 9 | import android.support.v4.app.Fragment; 10 | import android.util.Log; 11 | 12 | import java.lang.reflect.Field; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | import dagger.ObjectGraph; 17 | 18 | public class MCXApplication extends MultiDexApplication { 19 | public static final String LOG_TAG = "MCX"; 20 | 21 | private ObjectGraph objectGraph; 22 | 23 | public void inject(Activity activity) { 24 | getObjectGraph().inject(activity); 25 | } 26 | 27 | public void inject(ContentProvider contentProvider) { 28 | getObjectGraph().inject(contentProvider); 29 | } 30 | 31 | public void inject(Fragment fragment) { 32 | getObjectGraph().inject(fragment); 33 | } 34 | 35 | public void inject(AbstractThreadedSyncAdapter fragment) { 36 | getObjectGraph().inject(fragment); 37 | } 38 | 39 | public void injectSelf() { 40 | getObjectGraph().inject(this); 41 | } 42 | 43 | public synchronized ObjectGraph getObjectGraph() { 44 | if (objectGraph == null) { 45 | List modules = new ArrayList<>(); 46 | buildDaggerModules(modules); 47 | this.objectGraph = ObjectGraph.create(modules.toArray()); 48 | onObjectGraphCreated(this.objectGraph); 49 | } 50 | return objectGraph; 51 | } 52 | 53 | public void buildDaggerModules(List modules) { 54 | modules.add(new MCXModule()); 55 | } 56 | 57 | public void onObjectGraphCreated(ObjectGraph objectGraph) { 58 | } 59 | 60 | public static MCXApplication getRealApplication(Context applicationContext) { 61 | MCXApplication application = null; 62 | 63 | if (applicationContext instanceof MCXApplication) { 64 | application = (MCXApplication) applicationContext; 65 | } else { 66 | Application realApplication = null; 67 | Field magicField = null; 68 | try { 69 | magicField = applicationContext.getClass().getDeclaredField("realApplication"); 70 | magicField.setAccessible(true); 71 | realApplication = (Application) magicField.get(applicationContext); 72 | } catch (NoSuchFieldException e) { 73 | Log.e(LOG_TAG, e.getMessage(), e); 74 | } catch (IllegalAccessException e) { 75 | Log.e(LOG_TAG, e.getMessage(), e); 76 | } 77 | 78 | application = (MCXApplication) realApplication; 79 | } 80 | 81 | return application; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/MCXModule.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib; 2 | 3 | import org.michenux.drodrolib.db.sqlite.SQLiteDatabaseFactory; 4 | import org.michenux.drodrolib.gms.auth.GoogleAuthFragment; 5 | import org.michenux.drodrolib.security.UserHelper; 6 | 7 | import dagger.Module; 8 | 9 | @Module(injects = { 10 | SQLiteDatabaseFactory.class, 11 | UserHelper.class, 12 | GoogleAuthFragment.class 13 | }) 14 | public class MCXModule { 15 | } 16 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/accounts/AccountUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.accounts; 2 | 3 | import android.text.TextUtils; 4 | 5 | public class AccountUtils { 6 | public static String buildAccountTypeName(String flavor, String accountTypeName, boolean debug) { 7 | StringBuilder authority = new StringBuilder(); 8 | if (!TextUtils.isEmpty(flavor)) { 9 | authority.append(flavor); 10 | authority.append('.'); 11 | } 12 | authority.append(accountTypeName); 13 | if (debug) { 14 | authority.append(".debug"); 15 | } 16 | return authority.toString(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/accounts/DumbAccountAuthenticator.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.accounts; 2 | 3 | import android.accounts.AbstractAccountAuthenticator; 4 | import android.accounts.Account; 5 | import android.accounts.AccountAuthenticatorResponse; 6 | import android.accounts.NetworkErrorException; 7 | import android.content.Context; 8 | import android.os.Bundle; 9 | 10 | public class DumbAccountAuthenticator extends AbstractAccountAuthenticator { 11 | public DumbAccountAuthenticator(Context context) { 12 | super(context); 13 | } 14 | 15 | // Editing properties is not supported 16 | @Override 17 | public Bundle editProperties( 18 | AccountAuthenticatorResponse response, String accountType) { 19 | throw new UnsupportedOperationException(); 20 | } 21 | 22 | // Don't add additional accounts 23 | @Override 24 | public Bundle addAccount( 25 | AccountAuthenticatorResponse response, 26 | String accountType, 27 | String authTokenType, 28 | String[] requiredFeatures, 29 | Bundle bundle) throws NetworkErrorException { 30 | return null; 31 | } 32 | 33 | // Ignore attempts to confirm credentials 34 | @Override 35 | public Bundle confirmCredentials( 36 | AccountAuthenticatorResponse response, 37 | Account account, 38 | Bundle options) throws NetworkErrorException { 39 | return null; 40 | } 41 | 42 | // Getting an authentication token is not supported 43 | @Override 44 | public Bundle getAuthToken( 45 | AccountAuthenticatorResponse response, 46 | Account account, 47 | String authTokenType, 48 | Bundle options) throws NetworkErrorException { 49 | throw new UnsupportedOperationException(); 50 | } 51 | 52 | // Getting a label for the auth token is not supported 53 | @Override 54 | public String getAuthTokenLabel(String authTokenType) { 55 | throw new UnsupportedOperationException(); 56 | } 57 | 58 | // Updating user credentials is not supported 59 | @Override 60 | public Bundle updateCredentials( 61 | AccountAuthenticatorResponse response, 62 | Account account, 63 | String authTokenType, Bundle options) throws NetworkErrorException { 64 | throw new UnsupportedOperationException(); 65 | } 66 | 67 | // Checking features for the account is not supported 68 | @Override 69 | public Bundle hasFeatures( 70 | AccountAuthenticatorResponse response, 71 | Account account, String[] features) throws NetworkErrorException { 72 | throw new UnsupportedOperationException(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/battery/BatteryUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.battery; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.IntentFilter; 6 | import android.os.BatteryManager; 7 | 8 | public class BatteryUtils { 9 | public static boolean isChargingOrFull(Context context) { 10 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); 11 | Intent batteryStatus = context.registerReceiver(null, intentFilter); 12 | return isChargingOrFull(batteryStatus); 13 | } 14 | 15 | public static boolean isChargingOrFull(Intent batteryStatus) { 16 | int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); 17 | return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; 18 | } 19 | 20 | /** 21 | * @param context 22 | * @return BatteryManager.BATTERY_PLUGGED_USB, BatteryManager.BATTERY_PLUGGED_AC, BatteryManager.BATTERY_PLUGGED_WIRELESS 23 | */ 24 | public static int getChargingMode(Context context) { 25 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); 26 | Intent batteryStatus = context.registerReceiver(null, intentFilter); 27 | return getChargingMode(batteryStatus); 28 | } 29 | 30 | public static int getChargingMode(Intent batteryStatus) { 31 | return batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); 32 | } 33 | 34 | public static float getChargePct(Context context) { 35 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); 36 | Intent batteryStatus = context.registerReceiver(null, intentFilter); 37 | return getChargePct(batteryStatus); 38 | } 39 | 40 | public static float getChargePct(Intent batteryStatus) { 41 | int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); 42 | int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1); 43 | return level / (float) scale; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/content/ContentProviderUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.content; 2 | 3 | import android.content.ContentResolver; 4 | import android.database.Cursor; 5 | import android.net.Uri; 6 | import android.text.TextUtils; 7 | 8 | public class ContentProviderUtils { 9 | public static String buildAuthority(String packageName, String flavor, String name) { 10 | StringBuilder authority = new StringBuilder(packageName); 11 | if (!TextUtils.isEmpty(flavor)) { 12 | authority.append('.'); 13 | authority.append(flavor); 14 | } 15 | authority.append('.'); 16 | authority.append(name); 17 | return authority.toString(); 18 | } 19 | 20 | public static int count(Uri uri, String selection, String[] selectionArgs, ContentResolver contentResolver) { 21 | Cursor cursor = contentResolver.query(uri, new String[]{"count(*)"}, 22 | selection, selectionArgs, null); 23 | if (cursor.getCount() == 0) { 24 | cursor.close(); 25 | return 0; 26 | } else { 27 | cursor.moveToFirst(); 28 | int result = cursor.getInt(0); 29 | cursor.close(); 30 | return result; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/content/IntentUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.content; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | public class IntentUtils { 8 | public static void setEmailIntent(String email, String subject, String chooserTitle, Context context) { 9 | Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( 10 | "mailto", email, null)); 11 | emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 12 | context.startActivity(Intent.createChooser(emailIntent, chooserTitle)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/content/ReceiverUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.content; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.content.pm.PackageManager; 7 | 8 | public class ReceiverUtils { 9 | public static void enableReceiver(Class receiverClass, Context context) { 10 | ComponentName componentName = new ComponentName(context, receiverClass); 11 | PackageManager packageManager = context.getPackageManager(); 12 | packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); 13 | } 14 | 15 | public static void disableReceiver(Class receiverClass, Context context) { 16 | ComponentName componentName = new ComponentName(context, receiverClass); 17 | PackageManager packageManager = context.getPackageManager(); 18 | packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/db/sqlite/SQLiteDatabaseFactory.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.db.sqlite; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageManager.NameNotFoundException; 5 | import android.database.sqlite.SQLiteDatabase; 6 | 7 | import org.michenux.drodrolib.info.VersionUtils; 8 | 9 | import javax.inject.Inject; 10 | import javax.inject.Singleton; 11 | 12 | @Singleton 13 | public class SQLiteDatabaseFactory { 14 | /** 15 | * SQLite Open Helper 16 | */ 17 | private SQLiteDatabaseHelper helper; 18 | 19 | /** 20 | * SQLite Database 21 | */ 22 | private SQLiteDatabase database; 23 | 24 | @Inject 25 | public SQLiteDatabaseFactory() { 26 | } 27 | 28 | /** 29 | * @throws NameNotFoundException 30 | */ 31 | public void init(Context context, boolean writable, boolean enableFK) throws NameNotFoundException { 32 | this.helper = new SQLiteDatabaseHelper(context, "database", null, 33 | VersionUtils.getVersionCode(context)); 34 | // open and close database to init database (creation/upgrade) 35 | if (writable) { 36 | this.database = this.helper.getWritableDatabase(); 37 | if (enableFK) { 38 | this.database.execSQL("PRAGMA foreign_keys = ON"); 39 | } 40 | } else { 41 | this.database = this.helper.getReadableDatabase(); 42 | } 43 | } 44 | 45 | /** 46 | * @return 47 | */ 48 | public SQLiteDatabase getDatabase() { 49 | return this.database; 50 | } 51 | 52 | @Override 53 | protected void finalize() throws Throwable { 54 | super.finalize(); 55 | if (this.database != null && this.database.isOpen()) { 56 | this.database.close(); 57 | } 58 | } 59 | 60 | /** 61 | * 62 | */ 63 | public void closeDatabase() { 64 | this.database.close(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/db/utils/CursorUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.db.utils; 2 | 3 | import android.database.Cursor; 4 | 5 | public class CursorUtils { 6 | public static String getString(String columnName, Cursor cursor) { 7 | return cursor.getString(cursor.getColumnIndexOrThrow(columnName)); 8 | } 9 | 10 | public static int getInt(String columnName, Cursor cursor) { 11 | return cursor.getInt(cursor.getColumnIndexOrThrow(columnName)); 12 | } 13 | 14 | public static long getLong(String columnName, Cursor cursor) { 15 | return cursor.getLong(cursor.getColumnIndexOrThrow(columnName)); 16 | } 17 | 18 | public static double getDouble(String columnName, Cursor cursor) { 19 | return cursor.getDouble(cursor.getColumnIndexOrThrow(columnName)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/geoloc/DistanceComparator.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.geoloc; 2 | 3 | import java.util.Comparator; 4 | 5 | public class DistanceComparator implements Comparator { 6 | @Override 7 | public int compare(DistanceHolder dh1, DistanceHolder dh2) { 8 | float diff = dh1.getDistance() - dh2.getDistance(); 9 | return diff > 0 ? 1 : diff < 0 ? -1 : 0; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/geoloc/DistanceHolder.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.geoloc; 2 | 3 | public interface DistanceHolder { 4 | float getDistance(); 5 | } 6 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/geoloc/Localizable.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.geoloc; 2 | 3 | import android.location.Location; 4 | 5 | public interface Localizable { 6 | Location getLocation(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/geoloc/LocalizableComparator.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.geoloc; 2 | 3 | import android.location.Location; 4 | 5 | import java.util.Comparator; 6 | 7 | public class LocalizableComparator implements Comparator { 8 | private Location mFromLocation; 9 | 10 | public LocalizableComparator(Location fromLocation) { 11 | this.mFromLocation = fromLocation; 12 | } 13 | 14 | @Override 15 | public int compare(Localizable loc1, Localizable loc2) { 16 | float diff = mFromLocation.distanceTo(loc1.getLocation()) - mFromLocation.distanceTo(loc2.getLocation()); 17 | return diff > 0 ? 1 : diff < 0 ? -1 : 0; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/gms/GmsUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.gms; 2 | 3 | import android.content.Context; 4 | 5 | import com.google.android.gms.common.ConnectionResult; 6 | import com.google.android.gms.common.GooglePlayServicesUtil; 7 | 8 | public class GmsUtils { 9 | public static boolean supportsGooglePlayServices(Context context) { 10 | return GooglePlayServicesUtil.isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/gms/auth/GoogleAuthFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.gms.auth; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.google.android.gms.common.SignInButton; 11 | 12 | import org.michenux.drodrolib.MCXApplication; 13 | import org.michenux.drodrolib.R; 14 | import org.michenux.drodrolib.security.UserHelper; 15 | import org.michenux.drodrolib.security.UserSessionCallback; 16 | 17 | import javax.inject.Inject; 18 | 19 | public class GoogleAuthFragment extends Fragment implements UserSessionCallback, View.OnClickListener { 20 | @Inject 21 | UserHelper mUserHelper; 22 | 23 | private GoogleAuthDelegate mGoogleAuthDelegate; 24 | 25 | private SignInButton mSignInButton; 26 | 27 | @Override 28 | public void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | ((MCXApplication) getActivity().getApplication()).inject(this); 31 | 32 | mGoogleAuthDelegate = new GoogleAuthDelegate(this.getActivity(), mUserHelper); 33 | mGoogleAuthDelegate.setUserSessionCallback(this); 34 | 35 | } 36 | 37 | @Override 38 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 39 | View view = inflater.inflate(R.layout.login_googleplus, container, false); 40 | mSignInButton = (SignInButton) view.findViewById(R.id.sign_in_button); 41 | mSignInButton.setOnClickListener(this); 42 | return view; 43 | } 44 | 45 | @Override 46 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 47 | super.onActivityResult(requestCode, resultCode, data); 48 | mGoogleAuthDelegate.onActivityResult(requestCode, resultCode, data); 49 | } 50 | 51 | @Override 52 | public void onStart() { 53 | super.onStart(); 54 | mGoogleAuthDelegate.onStart(); 55 | } 56 | 57 | @Override 58 | public void onLogin() { 59 | updateButtons(true); 60 | this.getActivity().finish(); 61 | } 62 | 63 | @Override 64 | public void onLogout() { 65 | updateButtons(false); 66 | } 67 | 68 | private void updateButtons(boolean isSignedIn) { 69 | if (isSignedIn) { 70 | mSignInButton.setVisibility(View.INVISIBLE); 71 | } else { 72 | mSignInButton.setVisibility(View.VISIBLE); 73 | } 74 | } 75 | 76 | @Override 77 | public void onClick(View view) { 78 | if (view.getId() == R.id.sign_in_button) { 79 | mGoogleAuthDelegate.signIn(this.getActivity()); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/info/AppUsageUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.info; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.preference.PreferenceManager; 6 | 7 | public class AppUsageUtils { 8 | private static final String LASTUSED_PARAM = "lastUsed"; 9 | private static final String LASTSYNC_PARAM = "lastSync"; 10 | 11 | public static void updateLastUsedTimestamp(Context context) { 12 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 13 | SharedPreferences.Editor edit = prefs.edit(); 14 | edit.putLong(LASTUSED_PARAM, System.currentTimeMillis()); 15 | edit.commit(); 16 | } 17 | 18 | public static long getLastUsedTimestamp(Context context) { 19 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 20 | return prefs.getLong(LASTUSED_PARAM, 0); 21 | } 22 | 23 | public static long getLastSync(Context context) { 24 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 25 | return prefs.getLong(LASTSYNC_PARAM, 0); 26 | } 27 | 28 | public static void updateLastSync(Context context) { 29 | long lastSync = getLastSync(context); 30 | long now = System.currentTimeMillis(); 31 | if (lastSync < now) { 32 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 33 | SharedPreferences.Editor editor = prefs.edit(); 34 | editor.putLong(LASTSYNC_PARAM, now); 35 | editor.commit(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/info/VersionUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.info; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.content.pm.PackageManager.NameNotFoundException; 6 | 7 | public class VersionUtils { 8 | public static int getVersionCode(Context context) { 9 | PackageInfo manager = null; 10 | try { 11 | manager = context.getPackageManager().getPackageInfo( 12 | context.getPackageName(), 0); 13 | } catch (NameNotFoundException e) { 14 | throw new RuntimeException(e); 15 | } 16 | return manager.versionCode; 17 | } 18 | 19 | public static String getVersionName(Context context) { 20 | PackageInfo manager = null; 21 | try { 22 | manager = context.getPackageManager().getPackageInfo( 23 | context.getPackageName(), 0); 24 | } catch (NameNotFoundException e) { 25 | throw new RuntimeException(e); 26 | } 27 | return manager.versionName; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/lang/DateUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.lang; 2 | 3 | import java.util.Calendar; 4 | import java.util.Date; 5 | 6 | public class DateUtils { 7 | /** 8 | *

Checks if two dates are on the same day ignoring time.

9 | * 10 | * @param date1 the first date, not altered, not null 11 | * @param date2 the second date, not altered, not null 12 | * @return true if they represent the same day 13 | * @throws IllegalArgumentException if either date is null 14 | */ 15 | public static boolean isSameDay(Date date1, Date date2) { 16 | if (date1 == null || date2 == null) { 17 | throw new IllegalArgumentException("The dates must not be null"); 18 | } 19 | Calendar cal1 = Calendar.getInstance(); 20 | cal1.setTime(date1); 21 | Calendar cal2 = Calendar.getInstance(); 22 | cal2.setTime(date2); 23 | return isSameDay(cal1, cal2); 24 | } 25 | 26 | /** 27 | *

Checks if two calendars represent the same day ignoring time.

28 | * 29 | * @param cal1 the first calendar, not altered, not null 30 | * @param cal2 the second calendar, not altered, not null 31 | * @return true if they represent the same day 32 | * @throws IllegalArgumentException if either calendar is null 33 | */ 34 | public static boolean isSameDay(Calendar cal1, Calendar cal2) { 35 | if (cal1 == null || cal2 == null) { 36 | throw new IllegalArgumentException("The dates must not be null"); 37 | } 38 | return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && 39 | cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && 40 | cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); 41 | } 42 | 43 | /** 44 | *

Checks if a date is today.

45 | * 46 | * @param date the date, not altered, not null. 47 | * @return true if the date is today. 48 | * @throws IllegalArgumentException if the date is null 49 | */ 50 | public static boolean isToday(Date date) { 51 | return isSameDay(date, Calendar.getInstance().getTime()); 52 | } 53 | 54 | /** 55 | *

Checks if a calendar date is today.

56 | * 57 | * @param cal the calendar, not altered, not null 58 | * @return true if cal date is today 59 | * @throws IllegalArgumentException if the calendar is null 60 | */ 61 | public static boolean isToday(Calendar cal) { 62 | return isSameDay(cal, Calendar.getInstance()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/network/connectivity/ConnectivityUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.network.connectivity; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | public class ConnectivityUtils { 8 | public static boolean isConnected(Context context) { 9 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 10 | NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); 11 | return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); 12 | } 13 | 14 | public static boolean isConnectedWifi(Context context) { 15 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 16 | NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); 17 | return activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/network/gson/LocationDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.network.gson; 2 | 3 | import android.location.Location; 4 | 5 | import com.google.gson.JsonArray; 6 | import com.google.gson.JsonDeserializationContext; 7 | import com.google.gson.JsonDeserializer; 8 | import com.google.gson.JsonElement; 9 | import com.google.gson.JsonObject; 10 | import com.google.gson.JsonParseException; 11 | 12 | import java.lang.reflect.Type; 13 | 14 | public class LocationDeserializer implements JsonDeserializer { 15 | @Override 16 | public Location deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { 17 | JsonObject jsonObject = jsonElement.getAsJsonObject(); 18 | Location location = new Location("mongodb"); 19 | JsonArray coord = jsonObject.getAsJsonArray("coordinates"); 20 | location.setLongitude(coord.get(0).getAsDouble()); 21 | location.setLatitude(coord.get(1).getAsDouble()); 22 | return location; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/network/gson/TimestampDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.network.gson; 2 | 3 | import com.google.gson.JsonDeserializationContext; 4 | import com.google.gson.JsonDeserializer; 5 | import com.google.gson.JsonElement; 6 | import com.google.gson.JsonParseException; 7 | 8 | import java.lang.reflect.Type; 9 | import java.sql.Timestamp; 10 | 11 | public class TimestampDeserializer implements JsonDeserializer { 12 | public Timestamp deserialize(JsonElement json, Type typeOfT, 13 | JsonDeserializationContext context) throws JsonParseException { 14 | Timestamp result = null; 15 | long time = Long.parseLong(json.getAsString()); 16 | if (time > 0) { 17 | result = new Timestamp(time * 1000); 18 | } 19 | return result; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/network/okhttp/LoggingInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.network.okhttp; 2 | 3 | import android.util.Log; 4 | 5 | import org.michenux.drodrolib.BuildConfig; 6 | import org.michenux.drodrolib.MCXApplication; 7 | 8 | import java.io.IOException; 9 | 10 | import okhttp3.Interceptor; 11 | import okhttp3.Request; 12 | import okhttp3.Response; 13 | 14 | public class LoggingInterceptor implements Interceptor { 15 | @Override 16 | public Response intercept(Chain chain) throws IOException { 17 | Request request = chain.request(); 18 | long t1 = System.nanoTime(); 19 | 20 | String url = request.url().toString(); 21 | 22 | if (BuildConfig.DEBUG) { 23 | Log.d(MCXApplication.LOG_TAG, String.format("Sending request %s on %s%n%s", 24 | url, chain.connection(), request.headers())); 25 | } 26 | 27 | Response response = chain.proceed(request); 28 | 29 | long t2 = System.nanoTime(); 30 | 31 | if (BuildConfig.DEBUG) { 32 | Log.d(MCXApplication.LOG_TAG, String.format("Received response for %s in %.1fms%n%s", 33 | url, (t2 - t1) / 1e6d, response.headers())); 34 | } 35 | 36 | return response; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/network/ssl/TrustAllManager.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.network.ssl; 2 | 3 | import java.security.cert.CertificateException; 4 | import java.security.cert.X509Certificate; 5 | 6 | import javax.net.ssl.X509TrustManager; 7 | 8 | public class TrustAllManager implements X509TrustManager { 9 | public void checkClientTrusted(X509Certificate[] cert, String authType) throws CertificateException { 10 | } 11 | 12 | public void checkServerTrusted(X509Certificate[] cert, String authType) throws CertificateException { 13 | } 14 | 15 | public X509Certificate[] getAcceptedIssuers() { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/network/ssl/TrustAllSSLSocketFactory.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.network.ssl; 2 | 3 | import org.apache.http.conn.scheme.SocketFactory; 4 | import org.apache.http.conn.ssl.AllowAllHostnameVerifier; 5 | import org.apache.http.conn.ssl.SSLSocketFactory; 6 | 7 | import java.io.IOException; 8 | import java.net.InetAddress; 9 | import java.net.Socket; 10 | import java.security.KeyManagementException; 11 | import java.security.KeyStoreException; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.UnrecoverableKeyException; 14 | 15 | import javax.net.ssl.SSLContext; 16 | import javax.net.ssl.TrustManager; 17 | 18 | public class TrustAllSSLSocketFactory extends SSLSocketFactory { 19 | private javax.net.ssl.SSLSocketFactory factory; 20 | 21 | public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { 22 | super(null); 23 | try { 24 | SSLContext sslcontext = SSLContext.getInstance("TLS"); 25 | sslcontext.init(null, new TrustManager[]{new TrustAllManager()}, null); 26 | factory = sslcontext.getSocketFactory(); 27 | setHostnameVerifier(new AllowAllHostnameVerifier()); 28 | } catch (Exception ex) { 29 | } 30 | } 31 | 32 | public static SocketFactory getDefault() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { 33 | return new TrustAllSSLSocketFactory(); 34 | } 35 | 36 | public Socket createSocket() throws IOException { 37 | return factory.createSocket(); 38 | } 39 | 40 | public Socket createSocket(Socket socket, String s, int i, boolean flag) throws IOException { 41 | return factory.createSocket(socket, s, i, flag); 42 | } 43 | 44 | public Socket createSocket(InetAddress inaddr, int i, InetAddress inaddr1, int j) throws IOException { 45 | return factory.createSocket(inaddr, i, inaddr1, j); 46 | } 47 | 48 | public Socket createSocket(InetAddress inaddr, int i) throws IOException { 49 | return factory.createSocket(inaddr, i); 50 | } 51 | 52 | public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException { 53 | return factory.createSocket(s, i, inaddr, j); 54 | } 55 | 56 | public Socket createSocket(String s, int i) throws IOException { 57 | return factory.createSocket(s, i); 58 | } 59 | 60 | public String[] getDefaultCipherSuites() { 61 | return factory.getDefaultCipherSuites(); 62 | } 63 | 64 | public String[] getSupportedCipherSuites() { 65 | return factory.getSupportedCipherSuites(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/resources/AssetUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.resources; 2 | 3 | import android.content.res.AssetManager; 4 | 5 | import java.io.IOException; 6 | import java.util.Arrays; 7 | 8 | public class AssetUtils { 9 | /** 10 | * @param fileName searched file name 11 | * @param path subpath from the asset directory 12 | * @param assetManager assetManager 13 | * @return 14 | * @throws IOException 15 | */ 16 | public static boolean exists(String fileName, String path, AssetManager assetManager) throws IOException { 17 | for (String currentFileName : assetManager.list(path)) { 18 | if (currentFileName.equals(fileName)) { 19 | return true; 20 | } 21 | } 22 | return false; 23 | } 24 | 25 | /** 26 | * @param path 27 | * @param assetManager 28 | * @return 29 | * @throws IOException 30 | */ 31 | public static String[] list(String path, AssetManager assetManager) throws IOException { 32 | String[] files = assetManager.list(path); 33 | Arrays.sort(files); 34 | return files; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/resources/ResourceUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.resources; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.support.v4.content.ContextCompat; 6 | 7 | public class ResourceUtils { 8 | public static Drawable getDrawableByName(String name, Context context) { 9 | int drawableResource = context.getResources().getIdentifier( 10 | name, 11 | "drawable", 12 | context.getPackageName()); 13 | if (drawableResource == 0) { 14 | throw new RuntimeException("Can't find drawable with name: " + name); 15 | } 16 | return ContextCompat.getDrawable(context, drawableResource); 17 | } 18 | 19 | public static int getDrawableIdByName(String name, Context context) { 20 | int drawableResource = context.getResources().getIdentifier( 21 | name, 22 | "drawable", 23 | context.getPackageName()); 24 | if (drawableResource == 0) { 25 | throw new RuntimeException("Can't find drawable with name: " + name); 26 | } 27 | return drawableResource; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/security/SecurityUtils.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.security; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.content.pm.PackageManager; 6 | import android.content.pm.Signature; 7 | import android.util.Base64; 8 | import android.util.Log; 9 | 10 | import org.michenux.drodrolib.MCXApplication; 11 | 12 | import java.security.MessageDigest; 13 | import java.security.NoSuchAlgorithmException; 14 | 15 | public class SecurityUtils { 16 | public static String logHashKey(Context context) { 17 | try { 18 | PackageInfo info = context.getPackageManager().getPackageInfo( 19 | context.getPackageName(), 20 | PackageManager.GET_SIGNATURES); 21 | for (Signature signature : info.signatures) { 22 | MessageDigest md = MessageDigest.getInstance("SHA"); 23 | md.update(signature.toByteArray()); 24 | return Base64.encodeToString(md.digest(), Base64.DEFAULT); 25 | } 26 | } catch (PackageManager.NameNotFoundException e) { 27 | Log.e(MCXApplication.LOG_TAG, "logHashKey error", e); 28 | } catch (NoSuchAlgorithmException e) { 29 | Log.e(MCXApplication.LOG_TAG, "logHashKey error", e); 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/security/User.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.security; 2 | 3 | public class User { 4 | private String userId; 5 | 6 | private String provider; 7 | 8 | private String providerDisplayName; 9 | 10 | private String userName; 11 | 12 | private String displayName; 13 | 14 | private String firstName; 15 | 16 | private String lastName; 17 | 18 | private String mail; 19 | 20 | public String getUserName() { 21 | return userName; 22 | } 23 | 24 | public void setUserName(String userName) { 25 | this.userName = userName; 26 | } 27 | 28 | public String getUserId() { 29 | return userId; 30 | } 31 | 32 | public void setUserId(String userId) { 33 | this.userId = userId; 34 | } 35 | 36 | public String getFirstName() { 37 | return firstName; 38 | } 39 | 40 | public void setFirstName(String firstName) { 41 | this.firstName = firstName; 42 | } 43 | 44 | public String getLastName() { 45 | return lastName; 46 | } 47 | 48 | public void setLastName(String lastName) { 49 | this.lastName = lastName; 50 | } 51 | 52 | public String getProvider() { 53 | return provider; 54 | } 55 | 56 | public void setProvider(String provider) { 57 | this.provider = provider; 58 | } 59 | 60 | public String getDisplayName() { 61 | return displayName; 62 | } 63 | 64 | public void setDisplayName(String displayName) { 65 | this.displayName = displayName; 66 | } 67 | 68 | public String getProviderDisplayName() { 69 | return providerDisplayName; 70 | } 71 | 72 | public void setProviderDisplayName(String providerDisplayName) { 73 | this.providerDisplayName = providerDisplayName; 74 | } 75 | 76 | public String getMail() { 77 | return mail; 78 | } 79 | 80 | public void setMail(String mail) { 81 | this.mail = mail; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/security/UserHelper.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.security; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Singleton; 5 | 6 | @Singleton 7 | public class UserHelper { 8 | private User mCurrentUser; 9 | 10 | @Inject 11 | public UserHelper() { 12 | } 13 | 14 | public User getCurrentUser() { 15 | return mCurrentUser; 16 | } 17 | 18 | public void setCurrentUser(User currentUser) { 19 | this.mCurrentUser = currentUser; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/security/UserSessionCallback.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.security; 2 | 3 | public interface UserSessionCallback { 4 | public void onLogin(); 5 | 6 | public void onLogout(); 7 | } 8 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/animation/LiveButton.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.animation; 2 | 3 | import android.annotation.TargetApi; 4 | import android.view.MotionEvent; 5 | import android.view.View; 6 | import android.view.animation.DecelerateInterpolator; 7 | import android.view.animation.OvershootInterpolator; 8 | import android.widget.Button; 9 | 10 | import javax.inject.Inject; 11 | import javax.inject.Singleton; 12 | 13 | @Singleton 14 | public class LiveButton { 15 | private DecelerateInterpolator decelerator = new DecelerateInterpolator(); 16 | private OvershootInterpolator overshooter = new OvershootInterpolator(10f); 17 | 18 | @Inject 19 | LiveButton() { 20 | } 21 | 22 | public void setupLiveAnimOnButton(Button button, final Runnable onEndRunnable) { 23 | if (android.os.Build.VERSION.SDK_INT >= 16) { 24 | this.setupLiveAnimOnButtonL16(button, onEndRunnable); 25 | } else { 26 | button.setOnClickListener(new View.OnClickListener() { 27 | @Override 28 | public void onClick(View v) { 29 | onEndRunnable.run(); 30 | ; 31 | } 32 | }); 33 | } 34 | } 35 | 36 | @TargetApi(16) 37 | public void setupLiveAnimOnButtonL16(final Button button, final Runnable onEndRunnable) { 38 | button.animate().setDuration(400); 39 | button.setOnTouchListener(new View.OnTouchListener() { 40 | @Override 41 | public boolean onTouch(View arg0, MotionEvent arg1) { 42 | if (arg1.getAction() == MotionEvent.ACTION_DOWN) { 43 | button.animate().setInterpolator(decelerator). 44 | scaleX(.7f).scaleY(.7f); 45 | } else if (arg1.getAction() == MotionEvent.ACTION_UP) { 46 | button.animate().setInterpolator(overshooter). 47 | scaleX(1.6f).scaleY(1.6f).withEndAction(onEndRunnable); 48 | } 49 | return false; 50 | } 51 | }); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/changelog/ChangeLogDialogFragment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.changelog; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | import android.webkit.WebView; 9 | 10 | import org.michenux.drodrolib.info.VersionUtils; 11 | 12 | public class ChangeLogDialogFragment extends DialogFragment { 13 | public static ChangeLogDialogFragment newInstance(int title, int closeLabel, String changeLog) { 14 | ChangeLogDialogFragment changelogDialog = new ChangeLogDialogFragment(); 15 | Bundle args = new Bundle(); 16 | args.putInt("title", title); 17 | args.putInt("closeLabel", closeLabel); 18 | args.putString("changeLog", changeLog); 19 | changelogDialog.setArguments(args); 20 | return changelogDialog; 21 | } 22 | 23 | @Override 24 | public Dialog onCreateDialog(Bundle savedInstanceState) { 25 | int resTitle = getArguments().getInt("title"); 26 | int closeLabel = getArguments().getInt("closeLabel"); 27 | String changeLog = getArguments().getString("changeLog"); 28 | 29 | String title = getString(resTitle, VersionUtils.getVersionName(this.getActivity())); 30 | 31 | final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 32 | builder.setTitle(title); 33 | this.setCancelable(true); 34 | 35 | final WebView webView = new WebView(this.getActivity()); 36 | webView.loadDataWithBaseURL(null, changeLog, "text/html", "utf-8", null); 37 | builder.setView(webView); 38 | builder.setNeutralButton(closeLabel, 39 | new DialogInterface.OnClickListener() { 40 | public void onClick(DialogInterface dialog, int which) { 41 | dialog.cancel(); 42 | } 43 | }); 44 | return builder.create(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/changelog/EulaChangeLogChainHelper.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.changelog; 2 | 3 | import android.support.annotation.StringRes; 4 | import android.support.annotation.XmlRes; 5 | import android.support.v4.app.FragmentActivity; 6 | 7 | import org.michenux.drodrolib.ui.eula.EulaHelper; 8 | 9 | public class EulaChangeLogChainHelper { 10 | public static void show(FragmentActivity fragmentActivity, 11 | @StringRes int resEulaTitle, 12 | @StringRes int resEulaAcceptLabel, 13 | @StringRes int resEulaRefuseLabel, 14 | @StringRes int resChangeLogTitle, 15 | @StringRes int resChangeLogClose, 16 | @XmlRes int resChangeLog) { 17 | //not shown = already accepted 18 | boolean shown = EulaHelper.showAcceptRefuse(fragmentActivity, resEulaTitle, resEulaAcceptLabel, resEulaRefuseLabel); 19 | 20 | ChangeLogHelper changeLogHelper = new ChangeLogHelper(); 21 | if (!shown) { 22 | changeLogHelper.showWhatsNew(resChangeLogTitle, resChangeLogClose, resChangeLog, fragmentActivity); 23 | } else { 24 | //We don't show the changelog at first run of the first install, but we have to save the current version 25 | //for the future upgrades 26 | changeLogHelper.saveCurrentVersion(fragmentActivity); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/fragment/FragmentHelper.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.fragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentTransaction; 6 | 7 | public class FragmentHelper { 8 | /** 9 | * @param frag 10 | * @param container 11 | * @param fm 12 | */ 13 | public static void initFragment(Fragment frag, int container, FragmentManager fm) { 14 | FragmentTransaction ft = fm.beginTransaction(); 15 | ft.add(container, frag); 16 | ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 17 | ft.commit(); 18 | } 19 | 20 | /** 21 | * @param frag 22 | * @param container 23 | * @param fm 24 | */ 25 | public static void initFragmentWithBackstack(Fragment frag, int container, FragmentManager fm) { 26 | FragmentTransaction ft = fm.beginTransaction(); 27 | ft.add(container, frag); 28 | ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 29 | ft.addToBackStack(null); 30 | ft.commit(); 31 | } 32 | 33 | /** 34 | * @param container1 35 | * @param container2 36 | * @param fm 37 | */ 38 | public static void swapFragment(int container1, int container2, FragmentManager fm) { 39 | Fragment f1 = fm.findFragmentById(container1); 40 | Fragment f2 = fm.findFragmentById(container2); 41 | 42 | FragmentTransaction ft = fm.beginTransaction(); 43 | ft.remove(f1); 44 | ft.remove(f2); 45 | ft.commit(); 46 | fm.executePendingTransactions(); 47 | 48 | ft = fm.beginTransaction(); 49 | ft.add(container1, f2); 50 | ft.add(container2, f1); 51 | ft.setTransition(FragmentTransaction.TRANSIT_NONE); 52 | 53 | ft.commit(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/fragment/MasterDetailFragments.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.fragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | public class MasterDetailFragments { 6 | public Fragment master; 7 | 8 | public Fragment detail; 9 | } 10 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/navdrawer/NavdrawerHeaderArrowView.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.navdrawer; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.ImageView; 6 | 7 | public class NavdrawerHeaderArrowView extends ImageView { 8 | private boolean mExpanded = false; 9 | private static final int[] EXPANDED_STATE = new int[]{android.R.attr.state_expanded}; 10 | 11 | public NavdrawerHeaderArrowView(Context context) { 12 | super(context); 13 | } 14 | 15 | public NavdrawerHeaderArrowView(Context context, AttributeSet attrs) { 16 | super(context, attrs); 17 | } 18 | 19 | @Override 20 | public int[] onCreateDrawableState(int extraSpace) { 21 | int[] state = super.onCreateDrawableState(extraSpace + 1); 22 | if (mExpanded) { 23 | mergeDrawableStates(state, EXPANDED_STATE); 24 | } 25 | return state; 26 | } 27 | 28 | public boolean switchExpandedState() { 29 | this.mExpanded = !mExpanded; 30 | refreshDrawableState(); 31 | return this.mExpanded; 32 | } 33 | 34 | public boolean isExpanded() { 35 | return mExpanded; 36 | } 37 | 38 | public void setExpanded(boolean expanded) { 39 | if (mExpanded != expanded) { 40 | switchExpandedState(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/ui/snackbar/SnackbarHelper.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.ui.snackbar; 2 | 3 | import android.graphics.Color; 4 | import android.support.annotation.StringRes; 5 | import android.support.design.widget.Snackbar; 6 | import android.view.View; 7 | import android.widget.TextView; 8 | 9 | public class SnackbarHelper { 10 | public static void showInfoLongMessage(View view, @StringRes int message) { 11 | Snackbar snackbar = Snackbar 12 | .make(view, message, Snackbar.LENGTH_LONG); 13 | View sbView = snackbar.getView(); 14 | TextView textView = (TextView) sbView.findViewById(org.michenux.drodrolib.R.id.snackbar_text); 15 | textView.setTextColor(Color.YELLOW); 16 | snackbar.show(); 17 | } 18 | 19 | public static void showErrorLongMessageWithAction(View view, @StringRes int message, @StringRes int actionMessage, 20 | View.OnClickListener actionOnClickListener) { 21 | Snackbar snackbar = Snackbar 22 | .make(view, message, Snackbar.LENGTH_LONG) 23 | .setAction(actionMessage, actionOnClickListener); 24 | snackbar.setActionTextColor(Color.RED); 25 | View sbView = snackbar.getView(); 26 | TextView textView = (TextView) sbView.findViewById(org.michenux.drodrolib.R.id.snackbar_text); 27 | textView.setTextColor(Color.YELLOW); 28 | snackbar.show(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/wordpress/json/WPAttachment.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.wordpress.json; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class WPAttachment { 6 | private int id; 7 | private String url; 8 | private String slug; 9 | private String title; 10 | private String description; 11 | private String caption; 12 | @SerializedName("mime_type") 13 | private String mimeType; 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | 23 | public String getUrl() { 24 | return url; 25 | } 26 | 27 | public void setUrl(String url) { 28 | this.url = url; 29 | } 30 | 31 | public String getSlug() { 32 | return slug; 33 | } 34 | 35 | public void setSlug(String slug) { 36 | this.slug = slug; 37 | } 38 | 39 | public String getTitle() { 40 | return title; 41 | } 42 | 43 | public void setTitle(String title) { 44 | this.title = title; 45 | } 46 | 47 | public String getDescription() { 48 | return description; 49 | } 50 | 51 | public void setDescription(String description) { 52 | this.description = description; 53 | } 54 | 55 | public String getCaption() { 56 | return caption; 57 | } 58 | 59 | public void setCaption(String caption) { 60 | this.caption = caption; 61 | } 62 | 63 | public String getMimeType() { 64 | return mimeType; 65 | } 66 | 67 | public void setMimeType(String mimeType) { 68 | this.mimeType = mimeType; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/wordpress/json/WPAuthor.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.wordpress.json; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class WPAuthor { 6 | private long id; 7 | private String slug; 8 | private String name; 9 | 10 | @SerializedName("first_name") 11 | private String firstName; 12 | @SerializedName("last_name") 13 | private String lastName; 14 | @SerializedName("nickname") 15 | private String nickName; 16 | private String url; 17 | private String description; 18 | 19 | public long getId() { 20 | return id; 21 | } 22 | 23 | public void setId(long id) { 24 | this.id = id; 25 | } 26 | 27 | public String getSlug() { 28 | return slug; 29 | } 30 | 31 | public void setSlug(String slug) { 32 | this.slug = slug; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public String getFirstName() { 44 | return firstName; 45 | } 46 | 47 | public void setFirstName(String firstName) { 48 | this.firstName = firstName; 49 | } 50 | 51 | public String getLastName() { 52 | return lastName; 53 | } 54 | 55 | public void setLastName(String lastName) { 56 | this.lastName = lastName; 57 | } 58 | 59 | public String getNickName() { 60 | return nickName; 61 | } 62 | 63 | public void setNickName(String nickName) { 64 | this.nickName = nickName; 65 | } 66 | 67 | public String getUrl() { 68 | return url; 69 | } 70 | 71 | public void setUrl(String url) { 72 | this.url = url; 73 | } 74 | 75 | public String getDescription() { 76 | return description; 77 | } 78 | 79 | public void setDescription(String description) { 80 | this.description = description; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/wordpress/json/WPCustomFields.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.wordpress.json; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.List; 6 | 7 | public class WPCustomFields { 8 | @SerializedName("android_desc") 9 | List description; 10 | 11 | public List getDescription() { 12 | return description; 13 | } 14 | 15 | public void setDescription(List description) { 16 | this.description = description; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/wordpress/json/WPJsonResponse.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.wordpress.json; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.List; 6 | 7 | public class WPJsonResponse { 8 | public static final String STATUS_OK = "ok"; 9 | 10 | private String status; 11 | private int count; 12 | @SerializedName("count_total") 13 | private int countTotal; 14 | private int pages; 15 | private List posts; 16 | 17 | public String getStatus() { 18 | return status; 19 | } 20 | 21 | public void setStatus(String status) { 22 | this.status = status; 23 | } 24 | 25 | public int getCount() { 26 | return count; 27 | } 28 | 29 | public void setCount(int count) { 30 | this.count = count; 31 | } 32 | 33 | public int getCountTotal() { 34 | return countTotal; 35 | } 36 | 37 | public void setCountTotal(int countTotal) { 38 | this.countTotal = countTotal; 39 | } 40 | 41 | public int getPages() { 42 | return pages; 43 | } 44 | 45 | public void setPages(int pages) { 46 | this.pages = pages; 47 | } 48 | 49 | public List getPosts() { 50 | return posts; 51 | } 52 | 53 | public void setPosts(List posts) { 54 | this.posts = posts; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/wordpress/json/WPThumbnailImage.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.wordpress.json; 2 | 3 | public class WPThumbnailImage { 4 | private String url; 5 | private String width; 6 | private String height; 7 | 8 | public String getUrl() { 9 | return url; 10 | } 11 | 12 | public void setUrl(String url) { 13 | this.url = url; 14 | } 15 | 16 | public String getWidth() { 17 | return width; 18 | } 19 | 20 | public void setWidth(String width) { 21 | this.width = width; 22 | } 23 | 24 | public String getHeight() { 25 | return height; 26 | } 27 | 28 | public void setHeight(String height) { 29 | this.height = height; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /drodrolib/src/main/java/org/michenux/drodrolib/wordpress/json/WPThumbnailImages.java: -------------------------------------------------------------------------------- 1 | package org.michenux.drodrolib.wordpress.json; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class WPThumbnailImages { 6 | private WPThumbnailImage full; 7 | private WPThumbnailImage thumbnail; 8 | private WPThumbnailImage medium; 9 | private WPThumbnailImage large; 10 | 11 | @SerializedName("foundation-featured-image") 12 | private WPThumbnailImage foundationFeaturedImage; 13 | 14 | public WPThumbnailImage getFull() { 15 | return full; 16 | } 17 | 18 | public void setFull(WPThumbnailImage full) { 19 | this.full = full; 20 | } 21 | 22 | public WPThumbnailImage getThumbnail() { 23 | return thumbnail; 24 | } 25 | 26 | public void setThumbnail(WPThumbnailImage thumbnail) { 27 | this.thumbnail = thumbnail; 28 | } 29 | 30 | public WPThumbnailImage getMedium() { 31 | return medium; 32 | } 33 | 34 | public void setMedium(WPThumbnailImage medium) { 35 | this.medium = medium; 36 | } 37 | 38 | public WPThumbnailImage getLarge() { 39 | return large; 40 | } 41 | 42 | public void setLarge(WPThumbnailImage large) { 43 | this.large = large; 44 | } 45 | 46 | public WPThumbnailImage getFoundationFeaturedImage() { 47 | return foundationFeaturedImage; 48 | } 49 | 50 | public void setFoundationFeaturedImage(WPThumbnailImage foundationFeaturedImage) { 51 | this.foundationFeaturedImage = foundationFeaturedImage; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable-v21/expander_group.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable-xhdpi-v21/expander_close_mtrl_alpha.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/drodrolib/src/main/res/drawable-xhdpi-v21/expander_close_mtrl_alpha.9.png -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable-xhdpi-v21/expander_open_mtrl_alpha.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/drodrolib/src/main/res/drawable-xhdpi-v21/expander_open_mtrl_alpha.9.png -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable-xhdpi/expander_close_holo_dark.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/drodrolib/src/main/res/drawable-xhdpi/expander_close_holo_dark.9.png -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable-xhdpi/expander_open_holo_dark.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/drodrolib/src/main/res/drawable-xhdpi/expander_open_holo_dark.9.png -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable-xhdpi/navdrawer_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/drodrolib/src/main/res/drawable-xhdpi/navdrawer_profile.png -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable/expander_group.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 8 | 9 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/drawable/preferences_listselector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/layout/login_googleplus.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/layout/preference_list_content.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /drodrolib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Yes 4 | No 5 | 6 | Open navigation drawer 7 | Close navigation drawer 8 | 9 | Close 10 | 11 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 15 | 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Michenux/YourAppIdea/7db2a73608c3237bcdaef37db5678fa9fbcd5d7e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 06 15:55:44 PST 2017 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-3.3-all.zip 7 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':drodrolib', ':YourAppIdea' 2 | --------------------------------------------------------------------------------