├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── Androiddz.iml ├── Dz-Android.iml ├── HardGameDz.iml ├── README.md ├── app ├── .gitignore ├── Source.zip ├── app-release.apk ├── app.iml ├── build.gradle ├── fabric.properties ├── libs │ └── Parse-1.10.2.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── squalala │ │ └── dz6android │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── squalala │ │ └── dz6android │ │ ├── ActivityModule.java │ │ ├── ActivityScope.java │ │ ├── App.java │ │ ├── AppComponent.java │ │ ├── AppModule.java │ │ ├── adapter │ │ └── PostAdapter.java │ │ ├── common │ │ ├── AppConstants.java │ │ └── BaseFragment.java │ │ ├── custom │ │ ├── EmptyRecyclerView.java │ │ ├── EndlessRecyclerOnScrollListener.java │ │ └── HackyViewPager.java │ │ ├── data │ │ ├── api │ │ │ ├── ApiModule.java │ │ │ └── PostService.java │ │ └── prefs │ │ │ └── Preferences.java │ │ ├── eventbus │ │ ├── PostActionEvent.java │ │ ├── PostEvent.java │ │ └── QueryEvent.java │ │ ├── greendao │ │ ├── Article.java │ │ ├── ArticleDao.java │ │ ├── Category.java │ │ ├── CategoryArticle.java │ │ ├── CategoryArticleDao.java │ │ ├── CategoryDao.java │ │ ├── DaoMaster.java │ │ └── DaoSession.java │ │ ├── holder │ │ └── PostViewHolder.java │ │ ├── model │ │ └── Post.java │ │ ├── receiver │ │ ├── BootReceiver.java │ │ └── CustomPushReceiver.java │ │ ├── service │ │ ├── NotificationService.java │ │ └── WidgetService.java │ │ ├── ui │ │ ├── activity │ │ │ ├── MainActivity.java │ │ │ ├── SettingActivity.java │ │ │ ├── ShowPostActivity.java │ │ │ ├── SplashActivity.java │ │ │ └── ViewPagerActivity.java │ │ ├── fragment │ │ │ ├── AboutFragment.java │ │ │ ├── CategoryFragment.java │ │ │ ├── FavorisFragment.java │ │ │ ├── SettingsFragment.java │ │ │ └── ShowPostFragment.java │ │ └── widget │ │ │ ├── ListProvider.java │ │ │ └── MyWidgetProvider.java │ │ └── utils │ │ ├── BitmapUtils.java │ │ ├── ConnectionDetector.java │ │ ├── DateUtils.java │ │ ├── HtmlUtils.java │ │ ├── IntentUtils.java │ │ ├── NoteAppReminder.java │ │ ├── NotificationUtils.java │ │ ├── ParseUtils.java │ │ ├── RxUtils.java │ │ └── UrlToSplit.java │ └── res │ ├── drawable-hdpi-v11 │ └── ic_stat_000.png │ ├── drawable-hdpi │ ├── ic_search_white_36dp.png │ ├── ic_share_white_24dp.png │ ├── ic_shop_black_24dp.png │ ├── ic_star_border_white_36dp.png │ ├── ic_star_white_36dp.png │ └── ic_stat_000.png │ ├── drawable-mdpi-v11 │ └── ic_stat_000.png │ ├── drawable-mdpi │ ├── ic_search_white_36dp.png │ ├── ic_share_white_24dp.png │ ├── ic_shop_black_24dp.png │ ├── ic_star_border_white_36dp.png │ ├── ic_star_white_36dp.png │ └── ic_stat_000.png │ ├── drawable-xhdpi-v11 │ └── ic_stat_000.png │ ├── drawable-xhdpi │ ├── ic_search_white_36dp.png │ ├── ic_share_white_24dp.png │ ├── ic_shop_black_24dp.png │ ├── ic_star_border_white_36dp.png │ ├── ic_star_white_36dp.png │ └── ic_stat_000.png │ ├── drawable-xxhdpi-v11 │ └── ic_stat_000.png │ ├── drawable-xxhdpi │ ├── ic_search_white_36dp.png │ ├── ic_share_white_24dp.png │ ├── ic_shop_black_24dp.png │ ├── ic_star_border_white_36dp.png │ ├── ic_star_white_36dp.png │ └── ic_stat_000.png │ ├── drawable-xxxhdpi-v11 │ └── ic_stat_000.png │ ├── drawable-xxxhdpi │ ├── ic_search_white_36dp.png │ ├── ic_share_white_24dp.png │ ├── ic_shop_black_24dp.png │ ├── ic_star_border_white_36dp.png │ ├── ic_star_white_36dp.png │ └── ic_stat_000.png │ ├── drawable │ ├── image10.png │ ├── logo.png │ └── myshape.xml │ ├── layout │ ├── activity_main.xml │ ├── activity_show_post.xml │ ├── activity_show_posts.xml │ ├── activity_view_pager_images.xml │ ├── app_bar.xml │ ├── article_item.xml │ ├── cell_cards.xml │ ├── fragment_about.xml │ ├── fragment_category.xml │ └── widget_layout.xml │ ├── menu │ ├── menu_main.xml │ └── menu_post.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ ├── values │ ├── arrays.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ ├── preferences.xml │ └── widget_info.xml ├── build.gradle ├── com └── squalala │ └── android_dz │ ├── Customer.java │ ├── CustomerDao.java │ ├── DaoMaster.java │ ├── DaoSession.java │ ├── Note.java │ ├── NoteDao.java │ ├── Order.java │ └── OrderDao.java ├── device-2015-11-18-182906.png ├── device-2015-11-18-182916.png ├── device-2015-11-18-183006.png ├── device-2015-11-18-183447.png ├── device-2015-12-15-151621.png ├── device-2015-12-15-151643.png ├── device-2015-12-15-151704.png ├── device-2015-12-15-152000.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib └── lib.iml ├── libgenerator ├── .gitignore ├── build.gradle ├── libgenerator.iml └── src │ └── main │ └── java │ └── com │ └── example │ └── Generator.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Dz-Android -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /Androiddz.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Dz-Android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /HardGameDz.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wordpress-Android 2 | App that use WP-JSON API to retrieve posts from Wordpress website 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/Source.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/Source.zip -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/app-release.apk -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { url 'https://maven.fabric.io/public' } 4 | } 5 | 6 | dependencies { 7 | classpath 'io.fabric.tools:gradle:1.+' 8 | } 9 | } 10 | apply plugin: 'com.android.application' 11 | apply plugin: 'io.fabric' 12 | apply plugin: 'com.neenbedankt.android-apt' 13 | apply plugin: 'com.jakewharton.hugo' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "22.0.1" 18 | 19 | defaultConfig { 20 | applicationId "com.squalala.dz6android" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 3 24 | versionName "1.0.2" 25 | multiDexEnabled true 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | } 32 | debug { 33 | debuggable true 34 | } 35 | } 36 | 37 | 38 | } 39 | 40 | repositories { 41 | maven { url 'https://maven.fabric.io/public' } 42 | maven { url "https://jitpack.io" } 43 | } 44 | 45 | dependencies { 46 | compile fileTree(include: ['*.jar'], dir: 'libs') 47 | compile 'com.nineoldandroids:library:2.4.0' 48 | compile 'com.daimajia.easing:library:1.0.1@aar' 49 | compile 'com.daimajia.androidanimations:library:1.1.3@aar' 50 | compile 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0' 51 | compile 'com.android.support:appcompat-v7:23.1.0' 52 | compile 'com.android.support:recyclerview-v7:23.1.0' 53 | compile 'com.android.support:cardview-v7:23.1.0' 54 | compile 'com.android.support:design:23.1.0' 55 | compile 'com.parse.bolts:bolts-android:1.+' 56 | compile 'de.greenrobot:greendao:2.0.0' 57 | compile 'cn.pedant.sweetalert:library:1.3' 58 | compile('com.mikepenz:materialdrawer:4.3.1@aar') { 59 | transitive = true 60 | } 61 | 62 | compile 'com.mikepenz:material-design-iconic-typeface:+@aar' 63 | compile 'com.mikepenz:google-material-typeface:1.2.0.1@aar' 64 | compile 'com.mikepenz:fontawesome-typeface:4.4.0.1@aar' 65 | compile 'io.reactivex:rxandroid:1.0.1' 66 | compile 'com.squareup.picasso:picasso:2.5.2' 67 | compile 'de.greenrobot:eventbus:2.4.0' 68 | compile 'com.android.support:multidex:1.0.1' 69 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' 70 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' 71 | compile 'com.victor:lib:1.0.1' 72 | compile 'com.squareup.retrofit:retrofit:1.9.0' 73 | compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' 74 | compile 'com.squareup.okhttp:okhttp:2.4.0' 75 | compile 'com.jakewharton:butterknife:7.0.1' 76 | compile 'com.google.dagger:dagger:2.0.1' 77 | apt 'com.google.dagger:dagger-compiler:2.0.1' 78 | provided 'org.glassfish:javax.annotation:10.0-b28' 79 | compile 'com.github.chrisbanes.photoview:library:1.2.3' 80 | compile 'com.google.android.gms:play-services-analytics:7.5.0' 81 | compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') { 82 | transitive = true; 83 | } 84 | compile 'org.jsoup:jsoup:1.8.3' 85 | } 86 | -------------------------------------------------------------------------------- /app/fabric.properties: -------------------------------------------------------------------------------- 1 | #Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. 2 | #Sun Aug 23 18:10:32 CET 2015 3 | apiSecret=5051399a51f2110d87b3b848f50daf080034fe132ec84199c9dbd2780257c3e4 4 | -------------------------------------------------------------------------------- /app/libs/Parse-1.10.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/libs/Parse-1.10.2.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/brio/Documents/Programmation/adt-bundle-linux-x86_64-20130522/sdk/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/squalala/dz6android/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 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 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 22 | 23 | 24 | 25 | 34 | 35 | 36 | 39 | 40 | 41 | 44 | 45 | 47 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 59 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 72 | 73 | 74 | 75 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 90 | 91 | 94 | 95 | 96 | 97 | 100 | 101 | 102 | 105 | 106 | 109 | 110 | 111 | 112 | 113 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 137 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 150 | 151 | 152 | 153 | 154 | 157 | 158 | 159 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ActivityModule.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.app.Activity; 4 | 5 | import dagger.Module; 6 | import dagger.Provides; 7 | 8 | /** 9 | * This module represents objects which exist only for the scope of a single activity. We can 10 | * safely create singletons using the activity instance because the entire object graph will only 11 | * ever exist inside of that activity. 12 | */ 13 | @Module 14 | public class ActivityModule { 15 | 16 | private Activity activity; 17 | 18 | public ActivityModule(Activity activity) { 19 | this.activity = activity; 20 | } 21 | 22 | @Provides 23 | Activity provideActivity() { 24 | return activity; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ActivityScope.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | import javax.inject.Scope; 7 | 8 | @Scope 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ActivityScope { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/App.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.content.Context; 4 | import android.support.multidex.MultiDex; 5 | import android.support.multidex.MultiDexApplication; 6 | 7 | import com.crashlytics.android.Crashlytics; 8 | import com.google.android.gms.analytics.GoogleAnalytics; 9 | import com.google.android.gms.analytics.Tracker; 10 | import com.squalala.dz6android.utils.ParseUtils; 11 | import com.squareup.leakcanary.LeakCanary; 12 | 13 | import hugo.weaving.DebugLog; 14 | import io.fabric.sdk.android.Fabric; 15 | 16 | public class App extends MultiDexApplication { 17 | 18 | private AppComponent component; 19 | 20 | public static GoogleAnalytics analytics; 21 | public static Tracker tracker; 22 | 23 | 24 | @DebugLog 25 | @Override public void onCreate() { 26 | super.onCreate(); 27 | 28 | setupGraph(); 29 | 30 | setupAnalytics(); 31 | 32 | Fabric.with(this, new Crashlytics()); 33 | 34 | LeakCanary.install(this); 35 | 36 | ParseUtils.registerParse(this); 37 | } 38 | 39 | 40 | private void setupAnalytics() { 41 | analytics = GoogleAnalytics.getInstance(this); 42 | 43 | tracker = analytics.newTracker(getString(R.string.id_google_analytics)); 44 | 45 | // Cela permet de pouvoir récupérer les erreurs 46 | tracker.enableExceptionReporting(true); 47 | 48 | /** 49 | * Pouvoir récupérer des données démographiques et leurs centre d'intêrets 50 | */ 51 | tracker.enableAdvertisingIdCollection(true); 52 | 53 | tracker.enableAutoActivityTracking(true); 54 | } 55 | 56 | @Override 57 | protected void attachBaseContext(Context base) { 58 | super.attachBaseContext(base); 59 | MultiDex.install(this); 60 | } 61 | 62 | public static App get(Context context) { 63 | return (App) context.getApplicationContext(); 64 | } 65 | 66 | public AppComponent component() { 67 | return component; 68 | } 69 | 70 | private void setupGraph() { 71 | component = DaggerAppComponent.builder() 72 | .appModule(new AppModule(this)) 73 | .build(); 74 | component.inject(this); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/AppComponent.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.squalala.dz6android.common.BaseFragment; 7 | import com.squalala.dz6android.data.api.ApiModule; 8 | import com.squalala.dz6android.data.prefs.Preferences; 9 | import com.squalala.dz6android.greendao.ArticleDao; 10 | import com.squalala.dz6android.service.NotificationService; 11 | import com.squalala.dz6android.ui.activity.ShowPostActivity; 12 | import com.squalala.dz6android.ui.widget.ListProvider; 13 | 14 | import javax.inject.Singleton; 15 | 16 | import dagger.Component; 17 | 18 | 19 | /** 20 | * Created by Back Packer 21 | * Date : 30/04/15 22 | */ 23 | @Singleton 24 | @Component( 25 | modules = { 26 | AppModule.class, 27 | ApiModule.class 28 | } 29 | ) 30 | public interface AppComponent { 31 | 32 | void inject(App app); 33 | void inject(ShowPostActivity activity); 34 | void inject(BaseFragment fragment); 35 | void inject(NotificationService service); 36 | void inject(ListProvider listProvider); 37 | 38 | Application getApplication(); 39 | 40 | Context getContext(); 41 | 42 | Preferences getPreferences(); 43 | 44 | ArticleDao getArticleDao(); 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/AppModule.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.database.sqlite.SQLiteDatabase; 6 | 7 | import com.squalala.dz6android.common.AppConstants; 8 | import com.squalala.dz6android.data.prefs.Preferences; 9 | import com.squalala.dz6android.greendao.ArticleDao; 10 | import com.squalala.dz6android.greendao.CategoryArticleDao; 11 | import com.squalala.dz6android.greendao.CategoryDao; 12 | import com.squalala.dz6android.greendao.DaoMaster; 13 | import com.squalala.dz6android.greendao.DaoSession; 14 | 15 | import javax.inject.Singleton; 16 | 17 | import dagger.Module; 18 | import dagger.Provides; 19 | 20 | @Module 21 | public class AppModule { 22 | 23 | private App app; 24 | private DaoSession daoSession; 25 | 26 | public AppModule(App app) { 27 | this.app = app; 28 | 29 | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(app, AppConstants.DB_NAME, null); 30 | SQLiteDatabase db = helper.getWritableDatabase(); 31 | DaoMaster daoMaster = new DaoMaster(db); 32 | daoSession = daoMaster.newSession(); 33 | } 34 | 35 | @Provides 36 | @Singleton 37 | public ArticleDao provideArticleDao() { 38 | return daoSession.getArticleDao(); 39 | } 40 | 41 | @Provides 42 | @Singleton 43 | public CategoryDao provideCategoryDao() { 44 | return daoSession.getCategoryDao(); 45 | } 46 | 47 | @Provides 48 | @Singleton 49 | public CategoryArticleDao provideCategoryArticleDao() { 50 | return daoSession.getCategoryArticleDao(); 51 | } 52 | 53 | @Provides 54 | @Singleton 55 | public Application provideApplication() { 56 | return app; 57 | } 58 | 59 | @Provides 60 | @Singleton 61 | public Context provideContext() { 62 | return app.getApplicationContext(); 63 | } 64 | 65 | @Provides 66 | @Singleton 67 | public Preferences providePreferences() { 68 | return new Preferences(app.getApplicationContext()); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/adapter/PostAdapter.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.util.Log; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.squalala.dz6android.R; 10 | import com.squalala.dz6android.greendao.Article; 11 | import com.squalala.dz6android.holder.PostViewHolder; 12 | 13 | import java.util.List; 14 | 15 | import hugo.weaving.DebugLog; 16 | 17 | /** 18 | * Created by Back Packer 19 | * Date : 22/08/15 20 | */ 21 | public class PostAdapter extends RecyclerView.Adapter { 22 | 23 | private List
posts; 24 | 25 | 26 | private static final String TAG = PostAdapter.class.getSimpleName(); 27 | 28 | @DebugLog 29 | public PostAdapter(List
posts) { 30 | this.posts = posts; 31 | } 32 | 33 | @Override 34 | public PostViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 35 | 36 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_cards, parent,false); 37 | 38 | return new PostViewHolder(view); 39 | } 40 | 41 | @DebugLog 42 | @Override 43 | public void onBindViewHolder(PostViewHolder holder, int position) { 44 | Article post = posts.get(position); 45 | holder.bind(post); 46 | } 47 | 48 | @Override 49 | public int getItemCount() { 50 | return posts.size(); 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/common/AppConstants.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.common; 2 | 3 | /** 4 | * Created by Back Packer 5 | * Date : 23/08/15 6 | */ 7 | public class AppConstants { 8 | 9 | private AppConstants() {} 10 | 11 | public final static String API_URL = "http://www.dz-android.com/wp-json"; 12 | 13 | public final static int TIME_FETCH = 1000 * 60 * 10; // 10 minutes 14 | 15 | public final static int LIMIT_NUMBER_ARTICLES = 10; 16 | 17 | public final static int DEFAULT_PAGE = 1; 18 | 19 | public static final String DB_NAME= "dzandroid-db"; 20 | 21 | public static final String PARSE_CHANNEL = "dzandroid-dz"; 22 | 23 | public static final String PARSE_APPLICATION_ID = "8mpRgr9T1TDouF2FcGTdNnepXADtwXDAYHEHENkp"; 24 | 25 | public static final String PARSE_CLIENT_KEY = "Ts2zaGF54HQIPUp56MP2lfo9FMCOLTh1tlpXgmIk"; 26 | 27 | public static final int NOTIFICATION_ID = 100; 28 | 29 | public static final String PATH_LOGO = "M 407.07,149.00\n" + 30 | " C 469.09,217.35 474.52,319.91 423.48,396.00\n" + 31 | " 397.57,434.63 353.35,466.03 308.00,477.10\n" + 32 | " 287.73,482.05 271.68,483.03 251.00,483.00\n" + 33 | " 234.44,482.97 214.85,479.48 199.00,474.72\n" + 34 | " 139.65,456.89 92.52,412.69 70.19,355.00\n" + 35 | " 64.59,340.54 59.65,322.46 58.04,307.00\n" + 36 | " 58.04,307.00 58.04,298.00 58.04,298.00\n" + 37 | " 58.04,298.00 57.00,288.00 57.00,288.00\n" + 38 | " 56.72,263.89 59.73,239.86 67.69,217.00\n" + 39 | " 77.18,189.80 95.16,160.00 116.01,140.09\n" + 40 | " 123.80,132.65 132.27,125.73 141.00,119.42\n" + 41 | " 142.98,117.99 152.42,111.92 153.18,110.61\n" + 42 | " 155.08,107.32 148.11,98.92 146.17,96.00\n" + 43 | " 146.17,96.00 120.33,57.00 120.33,57.00\n" + 44 | " 117.10,52.15 111.92,46.04 115.85,40.11\n" + 45 | " 116.86,38.60 118.28,37.37 120.02,36.78\n" + 46 | " 127.52,34.25 133.00,45.00 136.22,50.00\n" + 47 | " 136.22,50.00 170.00,102.00 170.00,102.00\n" + 48 | " 216.02,82.48 255.90,76.46 305.00,88.12\n" + 49 | " 318.18,91.24 334.23,96.33 346.00,103.00\n" + 50 | " 348.10,97.59 355.47,87.30 359.00,82.00\n" + 51 | " 359.00,82.00 382.00,47.00 382.00,47.00\n" + 52 | " 385.64,41.49 392.33,31.09 399.57,39.23\n" + 53 | " 405.52,45.91 397.78,54.33 394.00,60.00\n" + 54 | " 394.00,60.00 370.83,95.00 370.83,95.00\n" + 55 | " 370.83,95.00 360.00,111.00 360.00,111.00\n" + 56 | " 376.21,118.03 395.25,135.97 407.07,149.00 Z\n" + 57 | " M 405.55,249.00\n" + 58 | " C 405.55,249.00 400.92,233.00 400.92,233.00\n" + 59 | " 393.76,212.12 381.94,193.13 366.91,177.00\n" + 60 | " 346.06,154.62 313.26,137.31 283.00,132.44\n" + 61 | " 270.30,130.39 256.87,130.85 244.00,131.00\n" + 62 | " 210.36,131.40 171.39,151.64 148.01,175.01\n" + 63 | " 133.95,189.08 120.36,210.24 113.54,229.00\n" + 64 | " 113.54,229.00 105.00,262.00 105.00,262.00\n" + 65 | " 105.00,262.00 408.00,262.00 408.00,262.00\n" + 66 | " 408.00,262.00 405.55,249.00 405.55,249.00 Z\n" + 67 | " M 205.98,198.51\n" + 68 | " C 219.37,208.20 211.30,227.05 196.00,226.92\n" + 69 | " 181.46,226.80 174.51,207.90 187.02,198.43\n" + 70 | " 190.04,196.14 192.39,195.98 196.00,195.72\n" + 71 | " 199.77,195.88 202.80,196.21 205.98,198.51 Z\n" + 72 | " M 330.61,200.21\n" + 73 | " C 339.54,209.92 333.32,226.10 320.00,226.89\n" + 74 | " 307.61,227.63 298.30,213.95 305.01,203.02\n" + 75 | " 308.14,197.90 312.38,196.36 318.00,195.61\n" + 76 | " 322.79,195.66 327.20,196.51 330.61,200.21 Z\n" + 77 | " M 109.00,334.00\n" + 78 | " C 110.12,341.17 114.06,348.66 117.54,355.00\n" + 79 | " 127.05,372.33 138.79,386.43 154.00,399.08\n" + 80 | " 197.42,435.19 260.19,446.51 313.00,425.55\n" + 81 | " 333.66,417.35 350.36,405.71 366.00,390.00\n" + 82 | " 378.27,377.67 396.88,351.26 400.00,334.00\n" + 83 | " 400.00,334.00 109.00,334.00 109.00,334.00 Z"; 84 | 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/common/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.common; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | 7 | import com.squalala.dz6android.App; 8 | import com.squalala.dz6android.data.api.PostService; 9 | import com.squalala.dz6android.data.prefs.Preferences; 10 | import com.squalala.dz6android.greendao.ArticleDao; 11 | import com.squalala.dz6android.greendao.CategoryArticleDao; 12 | import com.squalala.dz6android.greendao.CategoryDao; 13 | import com.squalala.dz6android.utils.ParseUtils; 14 | import com.squalala.dz6android.utils.RxUtils; 15 | 16 | import javax.inject.Inject; 17 | 18 | import hugo.weaving.DebugLog; 19 | import rx.subscriptions.CompositeSubscription; 20 | 21 | /** 22 | * Created by Back Packer 23 | * Date : 23/08/15 24 | */ 25 | public abstract class BaseFragment extends Fragment { 26 | 27 | protected CompositeSubscription _subscriptions = new CompositeSubscription(); 28 | 29 | @Inject 30 | protected PostService postService; 31 | 32 | @Inject 33 | protected Preferences preferences; 34 | 35 | @Inject 36 | protected ArticleDao articleDao; 37 | 38 | @Inject 39 | protected CategoryDao categoryDao; 40 | 41 | @Inject 42 | protected CategoryArticleDao categoryArticleDao; 43 | 44 | @DebugLog 45 | @Override 46 | public void onCreate(@Nullable Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | App.get(getActivity()).component().inject(this); 49 | 50 | 51 | if (!preferences.isLoggedIn()) { 52 | String email = ParseUtils.getEmail(getContext()); 53 | 54 | preferences.setEmail(email); 55 | 56 | ParseUtils.subscribeWithEmail(email); 57 | } 58 | 59 | } 60 | 61 | @Override 62 | public void onPause() { 63 | super.onPause(); 64 | RxUtils.unsubscribeIfNotNull(_subscriptions); 65 | } 66 | 67 | @Override 68 | public void onResume() { 69 | super.onResume(); 70 | _subscriptions = RxUtils.getNewCompositeSubIfUnsubscribed(_subscriptions); 71 | } 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/custom/EmptyRecyclerView.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.custom; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | 8 | /** 9 | * Created by Back Packer 10 | * Date : 05/10/15 11 | */ 12 | public class EmptyRecyclerView extends RecyclerView { 13 | private View emptyView; 14 | final private AdapterDataObserver observer = new AdapterDataObserver() { 15 | @Override 16 | public void onChanged() { 17 | checkIfEmpty(); 18 | } 19 | 20 | @Override 21 | public void onItemRangeInserted(int positionStart, int itemCount) { 22 | checkIfEmpty(); 23 | } 24 | 25 | @Override 26 | public void onItemRangeRemoved(int positionStart, int itemCount) { 27 | checkIfEmpty(); 28 | } 29 | }; 30 | 31 | public EmptyRecyclerView(Context context) { 32 | super(context); 33 | } 34 | 35 | public EmptyRecyclerView(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | } 38 | 39 | public EmptyRecyclerView(Context context, AttributeSet attrs, int defStyle) { 40 | super(context, attrs, defStyle); 41 | } 42 | 43 | void checkIfEmpty() { 44 | if (emptyView != null && getAdapter() != null) { 45 | final boolean emptyViewVisible = getAdapter().getItemCount() == 0; 46 | emptyView.setVisibility(emptyViewVisible ? VISIBLE : GONE); 47 | setVisibility(emptyViewVisible ? GONE : VISIBLE); 48 | } 49 | } 50 | 51 | @Override 52 | public void setAdapter(Adapter adapter) { 53 | final Adapter oldAdapter = getAdapter(); 54 | if (oldAdapter != null) { 55 | oldAdapter.unregisterAdapterDataObserver(observer); 56 | } 57 | super.setAdapter(adapter); 58 | if (adapter != null) { 59 | adapter.registerAdapterDataObserver(observer); 60 | } 61 | 62 | // checkIfEmpty(); 63 | } 64 | 65 | public void setEmptyView(View emptyView) { 66 | this.emptyView = emptyView; 67 | //checkIfEmpty(); 68 | } 69 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/custom/EndlessRecyclerOnScrollListener.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.custom; 2 | 3 | import android.support.v7.widget.LinearLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | 6 | /** 7 | * Created by Back Packer 8 | * Date : 27/08/15 9 | */ 10 | public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { 11 | public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName(); 12 | 13 | 14 | private int previousTotal = 0; // The total number of items in the dataset after the last load 15 | private boolean loading = true; // True if we are still waiting for the last set of data to load. 16 | private int visibleThreshold = 10; // The minimum amount of items to have below your current scroll position before loading more. 17 | int firstVisibleItem, visibleItemCount, totalItemCount; 18 | 19 | 20 | private int current_page = 1; 21 | 22 | 23 | private LinearLayoutManager mLinearLayoutManager; 24 | 25 | 26 | public EndlessRecyclerOnScrollListener(LinearLayoutManager linearLayoutManager) { 27 | this.mLinearLayoutManager = linearLayoutManager; 28 | } 29 | 30 | 31 | @Override 32 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 33 | super.onScrolled(recyclerView, dx, dy); 34 | 35 | 36 | visibleItemCount = recyclerView.getChildCount(); 37 | totalItemCount = mLinearLayoutManager.getItemCount(); 38 | firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition(); 39 | 40 | 41 | if (loading) { 42 | if (totalItemCount > previousTotal) { 43 | loading = false; 44 | previousTotal = totalItemCount; 45 | } 46 | } 47 | if (!loading && (totalItemCount - visibleItemCount) 48 | <= (firstVisibleItem + visibleThreshold)) { 49 | // End has been reached 50 | 51 | 52 | // Do something 53 | current_page++; 54 | 55 | 56 | onLoadMore(current_page); 57 | 58 | 59 | loading = true; 60 | } 61 | } 62 | 63 | 64 | public abstract void onLoadMore(int current_page); 65 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/custom/HackyViewPager.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.custom; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | /** 9 | * Created by Back Packer 10 | * Date : 25/04/15 11 | */ 12 | public class HackyViewPager extends ViewPager { 13 | 14 | 15 | private boolean isLocked; 16 | 17 | public HackyViewPager(Context context) { 18 | super(context); 19 | isLocked = false; 20 | } 21 | 22 | 23 | public HackyViewPager(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | isLocked = false; 26 | } 27 | 28 | 29 | @Override 30 | public boolean onInterceptTouchEvent(MotionEvent ev) { 31 | if (!isLocked) { 32 | try { 33 | return super.onInterceptTouchEvent(ev); 34 | } catch (IllegalArgumentException e) { 35 | e.printStackTrace(); 36 | return false; 37 | } 38 | } 39 | return false; 40 | } 41 | 42 | 43 | @Override 44 | public boolean onTouchEvent(MotionEvent event) { 45 | if (!isLocked) { 46 | return super.onTouchEvent(event); 47 | } 48 | return false; 49 | } 50 | 51 | public void toggleLock() { 52 | isLocked = !isLocked; 53 | } 54 | 55 | 56 | public void setLocked(boolean isLocked) { 57 | this.isLocked = isLocked; 58 | } 59 | 60 | 61 | public boolean isLocked() { 62 | return isLocked; 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/data/api/ApiModule.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.data.api; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.squalala.dz6android.common.AppConstants; 7 | import com.squalala.dz6android.utils.ConnectionDetector; 8 | import com.squareup.okhttp.Cache; 9 | import com.squareup.okhttp.OkHttpClient; 10 | 11 | import java.io.File; 12 | import java.util.concurrent.TimeUnit; 13 | 14 | import javax.inject.Singleton; 15 | 16 | import dagger.Module; 17 | import dagger.Provides; 18 | import hugo.weaving.DebugLog; 19 | import retrofit.Endpoint; 20 | import retrofit.Endpoints; 21 | import retrofit.RequestInterceptor; 22 | import retrofit.RestAdapter; 23 | import retrofit.client.OkClient; 24 | 25 | /** 26 | * Auteur : Fayçal Kaddouri 27 | * Nom du fichier : ApiModule.java 28 | * Date : 21 juin 2014 29 | * 30 | */ 31 | @Module 32 | public final class ApiModule { 33 | 34 | private static final String TAG = ApiModule.class.getSimpleName(); 35 | 36 | @Provides 37 | @Singleton Endpoint provideEndpoint() { 38 | return Endpoints.newFixedEndpoint(AppConstants.API_URL); 39 | } 40 | 41 | @Provides 42 | @Singleton 43 | RestAdapter provideRestAdapter(Endpoint endpoint, final Application app) { 44 | 45 | int cacheSize = 10 * 1024 * 1024; // 10 MiB 46 | File cacheDirectory = new File(app.getCacheDir().getAbsolutePath(), "HttpCache"); 47 | 48 | Cache cache = new Cache(cacheDirectory, cacheSize); 49 | 50 | OkHttpClient client = new OkHttpClient(); 51 | 52 | client.setCache(cache); 53 | client.setConnectTimeout(5, TimeUnit.MINUTES); 54 | client.setReadTimeout(5, TimeUnit.MINUTES); 55 | // client.setReadTimeout(60, TimeUnit.SECONDS); // socket timeout 56 | 57 | return new RestAdapter.Builder() 58 | .setLogLevel(RestAdapter.LogLevel.BASIC) 59 | .setEndpoint(endpoint) 60 | .setRequestInterceptor(new RequestInterceptor() { 61 | @Override 62 | public void intercept(RequestFacade request) { 63 | 64 | request.addHeader("Accept", "application/json;versions=1"); 65 | 66 | if (ConnectionDetector.isConnectingToInternet(app)) { 67 | Log.e(TAG, "Pas de cache"); 68 | int maxAge = 60; // read from cache for 1 minute 69 | request.addHeader("Cache-Control", "public, max-age=" + maxAge); 70 | } 71 | else { 72 | Log.e(TAG, "Utilisation du cache"); 73 | int maxStale = 60 * 60 * 24 * 28; // tolerate 4-weeks stale 74 | request.addHeader("Cache-Control", 75 | "public, only-if-cached, max-stale=" + maxStale); 76 | } 77 | } 78 | }) 79 | .setClient(new OkClient(client)) 80 | .build(); 81 | } 82 | 83 | @DebugLog 84 | @Provides 85 | @Singleton 86 | PostService providePostService(RestAdapter restAdapter) { 87 | return restAdapter.create(PostService.class); 88 | } 89 | 90 | 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/data/api/PostService.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.data.api; 2 | 3 | 4 | import com.squalala.dz6android.common.AppConstants; 5 | import com.squalala.dz6android.model.Post; 6 | 7 | import java.util.List; 8 | 9 | import retrofit.http.GET; 10 | import retrofit.http.Query; 11 | import rx.Observable; 12 | 13 | /** 14 | * Created by Back Packer 15 | * Date : 22/08/15 16 | */ 17 | public interface PostService { 18 | 19 | @GET("/posts?filter[posts_per_page]=" + AppConstants.LIMIT_NUMBER_ARTICLES) 20 | Observable> getPosts(@Query("page") int page, 21 | @Query("filter[category_name]") String category, 22 | @Query("filter[s]") String keyWord); 23 | 24 | 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/data/prefs/Preferences.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.data.prefs; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.preference.PreferenceManager; 6 | 7 | import com.squalala.dz6android.utils.DateUtils; 8 | 9 | import java.util.Date; 10 | 11 | import hugo.weaving.DebugLog; 12 | 13 | /** 14 | * Created by Back Packer 15 | * Date : 29/09/15 16 | */ 17 | public class Preferences { 18 | 19 | private SharedPreferences preferences; 20 | 21 | private static final String KEY_DATE = "date"; 22 | private static final String KEY_EMAIL = "email"; 23 | private static final String KEY_HIDE_READ_POST = "hide_read_post"; 24 | private static final String KEY_SPLASH = "splash"; 25 | 26 | public Preferences(Context context) { 27 | preferences = PreferenceManager.getDefaultSharedPreferences(context); 28 | } 29 | 30 | public void setLastDatePost(String date) { 31 | preferences.edit().putString(KEY_DATE, date).commit(); 32 | } 33 | 34 | @DebugLog 35 | public void setEmail(String email) { 36 | preferences.edit().putString(KEY_EMAIL, email).commit(); 37 | } 38 | 39 | public boolean isLoggedIn() { 40 | 41 | String email = preferences.getString(KEY_EMAIL, null); 42 | 43 | return !(email == null); 44 | } 45 | 46 | public void setSpashScreen(boolean value) { 47 | preferences.edit().putBoolean(KEY_SPLASH, value).commit(); 48 | } 49 | 50 | public boolean isSplashScreenViewed() { 51 | return preferences.getBoolean(KEY_SPLASH, false); 52 | } 53 | 54 | public void setHideReadPost(boolean value) { 55 | preferences.edit().putBoolean(KEY_HIDE_READ_POST, value).commit(); 56 | } 57 | 58 | public void incrementValue() { 59 | preferences.edit().putInt("note_app", getNoteAppValue() + 1).commit(); 60 | } 61 | 62 | public void setValueNoteApp(int value) { 63 | preferences.edit().putInt("note_app", value).commit(); 64 | } 65 | 66 | public int getNoteAppValue() { 67 | return preferences.getInt("note_app", 0); 68 | } 69 | 70 | public boolean isHideReadPost() { 71 | return preferences.getBoolean(KEY_HIDE_READ_POST, false); 72 | } 73 | 74 | public boolean isNotification() { 75 | return preferences.getBoolean("notification", true); 76 | } 77 | 78 | public boolean isLedFlash() { 79 | return preferences.getBoolean("led", true); 80 | } 81 | 82 | public boolean isVibreur() { 83 | return preferences.getBoolean("vibreur", true); 84 | } 85 | 86 | public boolean isSound() { 87 | return preferences.getBoolean("sound", true); 88 | } 89 | 90 | public Date getDate() { 91 | String dateStr = preferences.getString(KEY_DATE, null); 92 | 93 | if (dateStr == null) 94 | return null; 95 | 96 | return DateUtils.strToDate(dateStr); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/eventbus/PostActionEvent.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.eventbus; 2 | 3 | /** 4 | * Created by Back Packer 5 | * Date : 04/10/15 6 | */ 7 | public class PostActionEvent { 8 | 9 | public ActionType actionType; 10 | 11 | public PostActionEvent(ActionType actionType) { 12 | this.actionType = actionType; 13 | } 14 | 15 | public ActionType getActionType() { 16 | return actionType; 17 | } 18 | 19 | public enum ActionType { 20 | HIDE_READ_ARTICLES, 21 | SET_ALL_POST_READ, 22 | DELETE_ALL_READ_POST, 23 | DELETE_ALL 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/eventbus/PostEvent.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.eventbus; 2 | 3 | import com.squalala.dz6android.greendao.Article; 4 | 5 | /** 6 | * Created by Back Packer 7 | * Date : 04/10/15 8 | */ 9 | public class PostEvent { 10 | 11 | private Article article; 12 | 13 | public PostEvent(Article article) { 14 | this.article = article; 15 | } 16 | 17 | public Article getArticle() { 18 | return article; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/eventbus/QueryEvent.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.eventbus; 2 | 3 | /** 4 | * Created by Back Packer 5 | * Date : 29/09/15 6 | */ 7 | public class QueryEvent { 8 | String query; 9 | 10 | public QueryEvent(String query) { 11 | this.query = query; 12 | } 13 | 14 | public String getQuery() { 15 | return query; 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/greendao/Article.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.greendao; 2 | 3 | import java.util.List; 4 | import com.squalala.dz6android.greendao.DaoSession; 5 | import de.greenrobot.dao.DaoException; 6 | 7 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 8 | /** 9 | * Entity mapped to table "ARTICLE". 10 | */ 11 | public class Article { 12 | 13 | private Long id; 14 | /** Not-null value. */ 15 | private String title; 16 | /** Not-null value. */ 17 | private String content; 18 | private String urlImage; 19 | private String link; 20 | private String author; 21 | private Boolean status; 22 | private Boolean deleted; 23 | private Boolean favoris; 24 | private java.util.Date date; 25 | 26 | /** Used to resolve relations */ 27 | private transient DaoSession daoSession; 28 | 29 | /** Used for active entity operations. */ 30 | private transient ArticleDao myDao; 31 | 32 | private List articles; 33 | 34 | public Article() { 35 | } 36 | 37 | public Article(Long id) { 38 | this.id = id; 39 | } 40 | 41 | public Article(Long id, String title, String content, String urlImage, String link, String author, Boolean status, Boolean deleted, Boolean favoris, java.util.Date date) { 42 | this.id = id; 43 | this.title = title; 44 | this.content = content; 45 | this.urlImage = urlImage; 46 | this.link = link; 47 | this.author = author; 48 | this.status = status; 49 | this.deleted = deleted; 50 | this.favoris = favoris; 51 | this.date = date; 52 | } 53 | 54 | /** called by internal mechanisms, do not call yourself. */ 55 | public void __setDaoSession(DaoSession daoSession) { 56 | this.daoSession = daoSession; 57 | myDao = daoSession != null ? daoSession.getArticleDao() : null; 58 | } 59 | 60 | public Long getId() { 61 | return id; 62 | } 63 | 64 | public void setId(Long id) { 65 | this.id = id; 66 | } 67 | 68 | /** Not-null value. */ 69 | public String getTitle() { 70 | return title; 71 | } 72 | 73 | /** Not-null value; ensure this value is available before it is saved to the database. */ 74 | public void setTitle(String title) { 75 | this.title = title; 76 | } 77 | 78 | /** Not-null value. */ 79 | public String getContent() { 80 | return content; 81 | } 82 | 83 | /** Not-null value; ensure this value is available before it is saved to the database. */ 84 | public void setContent(String content) { 85 | this.content = content; 86 | } 87 | 88 | public String getUrlImage() { 89 | return urlImage; 90 | } 91 | 92 | public void setUrlImage(String urlImage) { 93 | this.urlImage = urlImage; 94 | } 95 | 96 | public String getLink() { 97 | return link; 98 | } 99 | 100 | public void setLink(String link) { 101 | this.link = link; 102 | } 103 | 104 | public String getAuthor() { 105 | return author; 106 | } 107 | 108 | public void setAuthor(String author) { 109 | this.author = author; 110 | } 111 | 112 | public Boolean getStatus() { 113 | return status; 114 | } 115 | 116 | public void setStatus(Boolean status) { 117 | this.status = status; 118 | } 119 | 120 | public Boolean getDeleted() { 121 | return deleted; 122 | } 123 | 124 | public void setDeleted(Boolean deleted) { 125 | this.deleted = deleted; 126 | } 127 | 128 | public Boolean getFavoris() { 129 | return favoris; 130 | } 131 | 132 | public void setFavoris(Boolean favoris) { 133 | this.favoris = favoris; 134 | } 135 | 136 | public java.util.Date getDate() { 137 | return date; 138 | } 139 | 140 | public void setDate(java.util.Date date) { 141 | this.date = date; 142 | } 143 | 144 | /** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */ 145 | public List getArticles() { 146 | if (articles == null) { 147 | if (daoSession == null) { 148 | throw new DaoException("Entity is detached from DAO context"); 149 | } 150 | CategoryArticleDao targetDao = daoSession.getCategoryArticleDao(); 151 | List articlesNew = targetDao._queryArticle_Articles(id); 152 | synchronized (this) { 153 | if(articles == null) { 154 | articles = articlesNew; 155 | } 156 | } 157 | } 158 | return articles; 159 | } 160 | 161 | /** Resets a to-many relationship, making the next get call to query for a fresh result. */ 162 | public synchronized void resetArticles() { 163 | articles = null; 164 | } 165 | 166 | /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */ 167 | public void delete() { 168 | if (myDao == null) { 169 | throw new DaoException("Entity is detached from DAO context"); 170 | } 171 | myDao.delete(this); 172 | } 173 | 174 | /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */ 175 | public void update() { 176 | if (myDao == null) { 177 | throw new DaoException("Entity is detached from DAO context"); 178 | } 179 | myDao.update(this); 180 | } 181 | 182 | /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */ 183 | public void refresh() { 184 | if (myDao == null) { 185 | throw new DaoException("Entity is detached from DAO context"); 186 | } 187 | myDao.refresh(this); 188 | } 189 | 190 | } 191 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/greendao/Category.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.greendao; 2 | 3 | import java.util.List; 4 | import com.squalala.dz6android.greendao.DaoSession; 5 | import de.greenrobot.dao.DaoException; 6 | 7 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 8 | /** 9 | * Entity mapped to table "CATEGORY". 10 | */ 11 | public class Category { 12 | 13 | private Long id; 14 | private String name; 15 | private String slug; 16 | 17 | /** Used to resolve relations */ 18 | private transient DaoSession daoSession; 19 | 20 | /** Used for active entity operations. */ 21 | private transient CategoryDao myDao; 22 | 23 | private List categories; 24 | 25 | public Category() { 26 | } 27 | 28 | public Category(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public Category(Long id, String name, String slug) { 33 | this.id = id; 34 | this.name = name; 35 | this.slug = slug; 36 | } 37 | 38 | /** called by internal mechanisms, do not call yourself. */ 39 | public void __setDaoSession(DaoSession daoSession) { 40 | this.daoSession = daoSession; 41 | myDao = daoSession != null ? daoSession.getCategoryDao() : null; 42 | } 43 | 44 | public Long getId() { 45 | return id; 46 | } 47 | 48 | public void setId(Long id) { 49 | this.id = id; 50 | } 51 | 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | public void setName(String name) { 57 | this.name = name; 58 | } 59 | 60 | public String getSlug() { 61 | return slug; 62 | } 63 | 64 | public void setSlug(String slug) { 65 | this.slug = slug; 66 | } 67 | 68 | /** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */ 69 | public List getCategories() { 70 | if (categories == null) { 71 | if (daoSession == null) { 72 | throw new DaoException("Entity is detached from DAO context"); 73 | } 74 | CategoryArticleDao targetDao = daoSession.getCategoryArticleDao(); 75 | List categoriesNew = targetDao._queryCategory_Categories(id); 76 | synchronized (this) { 77 | if(categories == null) { 78 | categories = categoriesNew; 79 | } 80 | } 81 | } 82 | return categories; 83 | } 84 | 85 | /** Resets a to-many relationship, making the next get call to query for a fresh result. */ 86 | public synchronized void resetCategories() { 87 | categories = null; 88 | } 89 | 90 | /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */ 91 | public void delete() { 92 | if (myDao == null) { 93 | throw new DaoException("Entity is detached from DAO context"); 94 | } 95 | myDao.delete(this); 96 | } 97 | 98 | /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */ 99 | public void update() { 100 | if (myDao == null) { 101 | throw new DaoException("Entity is detached from DAO context"); 102 | } 103 | myDao.update(this); 104 | } 105 | 106 | /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */ 107 | public void refresh() { 108 | if (myDao == null) { 109 | throw new DaoException("Entity is detached from DAO context"); 110 | } 111 | myDao.refresh(this); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/greendao/CategoryArticle.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.greendao; 2 | 3 | import com.squalala.dz6android.greendao.DaoSession; 4 | import de.greenrobot.dao.DaoException; 5 | 6 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 7 | /** 8 | * Entity mapped to table "CATEGORY_ARTICLE". 9 | */ 10 | public class CategoryArticle { 11 | 12 | private Long id; 13 | private long categoryId; 14 | private long articleId; 15 | 16 | /** Used to resolve relations */ 17 | private transient DaoSession daoSession; 18 | 19 | /** Used for active entity operations. */ 20 | private transient CategoryArticleDao myDao; 21 | 22 | private Category category; 23 | private Long category__resolvedKey; 24 | 25 | private Article article; 26 | private Long article__resolvedKey; 27 | 28 | 29 | public CategoryArticle() { 30 | } 31 | 32 | public CategoryArticle(Long id) { 33 | this.id = id; 34 | } 35 | 36 | public CategoryArticle(Long id, long categoryId, long articleId) { 37 | this.id = id; 38 | this.categoryId = categoryId; 39 | this.articleId = articleId; 40 | } 41 | 42 | /** called by internal mechanisms, do not call yourself. */ 43 | public void __setDaoSession(DaoSession daoSession) { 44 | this.daoSession = daoSession; 45 | myDao = daoSession != null ? daoSession.getCategoryArticleDao() : null; 46 | } 47 | 48 | public Long getId() { 49 | return id; 50 | } 51 | 52 | public void setId(Long id) { 53 | this.id = id; 54 | } 55 | 56 | public long getCategoryId() { 57 | return categoryId; 58 | } 59 | 60 | public void setCategoryId(long categoryId) { 61 | this.categoryId = categoryId; 62 | } 63 | 64 | public long getArticleId() { 65 | return articleId; 66 | } 67 | 68 | public void setArticleId(long articleId) { 69 | this.articleId = articleId; 70 | } 71 | 72 | /** To-one relationship, resolved on first access. */ 73 | public Category getCategory() { 74 | long __key = this.categoryId; 75 | if (category__resolvedKey == null || !category__resolvedKey.equals(__key)) { 76 | if (daoSession == null) { 77 | throw new DaoException("Entity is detached from DAO context"); 78 | } 79 | CategoryDao targetDao = daoSession.getCategoryDao(); 80 | Category categoryNew = targetDao.load(__key); 81 | synchronized (this) { 82 | category = categoryNew; 83 | category__resolvedKey = __key; 84 | } 85 | } 86 | return category; 87 | } 88 | 89 | public void setCategory(Category category) { 90 | if (category == null) { 91 | throw new DaoException("To-one property 'categoryId' has not-null constraint; cannot set to-one to null"); 92 | } 93 | synchronized (this) { 94 | this.category = category; 95 | categoryId = category.getId(); 96 | category__resolvedKey = categoryId; 97 | } 98 | } 99 | 100 | /** To-one relationship, resolved on first access. */ 101 | public Article getArticle() { 102 | long __key = this.articleId; 103 | if (article__resolvedKey == null || !article__resolvedKey.equals(__key)) { 104 | if (daoSession == null) { 105 | throw new DaoException("Entity is detached from DAO context"); 106 | } 107 | ArticleDao targetDao = daoSession.getArticleDao(); 108 | Article articleNew = targetDao.load(__key); 109 | synchronized (this) { 110 | article = articleNew; 111 | article__resolvedKey = __key; 112 | } 113 | } 114 | return article; 115 | } 116 | 117 | public void setArticle(Article article) { 118 | if (article == null) { 119 | throw new DaoException("To-one property 'articleId' has not-null constraint; cannot set to-one to null"); 120 | } 121 | synchronized (this) { 122 | this.article = article; 123 | articleId = article.getId(); 124 | article__resolvedKey = articleId; 125 | } 126 | } 127 | 128 | /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */ 129 | public void delete() { 130 | if (myDao == null) { 131 | throw new DaoException("Entity is detached from DAO context"); 132 | } 133 | myDao.delete(this); 134 | } 135 | 136 | /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */ 137 | public void update() { 138 | if (myDao == null) { 139 | throw new DaoException("Entity is detached from DAO context"); 140 | } 141 | myDao.update(this); 142 | } 143 | 144 | /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */ 145 | public void refresh() { 146 | if (myDao == null) { 147 | throw new DaoException("Entity is detached from DAO context"); 148 | } 149 | myDao.refresh(this); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/greendao/CategoryDao.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.greendao; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.Property; 9 | import de.greenrobot.dao.internal.DaoConfig; 10 | 11 | import com.squalala.dz6android.greendao.Category; 12 | 13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 14 | /** 15 | * DAO for table "CATEGORY". 16 | */ 17 | public class CategoryDao extends AbstractDao { 18 | 19 | public static final String TABLENAME = "CATEGORY"; 20 | 21 | /** 22 | * Properties of entity Category.
23 | * Can be used for QueryBuilder and for referencing column names. 24 | */ 25 | public static class Properties { 26 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 27 | public final static Property Name = new Property(1, String.class, "name", false, "NAME"); 28 | public final static Property Slug = new Property(2, String.class, "slug", false, "SLUG"); 29 | }; 30 | 31 | private DaoSession daoSession; 32 | 33 | 34 | public CategoryDao(DaoConfig config) { 35 | super(config); 36 | } 37 | 38 | public CategoryDao(DaoConfig config, DaoSession daoSession) { 39 | super(config, daoSession); 40 | this.daoSession = daoSession; 41 | } 42 | 43 | /** Creates the underlying database table. */ 44 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 45 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 46 | db.execSQL("CREATE TABLE " + constraint + "\"CATEGORY\" (" + // 47 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id 48 | "\"NAME\" TEXT," + // 1: name 49 | "\"SLUG\" TEXT);"); // 2: slug 50 | } 51 | 52 | /** Drops the underlying database table. */ 53 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 54 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CATEGORY\""; 55 | db.execSQL(sql); 56 | } 57 | 58 | /** @inheritdoc */ 59 | @Override 60 | protected void bindValues(SQLiteStatement stmt, Category entity) { 61 | stmt.clearBindings(); 62 | 63 | Long id = entity.getId(); 64 | if (id != null) { 65 | stmt.bindLong(1, id); 66 | } 67 | 68 | String name = entity.getName(); 69 | if (name != null) { 70 | stmt.bindString(2, name); 71 | } 72 | 73 | String slug = entity.getSlug(); 74 | if (slug != null) { 75 | stmt.bindString(3, slug); 76 | } 77 | } 78 | 79 | @Override 80 | protected void attachEntity(Category entity) { 81 | super.attachEntity(entity); 82 | entity.__setDaoSession(daoSession); 83 | } 84 | 85 | /** @inheritdoc */ 86 | @Override 87 | public Long readKey(Cursor cursor, int offset) { 88 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 89 | } 90 | 91 | /** @inheritdoc */ 92 | @Override 93 | public Category readEntity(Cursor cursor, int offset) { 94 | Category entity = new Category( // 95 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 96 | cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name 97 | cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // slug 98 | ); 99 | return entity; 100 | } 101 | 102 | /** @inheritdoc */ 103 | @Override 104 | public void readEntity(Cursor cursor, Category entity, int offset) { 105 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 106 | entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); 107 | entity.setSlug(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); 108 | } 109 | 110 | /** @inheritdoc */ 111 | @Override 112 | protected Long updateKeyAfterInsert(Category entity, long rowId) { 113 | entity.setId(rowId); 114 | return rowId; 115 | } 116 | 117 | /** @inheritdoc */ 118 | @Override 119 | public Long getKey(Category entity) { 120 | if(entity != null) { 121 | return entity.getId(); 122 | } else { 123 | return null; 124 | } 125 | } 126 | 127 | /** @inheritdoc */ 128 | @Override 129 | protected boolean isEntityUpdateable() { 130 | return true; 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/greendao/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.greendao; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | import de.greenrobot.dao.AbstractDaoMaster; 9 | import de.greenrobot.dao.identityscope.IdentityScopeType; 10 | 11 | import com.squalala.dz6android.greendao.ArticleDao; 12 | import com.squalala.dz6android.greendao.CategoryDao; 13 | import com.squalala.dz6android.greendao.CategoryArticleDao; 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | /** 17 | * Master of DAO (schema version 1000): knows all DAOs. 18 | */ 19 | public class DaoMaster extends AbstractDaoMaster { 20 | public static final int SCHEMA_VERSION = 1000; 21 | 22 | /** Creates underlying database table using DAOs. */ 23 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { 24 | ArticleDao.createTable(db, ifNotExists); 25 | CategoryDao.createTable(db, ifNotExists); 26 | CategoryArticleDao.createTable(db, ifNotExists); 27 | } 28 | 29 | /** Drops underlying database table using DAOs. */ 30 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { 31 | ArticleDao.dropTable(db, ifExists); 32 | CategoryDao.dropTable(db, ifExists); 33 | CategoryArticleDao.dropTable(db, ifExists); 34 | } 35 | 36 | public static abstract class OpenHelper extends SQLiteOpenHelper { 37 | 38 | public OpenHelper(Context context, String name, CursorFactory factory) { 39 | super(context, name, factory, SCHEMA_VERSION); 40 | } 41 | 42 | @Override 43 | public void onCreate(SQLiteDatabase db) { 44 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 45 | createAllTables(db, false); 46 | } 47 | } 48 | 49 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 50 | public static class DevOpenHelper extends OpenHelper { 51 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 52 | super(context, name, factory); 53 | } 54 | 55 | @Override 56 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 57 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 58 | dropAllTables(db, true); 59 | onCreate(db); 60 | } 61 | } 62 | 63 | public DaoMaster(SQLiteDatabase db) { 64 | super(db, SCHEMA_VERSION); 65 | registerDaoClass(ArticleDao.class); 66 | registerDaoClass(CategoryDao.class); 67 | registerDaoClass(CategoryArticleDao.class); 68 | } 69 | 70 | public DaoSession newSession() { 71 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 72 | } 73 | 74 | public DaoSession newSession(IdentityScopeType type) { 75 | return new DaoSession(db, type, daoConfigMap); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/greendao/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.greendao; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.Map; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.AbstractDaoSession; 9 | import de.greenrobot.dao.identityscope.IdentityScopeType; 10 | import de.greenrobot.dao.internal.DaoConfig; 11 | 12 | import com.squalala.dz6android.greendao.Article; 13 | import com.squalala.dz6android.greendao.Category; 14 | import com.squalala.dz6android.greendao.CategoryArticle; 15 | 16 | import com.squalala.dz6android.greendao.ArticleDao; 17 | import com.squalala.dz6android.greendao.CategoryDao; 18 | import com.squalala.dz6android.greendao.CategoryArticleDao; 19 | 20 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 21 | 22 | /** 23 | * {@inheritDoc} 24 | * 25 | * @see de.greenrobot.dao.AbstractDaoSession 26 | */ 27 | public class DaoSession extends AbstractDaoSession { 28 | 29 | private final DaoConfig articleDaoConfig; 30 | private final DaoConfig categoryDaoConfig; 31 | private final DaoConfig categoryArticleDaoConfig; 32 | 33 | private final ArticleDao articleDao; 34 | private final CategoryDao categoryDao; 35 | private final CategoryArticleDao categoryArticleDao; 36 | 37 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 38 | daoConfigMap) { 39 | super(db); 40 | 41 | articleDaoConfig = daoConfigMap.get(ArticleDao.class).clone(); 42 | articleDaoConfig.initIdentityScope(type); 43 | 44 | categoryDaoConfig = daoConfigMap.get(CategoryDao.class).clone(); 45 | categoryDaoConfig.initIdentityScope(type); 46 | 47 | categoryArticleDaoConfig = daoConfigMap.get(CategoryArticleDao.class).clone(); 48 | categoryArticleDaoConfig.initIdentityScope(type); 49 | 50 | articleDao = new ArticleDao(articleDaoConfig, this); 51 | categoryDao = new CategoryDao(categoryDaoConfig, this); 52 | categoryArticleDao = new CategoryArticleDao(categoryArticleDaoConfig, this); 53 | 54 | registerDao(Article.class, articleDao); 55 | registerDao(Category.class, categoryDao); 56 | registerDao(CategoryArticle.class, categoryArticleDao); 57 | } 58 | 59 | public void clear() { 60 | articleDaoConfig.getIdentityScope().clear(); 61 | categoryDaoConfig.getIdentityScope().clear(); 62 | categoryArticleDaoConfig.getIdentityScope().clear(); 63 | } 64 | 65 | public ArticleDao getArticleDao() { 66 | return articleDao; 67 | } 68 | 69 | public CategoryDao getCategoryDao() { 70 | return categoryDao; 71 | } 72 | 73 | public CategoryArticleDao getCategoryArticleDao() { 74 | return categoryArticleDao; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/holder/PostViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.holder; 2 | 3 | import android.graphics.Color; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.text.Html; 6 | import android.view.View; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.squalala.dz6android.R; 11 | import com.squalala.dz6android.greendao.Article; 12 | import com.squalala.dz6android.ui.activity.ShowPostActivity; 13 | import com.squalala.dz6android.utils.DateUtils; 14 | import com.squareup.picasso.Picasso; 15 | 16 | import butterknife.Bind; 17 | import butterknife.ButterKnife; 18 | import hugo.weaving.DebugLog; 19 | 20 | /** 21 | * Created by Back Packer 22 | * Date : 24/08/15 23 | */ 24 | public class PostViewHolder extends RecyclerView.ViewHolder 25 | implements View.OnClickListener { 26 | 27 | private ShowPostActivity.PostListener mListener; 28 | private Article post; 29 | 30 | @Bind(R.id.title) 31 | TextView title; 32 | 33 | @Bind(R.id.txt_date) 34 | TextView txtDate; 35 | 36 | @Bind(R.id.image) 37 | ImageView image; 38 | 39 | @DebugLog 40 | public PostViewHolder(View itemView) { 41 | super(itemView); 42 | 43 | ButterKnife.bind(this, itemView); 44 | 45 | itemView.setOnClickListener(this); 46 | } 47 | 48 | @DebugLog 49 | public void bind(Article post) { 50 | this.post = post; 51 | 52 | title.setText(Html.fromHtml(post.getTitle())); 53 | 54 | txtDate.setText(DateUtils.getRelativeTime(post.getDate())); 55 | 56 | Picasso.with(image.getContext()).load(post.getUrlImage()) 57 | .placeholder(R.drawable.image10) 58 | .fit().centerCrop() 59 | .into(image); 60 | 61 | // Il est lu 62 | if (post.getStatus()) { 63 | title.setTextColor(Color.GRAY); 64 | } 65 | else { 66 | title.setTextColor(Color.BLACK); 67 | } 68 | 69 | } 70 | 71 | @Override 72 | public void onClick(View v) { 73 | mListener = (ShowPostActivity.PostListener) v.getContext(); 74 | mListener.onSelectPost(post); 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/model/Post.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.model; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by Back Packer 10 | * Date : 22/08/15 11 | */ 12 | public class Post implements Serializable { 13 | 14 | @SerializedName("ID") 15 | private String id; 16 | 17 | @SerializedName("title") 18 | private String title; 19 | 20 | @SerializedName("featured_image") 21 | private FeaturedImage featuredImage; 22 | 23 | @SerializedName("content") 24 | private String content; 25 | 26 | @SerializedName("link") 27 | private String link; 28 | 29 | @SerializedName("date_gmt") 30 | private String dateGMT; 31 | 32 | @SerializedName("terms") 33 | private Terms terms; 34 | 35 | @SerializedName("author") 36 | private Author author; 37 | 38 | public String getId() { 39 | return id; 40 | } 41 | 42 | public String getContent() { 43 | return content; 44 | } 45 | 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | public String getDateGMT() { 51 | return dateGMT; 52 | } 53 | 54 | public FeaturedImage getFeaturedImage() { 55 | return featuredImage; 56 | } 57 | 58 | public String getLink() { 59 | return link; 60 | } 61 | 62 | public Terms getTerms () 63 | { 64 | return terms; 65 | } 66 | 67 | public String getUrlImage() { 68 | 69 | try { 70 | return featuredImage.attachment.sizes.medium.url; 71 | } catch (NullPointerException e) { 72 | return "http://image.noelshack.com/fichiers/2015/53/1451300086-image10.png"; 73 | } 74 | 75 | } 76 | 77 | public String getAuthor() { 78 | return author.username; 79 | } 80 | 81 | public class Author { 82 | @SerializedName("username") 83 | public String username; 84 | } 85 | 86 | public class Terms 87 | { 88 | @SerializedName("category") 89 | private Category[] category; 90 | 91 | public Category[] getCategory () 92 | { 93 | return category; 94 | } 95 | } 96 | 97 | public class Category 98 | { 99 | @SerializedName("name") 100 | private String name; 101 | @SerializedName("ID") 102 | private String ID; 103 | @SerializedName("slug") 104 | private String slug; 105 | 106 | public String getName () 107 | { 108 | return name; 109 | } 110 | 111 | public String getID () 112 | { 113 | return ID; 114 | } 115 | 116 | public String getSlug () 117 | { 118 | return slug; 119 | } 120 | } 121 | 122 | 123 | 124 | 125 | 126 | public static class Categories { 127 | @SerializedName("category") 128 | List categries; 129 | } 130 | 131 | 132 | private static class FeaturedImage { 133 | @SerializedName("attachment_meta") 134 | public Attachment attachment; 135 | @SerializedName("ID") 136 | public String ID; 137 | } 138 | 139 | private static class Attachment { 140 | @SerializedName("sizes") 141 | public Sizes sizes; 142 | } 143 | 144 | private static class Sizes { 145 | @SerializedName("medium") 146 | public Medium medium; 147 | } 148 | 149 | private static class Medium { 150 | @SerializedName("url") 151 | public String url; 152 | } 153 | 154 | 155 | } 156 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/receiver/BootReceiver.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.receiver; 2 | 3 | import android.app.AlarmManager; 4 | import android.app.PendingIntent; 5 | import android.content.BroadcastReceiver; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | 9 | import com.squalala.dz6android.common.AppConstants; 10 | import com.squalala.dz6android.service.NotificationService; 11 | 12 | import java.util.Calendar; 13 | 14 | import hugo.weaving.DebugLog; 15 | 16 | /** 17 | * Created by Back Packer 18 | * Date : 29/09/15 19 | */ 20 | public class BootReceiver extends BroadcastReceiver { 21 | 22 | @DebugLog 23 | @Override 24 | public void onReceive(Context context, Intent intent) { 25 | 26 | if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED") || 27 | intent.getAction().equals("com.squalala.dz6android_ACTION")) { 28 | // Set the alarm here. 29 | Calendar cal = Calendar.getInstance(); 30 | 31 | Intent intentService = new Intent(context, NotificationService.class); 32 | PendingIntent pintent = PendingIntent.getService(context, 0, intentService, 0); 33 | 34 | AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 35 | // schedule for every 30 seconds 36 | alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AppConstants.TIME_FETCH, pintent); 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/receiver/CustomPushReceiver.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.receiver; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.content.pm.ResolveInfo; 7 | import android.net.Uri; 8 | import android.util.Log; 9 | 10 | import com.parse.ParsePushBroadcastReceiver; 11 | import com.squalala.dz6android.ui.activity.MainActivity; 12 | import com.squalala.dz6android.ui.activity.ShowPostActivity; 13 | import com.squalala.dz6android.utils.NotificationUtils; 14 | 15 | import org.json.JSONException; 16 | import org.json.JSONObject; 17 | 18 | import java.util.List; 19 | 20 | import hugo.weaving.DebugLog; 21 | 22 | 23 | /** 24 | * Created by Ravi on 01/06/15. 25 | */ 26 | public class CustomPushReceiver extends ParsePushBroadcastReceiver { 27 | private final String TAG = CustomPushReceiver.class.getSimpleName(); 28 | 29 | private NotificationUtils notificationUtils; 30 | 31 | private Intent parseIntent; 32 | 33 | public CustomPushReceiver() { 34 | super(); 35 | } 36 | 37 | @DebugLog 38 | @Override 39 | protected void onPushReceive(Context context, Intent intent) { 40 | super.onPushReceive(context, intent); 41 | 42 | if (intent == null) 43 | return; 44 | 45 | try { 46 | JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data")); 47 | 48 | Log.e(TAG, "Push received: " + json); 49 | 50 | parseIntent = intent; 51 | 52 | parsePushJson(context, json); 53 | 54 | } catch (JSONException e) { 55 | Log.e(TAG, "Push message json exception: " + e.getMessage()); 56 | } 57 | } 58 | 59 | @Override 60 | protected void onPushDismiss(Context context, Intent intent) { 61 | super.onPushDismiss(context, intent); 62 | } 63 | 64 | @Override 65 | protected void onPushOpen(Context context, Intent intent) { 66 | super.onPushOpen(context, intent); 67 | } 68 | 69 | /** 70 | * Parses the push notification json 71 | * 72 | * @param context 73 | * @param json 74 | */ 75 | private void parsePushJson(Context context, JSONObject json) { 76 | try { 77 | boolean isBackground = json.getBoolean("is_background"); 78 | JSONObject data = json.getJSONObject("data"); 79 | String title = data.getString("title"); 80 | String message = data.getString("message"); 81 | 82 | String type = data.getString("type"); 83 | 84 | String fbNum = data.getString("fb_num"); 85 | 86 | String fbName = data.getString("fb_name"); 87 | 88 | String postId = data.getString("post_id"); 89 | 90 | Intent resultIntent = null; 91 | 92 | 93 | if (!isBackground) { 94 | 95 | 96 | if (type != null) 97 | { 98 | switch (type) 99 | { 100 | case "facebook": 101 | 102 | final String urlFb = "fb://page/"+ fbNum; 103 | 104 | resultIntent = new Intent(Intent.ACTION_VIEW); 105 | resultIntent.setData(Uri.parse(urlFb)); 106 | 107 | // If Facebook application is installed, use that else launch a browser 108 | final PackageManager packageManager = context.getPackageManager(); 109 | List list = 110 | packageManager.queryIntentActivities(resultIntent, 111 | PackageManager.MATCH_DEFAULT_ONLY); 112 | if (list.size() == 0) { 113 | final String urlBrowser = "https://www.facebook.com/" + fbName; 114 | resultIntent.setData(Uri.parse(urlBrowser)); 115 | } 116 | 117 | break; 118 | 119 | 120 | case "post": 121 | 122 | 123 | resultIntent = new Intent(context, ShowPostActivity.class); 124 | 125 | resultIntent.putExtra("id", Long.valueOf(postId)); 126 | resultIntent.putExtra("all_category", true); 127 | resultIntent.putExtra("notification", true); 128 | 129 | break; 130 | 131 | case "message": 132 | 133 | resultIntent = new Intent(context, MainActivity.class); 134 | 135 | break; 136 | } 137 | 138 | 139 | showNotificationMessage(context, title, message, resultIntent); 140 | } 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | } 150 | 151 | } catch (JSONException e) { 152 | Log.e(TAG, "Push message json exception: " + e.getMessage()); 153 | } 154 | } 155 | 156 | 157 | /** 158 | * Shows the notification message in the notification bar 159 | * If the app is in background, launches the app 160 | * 161 | * @param context 162 | * @param title 163 | * @param message 164 | * @param intent 165 | */ 166 | private void showNotificationMessage(Context context, String title, String message, Intent intent) { 167 | 168 | notificationUtils = new NotificationUtils(context); 169 | 170 | intent.putExtras(parseIntent.getExtras()); 171 | 172 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 173 | 174 | notificationUtils.showNotificationMessage(title, message, intent); 175 | } 176 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/service/WidgetService.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.service; 2 | 3 | import android.content.Intent; 4 | import android.widget.RemoteViewsService; 5 | 6 | import com.squalala.dz6android.ui.widget.ListProvider; 7 | 8 | /** 9 | * Created by Back Packer 10 | * Date : 13/10/15 11 | */ 12 | public class WidgetService extends RemoteViewsService { 13 | 14 | @Override 15 | public RemoteViewsFactory onGetViewFactory(Intent intent) { 16 | return (new ListProvider(this.getApplicationContext(), intent)); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/activity/SettingActivity.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.activity; 2 | 3 | import android.app.FragmentTransaction; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | 8 | import com.squalala.dz6android.R; 9 | import com.squalala.dz6android.ui.fragment.SettingsFragment; 10 | 11 | import butterknife.Bind; 12 | import butterknife.ButterKnife; 13 | 14 | /** 15 | * Created by Back Packer 16 | * Date : 29/09/15 17 | */ 18 | public class SettingActivity extends AppCompatActivity { 19 | 20 | @Bind(R.id.tool_bar) 21 | Toolbar toolbar; 22 | 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_main); 28 | 29 | setTitle(getString(R.string.reglage)); 30 | 31 | ButterKnife.bind(this); 32 | 33 | setSupportActionBar(toolbar); 34 | 35 | FragmentTransaction mFragmentTransaction = getFragmentManager() 36 | .beginTransaction(); 37 | mFragmentTransaction.replace(R.id.fragment_container, new SettingsFragment()); 38 | mFragmentTransaction.commit(); 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/activity/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.activity; 2 | 3 | import android.content.Intent; 4 | 5 | import com.daimajia.androidanimations.library.Techniques; 6 | import com.squalala.dz6android.R; 7 | import com.squalala.dz6android.common.AppConstants; 8 | import com.squalala.dz6android.data.prefs.Preferences; 9 | import com.viksaa.sssplash.lib.activity.AwesomeSplash; 10 | import com.viksaa.sssplash.lib.cnst.Flags; 11 | import com.viksaa.sssplash.lib.model.ConfigSplash; 12 | 13 | import hugo.weaving.DebugLog; 14 | 15 | /** 16 | * Created by Back Packer 17 | * Date : 10/10/15 18 | */ 19 | public class SplashActivity extends AwesomeSplash { 20 | 21 | private Preferences preferences; 22 | 23 | @Override 24 | public void initSplash(ConfigSplash configSplash) { 25 | 26 | preferences = new Preferences(this); 27 | 28 | if (!preferences.isSplashScreenViewed()) { 29 | /* you don't have to override every property */ 30 | 31 | //Customize Circular Reveal 32 | configSplash.setBackgroundColor(R.color.primary); //any color you want form colors.xml 33 | configSplash.setAnimCircularRevealDuration(2000); //int ms 34 | configSplash.setRevealFlagX(Flags.REVEAL_RIGHT); //or Flags.REVEAL_LEFT 35 | configSplash.setRevealFlagY(Flags.REVEAL_BOTTOM); //or Flags.REVEAL_TOP 36 | 37 | //Choose LOGO OR PATH; if you don't provide String value for path it's logo by default 38 | 39 | //Customize Path 40 | configSplash.setPathSplash(AppConstants.PATH_LOGO); //set path String 41 | configSplash.setOriginalHeight(520); //in relation to your svg (path) resource 42 | configSplash.setOriginalWidth(520); //in relation to your svg (path) resource 43 | configSplash.setAnimPathStrokeDrawingDuration(3000); 44 | configSplash.setPathSplashStrokeSize(3); //I advise value be <5 45 | configSplash.setPathSplashStrokeColor(android.R.color.white); //any color you want form colors.xml 46 | configSplash.setAnimPathFillingDuration(3000); 47 | configSplash.setPathSplashFillColor(R.color.white_custom); //path object filling color 48 | 49 | 50 | //Customize Title 51 | configSplash.setTitleSplash(getString(R.string.app_name)); 52 | configSplash.setTitleTextColor(android.R.color.white); 53 | configSplash.setTitleTextSize(30f); //float value 54 | configSplash.setAnimTitleDuration(3000); 55 | configSplash.setAnimTitleTechnique(Techniques.FadeIn); 56 | // configSplash.setTitleFont("fonts/myfont.ttf"); //provide string to your font located in assets/fonts/ 57 | } 58 | else 59 | navigateToMainActivity(); 60 | 61 | } 62 | 63 | @DebugLog 64 | @Override 65 | public void animationsFinished() { 66 | preferences.setSpashScreen(true); 67 | navigateToMainActivity(); 68 | } 69 | 70 | private void navigateToMainActivity() { 71 | Intent intent = new Intent(this, MainActivity.class); 72 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 73 | startActivity(intent); 74 | finish(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/activity/ViewPagerActivity.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.activity; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v4.view.PagerAdapter; 6 | import android.support.v4.view.ViewPager; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.Toolbar; 9 | import android.util.Log; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.ViewGroup.LayoutParams; 13 | 14 | import com.squalala.dz6android.App; 15 | import com.squalala.dz6android.R; 16 | import com.squalala.dz6android.custom.HackyViewPager; 17 | import com.squareup.picasso.Picasso; 18 | 19 | import java.util.List; 20 | 21 | import butterknife.Bind; 22 | import butterknife.ButterKnife; 23 | import uk.co.senab.photoview.PhotoView; 24 | 25 | /** 26 | * Created by Back Packer 27 | * Date : 25/04/15 28 | */ 29 | public class ViewPagerActivity extends AppCompatActivity { 30 | 31 | 32 | private static final String ISLOCKED_ARG = "isLocked"; 33 | 34 | @Bind(R.id.view_pager) HackyViewPager mViewPager; 35 | 36 | @Bind(R.id.tool_bar) 37 | Toolbar mToolbar; 38 | 39 | private List urlImages; 40 | 41 | private static final String TAG = ViewPagerActivity.class.getSimpleName(); 42 | 43 | @Override 44 | public void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | 47 | App.tracker.setScreenName(getClass().getName()); 48 | 49 | setContentView(R.layout.activity_view_pager_images); 50 | 51 | ButterKnife.bind(this); 52 | 53 | setSupportActionBar(mToolbar); 54 | mToolbar.setBackgroundColor(Color.TRANSPARENT); 55 | 56 | // Position sur laquelle l'utilisateur a cliqué. 57 | int position = getIntent().getExtras().getInt("position"); 58 | 59 | urlImages = getIntent().getStringArrayListExtra("urls"); 60 | 61 | if (urlImages.size() > 1) 62 | getSupportActionBar().setTitle( (position + 1) + "/" + urlImages.size()); 63 | else 64 | getSupportActionBar().setTitle(""); 65 | 66 | mViewPager.setAdapter(new SamplePagerAdapter()); 67 | mViewPager.setCurrentItem(position); 68 | 69 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 70 | @Override 71 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 72 | 73 | } 74 | 75 | @Override 76 | public void onPageSelected(int position) { 77 | getSupportActionBar().setTitle((position + 1) + "/" + urlImages.size()); 78 | } 79 | 80 | @Override 81 | public void onPageScrollStateChanged(int state) { 82 | 83 | } 84 | }); 85 | 86 | 87 | if (savedInstanceState != null) { 88 | boolean isLocked = savedInstanceState.getBoolean(ISLOCKED_ARG, false); 89 | ((HackyViewPager) mViewPager).setLocked(isLocked); 90 | } 91 | } 92 | 93 | private class SamplePagerAdapter extends PagerAdapter { 94 | 95 | @Override 96 | public int getCount() { 97 | return urlImages.size(); 98 | } 99 | 100 | @Override 101 | public View instantiateItem(ViewGroup container, int position) { 102 | Log.e(TAG, "instantiateItem"); 103 | 104 | PhotoView photoView = new PhotoView(container.getContext()); 105 | 106 | // Now just add PhotoView to ViewPager and return it 107 | container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 108 | 109 | Picasso.with(ViewPagerActivity.this) 110 | .load(urlImages.get(position).toString()) 111 | .fit().centerInside() 112 | .into(photoView); 113 | 114 | 115 | return photoView; 116 | } 117 | 118 | 119 | @Override 120 | public void destroyItem(ViewGroup container, int position, Object object) { 121 | container.removeView((View) object); 122 | } 123 | 124 | 125 | @Override 126 | public boolean isViewFromObject(View view, Object object) { 127 | return view == object; 128 | } 129 | 130 | 131 | } 132 | 133 | 134 | private boolean isViewPagerActive() { 135 | return (mViewPager != null && mViewPager instanceof HackyViewPager); 136 | } 137 | 138 | @Override 139 | protected void onSaveInstanceState(Bundle outState) { 140 | if (isViewPagerActive()) { 141 | outState.putBoolean(ISLOCKED_ARG, ((HackyViewPager) mViewPager).isLocked()); 142 | } 143 | super.onSaveInstanceState(outState); 144 | } 145 | 146 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/fragment/AboutFragment.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.fragment; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.text.Html; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.TextView; 11 | 12 | import com.squalala.dz6android.R; 13 | import com.squalala.dz6android.common.BaseFragment; 14 | 15 | import butterknife.Bind; 16 | import butterknife.ButterKnife; 17 | import hugo.weaving.DebugLog; 18 | 19 | /** 20 | * Created by Back Packer 21 | * Date : 30/09/15 22 | */ 23 | public class AboutFragment extends BaseFragment { 24 | 25 | @Bind(R.id.txt_about) 26 | TextView txtAbout; 27 | 28 | @Bind(R.id.txt_squalala) 29 | TextView txtSqualala; 30 | 31 | @DebugLog 32 | @Override 33 | public View onCreateView(LayoutInflater inflater, 34 | @Nullable ViewGroup container, 35 | @Nullable Bundle savedInstanceState) { 36 | return inflater.inflate(R.layout.fragment_about, container, false); 37 | } 38 | 39 | @Override 40 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 41 | super.onViewCreated(view, savedInstanceState); 42 | 43 | ButterKnife.bind(this, view); 44 | 45 | txtAbout.setText(Html.fromHtml(getString(R.string.about))); 46 | txtSqualala.setText(Html.fromHtml(getString(R.string.developped_by))); 47 | 48 | txtSqualala.setOnClickListener(new View.OnClickListener() { 49 | @Override 50 | public void onClick(View v) { 51 | Intent email = new Intent(Intent.ACTION_SEND); 52 | email.putExtra(Intent.EXTRA_EMAIL, new String[]{"contact@squalala.com"}); 53 | email.putExtra(Intent.EXTRA_SUBJECT, "Team Squalala DZ"); 54 | email.putExtra(Intent.EXTRA_TEXT, ""); 55 | email.setType("message/rfc822"); 56 | startActivity(Intent.createChooser(email, "Choisissez :")); 57 | } 58 | }); 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/fragment/FavorisFragment.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.widget.SwipeRefreshLayout; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.util.Log; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.TextView; 12 | 13 | import com.squalala.dz6android.R; 14 | import com.squalala.dz6android.adapter.PostAdapter; 15 | import com.squalala.dz6android.common.BaseFragment; 16 | import com.squalala.dz6android.custom.EmptyRecyclerView; 17 | import com.squalala.dz6android.eventbus.QueryEvent; 18 | import com.squalala.dz6android.greendao.Article; 19 | import com.squalala.dz6android.greendao.ArticleDao; 20 | import com.victor.loading.rotate.RotateLoading; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | import butterknife.Bind; 26 | import butterknife.ButterKnife; 27 | import de.greenrobot.dao.query.QueryBuilder; 28 | import de.greenrobot.dao.query.WhereCondition; 29 | import de.greenrobot.event.EventBus; 30 | import hugo.weaving.DebugLog; 31 | 32 | /** 33 | * Created by Back Packer 34 | * Date : 05/10/15 35 | */ 36 | public class FavorisFragment extends BaseFragment { 37 | 38 | @Bind(R.id.recyclerView) 39 | EmptyRecyclerView recyclerView; 40 | 41 | @Bind(R.id.swipe_container) 42 | SwipeRefreshLayout swipeLayout; 43 | 44 | @Bind(R.id.rotateloading) 45 | RotateLoading rotateLoading; 46 | 47 | @Bind(R.id.empty_view) 48 | TextView emptyView; 49 | 50 | 51 | private static final String TAG = FavorisFragment.class.getSimpleName(); 52 | private PostAdapter adapter; 53 | private List
listPost = new ArrayList<>(); 54 | private LinearLayoutManager linearLayoutManager; 55 | 56 | @DebugLog 57 | @Override 58 | public View onCreateView(LayoutInflater inflater, 59 | @Nullable ViewGroup container, 60 | @Nullable Bundle savedInstanceState) { 61 | return inflater.inflate(R.layout.fragment_category, container, false); 62 | } 63 | 64 | @DebugLog 65 | @Override 66 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 67 | super.onViewCreated(view, savedInstanceState); 68 | 69 | ButterKnife.bind(this, view); 70 | 71 | rotateLoading.setVisibility(View.VISIBLE); 72 | rotateLoading.start(); 73 | 74 | 75 | linearLayoutManager = new LinearLayoutManager(getContext()); 76 | 77 | recyclerView.setEmptyView(emptyView); 78 | recyclerView.setLayoutManager(linearLayoutManager); 79 | adapter = new PostAdapter(listPost); 80 | recyclerView.setAdapter(adapter); 81 | 82 | swipeLayout.setEnabled(false); 83 | 84 | } 85 | 86 | @Override 87 | public void onResume() { 88 | super.onResume(); 89 | 90 | listPost.clear(); 91 | 92 | QueryBuilder query = articleDao.queryBuilder(); 93 | query.where(ArticleDao.Properties.Favoris.eq(true)); 94 | 95 | listPost.addAll(query.list()); 96 | 97 | recyclerView.getAdapter().notifyDataSetChanged(); 98 | 99 | rotateLoading.stop(); 100 | rotateLoading.setVisibility(View.GONE); 101 | } 102 | 103 | @DebugLog 104 | public void onEvent(QueryEvent event) { 105 | 106 | rotateLoading.setVisibility(View.VISIBLE); 107 | rotateLoading.start(); 108 | 109 | String keyWord = event.getQuery(); 110 | Log.e(TAG, " " + keyWord); 111 | 112 | listPost.clear(); 113 | 114 | WhereCondition where1 = ArticleDao.Properties.Content.like("%" + keyWord + "%"); 115 | WhereCondition where2 = ArticleDao.Properties.Title.like("%" +keyWord+ "%"); 116 | WhereCondition where3 = ArticleDao.Properties.Favoris.eq(true); 117 | 118 | QueryBuilder query = articleDao.queryBuilder(); 119 | 120 | query.LOG_SQL = true; 121 | 122 | query.where(where3, query.or(where2, where1)); 123 | 124 | listPost.addAll(query.list()); 125 | 126 | recyclerView.getAdapter().notifyDataSetChanged(); 127 | 128 | rotateLoading.setVisibility(View.GONE); 129 | } 130 | 131 | @Override 132 | public void onStart() { 133 | super.onStart(); 134 | EventBus.getDefault().register(this); 135 | } 136 | 137 | @Override 138 | public void onStop() { 139 | super.onStop(); 140 | EventBus.getDefault().unregister(this); 141 | } 142 | 143 | 144 | } 145 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/fragment/SettingsFragment.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.preference.PreferenceFragment; 5 | 6 | import com.squalala.dz6android.R; 7 | 8 | /** 9 | * Created by Back Packer 10 | * Date : 29/09/15 11 | */ 12 | public class SettingsFragment extends PreferenceFragment { 13 | 14 | 15 | @Override 16 | public void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | addPreferencesFromResource(R.xml.preferences); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/widget/ListProvider.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.widget; 2 | 3 | 4 | import android.appwidget.AppWidgetManager; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.graphics.Bitmap; 8 | import android.text.Html; 9 | import android.widget.RemoteViews; 10 | import android.widget.RemoteViewsService; 11 | 12 | import com.squalala.dz6android.App; 13 | import com.squalala.dz6android.R; 14 | import com.squalala.dz6android.greendao.Article; 15 | import com.squalala.dz6android.greendao.ArticleDao; 16 | import com.squareup.picasso.Picasso; 17 | 18 | import java.io.IOException; 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | import javax.inject.Inject; 23 | 24 | import hugo.weaving.DebugLog; 25 | 26 | /** 27 | * Created by Back Packer 28 | * Date : 13/10/15 29 | */ 30 | public class ListProvider implements RemoteViewsService.RemoteViewsFactory { 31 | private List
articles; 32 | private Context context; 33 | private int appWidgetId; 34 | 35 | private RemoteViews remoteView; 36 | 37 | private static final String TAG = ListProvider.class.getSimpleName(); 38 | 39 | 40 | @Inject 41 | ArticleDao articleDao; 42 | 43 | 44 | @DebugLog 45 | public ListProvider(Context context, Intent intent) { 46 | App.get(context).component().inject(this); 47 | 48 | this.context = context; 49 | appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 50 | AppWidgetManager.INVALID_APPWIDGET_ID); 51 | 52 | articles = articleDao.queryBuilder() 53 | .list(); 54 | 55 | Collections.reverse(articles); 56 | } 57 | 58 | 59 | 60 | @Override 61 | public void onCreate() { 62 | 63 | } 64 | 65 | @Override 66 | public void onDataSetChanged() { 67 | 68 | } 69 | 70 | @Override 71 | public void onDestroy() { 72 | 73 | } 74 | 75 | @Override 76 | public int getCount() { 77 | return articles.size(); 78 | } 79 | 80 | @DebugLog 81 | @Override 82 | public RemoteViews getViewAt(int position) { 83 | remoteView = new RemoteViews( 84 | context.getPackageName(), R.layout.article_item); 85 | 86 | Article article = articles.get(position); 87 | 88 | final Bitmap b; 89 | try { 90 | b = Picasso.with(context).load(article.getUrlImage()).get(); 91 | remoteView.setImageViewBitmap(R.id.article_image, b); 92 | } catch (IOException e) { 93 | e.printStackTrace(); 94 | } 95 | 96 | Intent fillInIntent = new Intent(); 97 | fillInIntent.putExtra("id", article.getId()); 98 | fillInIntent.putExtra("notification", true); 99 | fillInIntent.putExtra("all_category", true); 100 | remoteView.setOnClickFillInIntent(R.id.article_image, fillInIntent); 101 | 102 | /* Picasso.with(context) 103 | .load(article.getUrlImage()) 104 | .into(remoteView, 105 | R.id.article_image, 106 | new int [] {appWidgetId});*/ 107 | 108 | remoteView.setTextViewText(R.id.article_text, Html.fromHtml(article.getTitle())); 109 | 110 | return remoteView; 111 | } 112 | 113 | @Override 114 | public RemoteViews getLoadingView() { 115 | return null; 116 | } 117 | 118 | @Override 119 | public int getViewTypeCount() { 120 | return 1; 121 | } 122 | 123 | @Override 124 | public long getItemId(int position) { 125 | return position; 126 | } 127 | 128 | @Override 129 | public boolean hasStableIds() { 130 | return true; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/ui/widget/MyWidgetProvider.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.ui.widget; 2 | 3 | import android.app.PendingIntent; 4 | import android.appwidget.AppWidgetManager; 5 | import android.appwidget.AppWidgetProvider; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.net.Uri; 9 | import android.util.Log; 10 | import android.widget.RemoteViews; 11 | 12 | import com.squalala.dz6android.R; 13 | import com.squalala.dz6android.service.WidgetService; 14 | import com.squalala.dz6android.ui.activity.ShowPostActivity; 15 | 16 | import hugo.weaving.DebugLog; 17 | 18 | /** 19 | * Created by Back Packer 20 | * Date : 13/10/15 21 | */ 22 | public class MyWidgetProvider extends AppWidgetProvider { 23 | 24 | private static final String TAG = MyWidgetProvider.class.getSimpleName(); 25 | 26 | 27 | @DebugLog 28 | @Override 29 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { 30 | super.onUpdate(context, appWidgetManager, appWidgetIds); 31 | 32 | final int N = appWidgetIds.length; 33 | 34 | Log.e(TAG, "size N : " + N); 35 | 36 | for (int i = 0; i < N; ++i) { 37 | RemoteViews remoteViews = updateWidgetListView(context, 38 | appWidgetIds[i]); 39 | 40 | Intent startActivityIntent = new Intent(context, ShowPostActivity.class); 41 | 42 | PendingIntent startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT); 43 | remoteViews.setPendingIntentTemplate(R.id.listViewWidget, startActivityPendingIntent); 44 | 45 | appWidgetManager.updateAppWidget(appWidgetIds[i], remoteViews); 46 | } 47 | 48 | super.onUpdate(context, appWidgetManager, appWidgetIds); 49 | } 50 | 51 | 52 | @DebugLog 53 | private RemoteViews updateWidgetListView(Context context, int appWidgetId) { 54 | 55 | 56 | //which layout to show on widget 57 | RemoteViews remoteViews = new RemoteViews(context.getPackageName(), 58 | R.layout.widget_layout); 59 | 60 | //RemoteViews Service needed to provide adapter for ListView 61 | Intent svcIntent = new Intent(context, WidgetService.class); 62 | //passing app widget id to that RemoteViews Service 63 | svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); 64 | //setting a unique Uri to the intent 65 | //don't know its purpose to me right now 66 | svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME))); 67 | //setting adapter to listview of the widget 68 | remoteViews.setRemoteAdapter(appWidgetId, R.id.listViewWidget, 69 | svcIntent); 70 | //setting an empty view in case of no data 71 | remoteViews.setEmptyView(R.id.listViewWidget, R.id.empty_view); 72 | return remoteViews; 73 | } 74 | 75 | @DebugLog 76 | @Override 77 | public void onEnabled(Context context) { 78 | super.onEnabled(context); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/BitmapUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.view.View; 8 | 9 | import com.squareup.okhttp.OkHttpClient; 10 | import com.squareup.okhttp.Request; 11 | import com.squareup.okhttp.Response; 12 | 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | 16 | /** 17 | * Auteur : Fayçal Kaddouri 18 | * Nom du fichier : BitmapUtils.java 19 | * Date : 27 nov. 2014 20 | * 21 | */ 22 | public class BitmapUtils { 23 | 24 | public static Bitmap getBitmapFromURL(String strURL) { 25 | try { 26 | 27 | OkHttpClient client = new OkHttpClient(); 28 | 29 | Request request = new Request.Builder() 30 | .url(strURL) 31 | .build(); 32 | 33 | Response response = client.newCall(request).execute(); 34 | 35 | InputStream input = response.body().byteStream(); 36 | Bitmap myBitmap = BitmapFactory.decodeStream(input); 37 | 38 | return myBitmap; 39 | 40 | } catch (IOException e) { 41 | 42 | e.printStackTrace(); 43 | return null; 44 | } 45 | } 46 | 47 | 48 | public static Bitmap takeScreenshot(Context context) { 49 | View rootView = ( (Activity) context).findViewById(android.R.id.content).getRootView(); 50 | rootView.setDrawingCacheEnabled(true); 51 | return rootView.getDrawingCache(); 52 | } 53 | 54 | public static Bitmap takeScreenshot(View view) { 55 | View rootView = view; 56 | rootView.setDrawingCacheEnabled(true); 57 | return rootView.getDrawingCache(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/ConnectionDetector.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | public class ConnectionDetector { 8 | 9 | private ConnectionDetector() {} 10 | 11 | public static boolean isConnectingToInternet(Context _context){ 12 | ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE); 13 | if (connectivity != null) 14 | { 15 | NetworkInfo[] info = connectivity.getAllNetworkInfo(); 16 | if (info != null) 17 | for (int i = 0; i < info.length; i++) 18 | if (info[i].getState() == NetworkInfo.State.CONNECTED) 19 | { 20 | return true; 21 | } 22 | 23 | } 24 | return false; 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by Back Packer 9 | * Date : 29/09/15 10 | */ 11 | public class DateUtils { 12 | 13 | public static String getRelativeTime(Date date) { 14 | 15 | long now = System.currentTimeMillis(); 16 | 17 | return (String) 18 | android.text.format 19 | .DateUtils.getRelativeTimeSpanString(date.getTime(), now, android.text.format.DateUtils.FORMAT_ABBREV_ALL); 20 | } 21 | 22 | public static Date strToDate(String dateStr) { 23 | 24 | Date date = null; 25 | 26 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 27 | 28 | try { 29 | 30 | date = format.parse(dateStr); 31 | 32 | } catch (ParseException e) { 33 | e.printStackTrace(); 34 | } 35 | 36 | return date; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/HtmlUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import org.jsoup.Jsoup; 4 | import org.jsoup.nodes.Document; 5 | import org.jsoup.nodes.Element; 6 | import org.jsoup.select.Elements; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * Created by Back Packer 12 | * Date : 07/10/15 13 | */ 14 | public class HtmlUtils { 15 | 16 | private HtmlUtils() {} 17 | 18 | public static String addAttributesToImages(String html) { 19 | 20 | Document doc = Jsoup.parse(html); 21 | 22 | // Get all img tags 23 | Elements img = doc.getElementsByTag("img"); 24 | 25 | int id = 0; 26 | 27 | for (Element el : img) { 28 | 29 | if (el.toString().contains("www.dz-android.com") && !el.toString().contains("resize=120") && 30 | !el.toString().contains("Telecharger-sur-Google-play-Small1.png")) { 31 | el.attr("id", String.valueOf(id++)); 32 | el.attr("onclick", "Image.onClickImage(this.id);"); 33 | } 34 | } 35 | 36 | // Pour supprimer la séction articles similaires 37 | doc.select("div.yarpp-related").remove(); 38 | // Supprimer la partie du partage 39 | doc.select("div.sd-sharing-enabled").remove(); 40 | // Supprimer le gif 41 | doc.select("p.pvc_stats").remove(); 42 | 43 | doc = Jsoup.parse(doc.html()); 44 | 45 | 46 | 47 | Element head = doc.head(); 48 | 49 | head.append(""); 50 | head.append(""); 51 | 52 | return doc.html(); 53 | } 54 | 55 | public static String addHtml(String content, String htmlToAdd ) 56 | { 57 | Document document = Jsoup.parse(content); 58 | 59 | Element body = document.body(); 60 | 61 | body.prepend(htmlToAdd); 62 | 63 | return document.html(); 64 | } 65 | 66 | 67 | public static ArrayList getUrlImages(String html) { 68 | 69 | ArrayList urlImages = new ArrayList<>(); 70 | 71 | Document doc = Jsoup.parse(html); 72 | 73 | // Get all img tags 74 | Elements img = doc.getElementsByTag("img"); 75 | 76 | for (Element el : img) { 77 | 78 | if (el.toString().contains("www.dz-android.com") && !el.toString().contains("resize=120") && 79 | !el.toString().contains("Telecharger-sur-Google-play-Small1.png")) 80 | urlImages.add(el.attr("src")); 81 | } 82 | 83 | /* for(String image : urlImages) 84 | System.out.println("#" + image);*/ 85 | 86 | return urlImages; 87 | } 88 | 89 | 90 | 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/IntentUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import android.content.ActivityNotFoundException; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.net.Uri; 8 | 9 | /** 10 | * Created by Back Packer 11 | * Date : 17/11/15 12 | */ 13 | public class IntentUtils { 14 | 15 | public static void viewYoutube(Context context, String url) { 16 | viewWithPackageName(context, url, "com.google.android.youtube"); 17 | } 18 | 19 | public static void viewWithPackageName(Context context, String url, String packageName) { 20 | try { 21 | Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 22 | if (isAppInstalled(context, packageName)) { 23 | viewIntent.setPackage(packageName); 24 | } 25 | context.startActivity(viewIntent); 26 | } catch (Exception e) { 27 | Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 28 | 29 | try { 30 | context.startActivity(viewIntent); 31 | } catch (ActivityNotFoundException a){} 32 | 33 | } 34 | } 35 | 36 | public static boolean isAppInstalled(Context context, String packageName) { 37 | PackageManager packageManager = context.getPackageManager(); 38 | try { 39 | packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); 40 | return true; 41 | } catch (PackageManager.NameNotFoundException e) { 42 | } 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/NotificationUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import android.app.ActivityManager; 4 | import android.app.Notification; 5 | import android.app.NotificationManager; 6 | import android.app.PendingIntent; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.graphics.BitmapFactory; 10 | import android.graphics.Color; 11 | import android.media.RingtoneManager; 12 | import android.net.Uri; 13 | import android.support.v4.app.NotificationCompat; 14 | import android.text.Html; 15 | import android.text.TextUtils; 16 | 17 | import com.squalala.dz6android.R; 18 | import com.squalala.dz6android.common.AppConstants; 19 | import com.squalala.dz6android.data.prefs.Preferences; 20 | 21 | import java.util.List; 22 | 23 | import hugo.weaving.DebugLog; 24 | 25 | /** 26 | * Created by Ravi on 01/06/15. 27 | */ 28 | public class NotificationUtils { 29 | 30 | private String TAG = NotificationUtils.class.getSimpleName(); 31 | 32 | private Context mContext; 33 | 34 | public NotificationUtils() { 35 | } 36 | 37 | public NotificationUtils(Context mContext) { 38 | this.mContext = mContext; 39 | } 40 | 41 | @DebugLog 42 | public void showNotificationMessage(String title, String message, Intent intent) { 43 | 44 | // Check for empty push message 45 | if (TextUtils.isEmpty(message)) 46 | return; 47 | 48 | Preferences preferences = new Preferences(mContext); 49 | 50 | if (!preferences.isNotification()) 51 | return; 52 | 53 | // notification icon 54 | int icon = R.mipmap.ic_launcher; 55 | 56 | int smallIcon = R.drawable.ic_stat_000; 57 | 58 | int mNotificationId = AppConstants.NOTIFICATION_ID; 59 | 60 | PendingIntent resultPendingIntent = 61 | PendingIntent.getActivity( 62 | mContext, 63 | 0, 64 | intent, 65 | PendingIntent.FLAG_CANCEL_CURRENT 66 | ); 67 | 68 | NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); 69 | 70 | NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( 71 | mContext); 72 | 73 | mBuilder.setSmallIcon(smallIcon).setTicker(title).setWhen(0) 74 | .setAutoCancel(true) 75 | .setContentTitle(Html.fromHtml(title)) 76 | .setTicker(Html.fromHtml(message)) 77 | .setStyle(inboxStyle) 78 | .setContentIntent(resultPendingIntent) 79 | .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon)) 80 | .setContentText(Html.fromHtml(message)); 81 | 82 | 83 | if (preferences.isSound()) { 84 | Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 85 | mBuilder.setSound(uri); 86 | } 87 | 88 | if (preferences.isLedFlash()) { 89 | mBuilder.setLights(Color.BLUE, 1000, 1000); 90 | } 91 | 92 | if (preferences.isVibreur()) { 93 | mBuilder.setVibrate(new long[] { 1000, 1000, 1000}); 94 | } 95 | 96 | 97 | Notification notification = mBuilder.build(); 98 | 99 | 100 | NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); 101 | notificationManager.notify(mNotificationId, notification); 102 | 103 | /* if (!isAppOnForeground(mContext)) { 104 | // notification icon 105 | int icon = R.mipmap.ic_launcher; 106 | 107 | int smallIcon = R.mipmap.image_128; 108 | 109 | int mNotificationId = AppConstants.NOTIFICATION_ID; 110 | 111 | PendingIntent resultPendingIntent = 112 | PendingIntent.getActivity( 113 | mContext, 114 | 0, 115 | intent, 116 | PendingIntent.FLAG_CANCEL_CURRENT 117 | ); 118 | 119 | NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); 120 | 121 | NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( 122 | mContext); 123 | Notification notification = mBuilder.setSmallIcon(smallIcon).setTicker(title).setWhen(0) 124 | .setAutoCancel(true) 125 | .setContentTitle(title) 126 | .setStyle(inboxStyle) 127 | .setContentIntent(resultPendingIntent) 128 | .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) 129 | .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon)) 130 | .setContentText(message) 131 | .build(); 132 | 133 | NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); 134 | notificationManager.notify(mNotificationId, notification); 135 | } else { 136 | intent.putExtra("title", title); 137 | intent.putExtra("message", message); 138 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); 139 | mContext.startActivity(intent); 140 | }*/ 141 | } 142 | 143 | /** 144 | * Method checks if the app is in background or not 145 | * 146 | * @param context 147 | * @return 148 | */ 149 | private boolean isAppOnForeground(Context context) { 150 | ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); 151 | List appProcesses = activityManager.getRunningAppProcesses(); 152 | if (appProcesses == null) { 153 | return false; 154 | } 155 | final String packageName = mContext.getPackageName(); 156 | for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { 157 | if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && appProcess.processName.equals(packageName)) { 158 | // Log.e("app",appPackageName); 159 | return true; 160 | } 161 | } 162 | return false; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/ParseUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import android.accounts.Account; 4 | import android.accounts.AccountManager; 5 | import android.app.Activity; 6 | import android.content.Context; 7 | import android.text.TextUtils; 8 | import android.util.Log; 9 | import android.util.Patterns; 10 | import android.widget.Toast; 11 | 12 | import com.parse.Parse; 13 | import com.parse.ParseException; 14 | import com.parse.ParseInstallation; 15 | import com.parse.ParsePush; 16 | import com.parse.SaveCallback; 17 | import com.squalala.dz6android.common.AppConstants; 18 | 19 | import java.util.regex.Pattern; 20 | 21 | 22 | /** 23 | * Created by Ravi on 01/06/15. 24 | */ 25 | public class ParseUtils { 26 | 27 | private static String TAG = ParseUtils.class.getSimpleName(); 28 | 29 | public static void verifyParseConfiguration(Context context) { 30 | if (TextUtils.isEmpty(AppConstants.PARSE_APPLICATION_ID) || TextUtils.isEmpty(AppConstants.PARSE_CLIENT_KEY)) { 31 | Toast.makeText(context, "Please configure your Parse Application ID and Client Key in AppConstants.java", Toast.LENGTH_LONG).show(); 32 | ((Activity) context).finish(); 33 | } 34 | } 35 | 36 | public static void registerParse(Context context) { 37 | // initializing parse library 38 | Parse.initialize(context, AppConstants.PARSE_APPLICATION_ID, AppConstants.PARSE_CLIENT_KEY); 39 | ParseInstallation.getCurrentInstallation().saveInBackground(); 40 | 41 | ParsePush.subscribeInBackground(AppConstants.PARSE_CHANNEL, new SaveCallback() { 42 | @Override 43 | public void done(ParseException e) { 44 | Log.e(TAG, "Successfully subscribed to Parse!"); 45 | } 46 | }); 47 | } 48 | 49 | public static void subscribeWithEmail(String email) { 50 | ParseInstallation installation = ParseInstallation.getCurrentInstallation(); 51 | 52 | installation.put("email", email); 53 | 54 | installation.saveInBackground(); 55 | 56 | Log.e(TAG, "Subscribed with email: " + email); 57 | } 58 | 59 | public static String getEmail(Context context) { 60 | // Supérieur à 2.1 61 | if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR) { 62 | 63 | Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ 64 | Account[] accounts = AccountManager.get(context).getAccounts(); 65 | for (Account account : accounts) { 66 | if (emailPattern.matcher(account.name).matches()) { 67 | String possibleEmail = account.name; 68 | return possibleEmail; 69 | } 70 | } 71 | } 72 | // Égale à 2.1 73 | else { 74 | Account[] accounts = AccountManager.get(context).getAccounts(); 75 | if (accounts.length > 0) { 76 | String possibleEmail = accounts[0].name; 77 | return possibleEmail; 78 | } 79 | } 80 | 81 | return "no_adress"; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/RxUtils.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import rx.Subscription; 4 | import rx.subscriptions.CompositeSubscription; 5 | 6 | public class RxUtils { 7 | 8 | public static void unsubscribeIfNotNull(Subscription subscription) { 9 | if (subscription != null) { 10 | subscription.unsubscribe(); 11 | } 12 | } 13 | 14 | public static CompositeSubscription getNewCompositeSubIfUnsubscribed(CompositeSubscription subscription) { 15 | if (subscription == null || subscription.isUnsubscribed()) { 16 | return new CompositeSubscription(); 17 | } 18 | 19 | return subscription; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/squalala/dz6android/utils/UrlToSplit.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android.utils; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Auteur : Fayçal Kaddouri 7 | * Nom du fichier : UrlToSplit.java 8 | * Date : 31 juil. 2014 9 | * 10 | */ 11 | public class UrlToSplit { 12 | 13 | public static String strWithComma(List url_images) { 14 | String urlToSplit = ""; 15 | 16 | for (int i = 0; i < url_images.size(); i++) { 17 | urlToSplit += url_images.get(i).toString() + ","; 18 | } 19 | 20 | if (urlToSplit.endsWith(",")) { 21 | urlToSplit = removeLastChar(urlToSplit); 22 | } 23 | 24 | return urlToSplit; 25 | } 26 | 27 | public static String strWithComma(String [] url_images) { 28 | String urlToSplit = ""; 29 | 30 | for (int i = 0; i < url_images.length; i++) { 31 | urlToSplit += url_images[i] + ","; 32 | } 33 | 34 | if (urlToSplit.endsWith(",")) { 35 | urlToSplit = removeLastChar(urlToSplit); 36 | } 37 | 38 | return urlToSplit; 39 | } 40 | 41 | public static String removeLastChar(String str) { 42 | return str.substring(0,str.length()-1); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi-v11/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi-v11/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_search_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi/ic_search_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_shop_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi/ic_shop_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_star_border_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi/ic_star_border_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_star_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi/ic_star_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-hdpi/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi-v11/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi-v11/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_search_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi/ic_search_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_shop_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi/ic_shop_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_star_border_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi/ic_star_border_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_star_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi/ic_star_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-mdpi/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi-v11/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi-v11/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_search_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi/ic_search_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_shop_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi/ic_shop_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_star_border_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi/ic_star_border_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_star_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi/ic_star_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xhdpi/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi-v11/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi-v11/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_search_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi/ic_search_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_shop_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi/ic_shop_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_star_border_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi/ic_star_border_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_star_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi/ic_star_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxhdpi/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi-v11/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi-v11/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_search_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi/ic_search_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_shop_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi/ic_shop_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_star_border_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi/ic_star_border_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_star_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi/ic_star_white_36dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_stat_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable-xxxhdpi/ic_stat_000.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/image10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable/image10.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/drawable/logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/myshape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_show_post.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 15 | 16 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_show_posts.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_view_pager_images.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/article_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/cell_cards.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 23 | 24 | 27 | 28 | 34 | 35 | 47 | 48 | 49 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 19 | 23 | 24 | 35 | 36 | 37 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_category.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 16 | 17 | 18 | 19 | 27 | 28 | 29 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/widget_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 14 | 15 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 12 | 13 | 17 | 18 | 22 | 23 | 27 | 28 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_post.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | derniere_24h 6 | actualites 7 | applications 8 | astuces 9 | jeux 10 | tutoriels 11 | 12 | 13 | 14 | Dernières 24h 15 | Actualités 16 | Applications 17 | Astuces 18 | Jeux 19 | Tutoriels 20 | Favoris 21 | Paramètres 22 | Contact 23 | Notez l\'application 24 | A propos 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #9fd54c 5 | #8DBB49 6 | #DCEDC8 7 | #FFC107 8 | #212121 9 | #727272 10 | #212121 11 | #B6B6B6 12 | 13 | 14 | #FAFAFA 15 | 16 | 17 | #F5DEB3 18 | 19 | #FF5722 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroiDZ 3 | 4 | UA-71398009-1 5 | 6 | Hello world! 7 | Settings 8 | 9 | Recherche 10 | Partager 11 | 12 | dz-android.com 13 | 14 | Notifications 15 | Son 16 | Vibreur 17 | 18 | Appuyer encore une fois pour quitter 19 | 20 | Son pour les notifications 21 | Activer les notifications 22 | Options 23 | 24 | Aucun résultat 25 | 26 | Article ajouté dans les favoris 27 | Article retiré des favoris 28 | 29 | Vibreur 30 | Vibreur pour les notifications 31 | 32 | Led Flash 33 | Faire clignoter le led du flash 34 | 35 | Réglages 36 | 37 | Pas de connexion internet 38 | 39 | Oui 40 | Cool ! 41 | Non 42 | 43 | Aimes-tu AndroiDZ ? 44 | Veux-tu noter l\'application ? 45 | 46 | Cacher les lus 47 | Tout marquer comme lu 48 | Tout supprimer 49 | Supprimer tous les lus 50 | 51 | 52 | Cacher les articles lus 53 | Article lu 54 | 55 | Application developped by Squalala Team

]]>
56 | 57 | 58 |
59 | 60 | 61 | Depuis le lancement d’AndroiDZ, notre principal objectif est la vulgarisation des nouvelles technologies avec une spécialité prononcée pour Android et les terminaux tournant sous cet OS, pour nos visiteurs Algériens et nos visiteurs à travers le monde (visiteurs de plus de 30 pays). 62 | 63 |

64 | Vous cherchez un téléphone ou souhaitez maîtriser parfaitement le vôtre ? Nos articles, dossiers et tutoriels sont là pour vous informer et vous guider. Votre smartphone n’aura plus aucun secret pour vous. 65 |
66 | Nous vous ferons découvrir les meilleures applications Android sur le Google Play. 67 |
68 | Si les tablettes vous intéressent, vous pourrez suivre l’actualité des différentes marques. Elles sont nombreuses et s’y retrouver est compliqué. AndroiDZ est là pour vous informer et vous guider dans l’univers Android.]]>
69 | 70 |
71 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 11 | 12 | 17 | 18 | 23 | 24 | 29 | 30 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/xml/widget_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /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.1.3' 9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+' 10 | classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1' 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | jcenter() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /com/squalala/android_dz/Customer.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import java.util.List; 4 | import com.squalala.dz6android.DaoSession; 5 | import de.greenrobot.dao.DaoException; 6 | 7 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 8 | /** 9 | * Entity mapped to table "CUSTOMER". 10 | */ 11 | public class Customer { 12 | 13 | private Long id; 14 | /** Not-null value. */ 15 | private String name; 16 | 17 | /** Used to resolve relations */ 18 | private transient DaoSession daoSession; 19 | 20 | /** Used for active entity operations. */ 21 | private transient CustomerDao myDao; 22 | 23 | private List orders; 24 | 25 | public Customer() { 26 | } 27 | 28 | public Customer(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public Customer(Long id, String name) { 33 | this.id = id; 34 | this.name = name; 35 | } 36 | 37 | /** called by internal mechanisms, do not call yourself. */ 38 | public void __setDaoSession(DaoSession daoSession) { 39 | this.daoSession = daoSession; 40 | myDao = daoSession != null ? daoSession.getCustomerDao() : null; 41 | } 42 | 43 | public Long getId() { 44 | return id; 45 | } 46 | 47 | public void setId(Long id) { 48 | this.id = id; 49 | } 50 | 51 | /** Not-null value. */ 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | /** Not-null value; ensure this value is available before it is saved to the database. */ 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | /** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */ 62 | public List getOrders() { 63 | if (orders == null) { 64 | if (daoSession == null) { 65 | throw new DaoException("Entity is detached from DAO context"); 66 | } 67 | OrderDao targetDao = daoSession.getOrderDao(); 68 | List ordersNew = targetDao._queryCustomer_Orders(id); 69 | synchronized (this) { 70 | if(orders == null) { 71 | orders = ordersNew; 72 | } 73 | } 74 | } 75 | return orders; 76 | } 77 | 78 | /** Resets a to-many relationship, making the next get call to query for a fresh result. */ 79 | public synchronized void resetOrders() { 80 | orders = null; 81 | } 82 | 83 | /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */ 84 | public void delete() { 85 | if (myDao == null) { 86 | throw new DaoException("Entity is detached from DAO context"); 87 | } 88 | myDao.delete(this); 89 | } 90 | 91 | /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */ 92 | public void update() { 93 | if (myDao == null) { 94 | throw new DaoException("Entity is detached from DAO context"); 95 | } 96 | myDao.update(this); 97 | } 98 | 99 | /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */ 100 | public void refresh() { 101 | if (myDao == null) { 102 | throw new DaoException("Entity is detached from DAO context"); 103 | } 104 | myDao.refresh(this); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /com/squalala/android_dz/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.Property; 9 | import de.greenrobot.dao.internal.DaoConfig; 10 | 11 | import com.squalala.dz6android.Customer; 12 | 13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 14 | /** 15 | * DAO for table "CUSTOMER". 16 | */ 17 | public class CustomerDao extends AbstractDao { 18 | 19 | public static final String TABLENAME = "CUSTOMER"; 20 | 21 | /** 22 | * Properties of entity Customer.
23 | * Can be used for QueryBuilder and for referencing column names. 24 | */ 25 | public static class Properties { 26 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 27 | public final static Property Name = new Property(1, String.class, "name", false, "NAME"); 28 | }; 29 | 30 | private DaoSession daoSession; 31 | 32 | 33 | public CustomerDao(DaoConfig config) { 34 | super(config); 35 | } 36 | 37 | public CustomerDao(DaoConfig config, DaoSession daoSession) { 38 | super(config, daoSession); 39 | this.daoSession = daoSession; 40 | } 41 | 42 | /** Creates the underlying database table. */ 43 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 44 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 45 | db.execSQL("CREATE TABLE " + constraint + "\"CUSTOMER\" (" + // 46 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id 47 | "\"NAME\" TEXT NOT NULL );"); // 1: name 48 | } 49 | 50 | /** Drops the underlying database table. */ 51 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 52 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CUSTOMER\""; 53 | db.execSQL(sql); 54 | } 55 | 56 | /** @inheritdoc */ 57 | @Override 58 | protected void bindValues(SQLiteStatement stmt, Customer entity) { 59 | stmt.clearBindings(); 60 | 61 | Long id = entity.getId(); 62 | if (id != null) { 63 | stmt.bindLong(1, id); 64 | } 65 | stmt.bindString(2, entity.getName()); 66 | } 67 | 68 | @Override 69 | protected void attachEntity(Customer entity) { 70 | super.attachEntity(entity); 71 | entity.__setDaoSession(daoSession); 72 | } 73 | 74 | /** @inheritdoc */ 75 | @Override 76 | public Long readKey(Cursor cursor, int offset) { 77 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 78 | } 79 | 80 | /** @inheritdoc */ 81 | @Override 82 | public Customer readEntity(Cursor cursor, int offset) { 83 | Customer entity = new Customer( // 84 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 85 | cursor.getString(offset + 1) // name 86 | ); 87 | return entity; 88 | } 89 | 90 | /** @inheritdoc */ 91 | @Override 92 | public void readEntity(Cursor cursor, Customer entity, int offset) { 93 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 94 | entity.setName(cursor.getString(offset + 1)); 95 | } 96 | 97 | /** @inheritdoc */ 98 | @Override 99 | protected Long updateKeyAfterInsert(Customer entity, long rowId) { 100 | entity.setId(rowId); 101 | return rowId; 102 | } 103 | 104 | /** @inheritdoc */ 105 | @Override 106 | public Long getKey(Customer entity) { 107 | if(entity != null) { 108 | return entity.getId(); 109 | } else { 110 | return null; 111 | } 112 | } 113 | 114 | /** @inheritdoc */ 115 | @Override 116 | protected boolean isEntityUpdateable() { 117 | return true; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /com/squalala/android_dz/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | import de.greenrobot.dao.AbstractDaoMaster; 9 | import de.greenrobot.dao.identityscope.IdentityScopeType; 10 | 11 | import com.squalala.dz6android.NoteDao; 12 | import com.squalala.dz6android.CustomerDao; 13 | import com.squalala.dz6android.OrderDao; 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | /** 17 | * Master of DAO (schema version 1000): knows all DAOs. 18 | */ 19 | public class DaoMaster extends AbstractDaoMaster { 20 | public static final int SCHEMA_VERSION = 1000; 21 | 22 | /** Creates underlying database table using DAOs. */ 23 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { 24 | NoteDao.createTable(db, ifNotExists); 25 | CustomerDao.createTable(db, ifNotExists); 26 | OrderDao.createTable(db, ifNotExists); 27 | } 28 | 29 | /** Drops underlying database table using DAOs. */ 30 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { 31 | NoteDao.dropTable(db, ifExists); 32 | CustomerDao.dropTable(db, ifExists); 33 | OrderDao.dropTable(db, ifExists); 34 | } 35 | 36 | public static abstract class OpenHelper extends SQLiteOpenHelper { 37 | 38 | public OpenHelper(Context context, String name, CursorFactory factory) { 39 | super(context, name, factory, SCHEMA_VERSION); 40 | } 41 | 42 | @Override 43 | public void onCreate(SQLiteDatabase db) { 44 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 45 | createAllTables(db, false); 46 | } 47 | } 48 | 49 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 50 | public static class DevOpenHelper extends OpenHelper { 51 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 52 | super(context, name, factory); 53 | } 54 | 55 | @Override 56 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 57 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 58 | dropAllTables(db, true); 59 | onCreate(db); 60 | } 61 | } 62 | 63 | public DaoMaster(SQLiteDatabase db) { 64 | super(db, SCHEMA_VERSION); 65 | registerDaoClass(NoteDao.class); 66 | registerDaoClass(CustomerDao.class); 67 | registerDaoClass(OrderDao.class); 68 | } 69 | 70 | public DaoSession newSession() { 71 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 72 | } 73 | 74 | public DaoSession newSession(IdentityScopeType type) { 75 | return new DaoSession(db, type, daoConfigMap); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /com/squalala/android_dz/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.Map; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.AbstractDaoSession; 9 | import de.greenrobot.dao.identityscope.IdentityScopeType; 10 | import de.greenrobot.dao.internal.DaoConfig; 11 | 12 | import com.squalala.dz6android.Note; 13 | import com.squalala.dz6android.Customer; 14 | import com.squalala.dz6android.Order; 15 | 16 | import com.squalala.dz6android.NoteDao; 17 | import com.squalala.dz6android.CustomerDao; 18 | import com.squalala.dz6android.OrderDao; 19 | 20 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 21 | 22 | /** 23 | * {@inheritDoc} 24 | * 25 | * @see de.greenrobot.dao.AbstractDaoSession 26 | */ 27 | public class DaoSession extends AbstractDaoSession { 28 | 29 | private final DaoConfig noteDaoConfig; 30 | private final DaoConfig customerDaoConfig; 31 | private final DaoConfig orderDaoConfig; 32 | 33 | private final NoteDao noteDao; 34 | private final CustomerDao customerDao; 35 | private final OrderDao orderDao; 36 | 37 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 38 | daoConfigMap) { 39 | super(db); 40 | 41 | noteDaoConfig = daoConfigMap.get(NoteDao.class).clone(); 42 | noteDaoConfig.initIdentityScope(type); 43 | 44 | customerDaoConfig = daoConfigMap.get(CustomerDao.class).clone(); 45 | customerDaoConfig.initIdentityScope(type); 46 | 47 | orderDaoConfig = daoConfigMap.get(OrderDao.class).clone(); 48 | orderDaoConfig.initIdentityScope(type); 49 | 50 | noteDao = new NoteDao(noteDaoConfig, this); 51 | customerDao = new CustomerDao(customerDaoConfig, this); 52 | orderDao = new OrderDao(orderDaoConfig, this); 53 | 54 | registerDao(Note.class, noteDao); 55 | registerDao(Customer.class, customerDao); 56 | registerDao(Order.class, orderDao); 57 | } 58 | 59 | public void clear() { 60 | noteDaoConfig.getIdentityScope().clear(); 61 | customerDaoConfig.getIdentityScope().clear(); 62 | orderDaoConfig.getIdentityScope().clear(); 63 | } 64 | 65 | public NoteDao getNoteDao() { 66 | return noteDao; 67 | } 68 | 69 | public CustomerDao getCustomerDao() { 70 | return customerDao; 71 | } 72 | 73 | public OrderDao getOrderDao() { 74 | return orderDao; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /com/squalala/android_dz/Note.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table "NOTE". 6 | */ 7 | public class Note { 8 | 9 | private Long id; 10 | /** Not-null value. */ 11 | private String text; 12 | private String comment; 13 | private java.util.Date date; 14 | 15 | public Note() { 16 | } 17 | 18 | public Note(Long id) { 19 | this.id = id; 20 | } 21 | 22 | public Note(Long id, String text, String comment, java.util.Date date) { 23 | this.id = id; 24 | this.text = text; 25 | this.comment = comment; 26 | this.date = date; 27 | } 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | /** Not-null value. */ 38 | public String getText() { 39 | return text; 40 | } 41 | 42 | /** Not-null value; ensure this value is available before it is saved to the database. */ 43 | public void setText(String text) { 44 | this.text = text; 45 | } 46 | 47 | public String getComment() { 48 | return comment; 49 | } 50 | 51 | public void setComment(String comment) { 52 | this.comment = comment; 53 | } 54 | 55 | public java.util.Date getDate() { 56 | return date; 57 | } 58 | 59 | public void setDate(java.util.Date date) { 60 | this.date = date; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /com/squalala/android_dz/NoteDao.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.Property; 9 | import de.greenrobot.dao.internal.DaoConfig; 10 | 11 | import com.squalala.dz6android.Note; 12 | 13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 14 | /** 15 | * DAO for table "NOTE". 16 | */ 17 | public class NoteDao extends AbstractDao { 18 | 19 | public static final String TABLENAME = "NOTE"; 20 | 21 | /** 22 | * Properties of entity Note.
23 | * Can be used for QueryBuilder and for referencing column names. 24 | */ 25 | public static class Properties { 26 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 27 | public final static Property Text = new Property(1, String.class, "text", false, "TEXT"); 28 | public final static Property Comment = new Property(2, String.class, "comment", false, "COMMENT"); 29 | public final static Property Date = new Property(3, java.util.Date.class, "date", false, "DATE"); 30 | }; 31 | 32 | 33 | public NoteDao(DaoConfig config) { 34 | super(config); 35 | } 36 | 37 | public NoteDao(DaoConfig config, DaoSession daoSession) { 38 | super(config, daoSession); 39 | } 40 | 41 | /** Creates the underlying database table. */ 42 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 43 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 44 | db.execSQL("CREATE TABLE " + constraint + "\"NOTE\" (" + // 45 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id 46 | "\"TEXT\" TEXT NOT NULL ," + // 1: text 47 | "\"COMMENT\" TEXT," + // 2: comment 48 | "\"DATE\" INTEGER);"); // 3: date 49 | } 50 | 51 | /** Drops the underlying database table. */ 52 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 53 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"NOTE\""; 54 | db.execSQL(sql); 55 | } 56 | 57 | /** @inheritdoc */ 58 | @Override 59 | protected void bindValues(SQLiteStatement stmt, Note entity) { 60 | stmt.clearBindings(); 61 | 62 | Long id = entity.getId(); 63 | if (id != null) { 64 | stmt.bindLong(1, id); 65 | } 66 | stmt.bindString(2, entity.getText()); 67 | 68 | String comment = entity.getComment(); 69 | if (comment != null) { 70 | stmt.bindString(3, comment); 71 | } 72 | 73 | java.util.Date date = entity.getDate(); 74 | if (date != null) { 75 | stmt.bindLong(4, date.getTime()); 76 | } 77 | } 78 | 79 | /** @inheritdoc */ 80 | @Override 81 | public Long readKey(Cursor cursor, int offset) { 82 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 83 | } 84 | 85 | /** @inheritdoc */ 86 | @Override 87 | public Note readEntity(Cursor cursor, int offset) { 88 | Note entity = new Note( // 89 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 90 | cursor.getString(offset + 1), // text 91 | cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // comment 92 | cursor.isNull(offset + 3) ? null : new java.util.Date(cursor.getLong(offset + 3)) // date 93 | ); 94 | return entity; 95 | } 96 | 97 | /** @inheritdoc */ 98 | @Override 99 | public void readEntity(Cursor cursor, Note entity, int offset) { 100 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 101 | entity.setText(cursor.getString(offset + 1)); 102 | entity.setComment(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); 103 | entity.setDate(cursor.isNull(offset + 3) ? null : new java.util.Date(cursor.getLong(offset + 3))); 104 | } 105 | 106 | /** @inheritdoc */ 107 | @Override 108 | protected Long updateKeyAfterInsert(Note entity, long rowId) { 109 | entity.setId(rowId); 110 | return rowId; 111 | } 112 | 113 | /** @inheritdoc */ 114 | @Override 115 | public Long getKey(Note entity) { 116 | if(entity != null) { 117 | return entity.getId(); 118 | } else { 119 | return null; 120 | } 121 | } 122 | 123 | /** @inheritdoc */ 124 | @Override 125 | protected boolean isEntityUpdateable() { 126 | return true; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /com/squalala/android_dz/Order.java: -------------------------------------------------------------------------------- 1 | package com.squalala.dz6android; 2 | 3 | import com.squalala.dz6android.DaoSession; 4 | import de.greenrobot.dao.DaoException; 5 | 6 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 7 | /** 8 | * Entity mapped to table "ORDERS". 9 | */ 10 | public class Order { 11 | 12 | private Long id; 13 | private java.util.Date date; 14 | private long customerId; 15 | 16 | /** Used to resolve relations */ 17 | private transient DaoSession daoSession; 18 | 19 | /** Used for active entity operations. */ 20 | private transient OrderDao myDao; 21 | 22 | private Customer customer; 23 | private Long customer__resolvedKey; 24 | 25 | 26 | public Order() { 27 | } 28 | 29 | public Order(Long id) { 30 | this.id = id; 31 | } 32 | 33 | public Order(Long id, java.util.Date date, long customerId) { 34 | this.id = id; 35 | this.date = date; 36 | this.customerId = customerId; 37 | } 38 | 39 | /** called by internal mechanisms, do not call yourself. */ 40 | public void __setDaoSession(DaoSession daoSession) { 41 | this.daoSession = daoSession; 42 | myDao = daoSession != null ? daoSession.getOrderDao() : null; 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public void setId(Long id) { 50 | this.id = id; 51 | } 52 | 53 | public java.util.Date getDate() { 54 | return date; 55 | } 56 | 57 | public void setDate(java.util.Date date) { 58 | this.date = date; 59 | } 60 | 61 | public long getCustomerId() { 62 | return customerId; 63 | } 64 | 65 | public void setCustomerId(long customerId) { 66 | this.customerId = customerId; 67 | } 68 | 69 | /** To-one relationship, resolved on first access. */ 70 | public Customer getCustomer() { 71 | long __key = this.customerId; 72 | if (customer__resolvedKey == null || !customer__resolvedKey.equals(__key)) { 73 | if (daoSession == null) { 74 | throw new DaoException("Entity is detached from DAO context"); 75 | } 76 | CustomerDao targetDao = daoSession.getCustomerDao(); 77 | Customer customerNew = targetDao.load(__key); 78 | synchronized (this) { 79 | customer = customerNew; 80 | customer__resolvedKey = __key; 81 | } 82 | } 83 | return customer; 84 | } 85 | 86 | public void setCustomer(Customer customer) { 87 | if (customer == null) { 88 | throw new DaoException("To-one property 'customerId' has not-null constraint; cannot set to-one to null"); 89 | } 90 | synchronized (this) { 91 | this.customer = customer; 92 | customerId = customer.getId(); 93 | customer__resolvedKey = customerId; 94 | } 95 | } 96 | 97 | /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */ 98 | public void delete() { 99 | if (myDao == null) { 100 | throw new DaoException("Entity is detached from DAO context"); 101 | } 102 | myDao.delete(this); 103 | } 104 | 105 | /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */ 106 | public void update() { 107 | if (myDao == null) { 108 | throw new DaoException("Entity is detached from DAO context"); 109 | } 110 | myDao.update(this); 111 | } 112 | 113 | /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */ 114 | public void refresh() { 115 | if (myDao == null) { 116 | throw new DaoException("Entity is detached from DAO context"); 117 | } 118 | myDao.refresh(this); 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /device-2015-11-18-182906.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-11-18-182906.png -------------------------------------------------------------------------------- /device-2015-11-18-182916.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-11-18-182916.png -------------------------------------------------------------------------------- /device-2015-11-18-183006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-11-18-183006.png -------------------------------------------------------------------------------- /device-2015-11-18-183447.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-11-18-183447.png -------------------------------------------------------------------------------- /device-2015-12-15-151621.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-12-15-151621.png -------------------------------------------------------------------------------- /device-2015-12-15-151643.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-12-15-151643.png -------------------------------------------------------------------------------- /device-2015-12-15-151704.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-12-15-151704.png -------------------------------------------------------------------------------- /device-2015-12-15-152000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/device-2015-12-15-152000.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackPackerDz/Wordpress-Android/3a1aa78a799fa77baa36dbad517fbf9e74d5c5d0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Sep 13 21:42:00 CET 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lib/lib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /libgenerator/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /libgenerator/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: ['*.jar']) 5 | 6 | compile 'de.greenrobot:greendao-generator:2.0.0' 7 | } -------------------------------------------------------------------------------- /libgenerator/libgenerator.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /libgenerator/src/main/java/com/example/Generator.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import de.greenrobot.daogenerator.DaoGenerator; 4 | import de.greenrobot.daogenerator.Entity; 5 | import de.greenrobot.daogenerator.Property; 6 | import de.greenrobot.daogenerator.Schema; 7 | import de.greenrobot.daogenerator.ToMany; 8 | 9 | public class Generator { 10 | 11 | public static void main(String[] args) throws Exception { 12 | Schema schema = new Schema(1000, "com.squalala.android_dz.greendao"); 13 | 14 | addArticle(schema); 15 | // addNote(schema); 16 | // addCustomerOrder(schema); 17 | 18 | new DaoGenerator().generateAll(schema, "../Androiddz/app/src/main/java"); 19 | } 20 | 21 | private static void addArticle(Schema schema) { 22 | 23 | Entity article = schema.addEntity("Article"); 24 | article.addIdProperty(); 25 | article.addStringProperty("title").notNull(); 26 | article.addStringProperty("content").notNull(); 27 | article.addStringProperty("urlImage"); 28 | article.addStringProperty("link"); 29 | article.addStringProperty("author"); 30 | // lu ou non lu 31 | article.addBooleanProperty("status"); 32 | // Supprimer ou non 33 | article.addBooleanProperty("deleted"); 34 | article.addBooleanProperty("favoris"); 35 | article.addDateProperty("date"); 36 | 37 | Entity category = schema.addEntity("Category"); 38 | category.addIdProperty(); 39 | category.addStringProperty("name"); 40 | category.addStringProperty("slug"); 41 | 42 | Entity categoryArticle = schema.addEntity("CategoryArticle"); 43 | categoryArticle.addIdProperty(); 44 | 45 | Property categoryId = categoryArticle.addLongProperty("categoryId").notNull().getProperty(); 46 | ToMany categoryToArticle = category.addToMany(categoryArticle, categoryId); 47 | categoryArticle.addToOne(category, categoryId); 48 | categoryToArticle.setName("categories"); 49 | 50 | Property articleId = categoryArticle.addLongProperty("articleId").notNull().getProperty(); 51 | ToMany articleToCategories = article.addToMany(categoryArticle, articleId); 52 | categoryArticle.addToOne(article, articleId); 53 | articleToCategories.setName("articles"); 54 | } 55 | 56 | private static void addNote(Schema schema) { 57 | Entity note = schema.addEntity("Note"); 58 | note.addIdProperty(); 59 | note.addStringProperty("text").notNull(); 60 | note.addStringProperty("comment"); 61 | note.addDateProperty("date"); 62 | } 63 | 64 | private static void addCustomerOrder(Schema schema) { 65 | Entity customer = schema.addEntity("Customer"); 66 | customer.addIdProperty(); 67 | customer.addStringProperty("name").notNull(); 68 | 69 | Entity order = schema.addEntity("Order"); 70 | order.setTableName("ORDERS"); // "ORDER" is a reserved keyword 71 | order.addIdProperty(); 72 | Property orderDate = order.addDateProperty("date").getProperty(); 73 | Property customerId = order.addLongProperty("customerId").notNull().getProperty(); 74 | order.addToOne(customer, customerId); 75 | 76 | ToMany customerToOrders = customer.addToMany(order, customerId); 77 | customerToOrders.setName("orders"); 78 | customerToOrders.orderAsc(orderDate); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':libgenerator' 2 | --------------------------------------------------------------------------------