├── config
├── libraries.gradle
└── quality
│ ├── findbugs
│ └── android-exclude-filter.xml
│ ├── pmd
│ └── pmd-ruleset.xml
│ └── quality.gradle
├── app
├── .gitignore
├── keystore
│ └── release.jks
├── src
│ ├── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── retweet.png
│ │ │ │ ├── widget.png
│ │ │ │ ├── ic_user_type_verified.png
│ │ │ │ ├── bg_message_to_light.xml
│ │ │ │ ├── bg_message_to_dark.xml
│ │ │ │ ├── bg_message_from.xml
│ │ │ │ └── light_ripple.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_notify.png
│ │ │ │ ├── ic_location.png
│ │ │ │ └── ic_action_save.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_notify.png
│ │ │ │ ├── ic_location.png
│ │ │ │ └── ic_action_save.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_notify.png
│ │ │ │ ├── ic_location.png
│ │ │ │ └── ic_action_save.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-hdpi-v9
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-mdpi-v9
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_notify.png
│ │ │ │ ├── ic_location.png
│ │ │ │ └── ic_action_save.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-hdpi-v11
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-mdpi-v11
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-xhdpi-v11
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-xhdpi-v9
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-xxhdpi-v11
│ │ │ │ └── ic_notify.png
│ │ │ ├── drawable-xxhdpi-v9
│ │ │ │ └── ic_notify.png
│ │ │ ├── xml
│ │ │ │ ├── track_app.xml
│ │ │ │ ├── account_authenticator.xml
│ │ │ │ ├── sync.xml
│ │ │ │ ├── widget_collection.xml
│ │ │ │ ├── recycler_view.xml
│ │ │ │ └── preference.xml
│ │ │ ├── values
│ │ │ │ ├── attr.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── preference.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── anim
│ │ │ │ ├── scale_up.xml
│ │ │ │ └── scale_down.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_message.xml
│ │ │ │ ├── menu_tweet.xml
│ │ │ │ ├── menu_trends.xml
│ │ │ │ ├── menu_login.xml
│ │ │ │ ├── menu_main_screen.xml
│ │ │ │ ├── menu_settings.xml
│ │ │ │ ├── menu_tweet_detail.xml
│ │ │ │ ├── menu_interactions.xml
│ │ │ │ ├── menu_message_compose.xml
│ │ │ │ └── menu_image_viewer.xml
│ │ │ ├── layout
│ │ │ │ ├── widget_collection.xml
│ │ │ │ ├── content_trends.xml
│ │ │ │ ├── content_login.xml
│ │ │ │ ├── content_image_viewer.xml
│ │ │ │ ├── content_tweet_detail.xml
│ │ │ │ ├── content_interactions.xml
│ │ │ │ ├── content_main_screen.xml
│ │ │ │ ├── content_message.xml
│ │ │ │ ├── content_message_compose.xml
│ │ │ │ ├── fragment_interactions.xml
│ │ │ │ ├── fragment_local_trends.xml
│ │ │ │ ├── fragment_trends.xml
│ │ │ │ ├── item_trend.xml
│ │ │ │ ├── activity_message.xml
│ │ │ │ ├── activity_interactions.xml
│ │ │ │ ├── activity_image_viewer.xml
│ │ │ │ ├── activity_tweet_detail.xml
│ │ │ │ ├── activity_login.xml
│ │ │ │ ├── activity_message_compose.xml
│ │ │ │ ├── message_bubble_left.xml
│ │ │ │ ├── message_bubble_right.xml
│ │ │ │ ├── fragment_image_viewer.xml
│ │ │ │ ├── fragment_message.xml
│ │ │ │ ├── activity_settings.xml
│ │ │ │ ├── fragment_login.xml
│ │ │ │ ├── activity_main_screen.xml
│ │ │ │ ├── activity_trends.xml
│ │ │ │ ├── activity_tweet.xml
│ │ │ │ ├── fragment_message_compose.xml
│ │ │ │ ├── item_widget.xml
│ │ │ │ ├── fragment_main_screen.xml
│ │ │ │ ├── item_direct_message.xml
│ │ │ │ └── content_tweet.xml
│ │ │ └── transition
│ │ │ │ └── changebounds_with_arcmotion.xml
│ │ ├── assets
│ │ │ └── fonts
│ │ │ │ └── roboto-mono-regular.ttf
│ │ └── java
│ │ │ └── com
│ │ │ └── ladwa
│ │ │ └── aditya
│ │ │ └── twitone
│ │ │ ├── ui
│ │ │ ├── base
│ │ │ │ ├── MvpView.java
│ │ │ │ ├── MvpPresenter.java
│ │ │ │ ├── BasePresenter.java
│ │ │ │ ├── BaseFragment.java
│ │ │ │ └── BaseActivity.java
│ │ │ ├── tweetdetail
│ │ │ │ ├── TweetDetailPresenter.java
│ │ │ │ └── TweetDetail.java
│ │ │ ├── settings
│ │ │ │ ├── SettingsStore.java
│ │ │ │ ├── SettingsActivity.java
│ │ │ │ ├── SettingsRepository.java
│ │ │ │ └── SettingsActivityFragment.java
│ │ │ ├── tweet
│ │ │ │ └── TweetPresenter.java
│ │ │ ├── widget
│ │ │ │ ├── WidgetCollectionService.java
│ │ │ │ ├── WidgetCollectionProvider.java
│ │ │ │ └── WidgetCollectionRemoteFactory.java
│ │ │ ├── login
│ │ │ │ ├── LoginActivity.java
│ │ │ │ └── LoginContract.java
│ │ │ ├── message
│ │ │ │ ├── Message.java
│ │ │ │ └── MessageContract.java
│ │ │ ├── imageviewer
│ │ │ │ └── ImageViewer.java
│ │ │ ├── interactions
│ │ │ │ ├── Interactions.java
│ │ │ │ └── InteractionsContract.java
│ │ │ ├── trends
│ │ │ │ └── TrendsContract.java
│ │ │ ├── messagecompose
│ │ │ │ ├── MessageCompose.java
│ │ │ │ ├── MessageComposeContract.java
│ │ │ │ └── MessageComposePresenter.java
│ │ │ ├── mainscreen
│ │ │ │ ├── MainScreenContract.java
│ │ │ │ └── EndlessRecyclerOnScrollListener.java
│ │ │ ├── customview
│ │ │ │ └── ChatBubbleTextView.java
│ │ │ └── adapter
│ │ │ │ ├── TrendAdapter.java
│ │ │ │ ├── DirectMessageAdapter.java
│ │ │ │ └── MessageComposeAdapter.java
│ │ │ ├── BasePresenter.java
│ │ │ ├── BaseView.java
│ │ │ ├── injection
│ │ │ ├── PerFragment.java
│ │ │ ├── PerActivity.java
│ │ │ ├── ConfigPersistent.java
│ │ │ ├── ActivityContext.java
│ │ │ ├── ApplicationContext.java
│ │ │ ├── component
│ │ │ │ ├── ActivityComponent.java
│ │ │ │ ├── FragmentComponent.java
│ │ │ │ ├── ConfigPersistentComponent.java
│ │ │ │ └── ApplicationComponent.java
│ │ │ └── module
│ │ │ │ ├── ActivityModule.java
│ │ │ │ ├── FragmentModule.java
│ │ │ │ └── ApplicationModule.java
│ │ │ ├── util
│ │ │ ├── CustomeScope.java
│ │ │ ├── Constants.java
│ │ │ ├── GlideConfiguration.java
│ │ │ ├── ScrollAwareFabBehaviour.java
│ │ │ ├── ConnectionReceiver.java
│ │ │ ├── NotificationUtil.java
│ │ │ ├── AnimationUtil.java
│ │ │ └── Utility.java
│ │ │ ├── AppModule.java
│ │ │ ├── data
│ │ │ ├── sync
│ │ │ │ ├── AuthenticatorService.java
│ │ │ │ ├── SyncService.java
│ │ │ │ └── Authenticator.java
│ │ │ ├── TwitterDataStore.java
│ │ │ ├── local
│ │ │ │ ├── TwitterDbHelper.java
│ │ │ │ └── models
│ │ │ │ │ ├── Trend.java
│ │ │ │ │ └── User.java
│ │ │ ├── remote
│ │ │ │ └── TwitterModule.java
│ │ │ └── TwitterComponent.java
│ │ │ └── BaseActivity.java
│ ├── androidTest
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── ladwa
│ │ │ └── aditya
│ │ │ └── twitone
│ │ │ ├── ApplicationTest.java
│ │ │ ├── LoginTest.java
│ │ │ └── LogoutTest.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── ladwa
│ │ └── aditya
│ │ └── twitone
│ │ └── ExampleUnitTest.java
├── google-services.json
└── proguard-rules.pro
├── settings.gradle
├── app-release.apk
├── screenshot
├── 1.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
└── 7.png
├── .idea
├── sonarlint
│ └── issuestore
│ │ └── index.pb
├── copyright
│ └── profiles_settings.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── vcs.xml
├── dictionaries
│ └── Aditya.xml
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
├── checkstyle-idea.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
├── misc.xml
└── markdown-navigator.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── README.md
/config/libraries.gradle:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app-release.apk
--------------------------------------------------------------------------------
/screenshot/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/1.png
--------------------------------------------------------------------------------
/screenshot/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/2.png
--------------------------------------------------------------------------------
/screenshot/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/3.png
--------------------------------------------------------------------------------
/screenshot/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/4.png
--------------------------------------------------------------------------------
/screenshot/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/5.png
--------------------------------------------------------------------------------
/screenshot/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/6.png
--------------------------------------------------------------------------------
/screenshot/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/screenshot/7.png
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/index.pb:
--------------------------------------------------------------------------------
1 |
2 | <
3 | build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
--------------------------------------------------------------------------------
/app/keystore/release.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/keystore/release.jks
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/retweet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable/retweet.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/widget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable/widget.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-hdpi/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-mdpi/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi-v9/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-hdpi-v9/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-hdpi/ic_location.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi-v9/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-mdpi-v9/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-mdpi/ic_location.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_location.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/roboto-mono-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/assets/fonts/roboto-mono-regular.ttf
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/base/MvpView.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.base;
2 |
3 |
4 | public interface MvpView {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi-v11/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-hdpi-v11/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-hdpi/ic_action_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi-v11/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-mdpi-v11/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-mdpi/ic_action_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi-v11/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xhdpi-v11/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi-v9/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xhdpi-v9/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_action_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi-v11/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xxhdpi-v11/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi-v9/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xxhdpi-v9/ic_notify.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_location.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_user_type_verified.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityaladwa/TwiTone-Android/HEAD/app/src/main/res/drawable/ic_user_type_verified.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/dictionaries/Aditya.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | aditya
5 | recieve
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/track_app.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | UA-57017077-2
4 | true
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/base/MvpPresenter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.base;
2 |
3 | public interface MvpPresenter {
4 |
5 | void attachView(V mvpView);
6 |
7 | void detachView();
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | /**
4 | * Created by Aditya on 25-Jun-16.
5 | */
6 | public interface BasePresenter {
7 | void subscribe();
8 |
9 | void unsubscribe();
10 | }
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 13 00:01:20 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | /**
4 | * A Base Presenter which is inherited by all other Presenters
5 | * Created by Aditya on 25-Jun-16.
6 | */
7 | public interface BaseView {
8 | void setPresenter(T presenter);
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_message_to_light.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_message_to_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/PerFragment.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection;
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 PerFragment {
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/PerActivity.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection;
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 PerActivity {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_message_from.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/ConfigPersistent.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection;
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 ConfigPersistent {
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/ActivityContext.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Qualifier;
7 |
8 | @Qualifier
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface ActivityContext {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/ApplicationContext.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Qualifier;
7 |
8 | @Qualifier
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface ApplicationContext {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #99ffffff
7 | #994d4d4d
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/account_authenticator.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/sync.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/scale_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/scale_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_message.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/CustomeScope.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 |
7 | import javax.inject.Scope;
8 |
9 | /**
10 | * Created by Aditya on 25-Jun-16.
11 | */
12 | @Documented
13 | @Scope
14 | @Retention(RetentionPolicy.RUNTIME)
15 | public @interface CustomeScope {
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_tweet.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/widget_collection.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_trends.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_login.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ladwa/aditya/twitone/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main_screen.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_settings.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_tweet_detail.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_interactions.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget_collection.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_message_compose.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/transition/changebounds_with_arcmotion.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/config/quality/findbugs/android-exclude-filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/tweetdetail/TweetDetailPresenter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.tweetdetail;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 |
6 | /**
7 | * A Presenter for Tweet Detail
8 | * Created by Aditya on 30-Jul-16.
9 | */
10 | public interface TweetDetailPresenter {
11 | interface View extends BaseView {
12 |
13 | }
14 |
15 | interface Presenter extends BasePresenter {
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/settings/SettingsStore.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.settings;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * An Interface that defines various setting that a yser can change
7 | * Created by Aditya on 20-Oct-16.
8 | */
9 |
10 | public interface SettingsStore {
11 | String getTheme();
12 |
13 | void setTheme(Context context);
14 |
15 | boolean isNotificationEnabled(Context context);
16 |
17 | int getSyncDuration(Context context);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_image_viewer.xml:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/component/ActivityComponent.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.component;
2 |
3 |
4 | import com.ladwa.aditya.twitone.injection.PerActivity;
5 | import com.ladwa.aditya.twitone.injection.module.ActivityModule;
6 | import com.ladwa.aditya.twitone.ui.base.BaseActivity;
7 |
8 | import dagger.Subcomponent;
9 |
10 | @PerActivity
11 | @Subcomponent(modules = ActivityModule.class)
12 | public interface ActivityComponent {
13 | void inject(BaseActivity baseActivity);
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_trends.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_login.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/Constants.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | /**
4 | * A class to keep all the constants that are used by this project
5 | * Created by Aditya on 26-Jun-16.
6 | */
7 | public class Constants {
8 | public static final String OAUTH_COMSUMER_KEY = "s01kRJpmpGr783CSY6pQCs2Nc";
9 | public static final String OAUTH_CONSUMER_SECRET = "CdxuKvF3QKoT34wWoYkslvlX3B80UU4mpg2btZXG2byWNXd3P6";
10 | public static final String OAUTH_CALLBACK_URL = "oauth://twitoneforandroid";
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_image_viewer.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_tweet_detail.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_interactions.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main_screen.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_message.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_message_compose.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/.idea/checkstyle-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/tweet/TweetPresenter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.tweet;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 |
6 | /**
7 | * A Class for Tweet Presenter
8 | * Created by Aditya on 30-Jul-16.
9 | */
10 | public class TweetPresenter {
11 | interface View extends BaseView {
12 | void getUserLocation();
13 |
14 | void onClickLocation();
15 |
16 | void onClickTweet();
17 |
18 | }
19 |
20 | interface Presenter extends BasePresenter {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/AppModule.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | import android.app.Application;
4 |
5 | import javax.inject.Singleton;
6 |
7 | import dagger.Module;
8 | import dagger.Provides;
9 |
10 | /**
11 | * Created by Aditya on 24-Jun-16.
12 | */
13 | @Module
14 | public class AppModule {
15 | Application mApplication;
16 |
17 | public AppModule(Application mApplication) {
18 | this.mApplication = mApplication;
19 | }
20 |
21 | @Provides
22 | @Singleton
23 | Application provideApplication() {
24 | return mApplication;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/component/FragmentComponent.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.component;
2 |
3 |
4 | import com.ladwa.aditya.twitone.injection.PerFragment;
5 | import com.ladwa.aditya.twitone.injection.module.FragmentModule;
6 | import com.ladwa.aditya.twitone.ui.login.LoginActivityFragment;
7 | import com.ladwa.aditya.twitone.ui.login.LoginPresenter;
8 |
9 | import dagger.Subcomponent;
10 |
11 |
12 | @PerFragment
13 | @Subcomponent(modules = FragmentModule.class)
14 | public interface FragmentComponent {
15 | void inject(LoginActivityFragment loginActivityFragment);
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/widget/WidgetCollectionService.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.widget;
2 |
3 | import android.content.Intent;
4 | import android.widget.RemoteViewsService;
5 |
6 | /**
7 | * A Setvice for Widget Collection
8 | * Created by Aditya on 25-Jul-16.
9 | */
10 | public class WidgetCollectionService extends RemoteViewsService {
11 | public static final String TAG = WidgetCollectionService.class.getSimpleName();
12 |
13 | @Override
14 | public RemoteViewsFactory onGetViewFactory(Intent intent) {
15 | return new WidgetCollectionRemoteFactory(getApplicationContext(), intent);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/login/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.login;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 |
6 | import com.ladwa.aditya.twitone.R;
7 | import com.ladwa.aditya.twitone.ui.base.BaseActivity;
8 |
9 |
10 | public class LoginActivity extends BaseActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_login);
16 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
17 | setSupportActionBar(toolbar);
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/component/ConfigPersistentComponent.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.component;
2 |
3 |
4 | import com.ladwa.aditya.twitone.injection.ConfigPersistent;
5 | import com.ladwa.aditya.twitone.injection.module.ActivityModule;
6 | import com.ladwa.aditya.twitone.injection.module.FragmentModule;
7 |
8 | import dagger.Component;
9 |
10 | @ConfigPersistent
11 | @Component(dependencies = ApplicationComponent.class)
12 | public interface ConfigPersistentComponent {
13 |
14 | ActivityComponent activityComponent(ActivityModule activityModule);
15 |
16 | FragmentComponent fragmentComponent(FragmentModule fragmentModule);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/ladwa/aditya/twitone/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | import com.ladwa.aditya.twitone.util.Utility;
4 |
5 | import org.junit.Test;
6 |
7 | import static org.junit.Assert.assertEquals;
8 |
9 | /**
10 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 |
18 | @Test
19 | public void checkDate() throws Exception {
20 | long timeDifference = Utility.getTimeDifference("2016-07-13 14:57:16");
21 | System.out.println(timeDifference);
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/sync/AuthenticatorService.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.sync;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.support.annotation.Nullable;
7 |
8 | /**
9 | * Created by Aditya on 23-Jul-16.
10 | */
11 | public class AuthenticatorService extends Service {
12 |
13 | private Authenticator mAuthenticator;
14 |
15 | @Override
16 | public void onCreate() {
17 | mAuthenticator = new Authenticator(this);
18 | }
19 |
20 | @Nullable
21 | @Override
22 | public IBinder onBind(Intent intent) {
23 | return mAuthenticator.getIBinder();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/message/Message.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.message;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 |
6 | import com.ladwa.aditya.twitone.BaseActivity;
7 | import com.ladwa.aditya.twitone.R;
8 |
9 |
10 | public class Message extends BaseActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_message);
16 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
17 | setSupportActionBar(toolbar);
18 |
19 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/imageviewer/ImageViewer.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.imageviewer;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 |
6 | import com.ladwa.aditya.twitone.BaseActivity;
7 | import com.ladwa.aditya.twitone.R;
8 |
9 | public class ImageViewer extends BaseActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_image_viewer);
15 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
16 | setSupportActionBar(toolbar);
17 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/interactions/Interactions.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.interactions;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 |
6 | import com.ladwa.aditya.twitone.BaseActivity;
7 | import com.ladwa.aditya.twitone.R;
8 |
9 |
10 | public class Interactions extends BaseActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_interactions);
16 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
17 | setSupportActionBar(toolbar);
18 |
19 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/light_ripple.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/tweetdetail/TweetDetail.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.tweetdetail;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 |
6 | import com.ladwa.aditya.twitone.R;
7 | import com.ladwa.aditya.twitone.ui.base.BaseActivity;
8 |
9 | public class TweetDetail extends BaseActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_tweet_detail);
15 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
16 | setSupportActionBar(toolbar);
17 | if (getSupportActionBar() != null) {
18 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
19 | }
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/module/ActivityModule.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.module;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | import com.ladwa.aditya.twitone.data.TwitterRepository;
7 | import com.ladwa.aditya.twitone.injection.ActivityContext;
8 |
9 | import dagger.Module;
10 | import dagger.Provides;
11 |
12 |
13 | @Module
14 | public class ActivityModule {
15 |
16 | private Activity mActivity;
17 |
18 | public ActivityModule(Activity activity) {
19 | mActivity = activity;
20 | }
21 |
22 | @Provides
23 | Activity provideActivity() {
24 | return mActivity;
25 | }
26 |
27 | @Provides
28 | @ActivityContext
29 | Context providesContext() {
30 | return mActivity;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/message/MessageContract.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.message;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 | import com.ladwa.aditya.twitone.data.local.models.DirectMessage;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * A interface for Message Contract
11 | * Created by Aditya on 20-Jul-16.
12 | */
13 | public interface MessageContract {
14 |
15 | interface View extends BaseView {
16 | void loadDirectMessage(List directMessageList);
17 |
18 | void stopRefreshing();
19 |
20 | void showError();
21 | }
22 |
23 |
24 | interface Presenter extends BasePresenter {
25 | void loadDirectMessage();
26 |
27 | void refreshRemoteDirectMessage();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | import com.ladwa.aditya.twitone.ui.settings.SettingsRepository;
8 |
9 | /**
10 | * A Base Activity that all other activites extend
11 | * Created by Aditya on 20-Oct-16.
12 | */
13 |
14 | public class BaseActivity extends AppCompatActivity {
15 |
16 |
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | SettingsRepository.getInstance().setTheme(this);
21 |
22 | }
23 |
24 | @Override
25 | protected void onDestroy() {
26 | super.onDestroy();
27 | SettingsRepository.destroyInstance();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/trends/TrendsContract.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.trends;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 | import com.ladwa.aditya.twitone.data.local.models.Trend;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * A Contract class for Trends
11 | * Created by Aditya on 22-Jul-16.
12 | */
13 | public interface TrendsContract {
14 |
15 | interface View extends BaseView {
16 | void loadedTrends(List trendList);
17 |
18 | void stopRefreshing();
19 |
20 | void showRefreshing();
21 |
22 | void showError();
23 | }
24 |
25 | interface Presenter extends BasePresenter {
26 | void loadTrends();
27 |
28 | void loadLocalTrends();
29 |
30 | void refreshRemoteTrends();
31 |
32 | void refreshRemoteLocalTrends();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/module/FragmentModule.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.module;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.v4.app.Fragment;
6 |
7 |
8 | import com.ladwa.aditya.twitone.injection.ActivityContext;
9 |
10 | import dagger.Module;
11 | import dagger.Provides;
12 |
13 | @Module
14 | public class FragmentModule {
15 | private Fragment mFragment;
16 |
17 | public FragmentModule(Fragment fragment) {
18 | mFragment = fragment;
19 | }
20 |
21 | @Provides
22 | Fragment providesFragment() {
23 | return mFragment;
24 | }
25 |
26 | @Provides
27 | Activity provideActivity() {
28 | return mFragment.getActivity();
29 | }
30 |
31 | @Provides
32 | @ActivityContext
33 | Context providesContext() {
34 | return mFragment.getActivity();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/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=-Xmx3072m -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
19 |
20 | GROUP = com.ladwa.aditya
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/messagecompose/MessageCompose.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.messagecompose;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 |
6 | import com.ladwa.aditya.twitone.BaseActivity;
7 | import com.ladwa.aditya.twitone.R;
8 |
9 | public class MessageCompose extends BaseActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_message_compose);
15 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_message_compose);
16 | setSupportActionBar(toolbar);
17 | if (getSupportActionBar() != null) {
18 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
19 | }
20 | }
21 |
22 |
23 | public void setActionBarTitle(String title) {
24 | getSupportActionBar().setTitle(title);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/sync/SyncService.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.sync;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.support.annotation.Nullable;
7 |
8 | /**
9 | * A service class that is bound to the Sync Adapter
10 | * Created by Aditya on 23-Jul-16.
11 | */
12 | public class SyncService extends Service {
13 | private static SyncAdapter sSyncAdapter = null;
14 | private static final Object sSyncAdapterLock = new Object();
15 |
16 |
17 | @Override
18 | public void onCreate() {
19 | synchronized (sSyncAdapterLock) {
20 | if (sSyncAdapter == null) {
21 | sSyncAdapter = new SyncAdapter(getApplicationContext(), true);
22 | }
23 | }
24 | }
25 |
26 | @Nullable
27 | @Override
28 | public IBinder onBind(Intent intent) {
29 | return sSyncAdapter.getSyncAdapterBinder();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/messagecompose/MessageComposeContract.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.messagecompose;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 | import com.ladwa.aditya.twitone.data.local.models.DirectMessage;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * A Contract Class for Message Compose
11 | * Created by Aditya on 31-Jul-16.
12 | */
13 | public class MessageComposeContract {
14 |
15 | interface View extends BaseView {
16 | void loadUserDirectMessage(List directMessageList);
17 |
18 | void stopRefreshing();
19 |
20 | void showError();
21 |
22 | void setUpRecyclerView();
23 |
24 | void clearEditText();
25 | }
26 |
27 |
28 | interface Presenter extends BasePresenter {
29 | void getUserDirectMessage();
30 |
31 | void sendDirectMessage(long recipentId, String message);
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_interactions.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
14 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_local_trends.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
13 |
14 |
15 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/component/ApplicationComponent.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.component;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 |
7 | import com.ladwa.aditya.twitone.data.TwitterRepository;
8 | import com.ladwa.aditya.twitone.injection.ApplicationContext;
9 | import com.ladwa.aditya.twitone.injection.module.ApplicationModule;
10 |
11 | import javax.inject.Singleton;
12 |
13 | import dagger.Component;
14 | import twitter4j.AsyncTwitter;
15 | import twitter4j.Twitter;
16 |
17 |
18 | @Singleton
19 | @Component(modules = ApplicationModule.class)
20 | public interface ApplicationComponent {
21 |
22 | @ApplicationContext
23 | Context context();
24 |
25 | Application application();
26 |
27 | TwitterRepository repository();
28 |
29 | Twitter twitter();
30 |
31 | AsyncTwitter async();
32 |
33 | SharedPreferences sharedPreferences();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "168112638208",
4 | "project_id": "firebase-twitone"
5 | },
6 | "client": [
7 | {
8 | "client_info": {
9 | "mobilesdk_app_id": "1:168112638208:android:32df67d25ab86225",
10 | "android_client_info": {
11 | "package_name": "com.ladwa.aditya.twitone"
12 | }
13 | },
14 | "oauth_client": [],
15 | "api_key": [
16 | {
17 | "current_key": "AIzaSyB6i72gDRsSHTmmYfXLd-UIjajxnjsfLsU"
18 | }
19 | ],
20 | "services": {
21 | "analytics_service": {
22 | "status": 2,
23 | "analytics_property": {
24 | "tracking_id": "UA-57017077-2"
25 | }
26 | },
27 | "appinvite_service": {
28 | "status": 1,
29 | "other_platform_oauth_client": []
30 | },
31 | "ads_service": {
32 | "status": 1
33 | }
34 | }
35 | }
36 | ],
37 | "configuration_version": "1"
38 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_trends.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
13 |
14 |
15 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
10 |
12 |
13 |
14 | -
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ladwa/aditya/twitone/LoginTest.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | import android.support.test.rule.ActivityTestRule;
4 | import android.support.test.runner.AndroidJUnit4;
5 |
6 | import com.ladwa.aditya.twitone.ui.login.LoginActivity;
7 |
8 | import org.junit.Rule;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 |
12 | import static android.support.test.espresso.Espresso.onView;
13 | import static android.support.test.espresso.action.ViewActions.click;
14 | import static android.support.test.espresso.matcher.ViewMatchers.withId;
15 |
16 | /**
17 | * A class to test the Login Button
18 | * Created by Aditya on 30-Jun-16.
19 | */
20 | @RunWith(AndroidJUnit4.class)
21 | public class LoginTest {
22 |
23 | @Rule
24 | public ActivityTestRule mLoginActivityActivityTestRule = new ActivityTestRule<>(LoginActivity.class);
25 |
26 |
27 | @Test
28 | public void clickLoginButton_LoginUser() throws Exception {
29 | onView(withId(R.id.twitter_login_button)).perform(click());
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/TwitterDataStore.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data;
2 |
3 | import com.ladwa.aditya.twitone.data.local.models.DirectMessage;
4 | import com.ladwa.aditya.twitone.data.local.models.Interaction;
5 | import com.ladwa.aditya.twitone.data.local.models.Trend;
6 | import com.ladwa.aditya.twitone.data.local.models.Tweet;
7 | import com.ladwa.aditya.twitone.data.local.models.User;
8 |
9 | import java.util.List;
10 |
11 | import rx.Observable;
12 |
13 | /**
14 | * An interface that Encapsulates all the Operations which will be implemented by Local Database and Remote Twitter Service
15 | * Created by Aditya on 25-Jun-16.
16 | */
17 | public interface TwitterDataStore {
18 |
19 | Observable getUserInfo(long userID);
20 |
21 | Observable> getTimeLine(long sinceId);
22 |
23 | Observable> getInteraction(long sinceId);
24 |
25 | Observable> getDirectMessage(long sinceId);
26 |
27 | Observable> getTrends();
28 |
29 | Observable> getLocalTrends(double latitude, double longitude);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/login/LoginContract.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.login;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 | import com.ladwa.aditya.twitone.ui.base.MvpPresenter;
6 | import com.ladwa.aditya.twitone.ui.base.MvpView;
7 |
8 | import rx.Observable;
9 | import twitter4j.auth.AccessToken;
10 | import twitter4j.auth.RequestToken;
11 |
12 | /**
13 | *
14 | * Created by Aditya on 24-Jun-16.
15 | */
16 | public interface LoginContract {
17 | interface View extends MvpView {
18 | void onError(String errorMessage);
19 |
20 | void onSuccess(String message);
21 |
22 | void startOauthIntent(RequestToken requestToken);
23 |
24 | void saveAccessTokenAnd(AccessToken accessToken);
25 |
26 | }
27 |
28 | interface Presenter extends MvpPresenter {
29 | void login();
30 |
31 | void getAccessToken(String verifier);
32 |
33 | Observable getRequestTokenObservable();
34 |
35 | Observable getAccessTokenObservable(final String verifier);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 16dp
7 | 50dp
8 | 4dp
9 |
10 | 15dp
11 | 15dp
12 | 10dp
13 | 7dp
14 | 30dp
15 |
16 | 15dp
17 | 15dp
18 |
19 | 11dp
20 | 7dp
21 | 7dp
22 | 20dp
23 | 15dp
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_trend.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
21 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_interactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tweet_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/settings/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.settings;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.Toolbar;
6 | import android.transition.Fade;
7 |
8 | import com.ladwa.aditya.twitone.BaseActivity;
9 | import com.ladwa.aditya.twitone.R;
10 | import com.ladwa.aditya.twitone.ui.mainscreen.MainScreen;
11 |
12 | public class SettingsActivity extends BaseActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_settings);
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 | setSupportActionBar(toolbar);
20 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
21 |
22 | }
23 |
24 | private void setupWindowAnimations() {
25 | Fade fade = new Fade();
26 | fade.setDuration(1000);
27 | getWindow().setEnterTransition(fade);
28 | getWindow().setExitTransition(fade);
29 | }
30 |
31 | @Override
32 | public void onBackPressed() {
33 | startActivity(new Intent(this, MainScreen.class));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_message_compose.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/GlideConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import android.app.ActivityManager;
4 | import android.content.Context;
5 |
6 | import com.bumptech.glide.Glide;
7 | import com.bumptech.glide.GlideBuilder;
8 | import com.bumptech.glide.load.DecodeFormat;
9 | import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
10 | import com.bumptech.glide.module.GlideModule;
11 |
12 | /**
13 | * A Configuration class for Glide Image loading library
14 | * Created by Aditya on 14-Jul-16.
15 | */
16 | public class GlideConfiguration implements GlideModule {
17 |
18 | private static final int CACHE_SIZE = 20 * 1024 * 1024;
19 |
20 | @Override
21 | public void applyOptions(Context context, GlideBuilder builder) {
22 | // Apply options to the builder here.
23 |
24 | ActivityManager activityManager =
25 | (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
26 | builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
27 |
28 | builder.setDiskCache(new InternalCacheDiskCacheFactory(context, CACHE_SIZE));
29 | }
30 |
31 | @Override
32 | public void registerComponents(Context context, Glide glide) {
33 | // register ModelLoaders here.
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/interactions/InteractionsContract.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.interactions;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 | import com.ladwa.aditya.twitone.data.local.models.Interaction;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * A Contract interface that holds the blueprint of the Interactions module
11 | * Created by Aditya on 19-Jul-16.
12 | */
13 | public interface InteractionsContract {
14 |
15 | interface View extends BaseView {
16 | void loadInteractions(List interactionList);
17 |
18 | void setScrollPos();
19 |
20 | void stopRefreshing();
21 |
22 | void showError();
23 |
24 | void saveScrollPosition();
25 |
26 | void createdFavouriteCallback(Interaction interaction);
27 |
28 | void destroyFavouriteCallback(Interaction interaction);
29 |
30 | void createRetweetCallback(Interaction interaction);
31 | }
32 |
33 | interface Presenter extends BasePresenter {
34 |
35 | void loadInteractions();
36 |
37 | void refreshRemoteInteraction();
38 |
39 | void createFavourite(long id);
40 |
41 | void unFavourite(long id);
42 |
43 | void createRetweet(long id);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/message_bubble_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/message_bubble_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
22 |
23 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/values/preference.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | //Preference
5 | pref_login
6 | pref_access_token
7 | pref_access_secret
8 | pref_userid
9 | pref_screen_name
10 | pref_user_location_latitude
11 | pref_user_location_longitude
12 | pref_notification
13 | pref_theme
14 |
15 |
16 | - Light
17 | - Dark
18 |
19 |
20 |
21 | - Light
22 | - Dark
23 |
24 |
25 |
26 | - 1 hour
27 | - 2 hour
28 | - 4 hour
29 | - 8 hour
30 |
31 |
32 |
33 | - 1
34 | - 2
35 | - 4
36 | - 8
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_image_viewer.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/ScrollAwareFabBehaviour.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import android.content.Context;
4 | import android.support.design.widget.CoordinatorLayout;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.v4.view.ViewCompat;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | /**
11 | * A FAB behaviour to hide upon scroll of recycler view
12 | * Created by Aditya on 21-Oct-16.
13 | */
14 |
15 | public class ScrollAwareFabBehaviour extends FloatingActionButton.Behavior {
16 |
17 |
18 | public ScrollAwareFabBehaviour(Context context, AttributeSet attrs) {
19 | super(context,attrs);
20 | }
21 |
22 | @Override
23 | public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
24 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
25 | if (dyConsumed < 0 && child.getVisibility() == View.VISIBLE) {
26 | child.hide();
27 | } else if (dyConsumed > 0 && child.getVisibility() == View.GONE) {
28 | child.show();
29 | }
30 | }
31 |
32 | @Override
33 | public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
34 | return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_message.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
20 |
21 |
25 |
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/mainscreen/MainScreenContract.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.mainscreen;
2 |
3 | import com.ladwa.aditya.twitone.BasePresenter;
4 | import com.ladwa.aditya.twitone.BaseView;
5 | import com.ladwa.aditya.twitone.data.local.models.Tweet;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * A contract that holds the abstraction of MainScreen
11 | * Created by Aditya on 27-Jun-16.
12 | */
13 | public interface MainScreenContract {
14 |
15 | interface View extends BaseView {
16 | void logout();
17 |
18 | void loadedUser(com.ladwa.aditya.twitone.data.local.models.User user);
19 |
20 | void loadTimeline(List tweetList);
21 |
22 | void setScrollPos();
23 |
24 | void saveScrollPosition();
25 |
26 | void stopRefreshing();
27 |
28 | void showRefreshing();
29 |
30 | void showNotification(int tweets);
31 |
32 | void showError();
33 |
34 | void createdFavouriteCallback(Tweet tweet);
35 |
36 | void destroyFavouriteCallback(Tweet tweet);
37 |
38 | void createRetweetCallback(Tweet tweet);
39 | }
40 |
41 | interface Presenter extends BasePresenter {
42 |
43 | void loadUserInfo();
44 |
45 | void loadTimeLine();
46 |
47 | void refreshRemoteTimeline();
48 |
49 | void createFavourite(long id);
50 |
51 | void unFavourite(long id);
52 |
53 | void createRetweet(long id);
54 |
55 | void deleteLocalData();
56 |
57 | void refreshBelowTimeline();
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/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 E:\Aditya\WorkSpace\Android_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 |
19 | -libraryjars libs
20 |
21 | -keep public class * extends android.app.Activity
22 | -keep public class * extends android.app.Application
23 |
24 | -keepattributes InnerClasses,Signature
25 |
26 | -keepnames class com.ladwa.aditya.twitone.** { *;}
27 |
28 | -keep interface android.support.v7.** { *; }
29 | -keep class android.support.v7.** { *; }
30 | -keep interface android.support.v4.** { *; }
31 | -keep class android.support.v4.** { *; }
32 |
33 | -keep interface com.ladwa.aditya.twitone.data.**
34 | -keep interface com.ladwa.aditya.twitone.ui.mainscreen.**
35 | -keep class com.ladwa.aditya.twitone.ui.mainscreen.**
36 |
37 | -keep class twitter4j.** { *; }
38 | -keep interface twitter4j.conf.**
39 |
40 | #Glide
41 | -keepnames class * implements com.bumptech.glide.module.GlideModule
42 |
43 |
44 | -dontwarn com.google.auto.value.**
45 | -dontwarn autovalue.shaded.**
46 | -dontwarn twitter4j.**
47 | -dontwarn rx.internal.util.unsafe.**
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_login.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
22 |
23 |
31 |
32 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main_screen.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
24 |
25 |
26 |
27 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_trends.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
29 |
30 |
31 |
32 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tweet.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
24 |
25 |
26 |
27 |
28 |
29 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preference.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
15 |
22 |
23 |
29 |
30 |
31 |
32 |
33 |
34 |
37 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/settings/SettingsRepository.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.settings;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import com.ladwa.aditya.twitone.R;
7 | import com.ladwa.aditya.twitone.TwitoneApp;
8 |
9 | import javax.inject.Inject;
10 |
11 | /**
12 | * A Repository that gives access to themes
13 | * Created by Aditya on 20-Oct-16.
14 | */
15 |
16 | public class SettingsRepository implements SettingsStore {
17 |
18 | private static SettingsRepository INSTANCE = null;
19 |
20 | @Inject SharedPreferences mSharedPreferences;
21 |
22 | private SettingsRepository() {
23 | TwitoneApp.getTwitterComponent().inject(this);
24 | }
25 |
26 | public static void destroyInstance() {
27 | INSTANCE = null;
28 | }
29 |
30 | public static SettingsRepository getInstance() {
31 | if (INSTANCE == null)
32 | INSTANCE = new SettingsRepository();
33 | return INSTANCE;
34 | }
35 |
36 | @Override
37 | public String getTheme() {
38 | return mSharedPreferences.getString("pref_theme", "string");
39 | }
40 |
41 | @Override
42 | public void setTheme(Context context) {
43 | String theme = getTheme();
44 | if (theme.equals(context.getResources().getStringArray(R.array.pref_theme_value)[0]))
45 | context.setTheme(R.style.AppTheme);
46 | else context.setTheme(R.style.AppThemeDark);
47 | }
48 |
49 | @Override
50 | public boolean isNotificationEnabled(Context context) {
51 | return mSharedPreferences.getBoolean(context.getString(R.string.pref_notification), true);
52 | }
53 |
54 | @Override
55 | public int getSyncDuration(Context context) {
56 | return 0;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/base/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.base;
2 |
3 | import rx.Observable;
4 | import rx.Single;
5 |
6 | public class BasePresenter implements MvpPresenter {
7 |
8 | private T mMvpView;
9 |
10 | @Override
11 | public void attachView(T mvpView) {
12 | mMvpView = mvpView;
13 | }
14 |
15 | @Override
16 | public void detachView() {
17 | mMvpView = null;
18 | }
19 |
20 | public boolean isViewAttached() {
21 | return mMvpView != null;
22 | }
23 |
24 | public T getMvpView() {
25 | return mMvpView;
26 | }
27 |
28 | public void checkViewAttached() {
29 | if (!isViewAttached()) throw new MvpViewNotAttachedException();
30 | }
31 |
32 | public static class MvpViewNotAttachedException extends RuntimeException {
33 | public MvpViewNotAttachedException() {
34 | super("Please call MvpPresenter.attachView(MvpView) before" +
35 | " requesting data to the MvpPresenter");
36 | }
37 | }
38 |
39 | protected static class DataResult {
40 |
41 | private T mData;
42 | private Throwable mError;
43 |
44 | public DataResult(T data) {
45 | mData = data;
46 | }
47 |
48 | public DataResult(Throwable error) {
49 | mError = error;
50 | }
51 |
52 | public Single toSingle() {
53 | if (mError != null) {
54 | return Single.error(mError);
55 | }
56 | return Single.just(mData);
57 | }
58 |
59 | public Observable toObservable() {
60 | if (mError != null) {
61 | return Observable.error(mError);
62 | }
63 | return Observable.just(mData);
64 | }
65 | }
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ladwa/aditya/twitone/LogoutTest.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone;
2 |
3 | import android.content.SharedPreferences;
4 | import android.preference.PreferenceManager;
5 | import android.support.test.rule.ActivityTestRule;
6 |
7 | import com.ladwa.aditya.twitone.ui.mainscreen.MainScreen;
8 |
9 | import org.junit.After;
10 | import org.junit.Before;
11 | import org.junit.Rule;
12 |
13 | import static android.support.test.espresso.action.ViewActions.click;
14 | import static android.support.test.espresso.matcher.ViewMatchers.withId;
15 |
16 | /**
17 | * A test to check functionality of Logout Button
18 | * Created by Aditya on 30-Jun-16.
19 | */
20 | public class LogoutTest {
21 |
22 | @Rule
23 | public ActivityTestRule mainScreenActivityTestRule = new ActivityTestRule<>(MainScreen.class);
24 |
25 | @Before()
26 | public void initSharedPreference() {
27 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(TwitoneApp.getInstance());
28 | SharedPreferences.Editor editor = sharedPreferences.edit();
29 | editor.putBoolean(mainScreenActivityTestRule.getActivity().getString(R.string.pref_login), true);
30 | editor.apply();
31 |
32 | }
33 |
34 | // @Test
35 | // public void clickLogoutButton_LogoutUser() throws Exception {
36 | // onView(withId(R.id.twitter_logout_button))
37 | // .perform(click());
38 | //
39 | // }
40 |
41 | @After
42 | public void removeSharedPreference() {
43 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(TwitoneApp.getInstance());
44 | SharedPreferences.Editor editor = sharedPreferences.edit();
45 | editor.putBoolean(mainScreenActivityTestRule.getActivity().getString(R.string.pref_login), false);
46 | editor.apply();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/config/quality/pmd/pmd-ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | Custom ruleset for ribot Android application
8 |
9 | .*/R.java
10 | .*/gen/.*
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_message_compose.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
15 |
16 |
22 |
23 |
33 |
34 |
35 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/settings/SettingsActivityFragment.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.settings;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.os.Bundle;
6 | import android.preference.PreferenceFragment;
7 | import android.support.v4.app.ActivityCompat;
8 | import android.support.v4.app.ActivityOptionsCompat;
9 |
10 | import com.ladwa.aditya.twitone.R;
11 |
12 | /**
13 | * A placeholder fragment containing a simple view.
14 | */
15 | public class SettingsActivityFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
16 |
17 | private static final String TAG = SettingsActivityFragment.class.getSimpleName();
18 |
19 | @Override
20 | public void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | addPreferencesFromResource(R.xml.preference);
23 | }
24 |
25 |
26 | @Override
27 | public void onResume() {
28 | super.onResume();
29 | getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
30 | }
31 |
32 | @Override
33 | public void onStop() {
34 | super.onStop();
35 | getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
36 | getActivity().finish();
37 | }
38 |
39 |
40 |
41 | @Override
42 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
43 | if (s.equals(this.getString(R.string.pref_theme_key))) {
44 | Intent intent = new Intent(SettingsActivityFragment.this.getActivity(), SettingsActivity.class);
45 |
46 | ActivityOptionsCompat activityOptionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity());
47 | ActivityCompat.startActivity(getActivity(), intent, activityOptionsCompat.toBundle());
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/customview/ChatBubbleTextView.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.customview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.v4.content.ContextCompat;
7 | import android.util.AttributeSet;
8 | import android.widget.TextView;
9 |
10 | import com.ladwa.aditya.twitone.R;
11 |
12 | /**
13 | *
14 | * Created by Aditya on 21-Oct-16.
15 | */
16 |
17 | public class ChatBubbleTextView extends TextView {
18 | private Drawable mBubbleBackground;
19 | private int mBubbleTextColor;
20 |
21 | public ChatBubbleTextView(Context context) {
22 | super(context);
23 | }
24 |
25 | public ChatBubbleTextView(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | applyCustomeProperty(context, attrs);
28 |
29 | }
30 |
31 | public ChatBubbleTextView(Context context, AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | applyCustomeProperty(context, attrs);
34 |
35 | }
36 |
37 | public ChatBubbleTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
38 | super(context, attrs, defStyleAttr, defStyleRes);
39 | applyCustomeProperty(context, attrs);
40 | }
41 |
42 |
43 | private void applyCustomeProperty(Context context, AttributeSet attrs) {
44 | TypedArray a = context.getTheme().obtainStyledAttributes(
45 | attrs, R.styleable.ChatBubble, 0, 0);
46 |
47 | try {
48 | mBubbleBackground = a.getDrawable(R.styleable.ChatBubble_bubble_background);
49 | mBubbleTextColor = a.getColor(R.styleable.ChatBubble_bubble_text_color,
50 | ContextCompat.getColor(context, R.color.md_black_1000));
51 | } finally {
52 | a.recycle();
53 | }
54 |
55 | setBackground(mBubbleBackground);
56 | setTextColor(mBubbleTextColor);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/adapter/TrendAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.ladwa.aditya.twitone.R;
11 | import com.ladwa.aditya.twitone.data.local.models.Trend;
12 |
13 | import java.util.List;
14 |
15 | import butterknife.BindView;
16 | import butterknife.ButterKnife;
17 |
18 | /**
19 | * An Adapter for Trends
20 | * Created by Aditya on 22-Jul-16.
21 | */
22 | public class TrendAdapter extends RecyclerView.Adapter {
23 | private List mTrendList;
24 | private Context mContext;
25 |
26 | public TrendAdapter(List mTrendList, Context mContext) {
27 | this.mTrendList = mTrendList;
28 | this.mContext = mContext;
29 | }
30 |
31 | @Override
32 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
33 | View itemView = LayoutInflater.from(parent.getContext())
34 | .inflate(R.layout.item_trend, parent, false);
35 | return new ViewHolder(itemView);
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(ViewHolder holder, int position) {
40 | holder.textViewTrend.setText(mTrendList.get(position).getTrend());
41 | }
42 |
43 | @Override
44 | public int getItemCount() {
45 | if (mTrendList != null)
46 | return mTrendList.size();
47 | else return 0;
48 | }
49 |
50 | public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
51 |
52 | @BindView(R.id.textview_trend)
53 | TextView textViewTrend;
54 |
55 | public ViewHolder(View itemView) {
56 | super(itemView);
57 | ButterKnife.bind(this, itemView);
58 | itemView.setOnClickListener(this);
59 | }
60 |
61 | @Override
62 | public void onClick(View v) {
63 |
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/ConnectionReceiver.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.net.ConnectivityManager;
7 | import android.net.NetworkInfo;
8 |
9 | import com.ladwa.aditya.twitone.TwitoneApp;
10 |
11 | /**
12 | * A BroadCast Receiver to listen for Connectivity Changes
13 | * {@link BroadcastReceiver}
14 | * Created by Aditya on 28-Jun-16.
15 | */
16 | public class ConnectionReceiver extends BroadcastReceiver {
17 |
18 | public static ConnectionReceiverListener connectionReceiverListener;
19 |
20 | public ConnectionReceiver() {
21 | super();
22 | }
23 |
24 | @Override
25 | public void onReceive(Context context, Intent intent) {
26 | ConnectivityManager cm = (ConnectivityManager) context
27 | .getSystemService(Context.CONNECTIVITY_SERVICE);
28 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
29 | boolean isConnected = activeNetwork != null
30 | && activeNetwork.isConnectedOrConnecting();
31 |
32 | if (connectionReceiverListener != null) {
33 | connectionReceiverListener.onNetworkConnectionChanged(isConnected);
34 | }
35 | }
36 |
37 | public static void destoryInstance() {
38 | connectionReceiverListener = null;
39 | }
40 |
41 | public static void setConnectionReceiverListener(ConnectionReceiverListener listener) {
42 | connectionReceiverListener = listener;
43 | }
44 |
45 | public static boolean isConnected() {
46 | ConnectivityManager
47 | cm = (ConnectivityManager) TwitoneApp.getInstance().getApplicationContext()
48 | .getSystemService(Context.CONNECTIVITY_SERVICE);
49 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
50 | return activeNetwork != null
51 | && activeNetwork.isConnectedOrConnecting();
52 | }
53 |
54 | public interface ConnectionReceiverListener {
55 | void onNetworkConnectionChanged(boolean isConnected);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/mainscreen/EndlessRecyclerOnScrollListener.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.mainscreen;
2 |
3 | import android.support.v7.widget.LinearLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | /**
7 | *
8 | * Created by Aditya on 11-Jan-17.
9 | */
10 |
11 | public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
12 | public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
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 = 5; // The minimum amount of items to have below your current scroll position before loading more.
17 | int firstVisibleItem, visibleItemCount, totalItemCount;
18 |
19 | private int current_page = 1;
20 |
21 | private LinearLayoutManager mLinearLayoutManager;
22 |
23 | public EndlessRecyclerOnScrollListener(LinearLayoutManager linearLayoutManager) {
24 | this.mLinearLayoutManager = linearLayoutManager;
25 | }
26 |
27 | @Override
28 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
29 | super.onScrolled(recyclerView, dx, dy);
30 |
31 | visibleItemCount = recyclerView.getChildCount();
32 | totalItemCount = mLinearLayoutManager.getItemCount();
33 | firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();
34 |
35 | if (loading) {
36 | if (totalItemCount > previousTotal) {
37 | loading = false;
38 | previousTotal = totalItemCount;
39 | }
40 | }
41 | if (!loading && (totalItemCount - visibleItemCount)
42 | <= (firstVisibleItem + visibleThreshold)) {
43 | // End has been reached
44 |
45 | // Do something
46 | current_page++;
47 |
48 | onLoadMore(current_page);
49 |
50 | loading = true;
51 | }
52 | }
53 |
54 | public abstract void onLoadMore(int current_page);
55 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/local/TwitterDbHelper.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.local;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteOpenHelper;
6 |
7 |
8 | /**
9 | * A Database Helper for the app
10 | * Created by Aditya on 04-Jul-16.
11 | */
12 | public class TwitterDbHelper extends SQLiteOpenHelper {
13 |
14 | public static final String DATABASE_NAME = "Twitone.db";
15 | public static final int DATABASE_VERSION = 3;
16 |
17 | public TwitterDbHelper(Context context) {
18 | super(context, DATABASE_NAME, null, DATABASE_VERSION);
19 | }
20 |
21 | @Override
22 | public void onCreate(SQLiteDatabase db) {
23 | db.execSQL(TwitterContract.User.getUserCreateQuery());
24 | db.execSQL(TwitterContract.Tweet.getTweetCreateQuery());
25 | db.execSQL(TwitterContract.Interaction.getInteractionCreateQuery());
26 | db.execSQL(TwitterContract.DirectMessage.getDirectMessageCreateQuery());
27 | db.execSQL(TwitterContract.Trends.getTrendsCreateQuery());
28 | // Timber.d("Created database" + DATABASE_NAME);
29 | }
30 |
31 | @Override
32 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
33 | db.execSQL(TwitterContract.User.getUserDeleteQuery());
34 | db.execSQL(TwitterContract.Tweet.getTweetDeleteQuery());
35 | db.execSQL(TwitterContract.Interaction.getInteractionDeleteQuery());
36 | db.execSQL(TwitterContract.DirectMessage.getDirectMessageDeleteQuery());
37 | db.execSQL(TwitterContract.Trends.getTrendsDeleteQuery());
38 | onCreate(db);
39 | }
40 |
41 | @Override
42 | public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
43 | db.execSQL(TwitterContract.User.getUserDeleteQuery());
44 | db.execSQL(TwitterContract.Tweet.getTweetDeleteQuery());
45 | db.execSQL(TwitterContract.Interaction.getInteractionDeleteQuery());
46 | db.execSQL(TwitterContract.DirectMessage.getDirectMessageDeleteQuery());
47 | db.execSQL(TwitterContract.Trends.getTrendsDeleteQuery());
48 | onCreate(db);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_widget.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
17 |
18 |
28 |
29 |
38 |
39 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main_screen.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
32 |
33 |
38 |
39 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/remote/TwitterModule.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.remote;
2 |
3 | import android.app.Application;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | import com.ladwa.aditya.twitone.data.local.TwitterLocalDataStore;
8 | import com.ladwa.aditya.twitone.util.Constants;
9 |
10 | import javax.inject.Singleton;
11 |
12 | import dagger.Module;
13 | import dagger.Provides;
14 | import twitter4j.AsyncTwitter;
15 | import twitter4j.AsyncTwitterFactory;
16 | import twitter4j.Twitter;
17 | import twitter4j.TwitterFactory;
18 | import twitter4j.conf.Configuration;
19 | import twitter4j.conf.ConfigurationBuilder;
20 |
21 | /**
22 | * A {@see Dagger} module for Twitter
23 | * Created by Aditya on 24-Jun-16.
24 | */
25 | @Module
26 | public class TwitterModule {
27 |
28 | @Provides
29 | @Singleton
30 | SharedPreferences providesSharedPreferences(Application application) {
31 | return PreferenceManager.getDefaultSharedPreferences(application);
32 | }
33 |
34 | @Provides
35 | @Singleton
36 | Twitter providesTwitter() {
37 | ConfigurationBuilder builder = new ConfigurationBuilder();
38 | builder.setOAuthConsumerKey(Constants.OAUTH_COMSUMER_KEY);
39 | builder.setOAuthConsumerSecret(Constants.OAUTH_CONSUMER_SECRET);
40 | Configuration configuration = builder.build();
41 | return new TwitterFactory(configuration).getInstance();
42 | }
43 |
44 | @Provides
45 | @Singleton
46 | AsyncTwitter providesTwitterAsync() {
47 | ConfigurationBuilder builder = new ConfigurationBuilder();
48 | builder.setOAuthConsumerKey(Constants.OAUTH_COMSUMER_KEY);
49 | builder.setOAuthConsumerSecret(Constants.OAUTH_CONSUMER_SECRET);
50 | Configuration configuration = builder.build();
51 | return new AsyncTwitterFactory(configuration).getInstance();
52 | }
53 |
54 |
55 | @Provides
56 | @Singleton
57 | TwitterRemoteDataSource providesTwitterRemoteDataSource() {
58 | return new TwitterRemoteDataSource();
59 | }
60 |
61 | @Provides
62 | @Singleton
63 | TwitterLocalDataStore providesTwitterLocalDataStore(Application context) {
64 | return new TwitterLocalDataStore(context);
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/NotificationUtil.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import android.app.PendingIntent;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.support.v4.app.NotificationCompat;
7 | import android.support.v4.app.NotificationManagerCompat;
8 |
9 | import com.ladwa.aditya.twitone.R;
10 | import com.ladwa.aditya.twitone.data.local.models.Tweet;
11 | import com.ladwa.aditya.twitone.ui.mainscreen.MainScreen;
12 | import com.ladwa.aditya.twitone.ui.settings.SettingsRepository;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * A Notification Utility class
18 | * Created by Aditya on 23-Jul-16.
19 | */
20 | public class NotificationUtil {
21 | private final static String TAG = NotificationUtil.class.getSimpleName();
22 |
23 | public static void showNotification(Context context, int size, String title, List tweetList) {
24 |
25 | if (SettingsRepository.getInstance().isNotificationEnabled(context))
26 | return;
27 | NotificationCompat.Builder mBuilder =
28 | new NotificationCompat.Builder(context)
29 | .setSmallIcon(R.drawable.ic_notify)
30 | .setContentTitle(size + context.getString(R.string.new_tweets))
31 | .setAutoCancel(true)
32 | .setDefaults(NotificationCompat.DEFAULT_ALL)
33 | .setContentText(title);
34 |
35 | NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
36 | inboxStyle.setBigContentTitle(size + context.getString(R.string.new_tweets));
37 | int loopTime;
38 | int loop = tweetList.size();
39 | if (loop < 5) {
40 | loopTime = loop;
41 | } else {
42 | loopTime = 5;
43 | }
44 |
45 |
46 | for (int i = 0; i < loopTime; i++) {
47 | inboxStyle.addLine("@" + tweetList.get(i).getScreenName() + " : " + tweetList.get(i).getTweet());
48 | }
49 |
50 | mBuilder.setStyle(inboxStyle);
51 | PendingIntent resultPendingIntent =
52 | PendingIntent.getActivity(
53 | context,
54 | 0,
55 | new Intent(context, MainScreen.class),
56 | PendingIntent.FLAG_UPDATE_CURRENT
57 | );
58 | mBuilder.setContentIntent(resultPendingIntent);
59 | NotificationManagerCompat.from(context).notify(100, mBuilder.build());
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/config/quality/quality.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Set up Checkstyle, Findbugs and PMD to perform extensive code analysis.
3 | *
4 | * Gradle tasks added:
5 | * - checkstyle
6 | * - findbugs
7 | * - pmd
8 | *
9 | * The three tasks above are added as dependencies of the check task so running check will
10 | * run all of them.
11 | */
12 |
13 | apply plugin: 'checkstyle'
14 | apply plugin: 'findbugs'
15 | apply plugin: 'pmd'
16 |
17 | findbugs {
18 | toolVersion = '3.0.0'
19 | }
20 |
21 | dependencies {
22 | checkstyle 'com.puppycrawl.tools:checkstyle:7.3.0'
23 | }
24 |
25 | def qualityConfigDir = "$project.rootDir/config/quality";
26 | def reportsDir = "$project.buildDir/reports"
27 |
28 | check.dependsOn 'checkstyle', 'findbugs', 'pmd'
29 |
30 | task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code style checks') {
31 | configFile file("$qualityConfigDir/checkstyle/checkstyle-config.xml")
32 | source 'src'
33 | include '**/*.java'
34 |
35 | reports {
36 | xml.enabled = true
37 | xml {
38 | destination "$reportsDir/checkstyle/checkstyle.xml"
39 | }
40 | }
41 |
42 | classpath = files( )
43 | }
44 |
45 | task findbugs(type: FindBugs,
46 | group: 'Verification',
47 | description: 'Inspect java bytecode for bugs',
48 | dependsOn: ['compileDebugSources','compileReleaseSources']) {
49 |
50 | ignoreFailures = false
51 | effort = "max"
52 | reportLevel = "high"
53 | excludeFilter = new File("$qualityConfigDir/findbugs/android-exclude-filter.xml")
54 | classes = files("$project.rootDir/app/build/intermediates/classes")
55 |
56 | source 'src'
57 | include '**/*.java'
58 | exclude '**/gen/**'
59 |
60 | reports {
61 | xml.enabled = true
62 | html.enabled = false
63 | xml {
64 | destination "$reportsDir/findbugs/findbugs.xml"
65 | }
66 | html {
67 | destination "$reportsDir/findbugs/findbugs.html"
68 | }
69 | }
70 |
71 | classpath = files()
72 | }
73 |
74 |
75 | task pmd(type: Pmd, group: 'Verification', description: 'Inspect sourcecode for bugs') {
76 | ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml")
77 | ignoreFailures = false
78 | ruleSets = []
79 |
80 | source 'src'
81 | include '**/*.java'
82 | exclude '**/gen/**'
83 |
84 | reports {
85 | xml.enabled = true
86 | html.enabled = true
87 | xml {
88 | destination "$reportsDir/pmd/pmd.xml"
89 | }
90 | html {
91 | destination "$reportsDir/pmd/pmd.html"
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/TwitterComponent.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data;
2 |
3 | import com.ladwa.aditya.twitone.AppModule;
4 | import com.ladwa.aditya.twitone.data.remote.TwitterModule;
5 | import com.ladwa.aditya.twitone.data.remote.TwitterRemoteDataSource;
6 | import com.ladwa.aditya.twitone.data.sync.SyncAdapter;
7 | import com.ladwa.aditya.twitone.ui.interactions.InteractionsFragment;
8 | import com.ladwa.aditya.twitone.ui.interactions.InteractionsPresenter;
9 | import com.ladwa.aditya.twitone.ui.login.LoginActivityFragment;
10 | import com.ladwa.aditya.twitone.ui.mainscreen.MainScreenFragment;
11 | import com.ladwa.aditya.twitone.ui.mainscreen.MainScreenPresenter;
12 | import com.ladwa.aditya.twitone.ui.message.MessageFragment;
13 | import com.ladwa.aditya.twitone.ui.message.MessagePresenter;
14 | import com.ladwa.aditya.twitone.ui.messagecompose.MessageComposeFragment;
15 | import com.ladwa.aditya.twitone.ui.messagecompose.MessageComposePresenter;
16 | import com.ladwa.aditya.twitone.ui.settings.SettingsRepository;
17 | import com.ladwa.aditya.twitone.ui.trends.LocalTrendsFragment;
18 | import com.ladwa.aditya.twitone.ui.trends.Trends;
19 | import com.ladwa.aditya.twitone.ui.trends.TrendsFragment;
20 | import com.ladwa.aditya.twitone.ui.trends.TrendsPresenter;
21 | import com.ladwa.aditya.twitone.ui.tweet.Tweet;
22 |
23 | import javax.inject.Singleton;
24 |
25 | import dagger.Component;
26 |
27 | /**
28 | * A dagger Component that is used to inject in various classes
29 | * Created by Aditya on 25-Jun-16.
30 | */
31 | @Singleton
32 | @Component(modules = {AppModule.class, TwitterModule.class})
33 | public interface TwitterComponent {
34 |
35 | //Expose methods from TwitterModule
36 | void inject(LoginActivityFragment fragment);
37 |
38 | void inject(SettingsRepository repository);
39 |
40 | void inject(MainScreenFragment fragment);
41 |
42 | void inject(MainScreenPresenter presenter);
43 |
44 | void inject(TwitterRemoteDataSource twitterRemoteDataSource);
45 |
46 | void inject(InteractionsFragment fragment);
47 |
48 | void inject(MessageFragment fragment);
49 |
50 | void inject(MessagePresenter presenter);
51 |
52 | void inject(TrendsFragment fragment);
53 |
54 | void inject(LocalTrendsFragment fragment);
55 |
56 | void inject(TrendsPresenter trendsPresenter);
57 |
58 | void inject(Trends activity);
59 |
60 | void inject(MessageComposeFragment fragment);
61 |
62 | void inject(MessageComposePresenter presenter);
63 |
64 | void inject(SyncAdapter syncAdapter);
65 |
66 | void inject(InteractionsPresenter presenter);
67 |
68 | void inject(Tweet tweet);
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/sync/Authenticator.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.sync;
2 |
3 | import android.accounts.AbstractAccountAuthenticator;
4 | import android.accounts.Account;
5 | import android.accounts.AccountAuthenticatorResponse;
6 | import android.accounts.NetworkErrorException;
7 | import android.content.Context;
8 | import android.os.Bundle;
9 |
10 | /**
11 | * An authentactor class
12 | * Created by Aditya on 23-Jul-16.
13 | */
14 | public class Authenticator extends AbstractAccountAuthenticator {
15 | // Simple constructor
16 | public Authenticator(Context context) {
17 | super(context);
18 | }
19 |
20 | // Editing properties is not supported
21 | @Override
22 | public Bundle editProperties(
23 | AccountAuthenticatorResponse r, String s) {
24 | throw new UnsupportedOperationException();
25 | }
26 |
27 | // Don't add additional accounts
28 | @Override
29 | public Bundle addAccount(
30 | AccountAuthenticatorResponse r,
31 | String s,
32 | String s2,
33 | String[] strings,
34 | Bundle bundle) throws NetworkErrorException {
35 | return null;
36 | }
37 |
38 | // Ignore attempts to confirm credentials
39 | @Override
40 | public Bundle confirmCredentials(
41 | AccountAuthenticatorResponse r,
42 | Account account,
43 | Bundle bundle) throws NetworkErrorException {
44 | return null;
45 | }
46 |
47 | // Getting an authentication token is not supported
48 | @Override
49 | public Bundle getAuthToken(
50 | AccountAuthenticatorResponse r,
51 | Account account,
52 | String s,
53 | Bundle bundle) throws NetworkErrorException {
54 | throw new UnsupportedOperationException();
55 | }
56 |
57 | // Getting a label for the auth token is not supported
58 | @Override
59 | public String getAuthTokenLabel(String s) {
60 | throw new UnsupportedOperationException();
61 | }
62 |
63 | // Updating user credentials is not supported
64 | @Override
65 | public Bundle updateCredentials(
66 | AccountAuthenticatorResponse r,
67 | Account account,
68 | String s, Bundle bundle) throws NetworkErrorException {
69 | throw new UnsupportedOperationException();
70 | }
71 |
72 | // Checking features for the account is not supported
73 | @Override
74 | public Bundle hasFeatures(
75 | AccountAuthenticatorResponse r,
76 | Account account, String[] strings) throws NetworkErrorException {
77 | throw new UnsupportedOperationException();
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/injection/module/ApplicationModule.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.injection.module;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.preference.PreferenceManager;
7 |
8 | import com.ladwa.aditya.twitone.data.local.TwitterLocalDataStore;
9 | import com.ladwa.aditya.twitone.data.remote.TwitterRemoteDataSource;
10 | import com.ladwa.aditya.twitone.injection.ApplicationContext;
11 | import com.ladwa.aditya.twitone.util.Constants;
12 |
13 | import javax.inject.Singleton;
14 |
15 | import dagger.Module;
16 | import dagger.Provides;
17 | import twitter4j.AsyncTwitter;
18 | import twitter4j.AsyncTwitterFactory;
19 | import twitter4j.Twitter;
20 | import twitter4j.TwitterFactory;
21 | import twitter4j.conf.Configuration;
22 | import twitter4j.conf.ConfigurationBuilder;
23 |
24 | @Module
25 | public class ApplicationModule {
26 |
27 | protected final Application mApplication;
28 |
29 | public ApplicationModule(Application application) {
30 | mApplication = application;
31 | }
32 |
33 | @Provides
34 | Application provideApplication() {
35 | return mApplication;
36 | }
37 |
38 | @Provides
39 | @ApplicationContext
40 | Context provideContext() {
41 | return mApplication;
42 | }
43 |
44 |
45 | @Provides
46 | @Singleton
47 | SharedPreferences providesSharedPreferences(Application context) {
48 | return PreferenceManager.getDefaultSharedPreferences(context);
49 | }
50 |
51 | @Provides
52 | @Singleton
53 | Twitter providesTwitter() {
54 | ConfigurationBuilder builder = new ConfigurationBuilder();
55 | builder.setOAuthConsumerKey(Constants.OAUTH_COMSUMER_KEY);
56 | builder.setOAuthConsumerSecret(Constants.OAUTH_CONSUMER_SECRET);
57 | Configuration configuration = builder.build();
58 | return new TwitterFactory(configuration).getInstance();
59 | }
60 |
61 | @Provides
62 | @Singleton
63 | AsyncTwitter providesTwitterAsync() {
64 | ConfigurationBuilder builder = new ConfigurationBuilder();
65 | builder.setOAuthConsumerKey(Constants.OAUTH_COMSUMER_KEY);
66 | builder.setOAuthConsumerSecret(Constants.OAUTH_CONSUMER_SECRET);
67 | Configuration configuration = builder.build();
68 | return new AsyncTwitterFactory(configuration).getInstance();
69 | }
70 |
71 |
72 | @Provides
73 | @Singleton
74 | TwitterRemoteDataSource providesTwitterRemoteDataSource() {
75 | return new TwitterRemoteDataSource();
76 | }
77 |
78 | @Provides
79 | @Singleton
80 | TwitterLocalDataStore providesTwitterLocalDataStore(Application context) {
81 | return new TwitterLocalDataStore(context);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/widget/WidgetCollectionProvider.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.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.widget.RemoteViews;
10 | import android.widget.Toast;
11 |
12 | import com.ladwa.aditya.twitone.R;
13 |
14 |
15 | /**
16 | * An App widget provider
17 | * Created by Aditya on 25-Jul-16.
18 | */
19 | public class WidgetCollectionProvider extends AppWidgetProvider {
20 | public static final String CLICK_ACTION = "CLICK_ACTION";
21 | public static final String EXTRA_ITEM = "EXTRA_ITEM";
22 |
23 |
24 | @Override
25 | public void onReceive(Context context, Intent intent) {
26 | AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
27 | if (intent.getAction().equals(CLICK_ACTION)) {
28 | int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
29 | AppWidgetManager.INVALID_APPWIDGET_ID);
30 | int viewIndex = intent.getIntExtra(EXTRA_ITEM, 0);
31 | Toast.makeText(context, "Touched view " + viewIndex, Toast.LENGTH_SHORT).show();
32 | }
33 | super.onReceive(context, intent);
34 | }
35 |
36 | @Override
37 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
38 | for (int i = 0; i < appWidgetIds.length; i++) {
39 | int id = appWidgetIds[i];
40 |
41 | Intent intentWidget = new Intent(context, WidgetCollectionService.class);
42 | intentWidget.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
43 | intentWidget.setData(Uri.parse(intentWidget.toUri(Intent.URI_INTENT_SCHEME)));
44 |
45 | RemoteViews views = new RemoteViews(context.getApplicationContext().getPackageName(), R.layout.widget_collection);
46 | views.setRemoteAdapter(R.id.widget_list_view, intentWidget);
47 |
48 | Intent clickIntent = new Intent(context, WidgetCollectionService.class);
49 | clickIntent.setAction(CLICK_ACTION);
50 | clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
51 | clickIntent.setData(Uri.parse(clickIntent.toUri(Intent.URI_INTENT_SCHEME)));
52 |
53 |
54 | PendingIntent clickPendingIntent = PendingIntent
55 | .getBroadcast(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
56 | views.setPendingIntentTemplate(R.id.widget_list_view, clickPendingIntent);
57 | appWidgetManager.updateAppWidget(id, views);
58 | }
59 | super.onUpdate(context, appWidgetManager, appWidgetIds);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/local/models/Trend.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.local.models;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import com.google.auto.value.AutoValue;
7 | import com.ladwa.aditya.twitone.data.local.TwitterContract;
8 | import com.pushtorefresh.storio.contentresolver.annotations.StorIOContentResolverColumn;
9 | import com.pushtorefresh.storio.contentresolver.annotations.StorIOContentResolverType;
10 | import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn;
11 | import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType;
12 |
13 | /**
14 | * A model for Trend
15 | * Created by Aditya on 22-Jul-16.
16 | */
17 | @AutoValue
18 | @StorIOSQLiteType(table = TwitterContract.Trends.TABLE_NAME)
19 | @StorIOContentResolverType(uri = TwitterContract.Trends.CONTENT_URI_STRING)
20 | public class Trend implements Parcelable {
21 |
22 |
23 | @StorIOSQLiteColumn(name = TwitterContract.Trends.COLUMN_TREND, key = true)
24 | @StorIOContentResolverColumn(name = TwitterContract.Trends.COLUMN_TREND, key = true)
25 | String trend;
26 |
27 | @StorIOSQLiteColumn(name = TwitterContract.Trends.COLUMN_DATE_CREATED)
28 | @StorIOContentResolverColumn(name = TwitterContract.Trends.COLUMN_DATE_CREATED)
29 | String dateCreated;
30 |
31 | @StorIOSQLiteColumn(name = TwitterContract.Trends.COLUMN_LOCAL)
32 | @StorIOContentResolverColumn(name = TwitterContract.Trends.COLUMN_LOCAL)
33 | int local;
34 |
35 | public Trend() {
36 | }
37 |
38 |
39 | protected Trend(Parcel in) {
40 | trend = in.readString();
41 | dateCreated = in.readString();
42 | local = in.readInt();
43 | }
44 |
45 | public static final Creator CREATOR = new Creator() {
46 | @Override
47 | public Trend createFromParcel(Parcel in) {
48 | return new Trend(in);
49 | }
50 |
51 | @Override
52 | public Trend[] newArray(int size) {
53 | return new Trend[size];
54 | }
55 | };
56 |
57 |
58 | public String getTrend() {
59 | return trend;
60 | }
61 |
62 | public void setTrend(String trend) {
63 | this.trend = trend;
64 | }
65 |
66 | public String getDateCreated() {
67 | return dateCreated;
68 | }
69 |
70 | public void setDateCreated(String dateCreated) {
71 | this.dateCreated = dateCreated;
72 | }
73 |
74 | public int getLocal() {
75 | return local;
76 | }
77 |
78 | public void setLocal(int local) {
79 | this.local = local;
80 | }
81 |
82 | @Override
83 | public int describeContents() {
84 | return 0;
85 | }
86 |
87 | @Override
88 | public void writeToParcel(Parcel dest, int flags) {
89 | dest.writeString(trend);
90 | dest.writeString(dateCreated);
91 | dest.writeInt(local);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/AnimationUtil.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.content.Context;
6 | import android.support.annotation.ColorRes;
7 | import android.support.v4.content.ContextCompat;
8 | import android.support.v4.view.animation.FastOutLinearInInterpolator;
9 | import android.view.View;
10 | import android.view.ViewAnimationUtils;
11 |
12 | /**
13 | * Created by Aditya on 30-Jul-16.
14 | */
15 | public class AnimationUtil {
16 |
17 | public static void animateRevealShow(final Context ctx, final View view, final int startRadius,
18 | @ColorRes final int color, int x, int y, final OnRevealAnimationListener listener) {
19 | float finalRadius = (float) Math.hypot(view.getWidth(), view.getHeight());
20 | Animator anim = ViewAnimationUtils.createCircularReveal(view, x, y, startRadius, finalRadius);
21 | anim.setDuration(300);
22 | anim.setStartDelay(80);
23 | anim.setInterpolator(new FastOutLinearInInterpolator());
24 | anim.addListener(new AnimatorListenerAdapter() {
25 | @Override
26 | public void onAnimationStart(Animator animation) {
27 | view.setBackgroundColor(ContextCompat.getColor(ctx, color));
28 | }
29 |
30 | @Override
31 | public void onAnimationEnd(Animator animation) {
32 | view.setVisibility(View.VISIBLE);
33 | if (listener != null) {
34 | listener.onRevealShow();
35 | }
36 | }
37 | });
38 | anim.start();
39 | }
40 |
41 | public static void animateRevealHide(final Context ctx, final View view, @ColorRes final int color,
42 | final int finalRadius, final OnRevealAnimationListener listener) {
43 | int cx = (view.getLeft() + view.getRight()) / 2;
44 | int cy = (view.getTop() + view.getBottom()) / 2;
45 | int initialRadius = view.getWidth();
46 |
47 | Animator anim =
48 | ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, finalRadius);
49 | anim.addListener(new AnimatorListenerAdapter() {
50 | @Override
51 | public void onAnimationStart(Animator animation) {
52 | super.onAnimationStart(animation);
53 | view.setBackgroundColor(ctx.getResources().getColor(color));
54 | }
55 |
56 | @Override
57 | public void onAnimationEnd(Animator animation) {
58 | super.onAnimationEnd(animation);
59 | listener.onRevealHide();
60 | view.setVisibility(View.INVISIBLE);
61 | }
62 | });
63 | anim.setDuration(300);
64 | anim.start();
65 | }
66 |
67 | public interface OnRevealAnimationListener {
68 | void onRevealHide();
69 |
70 | void onRevealShow();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_direct_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
26 |
27 |
37 |
38 |
48 |
49 |
58 |
59 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.app.ActionBar;
7 | import android.support.v7.widget.Toolbar;
8 |
9 |
10 | import com.ladwa.aditya.twitone.TwitoneApp;
11 | import com.ladwa.aditya.twitone.injection.component.ConfigPersistentComponent;
12 | import com.ladwa.aditya.twitone.injection.component.DaggerConfigPersistentComponent;
13 | import com.ladwa.aditya.twitone.injection.component.FragmentComponent;
14 | import com.ladwa.aditya.twitone.injection.module.FragmentModule;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 | import java.util.concurrent.atomic.AtomicLong;
19 |
20 | import timber.log.Timber;
21 |
22 | public abstract class BaseFragment extends Fragment {
23 |
24 | private static final String KEY_FRAGMENT_ID = "KEY_FRAGMENT_ID";
25 | private static final Map sComponentsMap = new HashMap<>();
26 | private static final AtomicLong NEXT_ID = new AtomicLong(0);
27 |
28 | private FragmentComponent mFragmentComponent;
29 | private long mFragmentId;
30 |
31 | @Override
32 | public void onCreate(@Nullable Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 |
35 | // Create the FragmentComponent and reuses cached ConfigPersistentComponent if this is
36 | // being called after a configuration change.
37 | mFragmentId = savedInstanceState != null ?
38 | savedInstanceState.getLong(KEY_FRAGMENT_ID) : NEXT_ID.getAndIncrement();
39 | ConfigPersistentComponent configPersistentComponent;
40 | if (!sComponentsMap.containsKey(mFragmentId)) {
41 | Timber.i("Creating new ConfigPersistentComponent id=%d", mFragmentId);
42 | configPersistentComponent = DaggerConfigPersistentComponent.builder()
43 | .applicationComponent(TwitoneApp.get(getActivity()).getComponent())
44 | .build();
45 | sComponentsMap.put(mFragmentId, configPersistentComponent);
46 | } else {
47 | Timber.i("Reusing ConfigPersistentComponent id=%d", mFragmentId);
48 | configPersistentComponent = sComponentsMap.get(mFragmentId);
49 | }
50 | mFragmentComponent = configPersistentComponent.fragmentComponent(new FragmentModule(this));
51 | }
52 |
53 | @Override
54 | public void onSaveInstanceState(Bundle outState) {
55 | super.onSaveInstanceState(outState);
56 | outState.putLong(KEY_FRAGMENT_ID, mFragmentId);
57 | }
58 |
59 | @Override
60 | public void onDestroy() {
61 | if (!getActivity().isChangingConfigurations()) {
62 | Timber.i("Clearing ConfigPersistentComponent id=%d", mFragmentId);
63 | sComponentsMap.remove(mFragmentId);
64 | }
65 | super.onDestroy();
66 | }
67 |
68 | public FragmentComponent fragmentComponent() {
69 | return mFragmentComponent;
70 | }
71 |
72 | public void setupToolbar(Toolbar toolbar) {
73 | ((BaseActivity) getActivity()).setSupportActionBar(toolbar);
74 | final ActionBar ab = ((BaseActivity) getActivity()).getSupportActionBar();
75 | ab.setDisplayShowHomeEnabled(false);
76 | ab.setDisplayHomeAsUpEnabled(false);
77 | ab.setDisplayShowCustomEnabled(true);
78 | ab.setDisplayShowTitleEnabled(false);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/widget/WidgetCollectionRemoteFactory.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.widget;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.database.Cursor;
6 | import android.database.CursorIndexOutOfBoundsException;
7 | import android.os.Bundle;
8 | import android.widget.RemoteViews;
9 | import android.widget.RemoteViewsService;
10 |
11 | import com.ladwa.aditya.twitone.R;
12 | import com.ladwa.aditya.twitone.data.local.TwitterContract;
13 | import com.ladwa.aditya.twitone.util.Utility;
14 |
15 |
16 | /**
17 | * A Remote Factory class for Collection Widget
18 | * Created by Aditya on 25-Jul-16.
19 | */
20 | public class WidgetCollectionRemoteFactory implements RemoteViewsService.RemoteViewsFactory {
21 |
22 | private Cursor mCursor;
23 | private Context mContext = null;
24 |
25 | public WidgetCollectionRemoteFactory(Context context, Intent intent) {
26 | this.mContext = context;
27 | }
28 |
29 | @Override
30 | public void onCreate() {
31 | mCursor = mContext.getContentResolver().query(TwitterContract.Tweet.CONTENT_URI, null, null, null, TwitterContract.Tweet.COLUMN_ID + " DESC ");
32 | }
33 |
34 | @Override
35 | public void onDataSetChanged() {
36 |
37 | }
38 |
39 | @Override
40 | public void onDestroy() {
41 |
42 | }
43 |
44 | @Override
45 | public int getCount() {
46 | return mCursor.getCount();
47 | }
48 |
49 | @Override
50 | public RemoteViews getViewAt(int position) {
51 | RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.item_widget);
52 | try {
53 | if (position < getCount()) {
54 | mCursor.moveToNext();
55 | views.setTextViewText(R.id.textview_user_name,
56 | mCursor.getString(mCursor.getColumnIndex(TwitterContract.Tweet.COLUMN_USER_NAME)));
57 | views.setTextViewText(R.id.textview_screen_name,
58 | mCursor.getString(mCursor.getColumnIndex(TwitterContract.Tweet.COLUMN_USER_SCREEN_NAME)));
59 | views.setTextViewText(R.id.textview_time,
60 | Utility.parseDate(mCursor.getString(mCursor.getColumnIndex(TwitterContract.Tweet.COLUMN_DATE_CREATED)))
61 | );
62 | views.setTextViewText(R.id.textview_tweet,
63 | mCursor.getString(mCursor.getColumnIndex(TwitterContract.Tweet.COLUMN_TWEET)));
64 |
65 |
66 | }
67 | } catch (CursorIndexOutOfBoundsException | NullPointerException e) {
68 | e.printStackTrace();
69 | }
70 |
71 | Bundle extras = new Bundle();
72 | extras.putInt(WidgetCollectionProvider.EXTRA_ITEM, position);
73 | Intent fillInIntent = new Intent();
74 | fillInIntent.putExtras(extras);
75 | // Make it possible to distinguish the individual on-click
76 | // action of a given item
77 | views.setOnClickFillInIntent(R.id.widget_relative_layout, fillInIntent);
78 |
79 | return views;
80 | }
81 |
82 | @Override
83 | public RemoteViews getLoadingView() {
84 | return null;
85 | }
86 |
87 | @Override
88 | public int getViewTypeCount() {
89 | return 1;
90 | }
91 |
92 | @Override
93 | public long getItemId(int position) {
94 | return position;
95 | }
96 |
97 | @Override
98 | public boolean hasStableIds() {
99 | return true;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/messagecompose/MessageComposePresenter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.messagecompose;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.ladwa.aditya.twitone.TwitoneApp;
7 | import com.ladwa.aditya.twitone.data.local.TwitterLocalDataStore;
8 | import com.ladwa.aditya.twitone.data.local.models.DirectMessage;
9 | import com.ladwa.aditya.twitone.data.remote.TwitterRemoteDataSource;
10 |
11 | import java.util.List;
12 |
13 | import javax.inject.Inject;
14 |
15 | import rx.Subscriber;
16 | import rx.android.schedulers.AndroidSchedulers;
17 | import rx.schedulers.Schedulers;
18 |
19 | /**
20 | * A Presenter Class for Compose Message module
21 | * Created by Aditya on 31-Jul-16.
22 | */
23 | public class MessageComposePresenter implements MessageComposeContract.Presenter {
24 |
25 | private static final String TAG = MessageComposePresenter.class.getSimpleName();
26 | private MessageComposeContract.View mView;
27 | private long mSenderId;
28 | private Context mContext;
29 |
30 | @Inject TwitterLocalDataStore mTwitterLocalDataStore;
31 | @Inject TwitterRemoteDataSource mTwitterRemoteDataSource;
32 |
33 |
34 | public MessageComposePresenter(MessageComposeContract.View mView, Context mContext, long senderid) {
35 | this.mView = mView;
36 | this.mContext = mContext;
37 | this.mSenderId = senderid;
38 | mView.setPresenter(this);
39 | TwitoneApp.getTwitterComponent().inject(this);
40 | }
41 |
42 | @Override
43 | public void getUserDirectMessage() {
44 | mTwitterLocalDataStore.getDirectMessageOfUser(mSenderId)
45 | .observeOn(AndroidSchedulers.mainThread())
46 | .subscribeOn(Schedulers.newThread())
47 | .subscribe(new Subscriber>() {
48 | @Override
49 | public void onCompleted() {
50 |
51 | }
52 |
53 | @Override
54 | public void onError(Throwable e) {
55 | Log.e(TAG, "Error :" + e.toString());
56 | }
57 |
58 | @Override
59 | public void onNext(List directMessageList) {
60 | mView.loadUserDirectMessage(directMessageList);
61 | mView.stopRefreshing();
62 | }
63 | });
64 |
65 | }
66 |
67 | @Override
68 | public void sendDirectMessage(long recipentId, String message) {
69 | mTwitterRemoteDataSource.sendDirectMessage(recipentId, message)
70 | .observeOn(AndroidSchedulers.mainThread())
71 | .subscribeOn(Schedulers.newThread())
72 | .subscribe(new Subscriber() {
73 | @Override
74 | public void onCompleted() {
75 | // Timber.d("Message sent");
76 | getUserDirectMessage();
77 | mView.clearEditText();
78 | }
79 |
80 | @Override
81 | public void onError(Throwable e) {
82 | // Timber.e(e, "Error :" + e.toString());
83 | }
84 |
85 | @Override
86 | public void onNext(DirectMessage directMessage) {
87 |
88 | }
89 | });
90 | }
91 |
92 | @Override
93 | public void subscribe() {
94 | getUserDirectMessage();
95 | }
96 |
97 | @Override
98 | public void unsubscribe() {
99 |
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_tweet.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
21 |
22 |
27 |
28 |
37 |
38 |
48 |
49 |
50 |
58 |
59 |
69 |
70 |
78 |
79 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | //Titles
4 | Twitone
5 | LoginActivity
6 | MainScreen
7 | Interactions
8 |
9 |
10 | Settings
11 |
12 |
13 |
14 | //Utility Strings
15 | Login In to Twitter
16 | Log Out
17 | Login Button
18 | Log Out
19 | Are you sure you want to Logout?
20 | Yes
21 | No
22 | Check internet connection
23 | An error occurred
24 | Favourite
25 | UnFavourite
26 | Retweeted
27 |
28 |
29 | //Drawer Items
30 | Timeline
31 | Interection
32 | Messages
33 | Settings
34 | Trends
35 | Log Out
36 | Profile Image
37 |
38 | //Timeline Item
39 | \@%1$s
40 |
41 | //Dummy
42 | At NEDA conclave I assured all the partners that their participation role in NEDA would be as important as BJPS.
43 | Scroll_pos_interaction
44 | Scroll_pos
45 | Message
46 | Trends
47 |
48 |
49 | Hello blank fragment
50 | " New Tweets"
51 |
52 | com.ladwa.aditya.twitone
53 | com.ladwa.aditya.twitone
54 | ImageViewer
55 | extra_url
56 | Save
57 | Storage permission needed to save Images
58 | Tweet
59 | What\'s happening?
60 | Cant determine your Location
61 | Location suspended
62 | Location failed
63 | 140
64 | TweetDetail
65 | extra_id
66 | extra_replay
67 | extra_is_replay
68 | profile_pic
69 | extra_tweet_parcle
70 | profile_pic_verified
71 | MessageCompose
72 | Type your message...
73 | extra_sender_id
74 | extra_sender_name
75 | Settings
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/util/Utility.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.util;
2 |
3 | import android.content.Context;
4 | import android.content.res.Configuration;
5 |
6 | import java.text.ParseException;
7 | import java.text.SimpleDateFormat;
8 | import java.util.Date;
9 | import java.util.Locale;
10 |
11 | /**
12 | * A Class with utility functions
13 | * Created by Aditya on 13-Jul-16.
14 | */
15 | public class Utility {
16 |
17 | public static final long TWO_DAY_IN_SECOND = 172800;
18 | public static final long DUMMY_TIME = 5;
19 |
20 | private static final int SECOND_MILLIS = 1000;
21 | private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
22 | private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
23 | private static final int DAY_MILLIS = 24 * HOUR_MILLIS;
24 |
25 |
26 | public static final String TWITTER_DATE = "Wed Jul 20 01:39:56 GMT+05:30 2016";
27 |
28 | public static String getDateTime() {
29 | SimpleDateFormat dateFormat = new SimpleDateFormat(
30 | "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
31 | Date date = new Date();
32 | return dateFormat.format(date);
33 | }
34 |
35 | public static long getTimeDifference(String dbDate) {
36 | Date d1 = null, d2 = null;
37 | SimpleDateFormat dateFormat = new SimpleDateFormat(
38 | "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
39 | String now = getDateTime();
40 |
41 | try {
42 | d2 = dateFormat.parse(now);
43 | d1 = dateFormat.parse(dbDate);
44 |
45 | } catch (ParseException e) {
46 | e.printStackTrace();
47 | }
48 | assert d2 != null;
49 | assert d1 != null;
50 | return (d2.getTime() - d1.getTime()) / 1000;
51 | }
52 |
53 | public static boolean checkProfileDataValidity(String date) {
54 | long second = getTimeDifference(date);
55 | return second < TWO_DAY_IN_SECOND;
56 | }
57 |
58 | public static boolean isTablet(Context context) {
59 | boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
60 | boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
61 | return (xlarge || large);
62 | }
63 |
64 | public static String parseDate(String date) {
65 | Date twitterDate = null;
66 | SimpleDateFormat sf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
67 | try {
68 | twitterDate = sf.parse(date);
69 | } catch (ParseException e) {
70 | e.printStackTrace();
71 | }
72 | return getTimeAgo(twitterDate.getTime());
73 | }
74 |
75 | public static String getTimeAgo(long time) {
76 | if (time < 1000000000000L) {
77 | // if timestamp given in seconds, convert to millis
78 | time *= 1000;
79 | }
80 |
81 | long now = new Date().getTime();
82 | if (time > now || time <= 0) {
83 | return null;
84 | }
85 |
86 | // TODO: localize
87 | final long diff = now - time;
88 | if (diff < MINUTE_MILLIS) {
89 | return "just now";
90 | } else if (diff < 2 * MINUTE_MILLIS) {
91 | return "1 min ago ";
92 | } else if (diff < 50 * MINUTE_MILLIS) {
93 | return diff / MINUTE_MILLIS + " mins ago";
94 | } else if (diff < 90 * MINUTE_MILLIS) {
95 | return "1 hour ago";
96 | } else if (diff < 24 * HOUR_MILLIS) {
97 | return diff / HOUR_MILLIS + " hours ago";
98 | } else if (diff < 48 * HOUR_MILLIS) {
99 | return "yesterday";
100 | } else {
101 | return diff / DAY_MILLIS + " days";
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.util.ArrayMap;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 |
9 | import com.ladwa.aditya.twitone.TwitoneApp;
10 | import com.ladwa.aditya.twitone.injection.component.ActivityComponent;
11 | import com.ladwa.aditya.twitone.injection.component.ConfigPersistentComponent;
12 | import com.ladwa.aditya.twitone.injection.component.DaggerConfigPersistentComponent;
13 | import com.ladwa.aditya.twitone.injection.module.ActivityModule;
14 | import com.ladwa.aditya.twitone.ui.settings.SettingsRepository;
15 |
16 | import java.util.Map;
17 | import java.util.concurrent.atomic.AtomicLong;
18 |
19 | import timber.log.Timber;
20 |
21 | public abstract class BaseActivity extends AppCompatActivity {
22 |
23 | private static final String KEY_ACTIVITY_ID = "KEY_ACTIVITY_ID";
24 | private static final AtomicLong NEXT_ID = new AtomicLong(0);
25 | private static final Map sComponentsMap = new ArrayMap<>();
26 |
27 | private ActivityComponent mActivityComponent;
28 | private long mActivityId;
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 |
34 | // Create the ActivityComponent and reuses cached ConfigPersistentComponent if this is
35 | // being called after a configuration change.
36 | mActivityId = savedInstanceState != null ?
37 | savedInstanceState.getLong(KEY_ACTIVITY_ID) : NEXT_ID.getAndIncrement();
38 | ConfigPersistentComponent configPersistentComponent;
39 | if (!sComponentsMap.containsKey(mActivityId)) {
40 | Timber.i("Creating new ConfigPersistentComponent id=%d", mActivityId);
41 | configPersistentComponent = DaggerConfigPersistentComponent.builder()
42 | .applicationComponent(TwitoneApp.get(this).getComponent())
43 | .build();
44 | sComponentsMap.put(mActivityId, configPersistentComponent);
45 | } else {
46 | Timber.i("Reusing ConfigPersistentComponent id=%d", mActivityId);
47 | configPersistentComponent = sComponentsMap.get(mActivityId);
48 | }
49 | mActivityComponent = configPersistentComponent.activityComponent(new ActivityModule(this));
50 | mActivityComponent.inject(this);
51 | SettingsRepository.getInstance().setTheme(this);
52 | }
53 |
54 | @Override
55 | protected void onSaveInstanceState(Bundle outState) {
56 | super.onSaveInstanceState(outState);
57 | outState.putLong(KEY_ACTIVITY_ID, mActivityId);
58 | }
59 |
60 | @Override
61 | protected void onDestroy() {
62 | SettingsRepository.destroyInstance();
63 | if (!isChangingConfigurations()) {
64 | Timber.i("Clearing ConfigPersistentComponent id=%d", mActivityId);
65 | sComponentsMap.remove(mActivityId);
66 | }
67 | super.onDestroy();
68 | }
69 |
70 | @Override
71 | public boolean onOptionsItemSelected(MenuItem item) {
72 | switch (item.getItemId()) {
73 | case android.R.id.home:
74 | finish();
75 | return true;
76 | default:
77 | return super.onOptionsItemSelected(item);
78 | }
79 | }
80 |
81 |
82 | public ActivityComponent activityComponent() {
83 | return mActivityComponent;
84 | }
85 |
86 | protected void setupToolbar(Toolbar toolbar) {
87 | setSupportActionBar(toolbar);
88 | getSupportActionBar().setDisplayShowTitleEnabled(false);
89 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
90 | }
91 |
92 | protected void initToolbar(Toolbar toolbar) {
93 | setSupportActionBar(toolbar);
94 | getSupportActionBar().setDisplayShowTitleEnabled(false);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Twitone [](https://github.com/LadwaAditya/TwiTone-Android/stargazers) [](https://github.com/LadwaAditya/TwiTone-Android/network) [](https://github.com/LadwaAditya/TwiTone-Android/issues)
2 |
3 |
4 | ## A light Twitter Client for Android
5 |
6 | ### Software Archeticture
7 |
8 | 1. Model View Presenter(MVP) - Presenter is used to Abstract the functionality that the individual component of the app provides
9 | 2. Repository Pattern - A local and remote data repository are used to get and store data. Provides a way to abstract and encapsulate functionality and caching.
10 |
11 | ----------------------------------------------------------------------------------------------------
12 |
13 |
14 |
15 |
16 | ### Show some :heart: and star the repo to support the project
17 | [](https://github.com/LadwaAditya/TwiTone-Android) [](https://github.com/LadwaAditya/TwiTone-Android/fork) [](https://github.com/LadwaAditya/TwiTone-Android) [](https://github.com/LadwaAditya)
18 | [](https://twitter.com/adi_ladwa)
19 |
20 | ## Libraries used
21 |
22 | 1. [StorIO](https://github.com/pushtorefresh/storio)
23 | 2. [Dagger 2](http://google.github.io/dagger/)
24 | 3. [RxJava](https://github.com/ReactiveX/RxJava) and [RxAndroid](https://github.com/ReactiveX/RxAndroid)
25 | 4. [Twitter4j](http://twitter4j.org/en/)
26 | 5. [Butterknife](https://github.com/JakeWharton/butterknife)
27 | 6. [LeakCanary](https://github.com/square/leakcanary)
28 | 7. [Material Progress Bar](https://github.com/DreaminginCodeZH/MaterialProgressBar)
29 | 8. [Material Drawer](https://github.com/mikepenz/MaterialDrawer)
30 | 9. [FontAwesome](https://github.com/FortAwesome/Font-Awesome)
31 | 10. [Glide 3](https://github.com/bumptech/glide)
32 | 11. [Circular Image view](https://github.com/hdodenhof/CircleImageView)
33 | 12. [Sub-sampling ImageView](https://github.com/davemorrissey/subsampling-scale-image-view)
34 | 13. [Stetho](http://facebook.github.io/stetho/)
35 | 14. [AutoValue](https://github.com/google/auto/tree/master/value)
36 | 15. [AutoParcle](https://github.com/frankiesardo/auto-parcel)
37 | 16. [Espresso](https://google.github.io/android-testing-support-library/)
38 | 17. [Google Play Services](https://developers.google.com/android/guides/overview)
39 |
40 |
41 | ----------------------------------------------------------------------------------------------------
42 |
43 | ## Buiding
44 |
45 | To build, install and run a debug version, run this from the root of the project:
46 |
47 | ```
48 | ./gradlew app:assembleDebug
49 | ```
50 |
51 |
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 |
60 | ## License
61 |
62 | ```
63 | Copyright 2017 Aditya Ladwa
64 |
65 | Licensed under the Apache License, Version 2.0 (the "License");
66 | you may not use this file except in compliance with the License.
67 | You may obtain a copy of the License at
68 |
69 | http://www.apache.org/licenses/LICENSE-2.0
70 |
71 | Unless required by applicable law or agreed to in writing, software
72 | distributed under the License is distributed on an "AS IS" BASIS,
73 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74 | See the License for the specific language governing permissions and
75 | limitations under the License.
76 | ```
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/data/local/models/User.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.data.local.models;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import com.google.auto.value.AutoValue;
7 | import com.ladwa.aditya.twitone.data.local.TwitterContract;
8 | import com.pushtorefresh.storio.contentresolver.annotations.StorIOContentResolverColumn;
9 | import com.pushtorefresh.storio.contentresolver.annotations.StorIOContentResolverType;
10 | import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn;
11 | import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType;
12 |
13 | /**
14 | * A model for User profile
15 | * Created by Aditya on 04-Jul-16.
16 | */
17 | @AutoValue
18 | @StorIOSQLiteType(table = TwitterContract.User.TABLE_NAME)
19 | @StorIOContentResolverType(uri = TwitterContract.User.CONTENT_URI_STRING)
20 | public class User implements Parcelable {
21 |
22 |
23 | public User() {
24 | }
25 |
26 | @StorIOSQLiteColumn(name = TwitterContract.User.COLUMN_ID, key = true)
27 | @StorIOContentResolverColumn(name = TwitterContract.User.COLUMN_ID, key = true)
28 | Long id;
29 |
30 | @StorIOSQLiteColumn(name = TwitterContract.User.COLUMN_NAME)
31 | @StorIOContentResolverColumn(name = TwitterContract.User.COLUMN_NAME)
32 | String name;
33 |
34 | @StorIOSQLiteColumn(name = TwitterContract.User.COLUMN_SCREEN_NAME)
35 | @StorIOContentResolverColumn(name = TwitterContract.User.COLUMN_SCREEN_NAME)
36 | String screenName;
37 |
38 | @StorIOSQLiteColumn(name = TwitterContract.User.COLUMN_PROFILE_IMAGE_URL)
39 | @StorIOContentResolverColumn(name = TwitterContract.User.COLUMN_PROFILE_IMAGE_URL)
40 | String profileUrl;
41 |
42 | @StorIOSQLiteColumn(name = TwitterContract.User.COLUMN_BANNER_URL)
43 | @StorIOContentResolverColumn(name = TwitterContract.User.COLUMN_BANNER_URL)
44 | String bannerUrl;
45 |
46 | @StorIOSQLiteColumn(name = TwitterContract.User.COLUMN_LAST_MODIFIED)
47 | @StorIOContentResolverColumn(name = TwitterContract.User.COLUMN_LAST_MODIFIED)
48 | String lastModified;
49 |
50 | public String getLastModified() {
51 | return lastModified;
52 | }
53 |
54 | public void setLastModified(String lastModified) {
55 | this.lastModified = lastModified;
56 | }
57 |
58 | public Long getId() {
59 | return id;
60 | }
61 |
62 | public void setId(Long id) {
63 | this.id = id;
64 | }
65 |
66 | public String getName() {
67 | return name;
68 | }
69 |
70 | public void setName(String name) {
71 | this.name = name;
72 | }
73 |
74 | public String getScreenName() {
75 | return screenName;
76 | }
77 |
78 | public void setScreenName(String screenName) {
79 | this.screenName = screenName;
80 | }
81 |
82 | public String getProfileUrl() {
83 | return profileUrl;
84 | }
85 |
86 | public void setProfileUrl(String profileUrl) {
87 | this.profileUrl = profileUrl;
88 | }
89 |
90 | public String getBannerUrl() {
91 | return bannerUrl;
92 | }
93 |
94 | public void setBannerUrl(String bannerUrl) {
95 | this.bannerUrl = bannerUrl;
96 | }
97 |
98 | protected User(Parcel in) {
99 | name = in.readString();
100 | screenName = in.readString();
101 | profileUrl = in.readString();
102 | bannerUrl = in.readString();
103 | lastModified = in.readString();
104 | }
105 |
106 | public static final Creator CREATOR = new Creator() {
107 | @Override
108 | public User createFromParcel(Parcel in) {
109 | return new User(in);
110 | }
111 |
112 | @Override
113 | public User[] newArray(int size) {
114 | return new User[size];
115 | }
116 | };
117 |
118 | @Override
119 | public int describeContents() {
120 | return 0;
121 | }
122 |
123 | @Override
124 | public void writeToParcel(Parcel dest, int flags) {
125 | dest.writeString(name);
126 | dest.writeString(screenName);
127 | dest.writeString(profileUrl);
128 | dest.writeString(bannerUrl);
129 | dest.writeString(lastModified);
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/adapter/DirectMessageAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.ColorDrawable;
5 | import android.preference.PreferenceManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.bumptech.glide.Glide;
14 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
15 | import com.ladwa.aditya.twitone.R;
16 | import com.ladwa.aditya.twitone.data.local.models.DirectMessage;
17 | import com.ladwa.aditya.twitone.util.Utility;
18 |
19 | import java.util.List;
20 |
21 | import butterknife.BindView;
22 | import butterknife.ButterKnife;
23 |
24 | /**
25 | * An Adapter for direct message
26 | * Created by Aditya on 20-Jul-16.
27 | */
28 | public class DirectMessageAdapter extends RecyclerView.Adapter {
29 |
30 | private List mDirectMessageList;
31 | private Context mContext;
32 | private DirectMessage mDirectMessage;
33 | private DirectMessageClickListener messageClickListener;
34 | private long id;
35 | private ColorDrawable mColorDrawablePlaceholder = new ColorDrawable(0xFFFF6666);
36 |
37 | public DirectMessageAdapter(List mDirectMessageList, Context mContext) {
38 | this.mDirectMessageList = mDirectMessageList;
39 | this.mContext = mContext;
40 | id = PreferenceManager.getDefaultSharedPreferences(mContext).getLong(mContext.getString(R.string.pref_userid), 0);
41 | }
42 |
43 | public interface DirectMessageClickListener {
44 | void onItemClick(View view, int position);
45 | }
46 |
47 | @Override
48 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
49 | View itemView = LayoutInflater.from(parent.getContext())
50 | .inflate(R.layout.item_direct_message, parent, false);
51 | return new ViewHolder(itemView);
52 | }
53 |
54 | @Override
55 | public void onBindViewHolder(ViewHolder holder, int position) {
56 | mDirectMessage = mDirectMessageList.get(position);
57 |
58 |
59 | holder.textViewText.setText(mDirectMessage.getText());
60 | holder.textViewUserName.setText(mDirectMessage.getSender());
61 | holder.textViewScreenName.setText(String.format(mContext.getString(R.string.user_name), mDirectMessage.getSenderScreenName()));
62 | holder.textViewDate.setText(Utility.parseDate(mDirectMessage.getDateCreated()));
63 | Glide.with(mContext)
64 | .load(mDirectMessage.getProfileUrl())
65 | .centerCrop()
66 | .placeholder(mColorDrawablePlaceholder)
67 | .diskCacheStrategy(DiskCacheStrategy.ALL)
68 | .dontAnimate()
69 | .into(holder.imageViewProfile);
70 |
71 |
72 | }
73 |
74 | @Override
75 | public int getItemCount() {
76 | if (mDirectMessageList == null)
77 | return 0;
78 | else return mDirectMessageList.size();
79 | }
80 |
81 | public void setMessageClickListener(DirectMessageClickListener messageClickListener) {
82 | this.messageClickListener = messageClickListener;
83 | }
84 |
85 | public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
86 |
87 |
88 | @BindView(R.id.imageview_profile_pic)
89 | ImageView imageViewProfile;
90 | @BindView(R.id.textview_text)
91 | TextView textViewText;
92 | @BindView(R.id.textview_screen_name)
93 | TextView textViewScreenName;
94 | @BindView(R.id.textview_time)
95 | TextView textViewDate;
96 | @BindView(R.id.textview_user_name)
97 | TextView textViewUserName;
98 |
99 |
100 | public ViewHolder(View itemView) {
101 | super(itemView);
102 | ButterKnife.bind(this, itemView);
103 | itemView.setOnClickListener(this);
104 | }
105 |
106 | @Override
107 | public void onClick(View v) {
108 | messageClickListener.onItemClick(v, getAdapterPosition());
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ladwa/aditya/twitone/ui/adapter/MessageComposeAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ladwa.aditya.twitone.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.ladwa.aditya.twitone.R;
11 | import com.ladwa.aditya.twitone.ui.customview.ChatBubbleTextView;
12 | import com.ladwa.aditya.twitone.data.local.models.DirectMessage;
13 |
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 |
19 | /**
20 | * An Adapter for Compose Message Module
21 | * Created by Aditya on 31-Jul-16.
22 | */
23 | public class MessageComposeAdapter extends RecyclerView.Adapter {
24 | private final int LEFT = 0, RIGHT = 1;
25 |
26 | private List mDirectMessageList;
27 | private Context mContext;
28 | private DirectMessage mDirectMessage;
29 | private long mSenderId;
30 |
31 | public MessageComposeAdapter(List mDirectMessageList, Context mContext, long senderId) {
32 | this.mDirectMessageList = mDirectMessageList;
33 | this.mContext = mContext;
34 | this.mSenderId = senderId;
35 | }
36 |
37 | @Override
38 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
39 | RecyclerView.ViewHolder viewHolder;
40 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
41 |
42 | switch (viewType) {
43 | case LEFT:
44 | viewHolder = new ViewHolderLeft(inflater.inflate(R.layout.message_bubble_left, parent, false));
45 | break;
46 | case RIGHT:
47 | viewHolder = new ViewHolderRight(inflater.inflate(R.layout.message_bubble_right, parent, false));
48 | break;
49 | default:
50 | viewHolder = new ViewHolderRight(inflater.inflate(R.layout.message_bubble_right, parent, false));
51 | break;
52 |
53 | }
54 | return viewHolder;
55 | }
56 |
57 | @Override
58 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
59 | mDirectMessage = mDirectMessageList.get(position);
60 |
61 | switch (holder.getItemViewType()) {
62 | case LEFT:
63 | ViewHolderLeft viewHolderLeft = (ViewHolderLeft) holder;
64 | viewHolderLeft.textViewMessage.setText(mDirectMessage.getText());
65 | viewHolderLeft.textViewSender.setText(mDirectMessage.getSender());
66 | break;
67 |
68 | case RIGHT:
69 | ViewHolderRight viewHolderRight = (ViewHolderRight) holder;
70 | viewHolderRight.textViewMessage.setText(mDirectMessage.getText());
71 | viewHolderRight.textViewSender.setText(mDirectMessage.getSender());
72 | break;
73 | default:
74 | break;
75 | }
76 | }
77 |
78 | @Override
79 | public int getItemCount() {
80 | if (mDirectMessageList == null)
81 | return 0;
82 | else return mDirectMessageList.size();
83 | }
84 |
85 | @Override
86 | public int getItemViewType(int position) {
87 | Long senderId = mDirectMessageList.get(position).getSenderId();
88 | if (senderId == mSenderId)
89 | return RIGHT;
90 | else
91 | return LEFT;
92 |
93 | }
94 |
95 | public class ViewHolderLeft extends RecyclerView.ViewHolder {
96 |
97 | @BindView(R.id.textview_from_sender)
98 | TextView textViewSender;
99 |
100 | @BindView(R.id.textview_from_message)
101 | TextView textViewMessage;
102 |
103 | public ViewHolderLeft(View itemView) {
104 | super(itemView);
105 | ButterKnife.bind(this, itemView);
106 | }
107 |
108 |
109 | }
110 |
111 |
112 | public class ViewHolderRight extends RecyclerView.ViewHolder {
113 |
114 | @BindView(R.id.textview_to_sender)
115 | TextView textViewSender;
116 |
117 | @BindView(R.id.textview_to_message)
118 | ChatBubbleTextView textViewMessage;
119 |
120 | public ViewHolderRight(View itemView) {
121 | super(itemView);
122 | ButterKnife.bind(this, itemView);
123 | }
124 |
125 | }
126 | }
127 |
--------------------------------------------------------------------------------