diff options
author | laco0416 <laco0416@gmail.com> | 2015-04-26 19:03:29 +0900 |
---|---|---|
committer | laco0416 <laco0416@gmail.com> | 2015-04-26 19:03:31 +0900 |
commit | d2cda779b3dcaad81ad68018270b84636a576c37 (patch) | |
tree | cf6b2e2019f0778ef96bb5b2ee7849b6722bee8d /app | |
parent | ae56571e6e1358ce2ae7afb24959d97af0917022 (diff) | |
download | SmileEssence-d2cda779b3dcaad81ad68018270b84636a576c37.tar.gz |
Reconstruct the project
Diffstat (limited to 'app')
-rw-r--r-- | app/.gitignore | 2 | ||||
-rw-r--r-- | app/app.iml | 24 | ||||
-rw-r--r-- | app/build.gradle | 76 | ||||
-rw-r--r-- | app/libs/ActiveAndroid-3.1.jar | bin | 0 -> 43493 bytes | |||
-rw-r--r-- | app/proguard-rules.pro | 2 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/command/CommandsTest.java | 10 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/command/NanigajaTest.java | 31 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/command/PostCommandsTest.java | 22 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/preference/SharedPreferenceHelperTest.java | 18 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/preference/UserPreferenceHelperTest.java | 16 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/twitter/TweetBuilderTest.java | 11 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/twitter/TwitterUtilsTest.java | 15 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/twitter/UserStreamListenerTest.java | 239 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/util/TwitterMock.java | 76 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/view/adapter/CustomListAdapterTest.java | 28 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java | 11 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/MessageViewModelTest.java | 11 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/StatusViewModelTest.java | 16 | ||||
-rw-r--r-- | app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/UserViewModelTest.java | 49 | ||||
-rw-r--r-- | app/src/main/AndroidManifest.xml | 95 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/Application.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/Application.java) | 9 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/IntentRouter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/IntentRouter.java) | 176 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditCommandActivity.java) | 72 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditExtractionActivity.java) | 91 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditTabActivity.java) | 52 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditTemplateActivity.java) | 91 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/LicenseActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/LicenseActivity.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/MainActivity.java) | 450 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/OAuthActivity.java) | 45 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/activity/SettingActivity.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/activity/SettingActivity.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/Command.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/Command.java) | 48 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandOpenHashtagDialog.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenHashtagDialog.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandOpenSearch.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenSearch.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandOpenTemplateList.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenTemplateList.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandOpenURL.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenURL.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenUserDetail.java) | 30 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserList.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenUserList.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandPasteToPost.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandPasteToPost.java) | 20 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandSaveAsTemplate.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/CommandSearchOnTwitter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandSearchOnTwitter.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/IConfirmable.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/IConfirmable.java) | 3 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommand.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommand.java) | 11 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandCopyTextToClipboard.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandSearchOnGoogle.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandSearchOnGoogle.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandShare.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandShare.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandTofuBuster.java) | 24 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/post/PostCommand.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommand.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandInsert.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandInsert.java) | 18 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandMakeAnonymous.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandMakeAnonymous.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandMorse.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandMorse.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandUseTemplate.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandUseTemplate.java) | 10 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandZekamashi.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandZekamashi.java) | 22 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommand.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommand.java) | 14 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToIgnore.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandAddToIgnore.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandAddToReply.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCongratulate.java) | 45 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopy.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopy.java) | 21 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopyTextToClipboard.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopyURLToClipboard.java) | 39 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandFavAndRT.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandMakeAnonymous.java) | 26 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandNanigaja.java) | 33 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenInBrowser.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenInBrowser.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenQuoteDialog.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenQuoteDialog.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenTalkView.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenTalkView.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandReview.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandSearchOnGoogle.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandSearchOnGoogle.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandShare.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandShare.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandTextQuote.java) | 25 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandTofuBuster.java) | 24 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandURLQuote.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandURLQuote.java) | 23 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommand.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommand.java) | 11 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandAddToReply.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandBlock.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandIntroduce.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandIntroduce.java) | 23 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenAclog.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenAclog.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenFavstar.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenFavstar.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenTwilog.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenTwilog.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReply.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandReply.java) | 23 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandReportForSpam.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandSendMessage.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandSendMessage.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandUnblock.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/CommandSettingCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/CommandSettingCache.java) | 18 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/DirectMessageCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/DirectMessageCache.java) | 21 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/FavoriteCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/FavoriteCache.java) | 34 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/ImageCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/ImageCache.java) | 31 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/StatusCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/StatusCache.java) | 30 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/UserCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/UserCache.java) | 27 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/data/UserListCache.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/data/UserListCache.java) | 21 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/entity/Account.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/entity/Account.java) | 12 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/entity/CommandSetting.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/entity/CommandSetting.java) | 15 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/entity/ExtractionWord.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/entity/ExtractionWord.java) | 20 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/entity/SearchQuery.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/entity/SearchQuery.java) | 25 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/entity/Template.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/entity/Template.java) | 20 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/logging/Logger.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/logging/Logger.java) | 18 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/notification/NotificationType.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/notification/NotificationType.java) | 3 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/notification/Notificator.java) | 72 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/preference/AppPreferenceHelper.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/preference/AppPreferenceHelper.java) | 6 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/preference/SharedPreferenceHelper.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/preference/SharedPreferenceHelper.java) | 45 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/preference/UserPreferenceHelper.java) | 73 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/OAuthSession.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/OAuthSession.java) | 29 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/StatusFilter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/StatusFilter.java) | 21 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/TweetBuilder.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/TweetBuilder.java) | 46 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/TwitterApi.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/TwitterApi.java) | 34 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/UserStreamListener.java) | 163 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/AccessTokenTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/AccessTokenTask.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockIDsTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/BlockIDsTask.java) | 31 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/BlockTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DeleteMessageTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DeleteStatusTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DirectMessagesTask.java) | 44 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/FavoriteTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/FollowTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/GetUserListsTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/GetUserListsTask.java) | 23 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/HomeTimelineTask.java) | 44 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/MentionsTimelineTask.java) | 44 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/MutesIDsTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/MutesIDsTask.java) | 31 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ReportForSpamTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/RequestTokenTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/RequestTokenTask.java) | 17 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/RetweetTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SearchTask.java) | 41 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SendMessageTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SentDirectMessagesTask.java) | 44 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowDirectMessageTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowDirectMessageTask.java) | 23 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowFriendshipTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowFriendshipTask.java) | 27 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowStatusTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowStatusTask.java) | 23 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowUserTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowUserTask.java) | 33 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/TweetTask.java) | 68 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/TwitterTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/TwitterTask.java) | 7 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnblockTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnfavoriteTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnfollowTask.java) | 28 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/UserListStatusesTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UserListStatusesTask.java) | 26 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UserTimelineTask.java) | 33 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/twitter/util/TwitterUtils.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/util/TwitterUtils.java) | 169 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/BitmapOptimizer.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapOptimizer.java) | 64 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/BitmapThumbnailTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapThumbnailTask.java) | 15 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/BitmapURLTask.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapURLTask.java) | 33 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/IntentUtils.java) | 27 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/Morse.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/Morse.java) | 58 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/NameStyles.java) | 21 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/NetworkHelper.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/NetworkHelper.java) | 9 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/StringUtils.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/StringUtils.java) | 26 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/Themes.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/Themes.java) | 25 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/util/UIHandler.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/util/UIHandler.java) | 24 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/CustomListFragment.java) | 70 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/HistoryFragment.java) | 13 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/HomeFragment.java) | 51 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/MentionsFragment.java) | 42 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/MessagesFragment.java) | 42 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/PostFragment.java) | 191 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/SearchFragment.java) | 191 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/SettingFragment.java) | 82 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/TextFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/TextFragment.java) | 12 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/UserListFragment.java) | 96 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/CustomListAdapter.java) | 101 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/EventListAdapter.java) | 7 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/MessageListAdapter.java) | 58 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/PageListAdapter.java) | 67 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/PostState.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/PostState.java) | 94 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/SearchListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/SearchListAdapter.java) | 30 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/StatusListAdapter.java) | 61 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/ChooseTemplateDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ChooseTemplateDialogFragment.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/ConfirmDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ConfirmDialogFragment.java) | 63 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/DialogHelper.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/DialogHelper.java) | 33 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/DisposeDialog.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/DisposeDialog.java) | 15 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/EditTextDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/EditTextDialogFragment.java) | 27 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/HashtagDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/HashtagDialogFragment.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MenuDialogFragment.java) | 35 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MessageDetailDialogFragment.java) | 131 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageMenuDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MessageMenuDialogFragment.java) | 65 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/PostMenuDialogFragment.java) | 22 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/QuoteDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/QuoteDialogFragment.java) | 29 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ReviewDialogFragment.java) | 56 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/SearchOnGoogleDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SearchOnGoogleDialogFragment.java) | 44 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectImageDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectImageDialogFragment.java) | 43 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectSearchQueryDialogFragment.java) | 31 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectUserListDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectUserListDialogFragment.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SendMessageDialogFragment.java) | 59 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/SimpleDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SimpleDialogFragment.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/StatusDetailDialogFragment.java) | 196 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusMenuDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/StatusMenuDialogFragment.java) | 65 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/TalkChainDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/TalkChainDialogFragment.java) | 49 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/UserDetailDialogFragment.java) | 232 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/dialog/UserMenuDialogFragment.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/UserMenuDialogFragment.java) | 38 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/listener/ListItemClickListener.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/view/listener/ListItemClickListener.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/CheckBoxModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/CheckBoxModel.java) | 25 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/EditableCheckBoxModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EditableCheckBoxModel.java) | 49 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/EnumEvent.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EnumEvent.java) | 9 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EventViewModel.java) | 68 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/IViewModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/IViewModel.java) | 3 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/MessageViewModel.java) | 69 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/StatusViewModel.java) | 235 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/UserListListAdapter.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/UserListListAdapter.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/UserViewModel.java) | 48 | ||||
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/menu/MainActivityMenuHelper.java (renamed from app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/menu/MainActivityMenuHelper.java) | 59 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_blue.xml | 11 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_blue_light.xml | 11 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_gray.xml | 11 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_gray_light.xml | 11 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_orange.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_orange_light.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_red.xml | 11 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_round_red_light.xml | 11 | ||||
-rw-r--r-- | app/src/main/res/drawable/button_selector_transparent.xml | 8 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_app_info.xml | 36 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_menu_list.xml | 8 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_review.xml | 17 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_search_on_google.xml | 19 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_send_message.xml | 35 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_status_detail.xml | 78 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_talk_list.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_user_detail.xml | 126 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_list.xml | 17 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_post.xml | 84 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_search.xml | 55 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_userlist.xml | 37 | ||||
-rw-r--r-- | app/src/main/res/layout/layout_edit_list.xml | 6 | ||||
-rw-r--r-- | app/src/main/res/layout/layout_license.xml | 33 | ||||
-rw-r--r-- | app/src/main/res/layout/layout_oauth.xml | 22 | ||||
-rw-r--r-- | app/src/main/res/layout/list_item_status.xml | 30 | ||||
-rw-r--r-- | app/src/main/res/layout/main.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/layout/menu_item_checkbox.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/layout/menu_item_editable_checkbox.xml | 24 | ||||
-rw-r--r-- | app/src/main/res/layout/menu_item_simple_text.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/layout/navigation_list_item.xml | 18 | ||||
-rw-r--r-- | app/src/main/res/layout/part_edittext.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/layout/setting.xml | 6 | ||||
-rw-r--r-- | app/src/main/res/menu/edit_list.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/values-ja/strings.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/app_info.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/values/arrays.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/attrs.xml | 63 | ||||
-rw-r--r-- | app/src/main/res/values/colors.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/commands.xml | 61 | ||||
-rw-r--r-- | app/src/main/res/values/ids.xml | 35 | ||||
-rw-r--r-- | app/src/main/res/values/keys.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/license.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/xml/setting.xml | 80 |
241 files changed, 3428 insertions, 5695 deletions
diff --git a/app/.gitignore b/app/.gitignore index b16f3f6c..796b96d1 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,3 +1 @@ /build -/src/main/resources/twitter4j.properties -/src/debug/resources/twitter4j.properties diff --git a/app/app.iml b/app/app.iml index e68320ef..2df7a68a 100644 --- a/app/app.iml +++ b/app/app.iml @@ -26,7 +26,6 @@ <component name="NewModuleRootManager" inherit-compiler-output="false"> <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" /> <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" /> - <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" /> @@ -85,21 +84,20 @@ <excludeFolder url="file://$MODULE_DIR$/build/test-results" /> <excludeFolder url="file://$MODULE_DIR$/build/tmp" /> </content> - <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" /> + <orderEntry type="jdk" jdkName="Android API 17 Platform" jdkType="Android SDK" /> <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" /> - <orderEntry type="library" exported="" name="twitter4j-media-support-4.0.2" level="project" /> - <orderEntry type="library" exported="" name="activeandroid-3.1.0-SNAPSHOT" level="project" /> - <orderEntry type="library" exported="" name="support-v13-21.0.3" level="project" /> - <orderEntry type="library" exported="" name="guava-16.0.1" level="project" /> - <orderEntry type="library" exported="" name="twitter4j-stream-4.0.2" level="project" /> - <orderEntry type="library" exported="" name="library-3.2.3" level="project" /> + <orderEntry type="library" exported="" name="support-v4-18.0.0" level="project" /> + <orderEntry type="library" exported="" name="twitter4j-media-support-4.0.3" level="project" /> + <orderEntry type="library" exported="" name="library-3.2.0" level="project" /> + <orderEntry type="library" exported="" name="twitter-text-1.6.1" level="project" /> + <orderEntry type="library" exported="" name="twitter4j-stream-4.0.3" level="project" /> + <orderEntry type="library" exported="" name="ActiveAndroid-3.1" level="project" /> + <orderEntry type="library" exported="" name="twitter4j-core-4.0.3" level="project" /> <orderEntry type="library" exported="" name="crouton-1.8.5" level="project" /> - <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" /> <orderEntry type="library" exported="" name="snakeyaml-1.12" level="project" /> - <orderEntry type="library" exported="" name="library-1.0.11" level="project" /> - <orderEntry type="library" exported="" name="twitter-text-1.6.1" level="project" /> - <orderEntry type="library" exported="" name="twitter4j-core-4.0.2" level="project" /> + <orderEntry type="library" exported="" name="support-v13-18.0.0" level="project" /> + <orderEntry type="library" exported="" name="guava-18.0" level="project" /> + <orderEntry type="library" exported="" name="modules/volley-unspecified" level="project" /> </component> </module> diff --git a/app/build.gradle b/app/build.gradle index d9615d75..eae64197 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,39 @@ apply plugin: 'com.android.application' -android { - compileSdkVersion 19 - buildToolsVersion "21.1.2" +def consumerKey, consumerSecret, accessToken, accessTokenSecret +if (System.getenv("CONSUMER_KEY") != null) { + println("### Environment variables are found. ###") + consumerKey = System.getenv("CONSUMER_KEY") + consumerSecret = System.getenv("CONSUMER_SECRET") + accessToken = System.getenv("ACCESS_TOKEN") + accessTokenSecret = System.getenv("ACCESS_TOKEN_SECRET") +} else { + Properties props = new Properties() + try { + props.load(file('./tokens.properties').newDataInputStream()) + consumerKey = props.get("consumerKey") + consumerSecret = props.get("consumerSecret") + accessToken = props.get("accessToken") + accessTokenSecret = props.get("accessTokenSecret") + } catch (Exception ignored) { + throw new GradleException("Missing tokens.properties, check the tokens.properties file."); + } +} + +android { + compileSdkVersion 17 + buildToolsVersion '22.0.1' defaultConfig { - applicationId "jp.rhe.smileessence" - minSdkVersion 19 + applicationId "net.lacolaco.smileessence" + minSdkVersion 17 targetSdkVersion 19 - versionCode 1 - versionName "1.0" + versionCode 25 + versionName "1.0.11.1" + buildConfigField "String", "CONSUMER_KEY", "\"${consumerKey}\"" + buildConfigField "String", "CONSUMER_SECRET", "\"${consumerSecret}\"" + buildConfigField "String", "ACCESS_TOKEN", "\"${accessToken}\"" + buildConfigField "String", "ACCESS_TOKEN_SECRET", "\"${accessTokenSecret}\"" } buildTypes { release { @@ -21,32 +45,32 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } + packagingOptions { - exclude 'META-INF/LICENSE.txt' // なにこれ!! - } - lintOptions { - abortOnError false + exclude 'META-INF/LICENSE.txt' } } -repositories { - mavenCentral() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } -} - dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.navercorp.pulltorefresh:library:3.2.3@aar' + compile fileTree(dir: 'libs', include: ['*.jar']) + // compile 'com.android.support:appcompat-v7:22.1.0' + compile 'com.android.support:support-v13:18.0.0' + // volley + compile project(':modules/volley') + // crouton compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') { + // exclusion is not necessary, but generally a good idea. exclude group: 'com.google.android', module: 'support-v4' } - compile 'com.mcxiaoke.volley:library:1.0.+@aar' - compile 'org.twitter4j:twitter4j-core:4.0.2' - compile 'org.twitter4j:twitter4j-media-support:4.0.2' - compile 'org.twitter4j:twitter4j-stream:4.0.2' - compile 'com.google.guava:guava:16.0.1' + // pull to refresh + compile 'com.navercorp.pulltorefresh:library:3.2.0@aar' + // t4j + compile 'org.twitter4j:twitter4j-core:4.0.3' + compile 'org.twitter4j:twitter4j-media-support:4.0.3' + compile 'org.twitter4j:twitter4j-stream:4.0.3' + // twitter-text compile 'com.twitter:twitter-text:1.6.1' - compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' - compile 'com.android.support:support-v4:21.0.3' - compile 'com.android.support:support-v13:21.0.3' + // guava + compile 'com.google.guava:guava:18.0' + } diff --git a/app/libs/ActiveAndroid-3.1.jar b/app/libs/ActiveAndroid-3.1.jar Binary files differnew file mode 100644 index 00000000..32adcaeb --- /dev/null +++ b/app/libs/ActiveAndroid-3.1.jar diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 45dc58a5..eb902516 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in /opt/android-sdk/tools/proguard/proguard-android.txt +# in /Users/laco/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/command/CommandsTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/command/CommandsTest.java index 75550a9c..8616dff1 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/command/CommandsTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/command/CommandsTest.java @@ -25,22 +25,20 @@ package net.lacolaco.smileessence.command; import android.test.ActivityInstrumentationTestCase2; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.util.TwitterMock; -public class CommandsTest extends ActivityInstrumentationTestCase2<MainActivity> -{ +public class CommandsTest extends ActivityInstrumentationTestCase2<MainActivity> { TwitterMock mock; - public CommandsTest() - { + public CommandsTest() { super(MainActivity.class); } @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/command/NanigajaTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/command/NanigajaTest.java index 28c2ec01..90d26193 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/command/NanigajaTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/command/NanigajaTest.java @@ -24,52 +24,55 @@ package net.lacolaco.smileessence.command; +import android.content.Context; +import android.content.res.Configuration; import android.test.ActivityInstrumentationTestCase2; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.status.StatusCommandNanigaja; import net.lacolaco.smileessence.util.TwitterMock; + +import java.util.Locale; + import twitter4j.Status; -public class NanigajaTest extends ActivityInstrumentationTestCase2<MainActivity> -{ +public class NanigajaTest extends ActivityInstrumentationTestCase2<MainActivity> { private TwitterMock mock; - public NanigajaTest() - { + public NanigajaTest() { super(MainActivity.class); } @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { this.mock = new TwitterMock(getInstrumentation().getContext()); + Context context = getActivity(); + Configuration config = context.getResources().getConfiguration(); + config.locale = Locale.JAPANESE; + context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); } - public void testBuildNormal() throws Exception - { + public void testBuildNormal() throws Exception { Status status = mock.getStatusMock(); StatusCommandNanigaja nanigaja = new StatusCommandNanigaja(getActivity(), status, mock.getAccount()); assertEquals("な~にが" + status.getText() + "じゃ", nanigaja.build()); } - public void testBuildReply() throws Exception - { + public void testBuildReply() throws Exception { Status status = mock.getReplyMock(); StatusCommandNanigaja nanigaja = new StatusCommandNanigaja(getActivity(), status, mock.getAccount()); assertTrue(nanigaja.build().startsWith("@" + status.getUser().getScreenName() + " な~にが")); } - public void testBuildRetweet() throws Exception - { + public void testBuildRetweet() throws Exception { Status status = mock.getRetweetMock(); StatusCommandNanigaja nanigaja = new StatusCommandNanigaja(getActivity(), status, mock.getAccount()); assertTrue(nanigaja.build().startsWith("@" + status.getRetweetedStatus().getUser().getScreenName() + " な~にが")); } @Override - public void tearDown() throws Exception - { + public void tearDown() throws Exception { getActivity().forceFinish(); } } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/command/PostCommandsTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/command/PostCommandsTest.java index 96ca4cb6..52295753 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/command/PostCommandsTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/command/PostCommandsTest.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.command; import android.test.ActivityInstrumentationTestCase2; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.post.PostCommandInsert; import net.lacolaco.smileessence.command.post.PostCommandMorse; @@ -32,30 +33,25 @@ import net.lacolaco.smileessence.command.post.PostCommandZekamashi; import net.lacolaco.smileessence.util.Morse; import net.lacolaco.smileessence.view.adapter.PostState; -public class PostCommandsTest extends ActivityInstrumentationTestCase2<MainActivity> -{ +public class PostCommandsTest extends ActivityInstrumentationTestCase2<MainActivity> { - public PostCommandsTest() - { + public PostCommandsTest() { super(MainActivity.class); } @Override - public void tearDown() throws Exception - { + public void tearDown() throws Exception { getActivity().forceFinish(); } - public void testMorse() throws Exception - { + public void testMorse() throws Exception { PostState.getState().removeListener(); String s = "テスト(テスト)"; PostCommandMorse morse = new PostCommandMorse(getActivity()); assertEquals(Morse.jaToMorse(s), morse.build(s)); } - public void testSubString() throws Exception - { + public void testSubString() throws Exception { String s = "テスト(テスト)"; PostCommandMorse morse = new PostCommandMorse(getActivity()); PostState.getState().removeListener(); @@ -64,16 +60,14 @@ public class PostCommandsTest extends ActivityInstrumentationTestCase2<MainActiv assertEquals(Morse.jaToMorse("テスト") + "(テスト)", PostState.getState().getText()); } - public void testInsert() throws Exception - { + public void testInsert() throws Exception { String s = "テスト"; String inserted = "AAA"; PostCommandInsert insert = new PostCommandInsert(getActivity(), inserted); assertEquals("テストAAA", insert.build(s)); } - public void testZekamashi() throws Exception - { + public void testZekamashi() throws Exception { String s = "(しまかぜ)"; PostCommandZekamashi zekamashi = new PostCommandZekamashi(getActivity()); assertEquals("(ぜかまし)", zekamashi.build(s)); diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/preference/SharedPreferenceHelperTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/preference/SharedPreferenceHelperTest.java index f9055103..66c60ea1 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/preference/SharedPreferenceHelperTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/preference/SharedPreferenceHelperTest.java @@ -26,40 +26,34 @@ package net.lacolaco.smileessence.preference; import android.test.InstrumentationTestCase; -public class SharedPreferenceHelperTest extends InstrumentationTestCase -{ +public class SharedPreferenceHelperTest extends InstrumentationTestCase { SharedPreferenceHelper helper; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { //can't create on test context. helper = new SharedPreferenceHelper(getInstrumentation().getTargetContext(), "TestPreference"); assertTrue(helper.putValue("test.sample", "test")); assertTrue(helper.putValue("test.empty", "")); } - public void testGetProperty() throws Exception - { + public void testGetProperty() throws Exception { String sample = helper.getValue("test.sample", ""); assertEquals("test", sample); } - public void testSetProperty() throws Exception - { + public void testSetProperty() throws Exception { assertTrue(helper.putValue("test.sample", "test1")); assertEquals("test1", helper.getValue("test.sample", "")); } - public void testGetEmptyValue() throws Exception - { + public void testGetEmptyValue() throws Exception { String empty = helper.getValue("test.empty", ""); assertEquals("", empty); } - public void testNotExists() throws Exception - { + public void testNotExists() throws Exception { String notExists = helper.getValue("test.null", ""); assertEquals("", notExists); } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/preference/UserPreferenceHelperTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/preference/UserPreferenceHelperTest.java index 513043ba..e7a6043e 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/preference/UserPreferenceHelperTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/preference/UserPreferenceHelperTest.java @@ -25,31 +25,27 @@ package net.lacolaco.smileessence.preference; import android.test.AndroidTestCase; + import net.lacolaco.smileessence.R; -public class UserPreferenceHelperTest extends AndroidTestCase -{ +public class UserPreferenceHelperTest extends AndroidTestCase { private UserPreferenceHelper pref; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { pref = new UserPreferenceHelper(getContext()); } - public void testNotFound() throws Exception - { + public void testNotFound() throws Exception { assertEquals("", pref.getValue(0, "")); } - public void testUseDefault() throws Exception - { + public void testUseDefault() throws Exception { assertNotSame(0, pref.getValue(R.string.key_setting_text_size, 10)); } - public void testPutAndGet() throws Exception - { + public void testPutAndGet() throws Exception { assertEquals(true, pref.putValue(R.string.key_test_preference, 10)); assertEquals(10, pref.getValue(R.string.key_test_preference, 0)); } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TweetBuilderTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TweetBuilderTest.java index 192aab19..3e8f55bd 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TweetBuilderTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TweetBuilderTest.java @@ -25,23 +25,22 @@ package net.lacolaco.smileessence.twitter; import android.test.InstrumentationTestCase; + import net.lacolaco.smileessence.util.TwitterMock; + import twitter4j.Status; import twitter4j.User; -public class TweetBuilderTest extends InstrumentationTestCase -{ +public class TweetBuilderTest extends InstrumentationTestCase { TwitterMock mock; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); } - public void testBuilder() throws Exception - { + public void testBuilder() throws Exception { User user = mock.getUserMock(); Status status = mock.getReplyMock(); TweetBuilder builder = new TweetBuilder(); diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TwitterUtilsTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TwitterUtilsTest.java index 74fd3f86..43db830c 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TwitterUtilsTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/twitter/TwitterUtilsTest.java @@ -25,24 +25,24 @@ package net.lacolaco.smileessence.twitter; import android.test.InstrumentationTestCase; + import junit.framework.Assert; + import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.util.TwitterMock; + import twitter4j.Status; -public class TwitterUtilsTest extends InstrumentationTestCase -{ +public class TwitterUtilsTest extends InstrumentationTestCase { - public void testLength() throws Exception - { + public void testLength() throws Exception { String text = "test"; Assert.assertEquals(text.length(), TwitterUtils.getFixedTextLength(text)); text = "test.com"; assertNotSame(text.length(), TwitterUtils.getFixedTextLength(text)); } - public void testURL() throws Exception - { + public void testURL() throws Exception { String screenName = "laco0416"; assertEquals("https://twitter.com/laco0416", TwitterUtils.getUserHomeURL(screenName)); @@ -51,8 +51,7 @@ public class TwitterUtilsTest extends InstrumentationTestCase assertEquals("http://twilog.org/laco0416", TwitterUtils.getTwilogURL(screenName)); } - public void testScreenNames() throws Exception - { + public void testScreenNames() throws Exception { TwitterMock mock = new TwitterMock(getInstrumentation().getContext()); Status retweetMock = mock.getRetweetMock(); assertEquals(3, TwitterUtils.getScreenNames(retweetMock, null).size()); diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/twitter/UserStreamListenerTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/twitter/UserStreamListenerTest.java index cef1973e..fcda127a 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/twitter/UserStreamListenerTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/twitter/UserStreamListenerTest.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter; import android.test.ActivityInstrumentationTestCase2; + import net.lacolaco.smileessence.activity.MainActivity; -import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.util.TwitterMock; +import net.lacolaco.smileessence.view.adapter.CustomListAdapter; + import twitter4j.DirectMessage; import twitter4j.Status; import twitter4j.StatusDeletionNotice; import twitter4j.User; -public class UserStreamListenerTest extends ActivityInstrumentationTestCase2<MainActivity> -{ +public class UserStreamListenerTest extends ActivityInstrumentationTestCase2<MainActivity> { TwitterMock mock; UserStreamListener listener; @@ -43,204 +44,122 @@ public class UserStreamListenerTest extends ActivityInstrumentationTestCase2<Mai private User user; private String secret; - public UserStreamListenerTest() - { + public UserStreamListenerTest() { super(MainActivity.class); } @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); listener = new UserStreamListener(getActivity()); token = mock.getAccessToken(); secret = mock.getAccessTokenSecret(); user = mock.getUserMock(); - } - - public void testOnStatus() throws Exception - { - final Status status = mock.getRetweetMock(); - getActivity().runOnUiThread(new Runnable() - { + getActivity().runOnUiThread(new Runnable() { @Override - public void run() - { + public void run() { Account account = new Account(token, secret, user.getId(), user.getScreenName()); getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onStatus(status); + getActivity().initializeView(); } }); - Thread.sleep(1000); - assertEquals(1, getActivity().getListAdapter(MainActivity.ADAPTER_HOME).getCount()); - assertEquals(status.getRetweetedStatus(), StatusCache.getInstance().get(status.getRetweetedStatus().getId())); + Thread.sleep(500); } - public void testOnStatusDelete() throws Exception - { - final Status status = mock.getReplyMock(); - getActivity().runOnUiThread(new Runnable() - { + public void testOnStatus() throws Exception { + final Status status = mock.getStatusMock(); + CustomListAdapter<?> home = getActivity().getListAdapter(MainActivity.ADAPTER_HOME); + listener.onStatus(status); + home.updateForce(); + Thread.sleep(500); + assertEquals(1, home.getCount()); + listener.onDeletionNotice(new StatusDeletionNotice() { @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onStatus(status); - listener.onDeletionNotice(new StatusDeletionNotice() - { - @Override - public long getStatusId() - { - return status.getId(); - } - - @Override - public long getUserId() - { - return status.getUser().getId(); - } - - @Override - public int compareTo(StatusDeletionNotice another) - { - return 0; - } - }); + public long getStatusId() { + return status.getId(); } - }); - Thread.sleep(1000); - assertEquals(0, getActivity().getListAdapter(MainActivity.ADAPTER_HOME).getCount()); - } - public void testOnMention() throws Exception - { - final Status status = mock.getReplyMock(); - getActivity().runOnUiThread(new Runnable() - { @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onStatus(status); + public long getUserId() { + return status.getUser().getId(); } - }); - Thread.sleep(1000); - assertEquals(1, getActivity().getListAdapter(MainActivity.ADAPTER_MENTIONS).getCount()); - assertEquals(1, getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY).getCount()); - } - public void testOnRetweeted() throws Exception - { - final Status status = mock.getRetweetMock(); - getActivity().runOnUiThread(new Runnable() - { @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onStatus(status); + public int compareTo(StatusDeletionNotice another) { + return 0; } }); - Thread.sleep(1000); - assertEquals(1, getActivity().getListAdapter(MainActivity.ADAPTER_HOME).getCount()); - assertEquals(0, getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY).getCount()); + home.updateForce(); + Thread.sleep(500); + assertEquals(0, home.getCount()); + } + + public void testOnMention() throws Exception { + final Status status = mock.getReplyMock(); + CustomListAdapter<?> mentions = getActivity().getListAdapter(MainActivity.ADAPTER_MENTIONS); + listener.onStatus(status); + mentions.updateForce(); + Thread.sleep(500); + assertEquals(1, mentions.getCount()); + } + + public void testOnRetweeted() throws Exception { + final Status status = mock.getRetweetMock(); + listener.onStatus(status); + CustomListAdapter<?> home = getActivity().getListAdapter(MainActivity.ADAPTER_HOME); + home.updateForce(); + Thread.sleep(500); + assertEquals(1, home.getCount()); } - public void testOnFavorited() throws Exception - { + public void testOnFavorited() throws Exception { final Status status = mock.getReplyMock(); final User source = status.getUser(); - getActivity().runOnUiThread(new Runnable() - { - @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onFavorite(source, user, status); - listener.onUnfavorite(source, user, status); - } - }); - Thread.sleep(1000); - assertEquals(2, getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY).getCount()); + CustomListAdapter<?> history = getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY); + listener.onFavorite(source, user, status); + history.updateForce(); + Thread.sleep(500); + assertEquals(1, history.getCount()); + listener.onUnfavorite(source, user, status); + history.updateForce(); + Thread.sleep(500); + assertEquals(2, history.getCount()); } - public void testOnFollow() throws Exception - { + public void testOnFollow() throws Exception { final User source = mock.getUserMock(); - getActivity().runOnUiThread(new Runnable() - { - @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onFollow(source, user); - } - }); - Thread.sleep(1000); - assertEquals(1, getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY).getCount()); + CustomListAdapter<?> history = getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY); + listener.onFollow(source, user); + history.updateForce(); + Thread.sleep(500); + assertEquals(1, history.getCount()); } - public void testOnBlock() throws Exception - { + public void testOnBlock() throws Exception { final User source = mock.getUserMock(); - getActivity().runOnUiThread(new Runnable() - { - @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onBlock(source, user); - listener.onUnblock(source, user); - } - }); - Thread.sleep(1000); - assertEquals(2, getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY).getCount()); + CustomListAdapter<?> history = getActivity().getListAdapter(MainActivity.ADAPTER_HISTORY); + listener.onBlock(source, user); + listener.onUnblock(source, user); + history.updateForce(); + Thread.sleep(500); + assertEquals(2, history.getCount()); } - public void testOnDirectMessage() throws Exception - { + public void testOnDirectMessage() throws Exception { final DirectMessage message = mock.getDirectMessageMock(); - getActivity().runOnUiThread(new Runnable() - { - @Override - public void run() - { - Account account = new Account(token, secret, user.getId(), user.getScreenName()); - getActivity().setCurrentAccount(account); - getActivity().startMainLogic(); - listener.onDirectMessage(message); - } - }); - Thread.sleep(1000); - assertEquals(1, getActivity().getListAdapter(MainActivity.ADAPTER_MESSAGES).getCount()); - getActivity().runOnUiThread(new Runnable() - { - @Override - public void run() - { - listener.onDeletionNotice(message.getId(), message.getSenderId()); - } - }); - Thread.sleep(1000); - assertEquals(0, getActivity().getListAdapter(MainActivity.ADAPTER_MESSAGES).getCount()); + CustomListAdapter<?> messages = getActivity().getListAdapter(MainActivity.ADAPTER_MESSAGES); + listener.onDirectMessage(message); + messages.updateForce(); + Thread.sleep(500); + assertEquals(1, messages.getCount()); + listener.onDeletionNotice(message.getId(), message.getSenderId()); + messages.updateForce(); + Thread.sleep(500); + assertEquals(0, messages.getCount()); } @Override - protected void tearDown() throws Exception - { + protected void tearDown() throws Exception { getActivity().forceFinish(); } } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/util/TwitterMock.java b/app/src/androidTest/java/net/lacolaco/smileessence/util/TwitterMock.java index 5505bf74..369aa547 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/util/TwitterMock.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/util/TwitterMock.java @@ -26,83 +26,85 @@ package net.lacolaco.smileessence.util; import android.content.Context; import android.content.res.AssetManager; + +import net.lacolaco.smileessence.BuildConfig; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; -import twitter4j.*; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; -public class TwitterMock -{ +import twitter4j.DirectMessage; +import twitter4j.JSONException; +import twitter4j.JSONObject; +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.TwitterException; +import twitter4j.TwitterObjectFactory; +import twitter4j.User; + +public class TwitterMock { AssetManager assets; - public TwitterMock(Context context) - { + public TwitterMock(Context context) { assets = context.getAssets(); } - private String getJson(String fileName) throws IOException - { - try(InputStream is = assets.open(fileName); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader reader = new BufferedReader(isr)) - { - String buffer = ""; + private String getJson(String fileName) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(assets.open(fileName))); + StringBuilder builder = new StringBuilder(); String str; - while((str = reader.readLine()) != null) - { - buffer += str; + while ((str = reader.readLine()) != null) { + builder.append(str); + } + return builder.toString(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (reader != null) { + reader.close(); } - return buffer; } + return null; } - public Status getStatusMock() throws IOException, TwitterException - { + public Status getStatusMock() throws IOException, TwitterException { return TwitterObjectFactory.createStatus(getJson("status.json")); } - public Status getReplyMock() throws IOException, TwitterException - { + public Status getReplyMock() throws IOException, TwitterException { return TwitterObjectFactory.createStatus(getJson("reply.json")); } - public Status getRetweetMock() throws IOException, TwitterException - { + public Status getRetweetMock() throws IOException, TwitterException { return TwitterObjectFactory.createStatus(getJson("retweet.json")); } - public User getUserMock() throws IOException, TwitterException - { + public User getUserMock() throws IOException, TwitterException { return TwitterObjectFactory.createUser(getJson("user.json")); } - public DirectMessage getDirectMessageMock() throws IOException, TwitterException - { + public DirectMessage getDirectMessageMock() throws IOException, TwitterException { return TwitterObjectFactory.createDirectMessage(getJson("directmessage.json")); } - public String getAccessToken() throws IOException, JSONException - { - return new JSONObject(getJson("tokens.json")).getString("token"); + public String getAccessToken() throws IOException, JSONException { + return BuildConfig.ACCESS_TOKEN; } - public String getAccessTokenSecret() throws IOException, JSONException - { - return new JSONObject(getJson("tokens.json")).getString("token_secret"); + public String getAccessTokenSecret() throws IOException, JSONException { + return BuildConfig.ACCESS_TOKEN_SECRET; } - public Twitter getTwitterMock() throws IOException, JSONException - { + public Twitter getTwitterMock() throws IOException, JSONException { return new TwitterApi(getAccessToken(), getAccessTokenSecret()).getTwitter(); } - public Account getAccount() throws IOException, TwitterException, JSONException - { + public Account getAccount() throws IOException, TwitterException, JSONException { return new Account(getAccessToken(), getAccessTokenSecret(), getUserMock().getId(), getUserMock().getScreenName()); } } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/view/adapter/CustomListAdapterTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/view/adapter/CustomListAdapterTest.java index 0e6d4da4..7722f1a6 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/view/adapter/CustomListAdapterTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/view/adapter/CustomListAdapterTest.java @@ -25,48 +25,43 @@ package net.lacolaco.smileessence.view.adapter; import android.test.ActivityInstrumentationTestCase2; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.util.TwitterMock; import net.lacolaco.smileessence.viewmodel.StatusViewModel; -public class CustomListAdapterTest extends ActivityInstrumentationTestCase2<MainActivity> -{ +public class CustomListAdapterTest extends ActivityInstrumentationTestCase2<MainActivity> { TwitterMock mock; CustomListAdapter<StatusViewModel> adapter; Account account; - public CustomListAdapterTest() - { + public CustomListAdapterTest() { super(MainActivity.class); } @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); adapter = new CustomListAdapter<>(getActivity(), StatusViewModel.class); account = mock.getAccount(); } - public void testAddItem() throws Exception - { + public void testAddItem() throws Exception { adapter.addToBottom(new StatusViewModel(mock.getReplyMock(), account)); adapter.notifyDataSetChanged(); assertEquals(1, adapter.getCount()); } - public void testUpdate() throws Exception - { + public void testUpdate() throws Exception { adapter.addToBottom(new StatusViewModel(mock.getReplyMock(), account)); assertEquals(0, adapter.getCount()); adapter.notifyDataSetChanged(); assertEquals(1, adapter.getCount()); } - public void testAddItems() throws Exception - { + public void testAddItems() throws Exception { StatusViewModel viewModel1 = new StatusViewModel(mock.getReplyMock(), account); StatusViewModel viewModel2 = new StatusViewModel(mock.getReplyMock(), account); adapter.addToBottom(viewModel1, viewModel2); @@ -74,8 +69,7 @@ public class CustomListAdapterTest extends ActivityInstrumentationTestCase2<Main assertEquals(2, adapter.getCount()); } - public void testRemoveItem() throws Exception - { + public void testRemoveItem() throws Exception { StatusViewModel viewModel = new StatusViewModel(mock.getReplyMock(), account); adapter.addToBottom(viewModel, viewModel); adapter.notifyDataSetChanged(); @@ -85,8 +79,7 @@ public class CustomListAdapterTest extends ActivityInstrumentationTestCase2<Main assertEquals(0, adapter.getCount()); } - public void testAddPosition() throws Exception - { + public void testAddPosition() throws Exception { StatusViewModel status1 = new StatusViewModel(mock.getReplyMock(), account); StatusViewModel status2 = new StatusViewModel(mock.getReplyMock(), account); adapter.addToBottom(status1); @@ -96,8 +89,7 @@ public class CustomListAdapterTest extends ActivityInstrumentationTestCase2<Main } @Override - protected void tearDown() throws Exception - { + protected void tearDown() throws Exception { getActivity().forceFinish(); } } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java index 343bd9f9..57ce28d9 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java @@ -27,26 +27,25 @@ package net.lacolaco.smileessence.viewmodel; import android.content.Context; import android.content.res.Configuration; import android.test.InstrumentationTestCase; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.util.TwitterMock; + import twitter4j.Status; import twitter4j.User; import java.util.Locale; -public class EventViewModelTest extends InstrumentationTestCase -{ +public class EventViewModelTest extends InstrumentationTestCase { TwitterMock mock; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); } - public void testNewInstance() throws Exception - { + public void testNewInstance() throws Exception { Context context = getInstrumentation().getTargetContext(); Status status = mock.getReplyMock(); User source = mock.getUserMock(); diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/MessageViewModelTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/MessageViewModelTest.java index d3f22236..b9adfd9a 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/MessageViewModelTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/MessageViewModelTest.java @@ -25,23 +25,22 @@ package net.lacolaco.smileessence.viewmodel; import android.test.InstrumentationTestCase; + import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.util.TwitterMock; + import twitter4j.DirectMessage; -public class MessageViewModelTest extends InstrumentationTestCase -{ +public class MessageViewModelTest extends InstrumentationTestCase { TwitterMock mock; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); } - public void testNewInstance() throws Exception - { + public void testNewInstance() throws Exception { DirectMessage dm = mock.getDirectMessageMock(); MessageViewModel viewModel = new MessageViewModel(dm, new Account(mock.getAccessToken(), mock.getAccessTokenSecret(), mock.getUserMock().getId(), mock.getUserMock().getScreenName())); assertEquals(dm.getId(), viewModel.getID()); diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/StatusViewModelTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/StatusViewModelTest.java index 600613c9..28d6c607 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/StatusViewModelTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/StatusViewModelTest.java @@ -25,36 +25,32 @@ package net.lacolaco.smileessence.viewmodel; import android.test.InstrumentationTestCase; + import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.util.TwitterMock; -public class StatusViewModelTest extends InstrumentationTestCase -{ +public class StatusViewModelTest extends InstrumentationTestCase { TwitterMock mock; Account account; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { mock = new TwitterMock(getInstrumentation().getContext()); account = new Account(mock.getAccessToken(), mock.getAccessTokenSecret(), mock.getUserMock().getId(), mock.getUserMock().getScreenName()); } - public void testID() throws Exception - { + public void testID() throws Exception { StatusViewModel status = new StatusViewModel(mock.getReplyMock(), account); assertNotSame(0L, status.getID()); } - public void testMention() throws Exception - { + public void testMention() throws Exception { StatusViewModel status = new StatusViewModel(mock.getReplyMock(), account); assertTrue(status.isMention(account.screenName)); } - public void testMyStatus() throws Exception - { + public void testMyStatus() throws Exception { StatusViewModel status = new StatusViewModel(mock.getStatusMock(), account); assertTrue(status.isMyStatus(account.userID)); } diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/UserViewModelTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/UserViewModelTest.java index bc694961..5b295286 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/UserViewModelTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/UserViewModelTest.java @@ -25,86 +25,71 @@ package net.lacolaco.smileessence.viewmodel; import android.test.InstrumentationTestCase; + import net.lacolaco.smileessence.util.TwitterMock; -public class UserViewModelTest extends InstrumentationTestCase -{ +public class UserViewModelTest extends InstrumentationTestCase { UserViewModel user; @Override - public void setUp() throws Exception - { + public void setUp() throws Exception { user = new UserViewModel(new TwitterMock(getInstrumentation().getContext()).getUserMock()); } - public void testID() throws Exception - { + public void testID() throws Exception { assertNotSame(0L, user.getID()); } - public void testScreenName() throws Exception - { + public void testScreenName() throws Exception { assertNotNull(user.getScreenName()); } - public void testName() throws Exception - { + public void testName() throws Exception { assertNotNull(user.getName()); } - public void testDescription() throws Exception - { + public void testDescription() throws Exception { assertNotNull(user.getDescription()); } - public void testLocation() throws Exception - { + public void testLocation() throws Exception { assertNotNull(user.getLocation()); } - public void testURL() throws Exception - { + public void testURL() throws Exception { assertNotNull(user.getURL()); } - public void testIconURL() throws Exception - { + public void testIconURL() throws Exception { assertNotNull(user.getIconURL()); } - public void testBannerURL() throws Exception - { + public void testBannerURL() throws Exception { assertNotNull(user.getBannerURL()); } - public void testStatusCount() throws Exception - { + public void testStatusCount() throws Exception { assertNotSame(0, user.getStatusesCount()); } - public void testFriendCount() throws Exception - { + public void testFriendCount() throws Exception { assertNotSame(0, user.getFriendsCount()); } - public void testFollowerCount() throws Exception - { + public void testFollowerCount() throws Exception { assertNotSame(0, user.getFollowersCount()); } - public void testFavoriteCount() throws Exception - { + public void testFavoriteCount() throws Exception { assertNotSame(0, user.getFavoritesCount()); } - public void testProtected() throws Exception - { + public void testProtected() throws Exception { assertFalse(user.isProtected()); } - public void testMarked() throws Exception - { + public void testMarked() throws Exception { assertFalse(user.isVerified()); } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c2c3bb79..37e9ae00 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2015 lacolaco.net @@ -24,120 +23,114 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="net.lacolaco.smileessence" - android:versionCode="25" - android:versionName="@string/app_version"> + package="net.lacolaco.smileessence"> - <uses-sdk - android:minSdkVersion="17" - android:targetSdkVersion="19"/> - - <uses-permission android:name="android.permission.INTERNET"/> - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application - android:label="@string/app_name" android:name=".Application" + android:allowBackup="true" android:icon="@drawable/icon_application" + android:label="@string/app_name" android:theme="@style/theme_dark"> <meta-data android:name="AA_DB_NAME" - android:value="app.db"/> + android:value="app.db" /> <meta-data android:name="AA_DB_VERSION" - android:value="1"/> + android:value="1" /> <activity android:name=".activity.MainActivity" + android:configChanges="orientation|screenSize|keyboardHidden" android:label="@string/app_name" android:launchMode="singleTask" - android:configChanges="orientation|screenSize|keyboardHidden" android:windowSoftInputMode="stateHidden|adjustResize"> <intent-filter> - <action android:name="android.intent.action.MAIN"/> - <category android:name="android.intent.category.LAUNCHER"/> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter android:label="@string/intent_post"> - <action android:name="android.intent.action.VIEW"/> + <action android:name="android.intent.action.VIEW" /> - <category android:name="android.intent.category.DEFAULT"/> - <category android:name="android.intent.category.BROWSABLE"/> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.BROWSABLE" /> <data android:host="twitter.com" android:path="/share" - android:scheme="https"/> + android:scheme="https" /> </intent-filter> - <intent-filter - android:label="@string/intent_post"> - <action android:name="android.intent.action.SEND"/> - <data android:mimeType="text/plain"/> - <category android:name="android.intent.category.DEFAULT"/> + <intent-filter android:label="@string/intent_post"> + <action android:name="android.intent.action.SEND" /> + <data android:mimeType="text/plain" /> + <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> - <action android:name="android.intent.action.SEND"/> - <category android:name="android.intent.category.DEFAULT"/> + <action android:name="android.intent.action.SEND" /> + <category android:name="android.intent.category.DEFAULT" /> - <data android:mimeType="image/jpeg"/> - <data android:mimeType="image/jpg"/> - <data android:mimeType="image/png"/> - <data android:mimeType="image/bmp"/> - <data android:mimeType="image/bitmap"/> + <data android:mimeType="image/jpeg" /> + <data android:mimeType="image/jpg" /> + <data android:mimeType="image/png" /> + <data android:mimeType="image/bmp" /> + <data android:mimeType="image/bitmap" /> </intent-filter> <intent-filter> - <action android:name="android.intent.action.VIEW"/> + <action android:name="android.intent.action.VIEW" /> - <category android:name="android.intent.category.DEFAULT"/> - <category android:name="android.intent.category.BROWSABLE"/> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.BROWSABLE" /> <data android:host="twitter.com" - android:scheme="http"/> + android:scheme="http" /> </intent-filter> <intent-filter> - <action android:name="android.intent.action.VIEW"/> + <action android:name="android.intent.action.VIEW" /> - <category android:name="android.intent.category.DEFAULT"/> - <category android:name="android.intent.category.BROWSABLE"/> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.BROWSABLE" /> <data android:host="twitter.com" - android:scheme="https"/> + android:scheme="https" /> </intent-filter> </activity> <activity android:name=".activity.SettingActivity" - android:label="@string/activity_setting" android:configChanges="keyboardHidden|orientation" - android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity"/> + android:label="@string/activity_setting" + android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity" /> <activity android:name=".activity.EditTemplateActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/activity_edit_template" - android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity"/> + android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity" /> <activity android:name=".activity.EditExtractionActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/activity_edit_extraction" - android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity"/> + android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity" /> <activity android:name=".activity.EditCommandActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/activity_edit_command" - android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity"/> + android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity" /> <activity android:name=".activity.EditTabActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/activity_edit_tab" - android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity"/> + android:parentActivityName="net.lacolaco.smileessence.activity.MainActivity" /> <activity android:name=".activity.LicenseActivity" android:label="@string/activity_licenses" - android:parentActivityName="net.lacolaco.smileessence.activity.SettingActivity"/> + android:parentActivityName="net.lacolaco.smileessence.activity.SettingActivity" /> <activity android:name=".activity.OAuthActivity" - android:label="@string/activity_authenticate" - android:configChanges="keyboardHidden|orientation"/> + android:configChanges="keyboardHidden|orientation" + android:label="@string/activity_authenticate" /> </application> </manifest> diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/Application.java b/app/src/main/java/net/lacolaco/smileessence/Application.java index 9a513dc0..20e6f7aa 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/Application.java +++ b/app/src/main/java/net/lacolaco/smileessence/Application.java @@ -24,8 +24,7 @@ package net.lacolaco.smileessence; -public class Application extends com.activeandroid.app.Application -{ +public class Application extends com.activeandroid.app.Application { // ------------------------------ FIELDS ------------------------------ @@ -33,13 +32,11 @@ public class Application extends com.activeandroid.app.Application // --------------------- GETTER / SETTER METHODS --------------------- - public int getThemeIndex() - { + public int getThemeIndex() { return themeIndex; } - public void setThemeIndex(int themeIndex) - { + public void setThemeIndex(int themeIndex) { this.themeIndex = themeIndex; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/IntentRouter.java b/app/src/main/java/net/lacolaco/smileessence/IntentRouter.java index 39fd4de8..db0cb4c4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/IntentRouter.java +++ b/app/src/main/java/net/lacolaco/smileessence/IntentRouter.java @@ -28,6 +28,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.CommandOpenUserDetail; import net.lacolaco.smileessence.logging.Logger; @@ -38,13 +39,13 @@ import net.lacolaco.smileessence.util.UIHandler; import net.lacolaco.smileessence.view.adapter.PostState; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment; + import twitter4j.Status; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class IntentRouter -{ +public class IntentRouter { // ------------------------------ FIELDS ------------------------------ @@ -52,34 +53,23 @@ public class IntentRouter // -------------------------- STATIC METHODS -------------------------- - public static void onNewIntent(MainActivity activity, Intent intent) - { + public static void onNewIntent(MainActivity activity, Intent intent) { Logger.debug("IntentRouter:onNewIntent"); Uri uri = intent.getData(); - if(uri != null) - { + if (uri != null) { onUriIntent(activity, uri); - } - else if(intent.getAction() != null) - { - switch(intent.getAction()) - { - case Intent.ACTION_SEND: - { - if(intent.getType().equals("text/plain")) - { + } else if (intent.getAction() != null) { + switch (intent.getAction()) { + case Intent.ACTION_SEND: { + if (intent.getType().equals("text/plain")) { Bundle extra = intent.getExtras(); - if(extra != null) - { + if (extra != null) { String text = getText(extra); openPostPage(activity, text); } - } - else - { + } else { Matcher matcher = Pattern.compile("image/.+").matcher(intent.getType()); - if(matcher.find()) - { + if (matcher.find()) { Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); openPostPageWithImage(activity, imageUri); } @@ -90,80 +80,60 @@ public class IntentRouter } } - private static String getText(Bundle extra) - { + private static String getText(Bundle extra) { StringBuilder builder = new StringBuilder(); - if(!TextUtils.isEmpty(extra.getCharSequence(Intent.EXTRA_SUBJECT))) - { + if (!TextUtils.isEmpty(extra.getCharSequence(Intent.EXTRA_SUBJECT))) { builder.append(extra.getCharSequence(Intent.EXTRA_SUBJECT)).append(" "); } builder.append(extra.getCharSequence(Intent.EXTRA_TEXT)); return builder.toString(); } - private static String getText(Uri uri) - { + private static String getText(Uri uri) { String text = ""; String url = ""; - if(uri.getQueryParameter("text") != null) - { + if (uri.getQueryParameter("text") != null) { text = uri.getQueryParameter("text").replaceAll("\\+", " "); - } - else if(uri.getQueryParameter("status") != null) - { + } else if (uri.getQueryParameter("status") != null) { text = uri.getQueryParameter("status").replaceAll("\\+", " "); } - if(uri.getQueryParameter("url") != null) - { + if (uri.getQueryParameter("url") != null) { url = uri.getQueryParameter("url"); } return text + " " + url; } - private static void onUriIntent(MainActivity activity, Uri uri) - { + private static void onUriIntent(MainActivity activity, Uri uri) { Logger.debug(uri.toString()); - if(isPostIntent(uri)) - { + if (isPostIntent(uri)) { String str = getText(uri); openPostPage(activity, str); - } - else if(isStatusIntent(uri)) - { + } else if (isStatusIntent(uri)) { long id = getStatusID(uri); showStatusDialog(activity, id); - } - else if(isUserIntent(uri)) - { + } else if (isUserIntent(uri)) { String screenName = getScreenName(uri); showUserDialog(activity, screenName); } } - private static String getScreenName(Uri uri) - { + private static String getScreenName(Uri uri) { String screenName; - if(uri.getQueryParameter("screen_name") != null) - { + if (uri.getQueryParameter("screen_name") != null) { screenName = uri.getQueryParameter("screen_name"); - } - else - { + } else { String[] arrayOfString = uri.toString().split("/"); screenName = arrayOfString[arrayOfString.length - 1]; } return screenName; } - private static long getStatusID(Uri uri) - { + private static long getStatusID(Uri uri) { String str = "-1"; String[] arrayOfString = uri.getPath().toString().split("/"); - for(int i = 0; i < arrayOfString.length; i++) - { - if(arrayOfString[i].startsWith("status")) - { + for (int i = 0; i < arrayOfString.length; i++) { + if (arrayOfString[i].startsWith("status")) { str = arrayOfString[(i + 1)]; break; } @@ -171,21 +141,14 @@ public class IntentRouter return Long.parseLong(str); } - private static boolean isPostIntent(Uri uri) - { - if(uri.getHost().equals(TWITTER_HOST)) - { - if(uri.getPath().equals("/share")) - { + private static boolean isPostIntent(Uri uri) { + if (uri.getHost().equals(TWITTER_HOST)) { + if (uri.getPath().equals("/share")) { return true; - } - else - { + } else { String[] arr = uri.toString().split("/"); - for(String s : arr) - { - if(s.startsWith("tweet") || s.startsWith("home")) - { + for (String s : arr) { + if (s.startsWith("tweet") || s.startsWith("home")) { return true; } } @@ -194,15 +157,11 @@ public class IntentRouter return false; } - private static boolean isStatusIntent(Uri uri) - { - if(uri.getHost().equals(TWITTER_HOST)) - { + private static boolean isStatusIntent(Uri uri) { + if (uri.getHost().equals(TWITTER_HOST)) { String[] arr = uri.toString().split("/"); - for(String s : arr) - { - if(s.equals("status") || s.equals("statuses")) - { + for (String s : arr) { + if (s.equals("status") || s.equals("statuses")) { return true; } } @@ -210,24 +169,17 @@ public class IntentRouter return false; } - private static boolean isUserIntent(Uri uri) - { - if(uri.getHost().equals(TWITTER_HOST)) - { - if(uri.getQueryParameter("screen_name") != null) - { + private static boolean isUserIntent(Uri uri) { + if (uri.getHost().equals(TWITTER_HOST)) { + if (uri.getQueryParameter("screen_name") != null) { return true; } String[] arrayOfString = uri.toString().split("/"); - if(arrayOfString.length == 4 && uri.getQuery() == null) - { + if (arrayOfString.length == 4 && uri.getQuery() == null) { return true; - } - else if(arrayOfString.length > 4) - { - if(arrayOfString[3].equals("#!") && uri.getQuery() == null) - { + } else if (arrayOfString.length > 4) { + if (arrayOfString[3].equals("#!") && uri.getQuery() == null) { return true; } } @@ -235,58 +187,44 @@ public class IntentRouter return false; } - private static void showStatusDialog(final MainActivity activity, long id) - { - if(id != -1) - { - TwitterUtils.tryGetStatus(activity.getCurrentAccount(), id, new TwitterUtils.StatusCallback() - { + private static void showStatusDialog(final MainActivity activity, long id) { + if (id != -1) { + TwitterUtils.tryGetStatus(activity.getCurrentAccount(), id, new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { StatusDetailDialogFragment fragment = new StatusDetailDialogFragment(); fragment.setStatusID(status.getId()); DialogHelper.showDialog(activity, fragment); } @Override - public void error() - { + public void error() { Notificator.publish(activity, R.string.error_intent_status_cannot_load, NotificationType.ALERT); } }); - } - else - { + } else { Notificator.publish(activity, R.string.error_intent_status_cannot_load, NotificationType.ALERT); } } - private static void showUserDialog(MainActivity activity, String screenName) - { + private static void showUserDialog(MainActivity activity, String screenName) { CommandOpenUserDetail openUserDetail = new CommandOpenUserDetail(activity, screenName, activity.getCurrentAccount()); openUserDetail.execute(); } - private static void openPostPage(final MainActivity activity, final String str) - { - new UIHandler() - { + private static void openPostPage(final MainActivity activity, final String str) { + new UIHandler() { @Override - public void run() - { + public void run() { PostState.newState().beginTransaction().setText(str).commitWithOpen(activity); } }.post(); } - private static void openPostPageWithImage(final MainActivity activity, final Uri imageUri) - { - new UIHandler() - { + private static void openPostPageWithImage(final MainActivity activity, final Uri imageUri) { + new UIHandler() { @Override - public void run() - { + public void run() { activity.openPostPageWithImage(imageUri); } }.post(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditCommandActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java index 82564c29..4c1c2ac8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditCommandActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java @@ -31,6 +31,7 @@ import android.support.v4.app.NavUtils; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; + import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.Command; @@ -47,8 +48,7 @@ import net.lacolaco.smileessence.viewmodel.CheckBoxModel; import java.util.ArrayList; import java.util.List; -public class EditCommandActivity extends Activity -{ +public class EditCommandActivity extends Activity { // ------------------------------ FIELDS ------------------------------ @@ -57,42 +57,31 @@ public class EditCommandActivity extends Activity // --------------------- GETTER / SETTER METHODS --------------------- - private CheckBoxModel[] getCheckBoxItems() - { + private CheckBoxModel[] getCheckBoxItems() { editedCommands = new ArrayList<>(); List<CheckBoxModel> checkBoxModels = new ArrayList<>(); List<CommandSetting> commandSettings = CommandSetting.getAll(); List<Command> commands = Command.getAllCommands(this); - for(Command command : commands) - { - if(command.getKey() < 0) - { + for (Command command : commands) { + if (command.getKey() < 0) { continue; } String text; - if(command instanceof StatusCommand) - { + if (command instanceof StatusCommand) { text = String.format("Tweet : %s", command.getText()); - } - else if(command instanceof UserCommand) - { + } else if (command instanceof UserCommand) { text = String.format("User : %s", command.getText()); - } - else - { + } else { continue; } editedCommands.add(command); CommandSetting setting = null; - for(CommandSetting s : commandSettings) - { - if(command.getKey() == s.commandKey) - { + for (CommandSetting s : commandSettings) { + if (command.getKey() == s.commandKey) { setting = s; } } - if(setting == null) - { + if (setting == null) { setting = new CommandSetting(command.getKey(), true); setting.save(); } @@ -102,16 +91,14 @@ public class EditCommandActivity extends Activity return checkBoxModels.toArray(new CheckBoxModel[checkBoxModels.size()]); } - private ListView getListView() - { + private ListView getListView() { return (ListView) findViewById(R.id.listview_edit_list); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onCreate(Bundle savedInstanceState) - { + protected void onCreate(Bundle savedInstanceState) { UserPreferenceHelper userPreferenceHelper = new UserPreferenceHelper(this); setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex())); super.onCreate(savedInstanceState); @@ -123,8 +110,7 @@ public class EditCommandActivity extends Activity } @Override - public boolean onCreateOptionsMenu(Menu menu) - { + public boolean onCreateOptionsMenu(Menu menu) { MenuItem allOn = menu.add(Menu.NONE, R.id.menu_edit_command_all_on, Menu.NONE, ""); allOn.setTitle(R.string.actionbar_edit_command_all_on); allOn.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); @@ -132,10 +118,8 @@ public class EditCommandActivity extends Activity } @Override - protected void onDestroy() - { - for(int i = 0; i < adapter.getCount(); i++) - { + protected void onDestroy() { + for (int i = 0; i < adapter.getCount(); i++) { CheckBoxModel checkBoxModel = (CheckBoxModel) adapter.getItem(i); Command command = editedCommands.get(i); CommandSetting commandSetting = CommandSetting.selectByKey(command.getKey()); @@ -147,17 +131,13 @@ public class EditCommandActivity extends Activity } @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch(item.getItemId()) - { - case R.id.menu_edit_command_all_on: - { + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_edit_command_all_on: { enableAll(); break; } - case android.R.id.home: - { + case android.R.id.home: { NavUtils.navigateUpFromSameTask(this); return true; } @@ -165,11 +145,9 @@ public class EditCommandActivity extends Activity return true; } - private void enableAll() - { + private void enableAll() { adapter.setNotifiable(false); - for(int i = 0; i < adapter.getCount(); i++) - { + for (int i = 0; i < adapter.getCount(); i++) { CheckBoxModel item = (CheckBoxModel) adapter.getItem(i); item.setChecked(true); } @@ -178,8 +156,7 @@ public class EditCommandActivity extends Activity updateListView(); } - private void initializeViews() - { + private void initializeViews() { ListView listView = getListView(); adapter = new CustomListAdapter<>(this, CheckBoxModel.class); listView.setAdapter(adapter); @@ -187,8 +164,7 @@ public class EditCommandActivity extends Activity adapter.update(); } - private void updateListView() - { + private void updateListView() { getListView().requestLayout(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditExtractionActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java index 8f78d6fa..f967ce04 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditExtractionActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java @@ -34,6 +34,7 @@ import android.view.*; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ListView; + import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.ExtractionWord; @@ -46,8 +47,7 @@ import net.lacolaco.smileessence.view.dialog.EditTextDialogFragment; import java.util.List; public class EditExtractionActivity extends Activity implements AdapterView.OnItemClickListener, - AbsListView.MultiChoiceModeListener -{ + AbsListView.MultiChoiceModeListener { // ------------------------------ FIELDS ------------------------------ @@ -55,14 +55,12 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt // --------------------- GETTER / SETTER METHODS --------------------- - private ExtractionWord[] getExtractionWords() - { + private ExtractionWord[] getExtractionWords() { List<ExtractionWord> all = ExtractionWord.getAll(); return all.toArray(new ExtractionWord[all.size()]); } - private ListView getListView() - { + private ListView getListView() { return (ListView) findViewById(R.id.listview_edit_list); } @@ -72,8 +70,7 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt // --------------------- Interface Callback --------------------- @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) - { + public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.clear(); MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.edit_list, menu); @@ -81,18 +78,14 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt } @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) - { + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) - { - switch(item.getItemId()) - { - case R.id.menu_edit_list_delete: - { + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_edit_list_delete: { deleteSelectedItems(); } } @@ -101,30 +94,26 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt } @Override - public void onDestroyActionMode(ActionMode mode) - { + public void onDestroyActionMode(ActionMode mode) { } // --------------------- Interface MultiChoiceModeListener --------------------- @Override - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) - { + public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { } // --------------------- Interface OnItemClickListener --------------------- @Override - public void onItemClick(AdapterView<?> parent, View view, int position, long id) - { + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { openEditExtractionWordDialog(position); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onCreate(Bundle savedInstanceState) - { + protected void onCreate(Bundle savedInstanceState) { setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex())); super.onCreate(savedInstanceState); setContentView(R.layout.layout_edit_list); @@ -135,8 +124,7 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt } @Override - public boolean onCreateOptionsMenu(Menu menu) - { + public boolean onCreateOptionsMenu(Menu menu) { MenuItem add = menu.add(Menu.NONE, R.id.menu_edit_list_add, Menu.NONE, ""); add.setIcon(android.R.drawable.ic_menu_add); add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); @@ -144,17 +132,13 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt } @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch(item.getItemId()) - { - case R.id.menu_edit_list_add: - { + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_edit_list_add: { addNewExtractionWord(); break; } - case android.R.id.home: - { + case android.R.id.home: { NavUtils.navigateUpFromSameTask(this); return true; } @@ -164,14 +148,11 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt // -------------------------- OTHER METHODS -------------------------- - public void deleteSelectedItems() - { + public void deleteSelectedItems() { SparseBooleanArray checkedItems = getListView().getCheckedItemPositions(); adapter.setNotifiable(false); - for(int i = adapter.getCount() - 1; i > -1; i--) - { - if(checkedItems.get(i)) - { + for (int i = adapter.getCount() - 1; i > -1; i--) { + if (checkedItems.get(i)) { ExtractionWord extractionWord = adapter.removeItem(i); extractionWord.delete(); } @@ -181,16 +162,12 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt updateListView(); } - public void openEditExtractionWordDialog(int position) - { + public void openEditExtractionWordDialog(int position) { final ExtractionWord extractionWord = (ExtractionWord) adapter.getItem(position); - EditTextDialogFragment dialogFragment = new EditTextDialogFragment() - { + EditTextDialogFragment dialogFragment = new EditTextDialogFragment() { @Override - public void onTextInput(String text) - { - if(TextUtils.isEmpty(text.trim())) - { + public void onTextInput(String text) { + if (TextUtils.isEmpty(text.trim())) { return; } extractionWord.text = text; @@ -203,16 +180,12 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt DialogHelper.showDialog(this, dialogFragment); } - private void addNewExtractionWord() - { + private void addNewExtractionWord() { final ExtractionWord extractionWord = new ExtractionWord(); - EditTextDialogFragment dialogFragment = new EditTextDialogFragment() - { + EditTextDialogFragment dialogFragment = new EditTextDialogFragment() { @Override - public void onTextInput(String text) - { - if(TextUtils.isEmpty(text.trim())) - { + public void onTextInput(String text) { + if (TextUtils.isEmpty(text.trim())) { return; } extractionWord.text = text; @@ -226,8 +199,7 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt DialogHelper.showDialog(this, dialogFragment); } - private void initializeViews() - { + private void initializeViews() { ListView listView = getListView(); adapter = new CustomListAdapter<>(this, ExtractionWord.class); listView.setAdapter(adapter); @@ -238,8 +210,7 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt listView.setMultiChoiceModeListener(this); } - private void updateListView() - { + private void updateListView() { getListView().requestLayout(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditTabActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java index 6b785bb8..e167152f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditTabActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java @@ -30,6 +30,7 @@ import android.os.Bundle; import android.support.v4.app.NavUtils; import android.view.MenuItem; import android.widget.ListView; + import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.logging.Logger; @@ -42,8 +43,7 @@ import net.lacolaco.smileessence.viewmodel.EditableCheckBoxModel; import java.util.ArrayList; import java.util.List; -public class EditTabActivity extends Activity -{ +public class EditTabActivity extends Activity { // ------------------------------ FIELDS ------------------------------ @@ -51,8 +51,7 @@ public class EditTabActivity extends Activity // --------------------- GETTER / SETTER METHODS --------------------- - private EditableCheckBoxModel[] getCheckBoxItems() - { + private EditableCheckBoxModel[] getCheckBoxItems() { List<EditableCheckBoxModel> models = new ArrayList<>(); EditableCheckBoxModel post = new EditableCheckBoxModel(getString(R.string.page_name_post)); @@ -70,39 +69,35 @@ public class EditTabActivity extends Activity models.add(messages); EditableCheckBoxModel history = new EditableCheckBoxModel(getString(R.string.page_name_history)); history.setChecked(getVisibility(R.string.key_page_history_visibility)) - .setInputText(String.valueOf(getPosition(R.string.key_page_history_position, 4))); + .setInputText(String.valueOf(getPosition(R.string.key_page_history_position, 4))); models.add(history); EditableCheckBoxModel search = new EditableCheckBoxModel(getString(R.string.page_name_search)); search.setChecked(getVisibility(R.string.key_page_search_visibility)) - .setInputText(String.valueOf(getPosition(R.string.key_page_search_position, 5))); + .setInputText(String.valueOf(getPosition(R.string.key_page_search_position, 5))); models.add(search); EditableCheckBoxModel list = new EditableCheckBoxModel(getString(R.string.page_name_list)); list.setChecked(getVisibility(R.string.key_page_list_visibility)) - .setInputText(String.valueOf(getPosition(R.string.key_page_list_position, 6))); + .setInputText(String.valueOf(getPosition(R.string.key_page_list_position, 6))); models.add(list); return models.toArray(new EditableCheckBoxModel[models.size()]); } - private ListView getListView() - { + private ListView getListView() { return (ListView) findViewById(R.id.listview_edit_list); } - private MainActivity getMainActivity() - { + private MainActivity getMainActivity() { return (MainActivity) getParent(); } - private UserPreferenceHelper getPreference() - { + private UserPreferenceHelper getPreference() { return new UserPreferenceHelper(this); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onCreate(Bundle savedInstanceState) - { + protected void onCreate(Bundle savedInstanceState) { UserPreferenceHelper userPreferenceHelper = getPreference(); setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex())); super.onCreate(savedInstanceState); @@ -114,8 +109,7 @@ public class EditTabActivity extends Activity } @Override - protected void onDestroy() - { + protected void onDestroy() { EditableCheckBoxModel messages = (EditableCheckBoxModel) adapter.getItem(3); putVisibility(R.string.key_page_messages_visibility, messages.isChecked()); //TODO putPosition(R.string.key_page_messages_position, Integer.parseInt(messages.getInputText())); @@ -130,12 +124,9 @@ public class EditTabActivity extends Activity } @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch(item.getItemId()) - { - case android.R.id.home: - { + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: { NavUtils.navigateUpFromSameTask(this); return true; } @@ -143,18 +134,15 @@ public class EditTabActivity extends Activity return true; } - private int getPosition(int key, int defaultValue) - { + private int getPosition(int key, int defaultValue) { return Integer.parseInt(getPreference().getValue(key, String.valueOf(defaultValue))); } - private boolean getVisibility(int key) - { + private boolean getVisibility(int key) { return getPreference().getValue(key, true); } - private void initializeViews() - { + private void initializeViews() { ListView listView = getListView(); adapter = new CustomListAdapter<>(this, EditableCheckBoxModel.class); listView.setAdapter(adapter); @@ -162,13 +150,11 @@ public class EditTabActivity extends Activity adapter.update(); } - private void putPosition(int key, int value) - { + private void putPosition(int key, int value) { getPreference().putValue(key, String.valueOf(value)); } - private void putVisibility(int key, boolean value) - { + private void putVisibility(int key, boolean value) { getPreference().putValue(key, value); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditTemplateActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java index 51673575..d87be8fb 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/EditTemplateActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java @@ -34,6 +34,7 @@ import android.view.*; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ListView; + import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.Template; @@ -46,8 +47,7 @@ import net.lacolaco.smileessence.view.dialog.EditTextDialogFragment; import java.util.List; public class EditTemplateActivity extends Activity implements AdapterView.OnItemClickListener, - AbsListView.MultiChoiceModeListener -{ + AbsListView.MultiChoiceModeListener { // ------------------------------ FIELDS ------------------------------ @@ -55,13 +55,11 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem // --------------------- GETTER / SETTER METHODS --------------------- - private ListView getListView() - { + private ListView getListView() { return (ListView) findViewById(R.id.listview_edit_list); } - private Template[] getTemplates() - { + private Template[] getTemplates() { List<Template> all = Template.getAll(); return all.toArray(new Template[all.size()]); } @@ -72,8 +70,7 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem // --------------------- Interface Callback --------------------- @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) - { + public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.clear(); MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.edit_list, menu); @@ -81,18 +78,14 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem } @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) - { + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) - { - switch(item.getItemId()) - { - case R.id.menu_edit_list_delete: - { + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_edit_list_delete: { deleteSelectedItems(); } } @@ -101,30 +94,26 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem } @Override - public void onDestroyActionMode(ActionMode mode) - { + public void onDestroyActionMode(ActionMode mode) { } // --------------------- Interface MultiChoiceModeListener --------------------- @Override - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) - { + public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { } // --------------------- Interface OnItemClickListener --------------------- @Override - public void onItemClick(AdapterView<?> parent, View view, int position, long id) - { + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { openEditTemplateDialog(position); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onCreate(Bundle savedInstanceState) - { + protected void onCreate(Bundle savedInstanceState) { setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex())); super.onCreate(savedInstanceState); setContentView(R.layout.layout_edit_list); @@ -135,8 +124,7 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem } @Override - public boolean onCreateOptionsMenu(Menu menu) - { + public boolean onCreateOptionsMenu(Menu menu) { MenuItem add = menu.add(Menu.NONE, R.id.menu_edit_list_add, Menu.NONE, ""); add.setIcon(android.R.drawable.ic_menu_add); add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); @@ -144,17 +132,13 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem } @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch(item.getItemId()) - { - case R.id.menu_edit_list_add: - { + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_edit_list_add: { addNewTemplate(); break; } - case android.R.id.home: - { + case android.R.id.home: { NavUtils.navigateUpFromSameTask(this); return true; } @@ -164,14 +148,11 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem // -------------------------- OTHER METHODS -------------------------- - public void deleteSelectedItems() - { + public void deleteSelectedItems() { SparseBooleanArray checkedItems = getListView().getCheckedItemPositions(); adapter.setNotifiable(false); - for(int i = adapter.getCount() - 1; i > -1; i--) - { - if(checkedItems.get(i)) - { + for (int i = adapter.getCount() - 1; i > -1; i--) { + if (checkedItems.get(i)) { Template template = adapter.removeItem(i); template.delete(); } @@ -181,16 +162,12 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem updateListView(); } - public void openEditTemplateDialog(int position) - { + public void openEditTemplateDialog(int position) { final Template template = (Template) adapter.getItem(position); - EditTextDialogFragment dialogFragment = new EditTextDialogFragment() - { + EditTextDialogFragment dialogFragment = new EditTextDialogFragment() { @Override - public void onTextInput(String text) - { - if(TextUtils.isEmpty(text.trim())) - { + public void onTextInput(String text) { + if (TextUtils.isEmpty(text.trim())) { return; } template.text = text; @@ -203,16 +180,12 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem DialogHelper.showDialog(this, dialogFragment); } - private void addNewTemplate() - { + private void addNewTemplate() { final Template template = new Template(); - EditTextDialogFragment dialogFragment = new EditTextDialogFragment() - { + EditTextDialogFragment dialogFragment = new EditTextDialogFragment() { @Override - public void onTextInput(String text) - { - if(TextUtils.isEmpty(text.trim())) - { + public void onTextInput(String text) { + if (TextUtils.isEmpty(text.trim())) { return; } template.text = text; @@ -226,8 +199,7 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem DialogHelper.showDialog(this, dialogFragment); } - private void initializeViews() - { + private void initializeViews() { ListView listView = getListView(); adapter = new CustomListAdapter<>(this, Template.class); listView.setAdapter(adapter); @@ -238,8 +210,7 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem listView.setMultiChoiceModeListener(this); } - private void updateListView() - { + private void updateListView() { getListView().requestLayout(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/LicenseActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/LicenseActivity.java index 470aac03..ca71ca72 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/LicenseActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/LicenseActivity.java @@ -31,6 +31,7 @@ import android.support.v4.app.NavUtils; import android.view.MenuItem; import android.widget.LinearLayout; import android.widget.TextView; + import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.util.Themes; @@ -38,13 +39,11 @@ import net.lacolaco.smileessence.util.Themes; import java.util.ArrayList; import java.util.List; -public class LicenseActivity extends Activity -{ +public class LicenseActivity extends Activity { // --------------------- GETTER / SETTER METHODS --------------------- - private List<String> getFileNames() - { + private List<String> getFileNames() { List<String> apacheFiles = new ArrayList<>(); apacheFiles.add(getString(R.string.library_name_twitter4j)); apacheFiles.add(getString(R.string.library_name_crouton)); @@ -56,16 +55,14 @@ public class LicenseActivity extends Activity return apacheFiles; } - private String getMarkerString() - { + private String getMarkerString() { return "-"; } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex())); super.onCreate(savedInstanceState); setContentView(R.layout.layout_license); @@ -76,12 +73,9 @@ public class LicenseActivity extends Activity } @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch(item.getItemId()) - { - case android.R.id.home: - { + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: { NavUtils.navigateUpFromSameTask(this); return true; } @@ -89,13 +83,11 @@ public class LicenseActivity extends Activity return true; } - private void setFiles() - { + private void setFiles() { LinearLayout files = (LinearLayout) findViewById(R.id.linear_license_files); List<String> apacheFiles = getFileNames(); String marker = getMarkerString(); - for(String apacheFile : apacheFiles) - { + for (String apacheFile : apacheFiles) { TextView name = new TextView(this); name.setText(String.format("%s %s", marker, apacheFile)); files.addView(name); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/MainActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java index 427973f0..657d196e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/MainActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java @@ -39,7 +39,9 @@ import android.view.Menu; import android.view.MenuItem; import android.view.WindowManager; import android.widget.ImageView; + import net.lacolaco.smileessence.Application; +import net.lacolaco.smileessence.BuildConfig; import net.lacolaco.smileessence.IntentRouter; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.CommandSettingCache; @@ -65,14 +67,14 @@ import net.lacolaco.smileessence.viewmodel.MessageViewModel; import net.lacolaco.smileessence.viewmodel.StatusViewModel; import net.lacolaco.smileessence.viewmodel.UserListListAdapter; import net.lacolaco.smileessence.viewmodel.menu.MainActivityMenuHelper; + import twitter4j.*; import java.util.Collection; import java.util.HashMap; import java.util.List; -public class MainActivity extends Activity -{ +public class MainActivity extends Activity { // ------------------------------ FIELDS ------------------------------ @@ -105,126 +107,100 @@ public class MainActivity extends Activity // --------------------- GETTER / SETTER METHODS --------------------- - public AppPreferenceHelper getAppPreferenceHelper() - { + public AppPreferenceHelper getAppPreferenceHelper() { return new AppPreferenceHelper(this); } - public Uri getCameraTempFilePath() - { + public Uri getCameraTempFilePath() { return cameraTempFilePath; } - public void setCameraTempFilePath(Uri cameraTempFilePath) - { + public void setCameraTempFilePath(Uri cameraTempFilePath) { this.cameraTempFilePath = cameraTempFilePath; } - public Account getCurrentAccount() - { + public Account getCurrentAccount() { return currentAccount; } - public void setCurrentAccount(Account account) - { + public void setCurrentAccount(Account account) { this.currentAccount = account; } - private String getLastSearch() - { + private String getLastSearch() { return getAppPreferenceHelper().getValue(KEY_LAST_USED_SEARCH_QUERY, ""); } - public void setLastSearch(String query) - { + public void setLastSearch(String query) { getAppPreferenceHelper().putValue(KEY_LAST_USED_SEARCH_QUERY, query); } - private long getLastUsedAccountID() - { + private long getLastUsedAccountID() { String id = getAppPreferenceHelper().getValue(KEY_LAST_USED_ACCOUNT_ID, ""); - if(TextUtils.isEmpty(id)) - { + if (TextUtils.isEmpty(id)) { return PAGE_GONE; - } - else - { + } else { return Long.parseLong(id); } } - private void setLastUsedAccountID(Account account) - { + private void setLastUsedAccountID(Account account) { getAppPreferenceHelper().putValue(KEY_LAST_USED_ACCOUNT_ID, account.getId()); } - private String getLastUserList() - { + private String getLastUserList() { return getAppPreferenceHelper().getValue(KEY_LAST_USER_LIST, ""); } - public Collection<CustomListAdapter<?>> getListAdapters() - { + public Collection<CustomListAdapter<?>> getListAdapters() { return adapterMap.values(); } - public int getPageHome() - { + public int getPageHome() { return ADAPTER_HOME; } - public int getPageIndexHistory() - { + public int getPageIndexHistory() { return pageIndexHistory; } - public int getPageIndexMessages() - { + public int getPageIndexMessages() { return pageIndexMessages; } - public int getPageIndexSearch() - { + public int getPageIndexSearch() { return pageIndexSearch; } - public int getPageIndexUserlist() - { + public int getPageIndexUserlist() { return pageIndexUserlist; } - public int getPageMentions() - { + public int getPageMentions() { return ADAPTER_MENTIONS; } - public int getPagePost() - { + public int getPagePost() { return PAGE_POST; } - public PageListAdapter getPagerAdapter() - { + public PageListAdapter getPagerAdapter() { return pagerAdapter; } - public int getThemeIndex() - { + public int getThemeIndex() { return ((Application) getApplication()).getThemeIndex(); } - public UserPreferenceHelper getUserPreferenceHelper() - { + public UserPreferenceHelper getUserPreferenceHelper() { return new UserPreferenceHelper(this); } - public String getVersion() - { - return getString(R.string.app_version); + public String getVersion() { + return BuildConfig.VERSION_NAME; } - private boolean isAuthorized() - { + private boolean isAuthorized() { long lastUsedAccountID = getLastUsedAccountID(); return lastUsedAccountID >= 0 && Account.load(Account.class, lastUsedAccountID) != null; } @@ -234,18 +210,15 @@ public class MainActivity extends Activity * * @return */ - public boolean isStreaming() - { + public boolean isStreaming() { return streaming; } - public void setStreaming(boolean streaming) - { + public void setStreaming(boolean streaming) { this.streaming = streaming; } - public void setSelectedPageIndex(int position) - { + public void setSelectedPageIndex(int position) { viewPager.setCurrentItem(position, true); } @@ -255,21 +228,16 @@ public class MainActivity extends Activity // --------------------- Interface Callback --------------------- @Override - public boolean dispatchKeyEvent(KeyEvent event) - { - if(event.getAction() != KeyEvent.ACTION_DOWN) - { + public boolean dispatchKeyEvent(KeyEvent event) { + if (event.getAction() != KeyEvent.ACTION_DOWN) { return super.dispatchKeyEvent(event); } - switch(event.getKeyCode()) - { - case KeyEvent.KEYCODE_BACK: - { + switch (event.getKeyCode()) { + case KeyEvent.KEYCODE_BACK: { finish(); return false; } - default: - { + default: { return super.dispatchKeyEvent(event); } } @@ -278,24 +246,16 @@ public class MainActivity extends Activity // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void finish() - { - if(viewPager == null) - { + public void finish() { + if (viewPager == null) { forceFinish(); - } - else if(viewPager.getCurrentItem() != ADAPTER_HOME) - { + } else if (viewPager.getCurrentItem() != ADAPTER_HOME) { viewPager.setCurrentItem(ADAPTER_HOME, true); - } - else - { - ConfirmDialogFragment.show(this, getString(R.string.dialog_confirm_finish_app), new Runnable() - { + } else { + ConfirmDialogFragment.show(this, getString(R.string.dialog_confirm_finish_app), new Runnable() { @Override - public void run() - { + public void run() { forceFinish(); } }); @@ -303,18 +263,14 @@ public class MainActivity extends Activity } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) - { - switch(requestCode) - { - case REQUEST_OAUTH: - { + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case REQUEST_OAUTH: { receiveOAuth(requestCode, resultCode, data); break; } case REQUEST_GET_PICTURE_FROM_GALLERY: - case REQUEST_GET_PICTURE_FROM_CAMERA: - { + case REQUEST_GET_PICTURE_FROM_CAMERA: { getImageUri(requestCode, resultCode, data); break; } @@ -322,58 +278,48 @@ public class MainActivity extends Activity } @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { setTheme(); super.onCreate(savedInstanceState); setContentView(R.layout.main); - if(isAuthorized()) - { + if (isAuthorized()) { setupAccount(); startMainLogic(); IntentRouter.onNewIntent(this, getIntent()); - } - else - { + } else { startOAuthActivity(); } Logger.debug("MainActivity:onCreate"); } @Override - public boolean onCreateOptionsMenu(Menu menu) - { + public boolean onCreateOptionsMenu(Menu menu) { MainActivityMenuHelper.addItemsToMenu(this, menu); return true; } @Override - protected void onDestroy() - { + protected void onDestroy() { super.onDestroy(); - if(stream != null) - { + if (stream != null) { stream.shutdown(); } Logger.debug("MainActivity:onDestroy"); } @Override - protected void onNewIntent(Intent intent) - { + protected void onNewIntent(Intent intent) { IntentRouter.onNewIntent(this, intent); super.onNewIntent(intent); } @Override - public boolean onOptionsItemSelected(MenuItem item) - { + public boolean onOptionsItemSelected(MenuItem item) { return MainActivityMenuHelper.onItemSelected(this, item); } @Override - protected void onPause() - { + protected void onPause() { super.onPause(); Logger.debug("MainActivity:onPause"); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -381,8 +327,7 @@ public class MainActivity extends Activity } @Override - protected void onResume() - { + protected void onResume() { super.onResume(); Logger.debug("MainActivity:onResume"); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -391,65 +336,50 @@ public class MainActivity extends Activity // -------------------------- OTHER METHODS -------------------------- - public int addListPage(String name, Class<? extends CustomListFragment> fragmentClass, CustomListAdapter<?> adapter, int adapterIndex, boolean visible) - { - if(visible) - { + public int addListPage(String name, Class<? extends CustomListFragment> fragmentClass, CustomListAdapter<?> adapter, int adapterIndex, boolean visible) { + if (visible) { Bundle args = new Bundle(); args.putInt(CustomListFragment.ADAPTER_INDEX, adapterIndex); addPage(name, fragmentClass, args, false); adapterMap.put(adapterIndex, adapter); return pagerAdapter.getCount() - 1; - } - else - { + } else { adapterMap.put(adapterIndex, adapter); return PAGE_GONE; } } - public boolean addPage(String name, Class<? extends Fragment> fragmentClass, Bundle args, boolean withNotify) - { - if(withNotify) - { + public boolean addPage(String name, Class<? extends Fragment> fragmentClass, Bundle args, boolean withNotify) { + if (withNotify) { return this.pagerAdapter.addPage(name, fragmentClass, args); - } - else - { + } else { return this.pagerAdapter.addPageWithoutNotify(name, fragmentClass, args); } } - public void forceFinish() - { + public void forceFinish() { super.finish(); } - public CustomListAdapter<?> getListAdapter(int i) - { + public CustomListAdapter<?> getListAdapter(int i) { return adapterMap.get(i); } - public void openPostPage() - { + public void openPostPage() { setSelectedPageIndex(MainActivity.PAGE_POST); } - public void openPostPageWithImage(Uri uri) - { - try - { + public void openPostPageWithImage(Uri uri) { + try { Cursor c = getContentResolver().query(uri, null, null, null, null); c.moveToFirst(); String path = c.getString(c.getColumnIndex(MediaStore.MediaColumns.DATA)); String rotatedPath = BitmapOptimizer.rotateImageByExif(this, path); PostState.getState().beginTransaction() - .setMediaFilePath(rotatedPath) - .commitWithOpen(this); + .setMediaFilePath(rotatedPath) + .commitWithOpen(this); Notificator.publish(this, R.string.notice_select_image_succeeded); - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); Notificator.publish(this, R.string.notice_select_image_failed, NotificationType.ALERT); } @@ -458,78 +388,62 @@ public class MainActivity extends Activity /** * Open search page */ - public void openSearchPage() - { + public void openSearchPage() { setSelectedPageIndex(pageIndexSearch); } /** * Open search page with given query */ - public void openSearchPage(final String query) - { + public void openSearchPage(final String query) { startNewSearch(TwitterApi.getTwitter(getCurrentAccount()), query); openSearchPage(); } - public void openUserListPage(String listFullName) - { + public void openUserListPage(String listFullName) { startUserList(TwitterApi.getTwitter(getCurrentAccount()), listFullName); openUserListPage(); } - public void saveLastUserList(String lastUserList) - { + public void saveLastUserList(String lastUserList) { getAppPreferenceHelper().putValue(KEY_LAST_USER_LIST, lastUserList); } - public void setListAdapter(int adapterIndex, CustomListAdapter<?> adapter) - { + public void setListAdapter(int adapterIndex, CustomListAdapter<?> adapter) { adapterMap.put(adapterIndex, adapter); } - public void setSelectedPageIndex(final int position, final boolean smooth) - { - new UIHandler() - { + public void setSelectedPageIndex(final int position, final boolean smooth) { + new UIHandler() { @Override - public void run() - { + public void run() { viewPager.setCurrentItem(position, smooth); } }.post(); } - public void startMainLogic() - { + public void startMainLogic() { initializeView(); initCommandSetting(); startTwitter(); } - public void startNewSearch(final Twitter twitter, final String query) - { + public void startNewSearch(final Twitter twitter, final String query) { setLastSearch(query); - if(!TextUtils.isEmpty(query)) - { + if (!TextUtils.isEmpty(query)) { final SearchListAdapter adapter = (SearchListAdapter) getListAdapter(ADAPTER_SEARCH); adapter.initSearch(query); adapter.clear(); adapter.updateForce(); - new SearchTask(twitter, query, this) - { + new SearchTask(twitter, query, this) { @Override - protected void onPostExecute(QueryResult queryResult) - { + protected void onPostExecute(QueryResult queryResult) { super.onPostExecute(queryResult); - if(queryResult != null) - { + if (queryResult != null) { List<twitter4j.Status> tweets = queryResult.getTweets(); - for(int i = tweets.size() - 1; i >= 0; i--) - { + for (int i = tweets.size() - 1; i >= 0; i--) { twitter4j.Status status = tweets.get(i); - if(!status.isRetweet()) - { + if (!status.isRetweet()) { StatusViewModel viewModel = new StatusViewModel(status, getCurrentAccount()); adapter.addToTop(viewModel); StatusFilter.filter(MainActivity.this, viewModel); @@ -543,14 +457,11 @@ public class MainActivity extends Activity } } - public boolean startStream() - { - if(!new NetworkHelper(this).canConnect()) - { + public boolean startStream() { + if (!new NetworkHelper(this).canConnect()) { return false; } - if(stream != null) - { + if (stream != null) { stream.shutdown(); } stream = new TwitterApi(currentAccount).getTwitterStream(); @@ -561,10 +472,8 @@ public class MainActivity extends Activity return true; } - public boolean startTwitter() - { - if(!startStream()) - { + public boolean startTwitter() { + if (!startStream()) { return false; } int count = TwitterUtils.getPagingCount(this); @@ -581,18 +490,14 @@ public class MainActivity extends Activity return true; } - public void updateActionBarIcon() - { + public void updateActionBarIcon() { Twitter twitter = new TwitterApi(currentAccount).getTwitter(); final ImageView homeIcon = (ImageView) findViewById(android.R.id.home); - ShowUserTask userTask = new ShowUserTask(twitter, currentAccount.userID) - { + ShowUserTask userTask = new ShowUserTask(twitter, currentAccount.userID) { @Override - protected void onPostExecute(User user) - { + protected void onPostExecute(User user) { super.onPostExecute(user); - if(user != null) - { + if (user != null) { String urlHttps = user.getProfileImageURLHttps(); homeIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); new BitmapURLTask(urlHttps, homeIcon).execute(); @@ -602,96 +507,78 @@ public class MainActivity extends Activity userTask.execute(); } - private void addHistoryPage() - { + private void addHistoryPage() { boolean visible = getUserPreferenceHelper().getValue(R.string.key_page_history_visibility, true); getUserPreferenceHelper().putValue(R.string.key_page_history_visibility, visible); EventListAdapter historyAdapter = new EventListAdapter(this); pageIndexHistory = addListPage(getString(R.string.page_name_history), HistoryFragment.class, historyAdapter, ADAPTER_HISTORY, visible); } - private void addHomePage() - { + private void addHomePage() { StatusListAdapter homeAdapter = new StatusListAdapter(this); addListPage(getString(R.string.page_name_home), HomeFragment.class, homeAdapter, ADAPTER_HOME, true); } - private void addMentionsPage() - { + private void addMentionsPage() { StatusListAdapter mentionsAdapter = new StatusListAdapter(this); addListPage(getString(R.string.page_name_mentions), MentionsFragment.class, mentionsAdapter, ADAPTER_MENTIONS, true); } - private void addMessagesPage() - { + private void addMessagesPage() { boolean visible = getUserPreferenceHelper().getValue(R.string.key_page_messages_visibility, true); getUserPreferenceHelper().putValue(R.string.key_page_messages_visibility, visible); MessageListAdapter messagesAdapter = new MessageListAdapter(this); pageIndexMessages = addListPage(getString(R.string.page_name_messages), MessagesFragment.class, messagesAdapter, ADAPTER_MESSAGES, visible); } - private void addPostPage() - { + private void addPostPage() { addPage(getString(R.string.page_name_post), PostFragment.class, null, true); } - private void addSearchPage() - { + private void addSearchPage() { boolean visible = getUserPreferenceHelper().getValue(R.string.key_page_search_visibility, true); getUserPreferenceHelper().putValue(R.string.key_page_search_visibility, visible); SearchListAdapter searchAdapter = new SearchListAdapter(this); pageIndexSearch = addListPage(getString(R.string.page_name_search), SearchFragment.class, searchAdapter, ADAPTER_SEARCH, visible); } - private void addUserListPage() - { + private void addUserListPage() { boolean visible = getUserPreferenceHelper().getValue(R.string.key_page_list_visibility, true); getUserPreferenceHelper().putValue(R.string.key_page_list_visibility, visible); UserListListAdapter userListAdapter = new UserListListAdapter(this); pageIndexUserlist = addListPage(getString(R.string.page_name_list), UserListFragment.class, userListAdapter, ADAPTER_USERLIST, visible); } - private void getImageUri(int requestCode, int resultCode, Intent data) - { - if(resultCode != RESULT_OK) - { + private void getImageUri(int requestCode, int resultCode, Intent data) { + if (resultCode != RESULT_OK) { Logger.error(requestCode); Notificator.publish(this, R.string.notice_select_image_failed); finish(); return; } Uri uri; - if(requestCode == REQUEST_GET_PICTURE_FROM_GALLERY) - { + if (requestCode == REQUEST_GET_PICTURE_FROM_GALLERY) { uri = data.getData(); - } - else - { + } else { uri = getCameraTempFilePath(); } openPostPageWithImage(uri); } - private void initCommandSetting() - { + private void initCommandSetting() { List<CommandSetting> commandSettings = CommandSetting.getAll(); - for(CommandSetting setting : commandSettings) - { + for (CommandSetting setting : commandSettings) { CommandSettingCache.getInstance().put(setting); } } - private void initHome(final Twitter twitter, final Paging paging) - { - new HomeTimelineTask(twitter, this, paging) - { + private void initHome(final Twitter twitter, final Paging paging) { + new HomeTimelineTask(twitter, this, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); StatusListAdapter adapter = (StatusListAdapter) getListAdapter(ADAPTER_HOME); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { StatusViewModel statusViewModel = new StatusViewModel(status, currentAccount); adapter.addToBottom(statusViewModel); StatusFilter.filter(MainActivity.this, statusViewModel); @@ -701,23 +588,18 @@ public class MainActivity extends Activity }.execute(); } - private void initInvisibleUser(Twitter twitter) - { + private void initInvisibleUser(Twitter twitter) { new BlockIDsTask(twitter).execute(); new MutesIDsTask(twitter).execute(); } - private void initMentions(final Twitter twitter, final Paging paging) - { - new MentionsTimelineTask(twitter, this, paging) - { + private void initMentions(final Twitter twitter, final Paging paging) { + new MentionsTimelineTask(twitter, this, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); StatusListAdapter adapter = (StatusListAdapter) getListAdapter(ADAPTER_MENTIONS); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { adapter.addToBottom(new StatusViewModel(status, currentAccount)); } adapter.updateForce(); @@ -725,35 +607,27 @@ public class MainActivity extends Activity }.execute(); } - private void initMessages(final Twitter twitter, final Paging paging) - { - if(pageIndexMessages == PAGE_GONE) - { + private void initMessages(final Twitter twitter, final Paging paging) { + if (pageIndexMessages == PAGE_GONE) { return; } - new DirectMessagesTask(twitter, this, paging) - { + new DirectMessagesTask(twitter, this, paging) { @Override - protected void onPostExecute(DirectMessage[] directMessages) - { + protected void onPostExecute(DirectMessage[] directMessages) { super.onPostExecute(directMessages); MessageListAdapter adapter = (MessageListAdapter) getListAdapter(ADAPTER_MESSAGES); - for(DirectMessage message : directMessages) - { + for (DirectMessage message : directMessages) { adapter.addToBottom(new MessageViewModel(message, currentAccount)); } adapter.notifyDataSetChanged(); } }.execute(); - new SentDirectMessagesTask(twitter, this, paging) - { + new SentDirectMessagesTask(twitter, this, paging) { @Override - protected void onPostExecute(DirectMessage[] directMessages) - { + protected void onPostExecute(DirectMessage[] directMessages) { super.onPostExecute(directMessages); MessageListAdapter adapter = (MessageListAdapter) getListAdapter(ADAPTER_MESSAGES); - for(DirectMessage message : directMessages) - { + for (DirectMessage message : directMessages) { adapter.addToBottom(new MessageViewModel(message, currentAccount)); } adapter.notifyDataSetChanged(); @@ -761,45 +635,36 @@ public class MainActivity extends Activity }.execute(); } - private void initPostState() - { + private void initPostState() { PostState.newState().beginTransaction().commit(); } - private void initSearch(Twitter twitter) - { - if(pageIndexSearch == PAGE_GONE) - { + private void initSearch(Twitter twitter) { + if (pageIndexSearch == PAGE_GONE) { return; } String lastUsedSearchQuery = getLastSearch(); - if(!TextUtils.isEmpty(lastUsedSearchQuery)) - { + if (!TextUtils.isEmpty(lastUsedSearchQuery)) { startNewSearch(twitter, lastUsedSearchQuery); } } - private void initUserList(Twitter twitter) - { - if(pageIndexUserlist == PAGE_GONE) - { + private void initUserList(Twitter twitter) { + if (pageIndexUserlist == PAGE_GONE) { return; } String lastUserList = getLastUserList(); - if(!TextUtils.isEmpty(lastUserList)) - { + if (!TextUtils.isEmpty(lastUserList)) { startUserList(twitter, lastUserList); } } - private void initUserListCache(Twitter twitter) - { + private void initUserListCache(Twitter twitter) { UserListCache.getInstance().clear(); new GetUserListsTask(twitter).execute(); } - private void initializePages() - { + private void initializePages() { addPostPage(); addHomePage(); addMentionsPage(); @@ -813,8 +678,7 @@ public class MainActivity extends Activity setSelectedPageIndex(ADAPTER_HOME, false); } - private void initializeView() - { + public void initializeView() { ActionBar bar = getActionBar(); bar.setDisplayShowHomeEnabled(true); bar.setDisplayShowTitleEnabled(false); @@ -824,25 +688,20 @@ public class MainActivity extends Activity initializePages(); } - private void openUserListPage() - { + private void openUserListPage() { setSelectedPageIndex(pageIndexUserlist); } - private void receiveOAuth(int requestCode, int resultCode, Intent data) - { - if(resultCode != RESULT_OK) - { + private void receiveOAuth(int requestCode, int resultCode, Intent data) { + if (resultCode != RESULT_OK) { Logger.error(requestCode); Notificator.publish(this, R.string.notice_error_authenticate); finish(); - } - else - { + } else { Account account = new Account(data.getStringExtra(OAuthSession.KEY_TOKEN), - data.getStringExtra(OAuthSession.KEY_TOKEN_SECRET), - data.getLongExtra(OAuthSession.KEY_USER_ID, -1L), - data.getStringExtra(OAuthSession.KEY_SCREEN_NAME)); + data.getStringExtra(OAuthSession.KEY_TOKEN_SECRET), + data.getLongExtra(OAuthSession.KEY_USER_ID, -1L), + data.getStringExtra(OAuthSession.KEY_SCREEN_NAME)); account.save(); setCurrentAccount(account); setLastUsedAccountID(account); @@ -850,38 +709,31 @@ public class MainActivity extends Activity } } - private void setTheme() - { + private void setTheme() { ((Application) getApplication()).setThemeIndex(getUserPreferenceHelper().getValue(R.string.key_setting_theme, 0)); setTheme(Themes.getTheme(getThemeIndex())); } - private void setupAccount() - { + private void setupAccount() { Account account = Account.load(Account.class, getLastUsedAccountID()); setCurrentAccount(account); } - private void startOAuthActivity() - { + private void startOAuthActivity() { startActivityForResult(new Intent(this, OAuthActivity.class), REQUEST_OAUTH); } - private void startUserList(Twitter twitter, String listFullName) - { + private void startUserList(Twitter twitter, String listFullName) { saveLastUserList(listFullName); final UserListListAdapter adapter = (UserListListAdapter) getListAdapter(ADAPTER_USERLIST); adapter.setListFullName(listFullName); adapter.clear(); adapter.updateForce(); - new UserListStatusesTask(twitter, listFullName, this) - { + new UserListStatusesTask(twitter, listFullName, this) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { StatusViewModel statusViewModel = new StatusViewModel(status, getCurrentAccount()); adapter.addToBottom(statusViewModel); StatusFilter.filter(MainActivity.this, statusViewModel); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/OAuthActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java index c06f2a50..6d571466 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/OAuthActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java @@ -34,13 +34,16 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.twitter.OAuthSession; + +import java.io.File; + import twitter4j.auth.AccessToken; -public class OAuthActivity extends Activity implements View.OnClickListener, TextWatcher -{ +public class OAuthActivity extends Activity implements View.OnClickListener, TextWatcher { public static final int PIN_CODE_LENGTH = 7; private TextView linkTextView; @@ -49,8 +52,7 @@ public class OAuthActivity extends Activity implements View.OnClickListener, Tex private OAuthSession oauthSession; @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_oauth); @@ -63,34 +65,26 @@ public class OAuthActivity extends Activity implements View.OnClickListener, Tex oauthSession = new OAuthSession(); String url = oauthSession.getAuthorizationURL(); - if(!TextUtils.isEmpty(url)) - { + if (!TextUtils.isEmpty(url)) { linkTextView.setText(url); - } - else - { + } else { new Notificator(this, R.string.notice_error_authenticate_request).makeToast().show(); finish(); } } @Override - protected void onResume() - { + protected void onResume() { super.onResume(); } @Override - public void onClick(View v) - { - switch(v.getId()) - { - case R.id.button_oauth_auth: - { + public void onClick(View v) { + switch (v.getId()) { + case R.id.button_oauth_auth: { AccessToken accessToken = oauthSession.getAccessToken(pinEditText.getText().toString()); - if(accessToken != null) - { + if (accessToken != null) { Intent intent = new Intent(); intent.putExtra(OAuthSession.KEY_TOKEN, accessToken.getToken()); intent.putExtra(OAuthSession.KEY_TOKEN_SECRET, accessToken.getTokenSecret()); @@ -98,9 +92,7 @@ public class OAuthActivity extends Activity implements View.OnClickListener, Tex intent.putExtra(OAuthSession.KEY_SCREEN_NAME, accessToken.getScreenName()); setResult(RESULT_OK, intent); finish(); - } - else - { + } else { setResult(RESULT_CANCELED); finish(); } @@ -109,18 +101,15 @@ public class OAuthActivity extends Activity implements View.OnClickListener, Tex } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) - { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) - { + public void onTextChanged(CharSequence s, int start, int before, int count) { authButton.setEnabled(s.length() == PIN_CODE_LENGTH); } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { } }
\ No newline at end of file diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/SettingActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/SettingActivity.java index 160417fc..89e9f68d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/activity/SettingActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/SettingActivity.java @@ -29,18 +29,17 @@ import android.app.Activity; import android.os.Bundle; import android.support.v4.app.NavUtils; import android.view.MenuItem; + import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.util.Themes; -public class SettingActivity extends Activity -{ +public class SettingActivity extends Activity { // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onCreate(Bundle savedInstanceState) - { + protected void onCreate(Bundle savedInstanceState) { setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex())); super.onCreate(savedInstanceState); setContentView(R.layout.setting); @@ -49,12 +48,9 @@ public class SettingActivity extends Activity } @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch(item.getItemId()) - { - case android.R.id.home: - { + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: { NavUtils.navigateUpFromSameTask(this); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/Command.java b/app/src/main/java/net/lacolaco/smileessence/command/Command.java index 4afa6d0b..ef18e0ef 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/Command.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/Command.java @@ -28,6 +28,7 @@ import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.message.*; import net.lacolaco.smileessence.command.status.*; @@ -35,6 +36,7 @@ import net.lacolaco.smileessence.command.user.*; import net.lacolaco.smileessence.data.CommandSettingCache; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.viewmodel.IViewModel; + import twitter4j.DirectMessage; import twitter4j.Status; import twitter4j.User; @@ -43,8 +45,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public abstract class Command implements IViewModel -{ +public abstract class Command implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -53,22 +54,19 @@ public abstract class Command implements IViewModel // -------------------------- STATIC METHODS -------------------------- - public Command(int key, Activity activity) - { + public Command(int key, Activity activity) { this.key = key; this.activity = activity; } - public static List<Command> getAllCommands(Activity activity) - { + public static List<Command> getAllCommands(Activity activity) { List<Command> commands = new ArrayList<>(); commands.addAll(getStatusCommands(activity, null, null)); commands.addAll(getUserCommands(activity, null, null)); return commands; } - public static List<Command> getUserCommands(Activity activity, User user, Account account) - { + public static List<Command> getUserCommands(Activity activity, User user, Account account) { List<Command> commands = new ArrayList<>(); commands.add(new UserCommandReply(activity, user)); commands.add(new UserCommandAddToReply(activity, user)); @@ -83,8 +81,7 @@ public abstract class Command implements IViewModel return commands; } - public static List<Command> getStatusCommands(Activity activity, Status status, Account account) - { + public static List<Command> getStatusCommands(Activity activity, Status status, Account account) { List<Command> commands = new ArrayList<>(); commands.add(new StatusCommandAddToReply(activity, status)); commands.add(new StatusCommandOpenTalkView(activity, status, account)); @@ -105,8 +102,7 @@ public abstract class Command implements IViewModel return commands; } - public static List<Command> getMessageCommands(Activity activity, DirectMessage message, Account account) - { + public static List<Command> getMessageCommands(Activity activity, DirectMessage message, Account account) { List<Command> commands = new ArrayList<>(); commands.add(new MessageCommandShare(activity, message)); commands.add(new MessageCommandCopyTextToClipboard(activity, message)); @@ -117,21 +113,15 @@ public abstract class Command implements IViewModel // --------------------------- CONSTRUCTORS --------------------------- - public static void filter(List<Command> commands) - { + public static void filter(List<Command> commands) { Iterator<Command> iterator = commands.iterator(); - while(iterator.hasNext()) - { + while (iterator.hasNext()) { Command command = iterator.next(); - if(!command.isEnabled()) - { + if (!command.isEnabled()) { iterator.remove(); - } - else if(command.getKey() >= 0) - { + } else if (command.getKey() >= 0) { boolean visibility = CommandSettingCache.getInstance().get(command.getKey()); - if(!visibility) - { + if (!visibility) { iterator.remove(); } } @@ -140,13 +130,11 @@ public abstract class Command implements IViewModel // --------------------- GETTER / SETTER METHODS --------------------- - public Activity getActivity() - { + public Activity getActivity() { return activity; } - public int getKey() - { + public int getKey() { return key; } @@ -156,10 +144,8 @@ public abstract class Command implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.menu_item_simple_text, null); } TextView textView = (TextView) convertedView.findViewById(R.id.textView_menuItem_simple); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenHashtagDialog.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenHashtagDialog.java index 8042ca96..e7f99ad9 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenHashtagDialog.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenHashtagDialog.java @@ -25,12 +25,13 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.HashtagDialogFragment; + import twitter4j.HashtagEntity; -public class CommandOpenHashtagDialog extends Command -{ +public class CommandOpenHashtagDialog extends Command { // ------------------------------ FIELDS ------------------------------ @@ -38,8 +39,7 @@ public class CommandOpenHashtagDialog extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandOpenHashtagDialog(Activity activity, HashtagEntity hashtagEntity) - { + public CommandOpenHashtagDialog(Activity activity, HashtagEntity hashtagEntity) { super(-1, activity); this.hashtagEntity = hashtagEntity; } @@ -47,22 +47,19 @@ public class CommandOpenHashtagDialog extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return "#" + hashtagEntity.getText(); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { HashtagDialogFragment dialogFragment = new HashtagDialogFragment(); dialogFragment.setText(hashtagEntity.getText()); DialogHelper.showDialog(getActivity(), dialogFragment); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenSearch.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenSearch.java index d6399d5b..0877bb55 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenSearch.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenSearch.java @@ -25,11 +25,11 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.SearchQuery; -public class CommandOpenSearch extends Command -{ +public class CommandOpenSearch extends Command { // ------------------------------ FIELDS ------------------------------ @@ -37,28 +37,24 @@ public class CommandOpenSearch extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandOpenSearch(Activity activity, SearchQuery searchQuery) - { + public CommandOpenSearch(Activity activity, SearchQuery searchQuery) { super(-1, activity); this.query = searchQuery; } // --------------------- GETTER / SETTER METHODS --------------------- - public SearchQuery getQuery() - { + public SearchQuery getQuery() { return query; } @Override - public String getText() - { + public String getText() { return query.query; } @Override - public boolean isEnabled() - { + public boolean isEnabled() { MainActivity activity = (MainActivity) getActivity(); return activity.getPageIndexSearch() != MainActivity.PAGE_GONE; } @@ -66,8 +62,7 @@ public class CommandOpenSearch extends Command // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { ((MainActivity) getActivity()).openSearchPage(query.query); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenTemplateList.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenTemplateList.java index 3aa954da..d304e0c9 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenTemplateList.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenTemplateList.java @@ -25,40 +25,36 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.Template; import net.lacolaco.smileessence.view.dialog.ChooseTemplateDialogFragment; import net.lacolaco.smileessence.view.dialog.DialogHelper; -public class CommandOpenTemplateList extends Command -{ +public class CommandOpenTemplateList extends Command { // --------------------------- CONSTRUCTORS --------------------------- - public CommandOpenTemplateList(Activity activity) - { + public CommandOpenTemplateList(Activity activity) { super(-1, activity); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_open_template_list); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !Template.getAll().isEmpty(); } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { ChooseTemplateDialogFragment fragment = new ChooseTemplateDialogFragment(); DialogHelper.showDialog(getActivity(), fragment); return false; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenURL.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenURL.java index 998596d8..35e5c00a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenURL.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenURL.java @@ -27,10 +27,10 @@ package net.lacolaco.smileessence.command; import android.app.Activity; import android.content.Intent; import android.net.Uri; + import net.lacolaco.smileessence.util.IntentUtils; -public class CommandOpenURL extends Command -{ +public class CommandOpenURL extends Command { // ------------------------------ FIELDS ------------------------------ @@ -38,8 +38,7 @@ public class CommandOpenURL extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandOpenURL(Activity activity, String url) - { + public CommandOpenURL(Activity activity, String url) { super(-1, activity); this.url = url; } @@ -47,22 +46,19 @@ public class CommandOpenURL extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return url; } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); IntentUtils.startActivityIfFound(getActivity(), intent); return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenUserDetail.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java index 8bdd4231..290b01cf 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenUserDetail.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.notification.NotificationType; @@ -33,10 +34,10 @@ import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.ShowUserTask; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.UserDetailDialogFragment; + import twitter4j.User; -public class CommandOpenUserDetail extends Command -{ +public class CommandOpenUserDetail extends Command { // ------------------------------ FIELDS ------------------------------ @@ -45,8 +46,7 @@ public class CommandOpenUserDetail extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandOpenUserDetail(Activity activity, String screenName, Account account) - { + public CommandOpenUserDetail(Activity activity, String screenName, Account account) { super(-1, activity); this.screenName = screenName; this.account = account; @@ -55,36 +55,28 @@ public class CommandOpenUserDetail extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return String.format("@%s", screenName); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { - new ShowUserTask(new TwitterApi(account).getTwitter(), screenName) - { + public boolean execute() { + new ShowUserTask(new TwitterApi(account).getTwitter(), screenName) { @Override - protected void onPostExecute(User user) - { + protected void onPostExecute(User user) { super.onPostExecute(user); - if(user != null) - { + if (user != null) { UserDetailDialogFragment fragment = new UserDetailDialogFragment(); fragment.setUserID(user.getId()); DialogHelper.showDialog(getActivity(), fragment); - } - else - { + } else { Notificator.publish(getActivity(), R.string.notice_error_show_user, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenUserList.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserList.java index a722aaf0..fafef0f1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandOpenUserList.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserList.java @@ -25,10 +25,10 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.activity.MainActivity; -public class CommandOpenUserList extends Command -{ +public class CommandOpenUserList extends Command { // ------------------------------ FIELDS ------------------------------ @@ -36,8 +36,7 @@ public class CommandOpenUserList extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandOpenUserList(Activity activity, String listFullName) - { + public CommandOpenUserList(Activity activity, String listFullName) { super(-1, activity); this.listFullName = listFullName; } @@ -45,22 +44,19 @@ public class CommandOpenUserList extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return listFullName; } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { MainActivity activity = (MainActivity) getActivity(); activity.openUserListPage(listFullName); return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandPasteToPost.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandPasteToPost.java index f4666055..34bc227a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandPasteToPost.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandPasteToPost.java @@ -25,12 +25,12 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.view.adapter.PostState; -public class CommandPasteToPost extends Command -{ +public class CommandPasteToPost extends Command { // ------------------------------ FIELDS ------------------------------ @@ -38,8 +38,7 @@ public class CommandPasteToPost extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandPasteToPost(Activity activity, String text) - { + public CommandPasteToPost(Activity activity, String text) { super(-1, activity); this.text = text; } @@ -47,25 +46,22 @@ public class CommandPasteToPost extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_paste_to_post); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { PostState.getState().beginTransaction() - .appendText(" " + text) - .commitWithOpen((MainActivity) getActivity()); + .appendText(" " + text) + .commitWithOpen((MainActivity) getActivity()); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandSaveAsTemplate.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java index fe5cb393..5783cfd0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandSaveAsTemplate.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java @@ -25,12 +25,12 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.Template; import net.lacolaco.smileessence.notification.Notificator; -public class CommandSaveAsTemplate extends Command -{ +public class CommandSaveAsTemplate extends Command { // ------------------------------ FIELDS ------------------------------ @@ -38,8 +38,7 @@ public class CommandSaveAsTemplate extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandSaveAsTemplate(Activity activity, String text) - { + public CommandSaveAsTemplate(Activity activity, String text) { super(-1, activity); this.text = text; } @@ -47,22 +46,19 @@ public class CommandSaveAsTemplate extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_save_as_template); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { new Template(text, 0).save(); new Notificator(getActivity(), R.string.notice_save_as_template).publish(); return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandSearchOnTwitter.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandSearchOnTwitter.java index f1557dd6..a2d2fd27 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/CommandSearchOnTwitter.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandSearchOnTwitter.java @@ -25,11 +25,11 @@ package net.lacolaco.smileessence.command; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; -public class CommandSearchOnTwitter extends Command -{ +public class CommandSearchOnTwitter extends Command { // ------------------------------ FIELDS ------------------------------ @@ -37,8 +37,7 @@ public class CommandSearchOnTwitter extends Command // --------------------------- CONSTRUCTORS --------------------------- - public CommandSearchOnTwitter(Activity activity, String text) - { + public CommandSearchOnTwitter(Activity activity, String text) { super(-1, activity); this.text = text; } @@ -46,22 +45,19 @@ public class CommandSearchOnTwitter extends Command // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_search_on_twitter); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return ((MainActivity) getActivity()).getPageIndexSearch() != MainActivity.PAGE_GONE; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { ((MainActivity) getActivity()).openSearchPage(text); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/IConfirmable.java b/app/src/main/java/net/lacolaco/smileessence/command/IConfirmable.java index 47c17e65..0c0fddc8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/IConfirmable.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/IConfirmable.java @@ -27,7 +27,6 @@ package net.lacolaco.smileessence.command; /** * Marker interface to make command confirmable */ -public interface IConfirmable -{ +public interface IConfirmable { } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommand.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommand.java index 2fecb24f..a36b872d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommand.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommand.java @@ -25,11 +25,12 @@ package net.lacolaco.smileessence.command.message; import android.app.Activity; + import net.lacolaco.smileessence.command.Command; + import twitter4j.DirectMessage; -public abstract class MessageCommand extends Command -{ +public abstract class MessageCommand extends Command { // ------------------------------ FIELDS ------------------------------ @@ -37,16 +38,14 @@ public abstract class MessageCommand extends Command // --------------------------- CONSTRUCTORS --------------------------- - public MessageCommand(int key, Activity activity, DirectMessage message) - { + public MessageCommand(int key, Activity activity, DirectMessage message) { super(key, activity); this.message = message; } // --------------------- GETTER / SETTER METHODS --------------------- - protected DirectMessage getMessage() - { + protected DirectMessage getMessage() { return message; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandCopyTextToClipboard.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java index b3928a2e..435090fa 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandCopyTextToClipboard.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2012-2014 lacolaco.net + * Copyright (c) 2012-2015 lacolaco.net * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,39 +27,36 @@ package net.lacolaco.smileessence.command.message; import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.DirectMessage; -public class MessageCommandCopyTextToClipboard extends MessageCommand -{ +public class MessageCommandCopyTextToClipboard extends MessageCommand { // --------------------------- CONSTRUCTORS --------------------------- - public MessageCommandCopyTextToClipboard(Activity activity, DirectMessage message) - { + public MessageCommandCopyTextToClipboard(Activity activity, DirectMessage message) { super(-1, activity, message); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_copy_text_to_clipboard); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("message text", getMessage().getText())); Notificator.publish(getActivity(), R.string.notice_copy_clipboard); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandSearchOnGoogle.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandSearchOnGoogle.java index 15f3ab38..2c4f8534 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandSearchOnGoogle.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandSearchOnGoogle.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.message; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.SearchOnGoogleDialogFragment; + import twitter4j.DirectMessage; -public class MessageCommandSearchOnGoogle extends MessageCommand -{ +public class MessageCommandSearchOnGoogle extends MessageCommand { // --------------------------- CONSTRUCTORS --------------------------- - public MessageCommandSearchOnGoogle(Activity activity, DirectMessage message) - { + public MessageCommandSearchOnGoogle(Activity activity, DirectMessage message) { super(R.id.key_command_message_search_on_google, activity, message); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_search_on_google); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { SearchOnGoogleDialogFragment dialogFragment = new SearchOnGoogleDialogFragment(); dialogFragment.setText(getMessage().getText()); DialogHelper.showDialog(getActivity(), dialogFragment); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandShare.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandShare.java index 811e1d4e..f1a19d6d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandShare.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandShare.java @@ -26,40 +26,37 @@ package net.lacolaco.smileessence.command.message; import android.app.Activity; import android.content.Intent; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.util.IntentUtils; + import twitter4j.DirectMessage; -public class MessageCommandShare extends MessageCommand -{ +public class MessageCommandShare extends MessageCommand { // --------------------------- CONSTRUCTORS --------------------------- - public MessageCommandShare(Activity activity, DirectMessage message) - { + public MessageCommandShare(Activity activity, DirectMessage message) { super(R.id.key_command_message_share, activity, message); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_share); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandTofuBuster.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java index eedbad95..7b3bde07 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/message/MessageCommandTofuBuster.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java @@ -27,51 +27,45 @@ package net.lacolaco.smileessence.command.message; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.DirectMessage; -public class MessageCommandTofuBuster extends MessageCommand -{ +public class MessageCommandTofuBuster extends MessageCommand { // --------------------------- CONSTRUCTORS --------------------------- - public MessageCommandTofuBuster(Activity activity, DirectMessage message) - { + public MessageCommandTofuBuster(Activity activity, DirectMessage message) { super(R.id.key_command_message_tofubuster, activity, message); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_tofubuster); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String ACTION_SHOW_TEXT = "com.product.kanzmrsw.tofubuster.ACTION_SHOW_TEXT"; String text = getMessage().getText(); Intent i = new Intent(ACTION_SHOW_TEXT); i.putExtra(Intent.EXTRA_TEXT, text); i.putExtra(Intent.EXTRA_SUBJECT, getActivity().getString(R.string.app_name)); i.putExtra("isCopyEnabled", true); - try - { + try { getActivity().startActivity(i); - } - catch(ActivityNotFoundException e) - { + } catch (ActivityNotFoundException e) { new Notificator(getActivity(), R.string.notice_tofubuster_not_found).publish(); } return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommand.java b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommand.java index f4a7c6e6..56f648ff 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommand.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommand.java @@ -25,16 +25,15 @@ package net.lacolaco.smileessence.command.post; import android.app.Activity; + import net.lacolaco.smileessence.command.Command; import net.lacolaco.smileessence.view.adapter.PostState; -public abstract class PostCommand extends Command -{ +public abstract class PostCommand extends Command { // --------------------------- CONSTRUCTORS --------------------------- - public PostCommand(Activity activity) - { + public PostCommand(Activity activity) { super(-1, activity); } @@ -43,14 +42,12 @@ public abstract class PostCommand extends Command public abstract String build(String s); @Override - public boolean execute() - { + public boolean execute() { PostState state = PostState.getState(); String text = state.getText(); int start = state.getSelectionStart(); int end = state.getSelectionEnd(); - if(start == end && isReplaceCommand()) - { + if (start == end && isReplaceCommand()) { start = 0; end = text.length(); } @@ -60,8 +57,7 @@ public abstract class PostCommand extends Command String builtString = builder.replace(start, end, replacedText).toString(); PostState.PostStateTransaction transaction = state.beginTransaction(); int incremental = replacedText.length() - substring.length(); - if(incremental > 0) - { + if (incremental > 0) { transaction.setCursor(end + incremental); } transaction.setText(builtString).commit(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandInsert.java b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandInsert.java index f1e1769e..32fede6f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandInsert.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandInsert.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.command.post; import android.app.Activity; -public class PostCommandInsert extends PostCommand -{ +public class PostCommandInsert extends PostCommand { // ------------------------------ FIELDS ------------------------------ @@ -35,8 +34,7 @@ public class PostCommandInsert extends PostCommand // --------------------------- CONSTRUCTORS --------------------------- - public PostCommandInsert(Activity activity, String inserted) - { + public PostCommandInsert(Activity activity, String inserted) { super(activity); this.inserted = inserted; } @@ -44,28 +42,24 @@ public class PostCommandInsert extends PostCommand // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return inserted; } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } @Override - public boolean isReplaceCommand() - { + public boolean isReplaceCommand() { return false; } // -------------------------- OTHER METHODS -------------------------- @Override - public String build(String s) - { + public String build(String s) { return s + inserted; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandMakeAnonymous.java b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandMakeAnonymous.java index 321f1df5..5ac98a1b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandMakeAnonymous.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandMakeAnonymous.java @@ -26,44 +26,39 @@ package net.lacolaco.smileessence.command.post; import android.app.Activity; import android.text.TextUtils; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.view.adapter.PostState; -public class PostCommandMakeAnonymous extends PostCommand -{ +public class PostCommandMakeAnonymous extends PostCommand { // --------------------------- CONSTRUCTORS --------------------------- - public PostCommandMakeAnonymous(Activity activity) - { + public PostCommandMakeAnonymous(Activity activity) { super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_make_anonymous); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !TextUtils.isEmpty(PostState.getState().getText()); } @Override - public boolean isReplaceCommand() - { + public boolean isReplaceCommand() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public String build(String s) - { + public String build(String s) { return getActivity().getString(R.string.format_status_command_make_anonymous, s).trim(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandMorse.java b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandMorse.java index ff7c686c..a03f6684 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandMorse.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandMorse.java @@ -26,45 +26,40 @@ package net.lacolaco.smileessence.command.post; import android.app.Activity; import android.text.TextUtils; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.util.Morse; import net.lacolaco.smileessence.view.adapter.PostState; -public class PostCommandMorse extends PostCommand -{ +public class PostCommandMorse extends PostCommand { // --------------------------- CONSTRUCTORS --------------------------- - public PostCommandMorse(Activity activity) - { + public PostCommandMorse(Activity activity) { super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_post_morse); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !TextUtils.isEmpty(PostState.getState().getText()); } @Override - public boolean isReplaceCommand() - { + public boolean isReplaceCommand() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public String build(String s) - { + public String build(String s) { return Morse.jaToMorse(s); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandUseTemplate.java b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandUseTemplate.java index 143f6c3e..2701f870 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandUseTemplate.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandUseTemplate.java @@ -25,10 +25,10 @@ package net.lacolaco.smileessence.command.post; import android.app.Activity; + import net.lacolaco.smileessence.entity.Template; -public class PostCommandUseTemplate extends PostCommandInsert -{ +public class PostCommandUseTemplate extends PostCommandInsert { // ------------------------------ FIELDS ------------------------------ @@ -36,8 +36,7 @@ public class PostCommandUseTemplate extends PostCommandInsert // --------------------------- CONSTRUCTORS --------------------------- - public PostCommandUseTemplate(Activity activity, Template template) - { + public PostCommandUseTemplate(Activity activity, Template template) { super(activity, template.text); this.template = template; } @@ -45,8 +44,7 @@ public class PostCommandUseTemplate extends PostCommandInsert // ------------------------ OVERRIDE METHODS ------------------------ @Override - public boolean execute() - { + public boolean execute() { template.count++; template.save(); return super.execute(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandZekamashi.java b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandZekamashi.java index bf329777..323f2e28 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/post/PostCommandZekamashi.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/post/PostCommandZekamashi.java @@ -26,52 +26,46 @@ package net.lacolaco.smileessence.command.post; import android.app.Activity; import android.text.TextUtils; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.view.adapter.PostState; -public class PostCommandZekamashi extends PostCommand -{ +public class PostCommandZekamashi extends PostCommand { private static final String[] brackets = new String[]{"(,)", "(,)", "「,」", "[,]", "{,}", "<,>", "/,\\", "\,/"}; // --------------------------- CONSTRUCTORS --------------------------- - public PostCommandZekamashi(Activity activity) - { + public PostCommandZekamashi(Activity activity) { super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_post_zekamashi); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !TextUtils.isEmpty(PostState.getState().getText()); } @Override - public boolean isReplaceCommand() - { + public boolean isReplaceCommand() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public String build(String s) - { + public String build(String s) { StringBuilder builder = new StringBuilder(s); builder.reverse(); String reversed = builder.toString(); String temp = "########TEMP########"; - for(String bracket : brackets) - { + for (String bracket : brackets) { String first = bracket.split(",")[0]; String second = bracket.split(",")[1]; reversed = reversed.replace(first, temp).replace(second, first).replace(temp, second); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommand.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommand.java index e9b6a103..dd28dd5f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommand.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommand.java @@ -25,11 +25,12 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.command.Command; + import twitter4j.Status; -public abstract class StatusCommand extends Command -{ +public abstract class StatusCommand extends Command { // ------------------------------ FIELDS ------------------------------ @@ -37,21 +38,18 @@ public abstract class StatusCommand extends Command // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommand(int key, Activity activity, Status status) - { + public StatusCommand(int key, Activity activity, Status status) { super(key, activity); this.status = status; } // --------------------- GETTER / SETTER METHODS --------------------- - protected final Status getOriginalStatus() - { + protected final Status getOriginalStatus() { return status.isRetweet() ? status.getRetweetedStatus() : status; } - protected final Status getStatus() - { + protected final Status getStatus() { return status; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandAddToIgnore.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToIgnore.java index 70807801..f9f1c502 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandAddToIgnore.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToIgnore.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; -public class StatusCommandAddToIgnore extends StatusCommand -{ +public class StatusCommandAddToIgnore extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandAddToIgnore(Activity activity, Status status) - { + public StatusCommandAddToIgnore(Activity activity, Status status) { super(R.id.key_command_status_add_to_ignore, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_add_to_ignore); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { StatusCache.getInstance().addToIgnoreStatus(getOriginalStatus().getId()); Notificator.publish(getActivity(), R.string.notice_add_to_ignore); return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandAddToReply.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java index 49866450..ee7d2f74 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandAddToReply.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.Status; -public class StatusCommandAddToReply extends StatusCommand -{ +public class StatusCommandAddToReply extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandAddToReply(Activity activity, Status status) - { + public StatusCommandAddToReply(Activity activity, Status status) { super(R.id.key_command_status_add_to_reply, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_add_to_reply); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String text = String.format("@%s ", getOriginalStatus().getUser().getScreenName()); PostState.getState().beginTransaction().insertText(0, text).moveCursor(text.length()).commit(); Notificator.publish(getActivity(), R.string.notice_add_to_reply); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCongratulate.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java index 7f76d582..6c260358 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCongratulate.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; @@ -32,14 +33,14 @@ import net.lacolaco.smileessence.twitter.TweetBuilder; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.TweetTask; + import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; import java.util.Random; -public class StatusCommandCongratulate extends StatusCommand implements IConfirmable -{ +public class StatusCommandCongratulate extends StatusCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -47,8 +48,7 @@ public class StatusCommandCongratulate extends StatusCommand implements IConfirm // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandCongratulate(Activity activity, Status status, Account account) - { + public StatusCommandCongratulate(Activity activity, Status status, Account account) { super(R.id.key_command_status_congratulate, activity, status); this.account = account; } @@ -56,56 +56,43 @@ public class StatusCommandCongratulate extends StatusCommand implements IConfirm // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_congratulate); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !getOriginalStatus().getUser().isProtected(); } // -------------------------- OTHER METHODS -------------------------- - public String build() - { + public String build() { Status status = getOriginalStatus(); int favCount; Random rand = new Random(); int r = rand.nextInt(100); - if(r < 50) - { + if (r < 50) { favCount = 50; - } - else if(r < 80) - { + } else if (r < 80) { favCount = 100; - } - else if(r < 90) - { + } else if (r < 90) { favCount = 250; - } - else if(r < 99) - { + } else if (r < 99) { favCount = 1000; - } - else - { + } else { favCount = 10000; } return String.format("@%s Congrats on your %s ★ tweet! http://favstar.fm/t/%s", - status.getUser().getScreenName(), favCount, status.getId()); + status.getUser().getScreenName(), favCount, status.getId()); } @Override - public boolean execute() - { + public boolean execute() { Status status = getOriginalStatus(); StatusUpdate update = new TweetBuilder().setText(build()) - .setInReplyToStatusID(status.getId()) - .build(); + .setInReplyToStatusID(status.getId()) + .build(); Twitter twitter = new TwitterApi(account).getTwitter(); new TweetTask(twitter, update, getActivity()).execute(); new FavoriteTask(twitter, status.getId(), getActivity()).execute(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopy.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopy.java index c34df7ce..f1647465 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopy.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopy.java @@ -25,43 +25,40 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.Status; -public class StatusCommandCopy extends StatusCommand -{ +public class StatusCommandCopy extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandCopy(Activity activity, Status status) - { + public StatusCommandCopy(Activity activity, Status status) { super(R.id.key_command_status_copy, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_copy); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { PostState.newState().beginTransaction() - .setText(getOriginalStatus().getText()) - .commitWithOpen((MainActivity) getActivity()); + .setText(getOriginalStatus().getText()) + .commitWithOpen((MainActivity) getActivity()); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopyTextToClipboard.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java index 51bdc3d8..c01a0929 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopyTextToClipboard.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2012-2014 lacolaco.net + * Copyright (c) 2012-2015 lacolaco.net * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,39 +27,36 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; -public class StatusCommandCopyTextToClipboard extends StatusCommand -{ +public class StatusCommandCopyTextToClipboard extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandCopyTextToClipboard(Activity activity, Status status) - { + public StatusCommandCopyTextToClipboard(Activity activity, Status status) { super(R.id.key_command_status_copy_text_to_clipboard, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_copy_text_to_clipboard); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("tweet text", getOriginalStatus().getText())); Notificator.publish(getActivity(), R.string.notice_copy_clipboard); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopyURLToClipboard.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java index 111c8bef..ea031d2a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandCopyURLToClipboard.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java @@ -1,3 +1,27 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2012-2015 lacolaco.net + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package net.lacolaco.smileessence.command.status; import android.app.Activity; @@ -10,35 +34,30 @@ import net.lacolaco.smileessence.twitter.util.TwitterUtils; import twitter4j.Status; -public class StatusCommandCopyURLToClipboard extends StatusCommand -{ +public class StatusCommandCopyURLToClipboard extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandCopyURLToClipboard(Activity activity, Status status) - { + public StatusCommandCopyURLToClipboard(Activity activity, Status status) { super(R.id.key_command_status_copy_url_to_clipboard, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_copy_url_to_clipboard); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String statusURL = TwitterUtils.getStatusURL(getOriginalStatus()); ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("tweet url", statusURL)); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandFavAndRT.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java index 16adae6e..1f82e261 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandFavAndRT.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.RetweetTask; + import twitter4j.Status; import twitter4j.User; -public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable -{ +public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -43,8 +44,7 @@ public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandFavAndRT(Activity activity, Status status, Account account) - { + public StatusCommandFavAndRT(Activity activity, Status status, Account account) { super(R.id.key_command_status_fav_and_rt, activity, status); this.account = account; } @@ -52,14 +52,12 @@ public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_fav_and_rt); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { User user = getOriginalStatus().getUser(); return !user.isProtected() && user.getId() != account.userID; } @@ -67,8 +65,7 @@ public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { new FavoriteTask(new TwitterApi(account).getTwitter(), getOriginalStatus().getId(), getActivity()).execute(); new RetweetTask(new TwitterApi(account).getTwitter(), getOriginalStatus().getId(), getActivity()).execute(); return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandMakeAnonymous.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java index 77cc03ab..8526c30f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandMakeAnonymous.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; @@ -32,12 +33,12 @@ import net.lacolaco.smileessence.twitter.TweetBuilder; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.TweetTask; + import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; -public class StatusCommandMakeAnonymous extends StatusCommand implements IConfirmable -{ +public class StatusCommandMakeAnonymous extends StatusCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -45,24 +46,20 @@ public class StatusCommandMakeAnonymous extends StatusCommand implements IConfir // -------------------------- STATIC METHODS -------------------------- - public StatusCommandMakeAnonymous(Activity activity, Status status, Account account) - { + public StatusCommandMakeAnonymous(Activity activity, Status status, Account account) { super(R.id.key_command_status_make_anonymous, activity, status); this.account = account; } // --------------------------- CONSTRUCTORS --------------------------- - public static String build(Activity activity, Status status, Account account) - { + public static String build(Activity activity, Status status, Account account) { String str = status.getText(); String header = ""; - if(str.startsWith(".")) - { + if (str.startsWith(".")) { str = str.replaceFirst(".", ""); } - if(str.startsWith(String.format("@%s", account.screenName))) - { + if (str.startsWith(String.format("@%s", account.screenName))) { str = str.replaceFirst(String.format("@%s", account.screenName), "").trim(); } str = activity.getString(R.string.format_status_command_make_anonymous, str).trim(); @@ -72,22 +69,19 @@ public class StatusCommandMakeAnonymous extends StatusCommand implements IConfir // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_make_anonymous); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { StatusUpdate update = new TweetBuilder().setText(build(getActivity(), getOriginalStatus(), account)).build(); Twitter twitter = new TwitterApi(account).getTwitter(); new TweetTask(twitter, update, getActivity()).execute(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandNanigaja.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java index a373e80e..99d786ae 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandNanigaja.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; @@ -32,12 +33,12 @@ import net.lacolaco.smileessence.twitter.TweetBuilder; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.TweetTask; + import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; -public class StatusCommandNanigaja extends StatusCommand implements IConfirmable -{ +public class StatusCommandNanigaja extends StatusCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -45,8 +46,7 @@ public class StatusCommandNanigaja extends StatusCommand implements IConfirmable // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandNanigaja(Activity activity, Status status, Account account) - { + public StatusCommandNanigaja(Activity activity, Status status, Account account) { super(R.id.key_command_status_nanigaja, activity, status); this.account = account; } @@ -54,30 +54,25 @@ public class StatusCommandNanigaja extends StatusCommand implements IConfirmable // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_nanigaja); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- - public String build() - { + public String build() { Status status = getOriginalStatus(); String str = status.getText(); String header = ""; - if(str.startsWith(".")) - { + if (str.startsWith(".")) { str = str.replaceFirst(".", ""); } - if(str.startsWith(String.format("@%s", account.screenName))) - { + if (str.startsWith(String.format("@%s", account.screenName))) { str = str.replaceFirst(String.format("@%s", account.screenName), "").trim(); header = "@" + status.getUser().getScreenName(); } @@ -86,20 +81,18 @@ public class StatusCommandNanigaja extends StatusCommand implements IConfirmable } @Override - public boolean execute() - { + public boolean execute() { Status status = getOriginalStatus(); StatusUpdate update = new TweetBuilder().setText(build()) - .setInReplyToStatusID(status.getId()) - .build(); + .setInReplyToStatusID(status.getId()) + .build(); Twitter twitter = new TwitterApi(account).getTwitter(); new TweetTask(twitter, update, getActivity()).execute(); new FavoriteTask(twitter, status.getId(), getActivity()).execute(); return true; } - private String getFormatString(Activity activity) - { + private String getFormatString(Activity activity) { return activity.getString(R.string.format_status_command_nanigaja); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenInBrowser.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenInBrowser.java index 0cbed1ee..bef7638b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenInBrowser.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenInBrowser.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.CommandOpenURL; import net.lacolaco.smileessence.twitter.util.TwitterUtils; + import twitter4j.Status; -public class StatusCommandOpenInBrowser extends StatusCommand -{ +public class StatusCommandOpenInBrowser extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandOpenInBrowser(Activity activity, Status status) - { + public StatusCommandOpenInBrowser(Activity activity, Status status) { super(R.id.key_command_status_open_in_browser, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_open_in_browser); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { return new CommandOpenURL(getActivity(), TwitterUtils.getStatusURL(getOriginalStatus())).execute(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenQuoteDialog.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenQuoteDialog.java index 77a51696..505f26fa 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenQuoteDialog.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenQuoteDialog.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.QuoteDialogFragment; + import twitter4j.Status; -public class StatusCommandOpenQuoteDialog extends StatusCommand -{ +public class StatusCommandOpenQuoteDialog extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandOpenQuoteDialog(Activity activity, Status status) - { + public StatusCommandOpenQuoteDialog(Activity activity, Status status) { super(R.id.key_command_status_quote, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_quote); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { QuoteDialogFragment dialogFragment = new QuoteDialogFragment(); dialogFragment.setStatusID(getOriginalStatus().getId()); DialogHelper.showDialog(getActivity(), dialogFragment, "quoteDialog"); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenTalkView.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenTalkView.java index ee80092b..fbc4ffe9 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandOpenTalkView.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandOpenTalkView.java @@ -25,14 +25,15 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.TalkChainDialogFragment; + import twitter4j.Status; -public class StatusCommandOpenTalkView extends StatusCommand -{ +public class StatusCommandOpenTalkView extends StatusCommand { // ------------------------------ FIELDS ------------------------------ @@ -40,8 +41,7 @@ public class StatusCommandOpenTalkView extends StatusCommand // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandOpenTalkView(Activity activity, Status status, Account account) - { + public StatusCommandOpenTalkView(Activity activity, Status status, Account account) { super(R.id.key_command_status_open_chain, activity, status); this.account = account; } @@ -49,22 +49,19 @@ public class StatusCommandOpenTalkView extends StatusCommand // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_open_talk_view); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return getOriginalStatus().getInReplyToStatusId() >= 0; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { TalkChainDialogFragment dialogFragment = new TalkChainDialogFragment(); dialogFragment.setStatusID(getOriginalStatus().getId()); DialogHelper.showDialog(getActivity(), dialogFragment); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandReview.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java index 3d5d5a77..7eec5526 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandReview.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.ReviewDialogFragment; + import twitter4j.Status; -public class StatusCommandReview extends StatusCommand -{ +public class StatusCommandReview extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandReview(Activity activity, Status status) - { + public StatusCommandReview(Activity activity, Status status) { super(R.id.key_command_status_review, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_review); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !getOriginalStatus().getUser().isProtected(); } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { ReviewDialogFragment dialogFragment = new ReviewDialogFragment(); dialogFragment.setStatusID(getOriginalStatus().getId()); DialogHelper.showDialog(getActivity(), dialogFragment); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandSearchOnGoogle.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandSearchOnGoogle.java index b044e5ac..5b556475 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandSearchOnGoogle.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandSearchOnGoogle.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.SearchOnGoogleDialogFragment; + import twitter4j.Status; -public class StatusCommandSearchOnGoogle extends StatusCommand -{ +public class StatusCommandSearchOnGoogle extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandSearchOnGoogle(Activity activity, Status status) - { + public StatusCommandSearchOnGoogle(Activity activity, Status status) { super(R.id.key_command_status_search_on_google, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_search_on_google); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { SearchOnGoogleDialogFragment dialogFragment = new SearchOnGoogleDialogFragment(); dialogFragment.setText(getOriginalStatus().getText()); DialogHelper.showDialog(getActivity(), dialogFragment); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandShare.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandShare.java index 1745cd39..2874b3f9 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandShare.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandShare.java @@ -26,40 +26,37 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; import android.content.Intent; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.util.IntentUtils; + import twitter4j.Status; -public class StatusCommandShare extends StatusCommand -{ +public class StatusCommandShare extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandShare(Activity activity, Status status) - { + public StatusCommandShare(Activity activity, Status status) { super(R.id.key_command_status_share, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_share); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandTextQuote.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java index d4cadff2..f502c0fa 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandTextQuote.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java @@ -25,47 +25,44 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.twitter.TweetBuilder; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.Status; -public class StatusCommandTextQuote extends StatusCommand -{ +public class StatusCommandTextQuote extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandTextQuote(Activity activity, Status status) - { + public StatusCommandTextQuote(Activity activity, Status status) { super(-1, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_quote_text); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return !getStatus().getUser().isProtected(); } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { TweetBuilder builder = new TweetBuilder().setQuotation(getOriginalStatus()); PostState.newState().beginTransaction() - .setText(builder.buildText()) - .setInReplyToStatusID(getOriginalStatus().getId()) - .setCursor(0) - .commitWithOpen((MainActivity) getActivity()); + .setText(builder.buildText()) + .setInReplyToStatusID(getOriginalStatus().getId()) + .setCursor(0) + .commitWithOpen((MainActivity) getActivity()); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandTofuBuster.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java index ffe587c4..7ceb70a5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandTofuBuster.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java @@ -27,51 +27,45 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; -public class StatusCommandTofuBuster extends StatusCommand -{ +public class StatusCommandTofuBuster extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandTofuBuster(Activity activity, Status status) - { + public StatusCommandTofuBuster(Activity activity, Status status) { super(R.id.key_command_status_tofubuster, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_tofubuster); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String ACTION_SHOW_TEXT = "com.product.kanzmrsw.tofubuster.ACTION_SHOW_TEXT"; String text = getOriginalStatus().getText(); Intent i = new Intent(ACTION_SHOW_TEXT); i.putExtra(Intent.EXTRA_TEXT, text); i.putExtra(Intent.EXTRA_SUBJECT, getActivity().getString(R.string.app_name)); i.putExtra("isCopyEnabled", true); - try - { + try { getActivity().startActivity(i); - } - catch(ActivityNotFoundException e) - { + } catch (ActivityNotFoundException e) { new Notificator(getActivity(), R.string.notice_tofubuster_not_found).publish(); } return true; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandURLQuote.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandURLQuote.java index 6fda35d3..d713fbe7 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/status/StatusCommandURLQuote.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandURLQuote.java @@ -25,45 +25,42 @@ package net.lacolaco.smileessence.command.status; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.Status; -public class StatusCommandURLQuote extends StatusCommand -{ +public class StatusCommandURLQuote extends StatusCommand { // --------------------------- CONSTRUCTORS --------------------------- - public StatusCommandURLQuote(Activity activity, Status status) - { + public StatusCommandURLQuote(Activity activity, Status status) { super(-1, activity, status); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_status_quote_url); } @Override - public boolean isEnabled() - { - return true; + public boolean isEnabled() { + return !getStatus().getUser().isProtected(); } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String statusURL = TwitterUtils.getStatusURL(getOriginalStatus()); PostState.newState().beginTransaction() - .setText(statusURL) - .commitWithOpen((MainActivity) getActivity()); + .setText(statusURL) + .commitWithOpen((MainActivity) getActivity()); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommand.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommand.java index 861e101e..a3fae3c8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommand.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommand.java @@ -25,11 +25,12 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.command.Command; + import twitter4j.User; -public abstract class UserCommand extends Command -{ +public abstract class UserCommand extends Command { // ------------------------------ FIELDS ------------------------------ @@ -37,16 +38,14 @@ public abstract class UserCommand extends Command // --------------------------- CONSTRUCTORS --------------------------- - public UserCommand(int key, Activity activity, User user) - { + public UserCommand(int key, Activity activity, User user) { super(key, activity); this.user = user; } // --------------------- GETTER / SETTER METHODS --------------------- - protected User getUser() - { + protected User getUser() { return user; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandAddToReply.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java index 65e3edd9..6494eba4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandAddToReply.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.User; -public class UserCommandAddToReply extends UserCommand -{ +public class UserCommandAddToReply extends UserCommand { // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandAddToReply(Activity activity, User user) - { + public UserCommandAddToReply(Activity activity, User user) { super(R.id.key_command_user_add_to_reply, activity, user); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_add_to_reply); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String text = String.format("@%s ", getUser().getScreenName()); PostState.getState().beginTransaction().insertText(0, text).moveCursor(text.length()).commit(); Notificator.publish(getActivity(), R.string.notice_add_to_reply); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandBlock.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java index 020d2fb8..ec1e9c0e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandBlock.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java @@ -25,15 +25,16 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.BlockTask; + import twitter4j.User; -public class UserCommandBlock extends UserCommand implements IConfirmable -{ +public class UserCommandBlock extends UserCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -41,8 +42,7 @@ public class UserCommandBlock extends UserCommand implements IConfirmable // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandBlock(Activity activity, User user, Account account) - { + public UserCommandBlock(Activity activity, User user, Account account) { super(R.id.key_command_user_block, activity, user); this.account = account; } @@ -50,22 +50,19 @@ public class UserCommandBlock extends UserCommand implements IConfirmable // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_block); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return getUser().getId() != account.userID; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { new BlockTask(TwitterApi.getTwitter(account), getUser().getId(), getActivity()).execute(); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandIntroduce.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandIntroduce.java index 77dd0f3f..f810aaae 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandIntroduce.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandIntroduce.java @@ -25,44 +25,41 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.User; -public class UserCommandIntroduce extends UserCommand -{ +public class UserCommandIntroduce extends UserCommand { // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandIntroduce(Activity activity, User user) - { + public UserCommandIntroduce(Activity activity, User user) { super(R.id.key_command_user_introduce, activity, user); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_introduce); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { PostState.newState().beginTransaction() - .setText(String.format(" (@%s)", getUser().getScreenName())) - .setCursor(0) - .commitWithOpen((MainActivity) getActivity()); + .setText(String.format(" (@%s)", getUser().getScreenName())) + .setCursor(0) + .commitWithOpen((MainActivity) getActivity()); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenAclog.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenAclog.java index 209d1fb0..63f304e1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenAclog.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenAclog.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.CommandOpenURL; import net.lacolaco.smileessence.twitter.util.TwitterUtils; + import twitter4j.User; -public class UserCommandOpenAclog extends UserCommand -{ +public class UserCommandOpenAclog extends UserCommand { // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandOpenAclog(Activity activity, User user) - { + public UserCommandOpenAclog(Activity activity, User user) { super(R.id.key_command_user_open_aclog, activity, user); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_open_aclog); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { return new CommandOpenURL(getActivity(), TwitterUtils.getAclogTimelineURL(getUser().getScreenName())).execute(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenFavstar.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenFavstar.java index f4cf88dd..f0175e00 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenFavstar.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenFavstar.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.CommandOpenURL; import net.lacolaco.smileessence.twitter.util.TwitterUtils; + import twitter4j.User; -public class UserCommandOpenFavstar extends UserCommand -{ +public class UserCommandOpenFavstar extends UserCommand { // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandOpenFavstar(Activity activity, User user) - { + public UserCommandOpenFavstar(Activity activity, User user) { super(R.id.key_command_user_open_favstar, activity, user); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_open_favstar); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { return new CommandOpenURL(getActivity(), TwitterUtils.getFavstarRecentURL(getUser().getScreenName())).execute(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenTwilog.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenTwilog.java index 43499f04..7ee8ec1c 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandOpenTwilog.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandOpenTwilog.java @@ -25,40 +25,37 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.CommandOpenURL; import net.lacolaco.smileessence.twitter.util.TwitterUtils; + import twitter4j.User; -public class UserCommandOpenTwilog extends UserCommand -{ +public class UserCommandOpenTwilog extends UserCommand { // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandOpenTwilog(Activity activity, User user) - { + public UserCommandOpenTwilog(Activity activity, User user) { super(R.id.key_command_user_open_twilog, activity, user); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_open_twilog); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { return new CommandOpenURL(getActivity(), TwitterUtils.getTwilogURL(getUser().getScreenName())).execute(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandReply.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReply.java index 04eeefe6..94dd6cfa 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandReply.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReply.java @@ -25,46 +25,43 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.twitter.TweetBuilder; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.User; -public class UserCommandReply extends UserCommand -{ +public class UserCommandReply extends UserCommand { // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandReply(Activity activity, User user) - { + public UserCommandReply(Activity activity, User user) { super(R.id.key_command_user_reply, activity, user); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_reply); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { String text = new TweetBuilder().addScreenName(getUser().getScreenName()).buildText(); PostState.newState().beginTransaction() - .setText(text) - .setCursor(text.length()) - .commitWithOpen((MainActivity) getActivity()); + .setText(text) + .setCursor(text.length()) + .commitWithOpen((MainActivity) getActivity()); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandReportForSpam.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java index 537300c4..553dc632 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandReportForSpam.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java @@ -25,15 +25,16 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.ReportForSpamTask; + import twitter4j.User; -public class UserCommandReportForSpam extends UserCommand implements IConfirmable -{ +public class UserCommandReportForSpam extends UserCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -41,8 +42,7 @@ public class UserCommandReportForSpam extends UserCommand implements IConfirmabl // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandReportForSpam(Activity activity, User user, Account account) - { + public UserCommandReportForSpam(Activity activity, User user, Account account) { super(R.id.key_command_user_r4s, activity, user); this.account = account; } @@ -50,22 +50,19 @@ public class UserCommandReportForSpam extends UserCommand implements IConfirmabl // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_r4s); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return getUser().getId() != account.userID; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { new ReportForSpamTask(new TwitterApi(account).getTwitter(), getUser().getId(), getActivity()).execute(); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandSendMessage.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandSendMessage.java index b45765c5..43982030 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandSendMessage.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandSendMessage.java @@ -25,14 +25,15 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.SendMessageDialogFragment; + import twitter4j.User; -public class UserCommandSendMessage extends UserCommand -{ +public class UserCommandSendMessage extends UserCommand { // ------------------------------ FIELDS ------------------------------ @@ -40,8 +41,7 @@ public class UserCommandSendMessage extends UserCommand // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandSendMessage(Activity activity, User user, Account account) - { + public UserCommandSendMessage(Activity activity, User user, Account account) { super(R.id.key_command_user_send_message, activity, user); this.account = account; } @@ -49,22 +49,19 @@ public class UserCommandSendMessage extends UserCommand // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_send_message); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return account.userID != getUser().getId(); } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { SendMessageDialogFragment dialogFragment = new SendMessageDialogFragment(); dialogFragment.setScreenName(getUser().getScreenName()); DialogHelper.showDialog(getActivity(), dialogFragment); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandUnblock.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java index 0d95b655..7f1a8776 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/command/user/UserCommandUnblock.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java @@ -25,15 +25,16 @@ package net.lacolaco.smileessence.command.user; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.IConfirmable; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.UnblockTask; + import twitter4j.User; -public class UserCommandUnblock extends UserCommand implements IConfirmable -{ +public class UserCommandUnblock extends UserCommand implements IConfirmable { // ------------------------------ FIELDS ------------------------------ @@ -41,8 +42,7 @@ public class UserCommandUnblock extends UserCommand implements IConfirmable // --------------------------- CONSTRUCTORS --------------------------- - public UserCommandUnblock(Activity activity, User user, Account account) - { + public UserCommandUnblock(Activity activity, User user, Account account) { super(R.id.key_command_user_unblock, activity, user); this.account = account; } @@ -50,22 +50,19 @@ public class UserCommandUnblock extends UserCommand implements IConfirmable // --------------------- GETTER / SETTER METHODS --------------------- @Override - public String getText() - { + public String getText() { return getActivity().getString(R.string.command_user_unblock); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return getUser().getId() != account.userID; } // -------------------------- OTHER METHODS -------------------------- @Override - public boolean execute() - { + public boolean execute() { new UnblockTask(new TwitterApi(account).getTwitter(), getUser().getId(), getActivity()).execute(); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/CommandSettingCache.java b/app/src/main/java/net/lacolaco/smileessence/data/CommandSettingCache.java index 8862abc6..ad0ed9c6 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/CommandSettingCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/CommandSettingCache.java @@ -28,8 +28,7 @@ import net.lacolaco.smileessence.entity.CommandSetting; import java.util.concurrent.ConcurrentHashMap; -public class CommandSettingCache -{ +public class CommandSettingCache { // ------------------------------ FIELDS ------------------------------ @@ -39,32 +38,27 @@ public class CommandSettingCache // -------------------------- STATIC METHODS -------------------------- - private CommandSettingCache() - { + private CommandSettingCache() { } // --------------------------- CONSTRUCTORS --------------------------- - public static CommandSettingCache getInstance() - { + public static CommandSettingCache getInstance() { return instance; } // -------------------------- OTHER METHODS -------------------------- - public Boolean get(int id) - { + public Boolean get(int id) { Boolean visibility = cache.get(Integer.valueOf(id)); return visibility != null ? visibility : true; } - public void put(CommandSetting commandSetting) - { + public void put(CommandSetting commandSetting) { cache.put(commandSetting.commandKey, commandSetting.visibility); } - public boolean remove(int id) - { + public boolean remove(int id) { return cache.remove(Integer.valueOf(id)); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/DirectMessageCache.java b/app/src/main/java/net/lacolaco/smileessence/data/DirectMessageCache.java index a4f626ca..c7a83b50 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/DirectMessageCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/DirectMessageCache.java @@ -29,8 +29,7 @@ import twitter4j.DirectMessage; import java.util.Collection; import java.util.concurrent.ConcurrentHashMap; -public class DirectMessageCache -{ +public class DirectMessageCache { // ------------------------------ FIELDS ------------------------------ @@ -40,14 +39,12 @@ public class DirectMessageCache // -------------------------- STATIC METHODS -------------------------- - private DirectMessageCache() - { + private DirectMessageCache() { } // --------------------------- CONSTRUCTORS --------------------------- - public static DirectMessageCache getInstance() - { + public static DirectMessageCache getInstance() { return instance; } @@ -58,8 +55,7 @@ public class DirectMessageCache * * @return cached all message */ - public Collection<DirectMessage> all() - { + public Collection<DirectMessage> all() { return cache.values(); } @@ -69,8 +65,7 @@ public class DirectMessageCache * @param id message id * @return cached value */ - public DirectMessage get(long id) - { + public DirectMessage get(long id) { return cache.get(id); } @@ -80,8 +75,7 @@ public class DirectMessageCache * @param message * @return the previous value associated with key, or null if there was no mapping for key */ - public DirectMessage put(DirectMessage message) - { + public DirectMessage put(DirectMessage message) { return cache.put(message.getId(), message); } @@ -91,8 +85,7 @@ public class DirectMessageCache * @param id message id * @return removed message */ - public DirectMessage remove(long id) - { + public DirectMessage remove(long id) { return cache.remove(id); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/FavoriteCache.java b/app/src/main/java/net/lacolaco/smileessence/data/FavoriteCache.java index 2d31dc40..f8213040 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/FavoriteCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/FavoriteCache.java @@ -28,8 +28,7 @@ import twitter4j.Status; import java.util.concurrent.ConcurrentHashMap; -public class FavoriteCache -{ +public class FavoriteCache { // ------------------------------ FIELDS ------------------------------ @@ -39,14 +38,12 @@ public class FavoriteCache // -------------------------- STATIC METHODS -------------------------- - private FavoriteCache() - { + private FavoriteCache() { } // --------------------------- CONSTRUCTORS --------------------------- - public static FavoriteCache getInstance() - { + public static FavoriteCache getInstance() { return instance; } @@ -55,8 +52,7 @@ public class FavoriteCache /** * Get status by id */ - public boolean get(long id) - { + public boolean get(long id) { Boolean favorited = cache.get(id); return favorited != null ? favorited : false; } @@ -64,36 +60,28 @@ public class FavoriteCache /** * Put status into cache */ - public void put(Status status) - { - if(!status.isRetweet()) - { + public void put(Status status) { + if (!status.isRetweet()) { cache.put(status.getId(), status.isFavorited()); } } - public void put(Status status, boolean favorited) - { - if(status.isRetweet()) - { + public void put(Status status, boolean favorited) { + if (status.isRetweet()) { cache.put(status.getRetweetedStatus().getId(), favorited); - } - else - { + } else { cache.put(status.getId(), favorited); } } - public void put(long id, boolean favorited) - { + public void put(long id, boolean favorited) { cache.put(id, favorited); } /** * Remove favorite by id */ - public boolean remove(long id) - { + public boolean remove(long id) { return cache.remove(id); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/ImageCache.java b/app/src/main/java/net/lacolaco/smileessence/data/ImageCache.java index 7f74ca71..6337cba9 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/ImageCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/ImageCache.java @@ -26,12 +26,12 @@ package net.lacolaco.smileessence.data; import android.graphics.Bitmap; import android.util.LruCache; + import com.android.volley.RequestQueue; import com.android.volley.VolleyError; import com.android.volley.toolbox.*; -public class ImageCache implements ImageLoader.ImageCache -{ +public class ImageCache implements ImageLoader.ImageCache { // ------------------------------ FIELDS ------------------------------ @@ -42,8 +42,7 @@ public class ImageCache implements ImageLoader.ImageCache // -------------------------- STATIC METHODS -------------------------- - private ImageCache() - { + private ImageCache() { int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); int cacheSize = maxMemory / 8; cache = new LruCache<>(cacheSize); @@ -54,8 +53,7 @@ public class ImageCache implements ImageLoader.ImageCache // --------------------------- CONSTRUCTORS --------------------------- - public static ImageCache getInstance() - { + public static ImageCache getInstance() { return instance; } @@ -65,37 +63,30 @@ public class ImageCache implements ImageLoader.ImageCache // --------------------- Interface ImageCache --------------------- @Override - public Bitmap getBitmap(String url) - { + public Bitmap getBitmap(String url) { return cache.get(url); } @Override - public void putBitmap(String url, Bitmap bitmap) - { + public void putBitmap(String url, Bitmap bitmap) { cache.put(url, bitmap); } // -------------------------- OTHER METHODS -------------------------- - public ImageLoader.ImageContainer requestBitmap(String imageURL) - { - return imageLoader.get(imageURL, new ImageLoader.ImageListener() - { + public ImageLoader.ImageContainer requestBitmap(String imageURL) { + return imageLoader.get(imageURL, new ImageLoader.ImageListener() { @Override - public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) - { + public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) { } @Override - public void onErrorResponse(VolleyError error) - { + public void onErrorResponse(VolleyError error) { } }); } - public void setImageToView(String imageURL, NetworkImageView view) - { + public void setImageToView(String imageURL, NetworkImageView view) { view.setImageUrl(imageURL, imageLoader); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/StatusCache.java b/app/src/main/java/net/lacolaco/smileessence/data/StatusCache.java index 8f949754..76c89a40 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/StatusCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/StatusCache.java @@ -29,8 +29,7 @@ import twitter4j.Status; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; -public class StatusCache -{ +public class StatusCache { // ------------------------------ FIELDS ------------------------------ @@ -42,21 +41,18 @@ public class StatusCache // -------------------------- STATIC METHODS -------------------------- - private StatusCache() - { + private StatusCache() { } // --------------------------- CONSTRUCTORS --------------------------- - public static StatusCache getInstance() - { + public static StatusCache getInstance() { return instance; } // -------------------------- OTHER METHODS -------------------------- - public void addToIgnoreStatus(long id) - { + public void addToIgnoreStatus(long id) { ignoreIDs.add(id); } @@ -66,13 +62,11 @@ public class StatusCache * @param id status id * @return cached value */ - public Status get(long id) - { + public Status get(long id) { return cache.get(id); } - public boolean isIgnored(long id) - { + public boolean isIgnored(long id) { return ignoreIDs.contains(id); } @@ -82,14 +76,11 @@ public class StatusCache * @param status * @return the previous value associated with key, or null if there was no mapping for key */ - public Status put(Status status) - { - if(status.isRetweet()) - { + public Status put(Status status) { + if (status.isRetweet()) { put(status.getRetweetedStatus()); } - if(cache.containsKey(status.getId())) - { + if (cache.containsKey(status.getId())) { cache.remove(status.getId()); } return cache.put(status.getId(), status); @@ -101,8 +92,7 @@ public class StatusCache * @param id status id * @return removed status */ - public Status remove(long id) - { + public Status remove(long id) { return cache.remove(id); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/UserCache.java b/app/src/main/java/net/lacolaco/smileessence/data/UserCache.java index 4b5864f6..831a0949 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/UserCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/UserCache.java @@ -29,8 +29,7 @@ import twitter4j.User; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; -public class UserCache -{ +public class UserCache { // ------------------------------ FIELDS ------------------------------ @@ -42,14 +41,12 @@ public class UserCache // -------------------------- STATIC METHODS -------------------------- - private UserCache() - { + private UserCache() { } // --------------------------- CONSTRUCTORS --------------------------- - public static UserCache getInstance() - { + public static UserCache getInstance() { return instance; } @@ -61,13 +58,11 @@ public class UserCache * @param id user id * @return cached value */ - public User get(long id) - { + public User get(long id) { return cache.get(id); } - public boolean isInvisibleUserID(long id) - { + public boolean isInvisibleUserID(long id) { return invisibleIDs.contains(Long.valueOf(id)); } @@ -77,13 +72,11 @@ public class UserCache * @param user * @return the previous value associated with key, or null if there was no mapping for key */ - public User put(User user) - { + public User put(User user) { return cache.put(user.getId(), user); } - public void putInvisibleUser(long id) - { + public void putInvisibleUser(long id) { invisibleIDs.add(id); } @@ -93,13 +86,11 @@ public class UserCache * @param id user id * @return removed user */ - public User remove(long id) - { + public User remove(long id) { return cache.remove(id); } - public void removeInvisibleUser(long id) - { + public void removeInvisibleUser(long id) { invisibleIDs.remove(Long.valueOf(id)); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/UserListCache.java b/app/src/main/java/net/lacolaco/smileessence/data/UserListCache.java index ea2e3c34..96ceb726 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/data/UserListCache.java +++ b/app/src/main/java/net/lacolaco/smileessence/data/UserListCache.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.data; import java.util.concurrent.ConcurrentLinkedQueue; -public class UserListCache -{ +public class UserListCache { // ------------------------------ FIELDS ------------------------------ @@ -37,28 +36,24 @@ public class UserListCache // -------------------------- STATIC METHODS -------------------------- - private UserListCache() - { + private UserListCache() { } // --------------------------- CONSTRUCTORS --------------------------- - public static UserListCache getInstance() - { + public static UserListCache getInstance() { return instance; } // --------------------- GETTER / SETTER METHODS --------------------- - public String[] getAll() - { + public String[] getAll() { return cache.toArray(new String[cache.size()]); } // -------------------------- OTHER METHODS -------------------------- - public void clear() - { + public void clear() { cache.clear(); } @@ -67,13 +62,11 @@ public class UserListCache * * @param userList */ - public void put(String userList) - { + public void put(String userList) { cache.add(userList); } - public void remove(String userList) - { + public void remove(String userList) { cache.remove(userList); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/Account.java b/app/src/main/java/net/lacolaco/smileessence/entity/Account.java index 9c941840..c85e585b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/Account.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/Account.java @@ -30,8 +30,7 @@ import com.activeandroid.annotation.Table; import com.activeandroid.query.Delete; @Table(name = "Accounts") -public class Account extends Model -{ +public class Account extends Model { // ------------------------------ FIELDS ------------------------------ @@ -46,15 +45,13 @@ public class Account extends Model // -------------------------- STATIC METHODS -------------------------- - public Account() - { + public Account() { super(); } // --------------------------- CONSTRUCTORS --------------------------- - public Account(String token, String tokenSecret, long userID, String screenName) - { + public Account(String token, String tokenSecret, long userID, String screenName) { super(); this.accessToken = token; this.accessSecret = tokenSecret; @@ -62,8 +59,7 @@ public class Account extends Model this.screenName = screenName; } - public static void deleteAll() - { + public static void deleteAll() { new Delete().from(Account.class).execute(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/CommandSetting.java b/app/src/main/java/net/lacolaco/smileessence/entity/CommandSetting.java index 78a16bf6..3cb08ce0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/CommandSetting.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/CommandSetting.java @@ -32,8 +32,7 @@ import com.activeandroid.query.Select; import java.util.List; @Table(name = "Commands") -public class CommandSetting extends Model -{ +public class CommandSetting extends Model { // ------------------------------ FIELDS ------------------------------ @@ -44,13 +43,11 @@ public class CommandSetting extends Model // -------------------------- STATIC METHODS -------------------------- - public CommandSetting() - { + public CommandSetting() { super(); } - public CommandSetting(int commandKey, boolean visibility) - { + public CommandSetting(int commandKey, boolean visibility) { super(); this.commandKey = commandKey; this.visibility = visibility; @@ -58,13 +55,11 @@ public class CommandSetting extends Model // --------------------------- CONSTRUCTORS --------------------------- - public static List<CommandSetting> getAll() - { + public static List<CommandSetting> getAll() { return new Select().from(CommandSetting.class).execute(); } - public static CommandSetting selectByKey(int key) - { + public static CommandSetting selectByKey(int key) { return new Select().from(CommandSetting.class).where("CommandKey = ?", key).executeSingle(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/ExtractionWord.java b/app/src/main/java/net/lacolaco/smileessence/entity/ExtractionWord.java index 404686fa..8ff23b9b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/ExtractionWord.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/ExtractionWord.java @@ -28,18 +28,19 @@ import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; + import com.activeandroid.Model; import com.activeandroid.annotation.Column; import com.activeandroid.annotation.Table; import com.activeandroid.query.Select; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.viewmodel.IViewModel; import java.util.List; @Table(name = "Extraction") -public class ExtractionWord extends Model implements IViewModel -{ +public class ExtractionWord extends Model implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -48,21 +49,18 @@ public class ExtractionWord extends Model implements IViewModel // -------------------------- STATIC METHODS -------------------------- - public ExtractionWord() - { + public ExtractionWord() { super(); } // --------------------------- CONSTRUCTORS --------------------------- - public ExtractionWord(String text) - { + public ExtractionWord(String text) { super(); this.text = text; } - public static List<ExtractionWord> getAll() - { + public static List<ExtractionWord> getAll() { return new Select().from(ExtractionWord.class).execute(); } @@ -72,10 +70,8 @@ public class ExtractionWord extends Model implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.menu_item_simple_text, null); } TextView textView = (TextView) convertedView.findViewById(R.id.textView_menuItem_simple); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/SearchQuery.java b/app/src/main/java/net/lacolaco/smileessence/entity/SearchQuery.java index 2d248c98..002f5e7d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/SearchQuery.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/SearchQuery.java @@ -33,8 +33,7 @@ import java.util.Date; import java.util.List; @Table(name = "SearchQueries") -public class SearchQuery extends Model -{ +public class SearchQuery extends Model { // ------------------------------ FIELDS ------------------------------ @@ -46,19 +45,16 @@ public class SearchQuery extends Model // -------------------------- STATIC METHODS -------------------------- - public SearchQuery() - { + public SearchQuery() { super(); } - public SearchQuery(String query, Date createdAt) - { + public SearchQuery(String query, Date createdAt) { this.query = query; this.createdAt = createdAt; } - public static List<SearchQuery> getAll() - { + public static List<SearchQuery> getAll() { return new Select().from(SearchQuery.class).orderBy("CreatedAt DESC").execute(); } @@ -68,21 +64,16 @@ public class SearchQuery extends Model * @param query * @return */ - public static boolean saveIfNotFound(String query) - { - if(findByQuery(query) != null) - { + public static boolean saveIfNotFound(String query) { + if (findByQuery(query) != null) { return false; - } - else - { + } else { new SearchQuery(query, new Date()).save(); return true; } } - public static SearchQuery findByQuery(String query) - { + public static SearchQuery findByQuery(String query) { return new Select().from(SearchQuery.class).where("Query = ?", query).executeSingle(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/Template.java b/app/src/main/java/net/lacolaco/smileessence/entity/Template.java index 276dc30f..23c68687 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/entity/Template.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/Template.java @@ -28,18 +28,19 @@ import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; + import com.activeandroid.Model; import com.activeandroid.annotation.Column; import com.activeandroid.annotation.Table; import com.activeandroid.query.Select; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.viewmodel.IViewModel; import java.util.List; @Table(name = "Templates") -public class Template extends Model implements IViewModel -{ +public class Template extends Model implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -50,22 +51,19 @@ public class Template extends Model implements IViewModel // -------------------------- STATIC METHODS -------------------------- - public Template() - { + public Template() { super(); } // --------------------------- CONSTRUCTORS --------------------------- - public Template(String text, int count) - { + public Template(String text, int count) { super(); this.text = text; this.count = count; } - public static List<Template> getAll() - { + public static List<Template> getAll() { return new Select().from(Template.class).orderBy("COUNT DESC").execute(); } @@ -75,10 +73,8 @@ public class Template extends Model implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.menu_item_simple_text, null); } TextView textView = (TextView) convertedView.findViewById(R.id.textView_menuItem_simple); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/logging/Logger.java b/app/src/main/java/net/lacolaco/smileessence/logging/Logger.java index d0ea41d4..cf2f81bf 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/logging/Logger.java +++ b/app/src/main/java/net/lacolaco/smileessence/logging/Logger.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.logging; import android.util.Log; -public class Logger -{ +public class Logger { // ------------------------------ FIELDS ------------------------------ @@ -35,28 +34,23 @@ public class Logger // -------------------------- STATIC METHODS -------------------------- - public static void debug(Object message) - { + public static void debug(Object message) { Log.d(TAG, String.valueOf(message)); } - public static void info(Object message) - { + public static void info(Object message) { Log.i(TAG, String.valueOf(message)); } - public static void error(Object message) - { + public static void error(Object message) { Log.e(TAG, String.valueOf(message)); } - public static void warn(Object message) - { + public static void warn(Object message) { Log.w(TAG, String.valueOf(message)); } - public static void verbose(Object message) - { + public static void verbose(Object message) { Log.v(TAG, String.valueOf(message)); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/notification/NotificationType.java b/app/src/main/java/net/lacolaco/smileessence/notification/NotificationType.java index a02c1984..35faa0ff 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/notification/NotificationType.java +++ b/app/src/main/java/net/lacolaco/smileessence/notification/NotificationType.java @@ -24,8 +24,7 @@ package net.lacolaco.smileessence.notification; -public enum NotificationType -{ +public enum NotificationType { INFO, ALERT; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/notification/Notificator.java b/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java index 7815823d..6a75e2eb 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/notification/Notificator.java +++ b/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java @@ -26,14 +26,15 @@ package net.lacolaco.smileessence.notification; import android.app.Activity; import android.widget.Toast; + import de.keyboardsurfer.android.widget.crouton.Configuration; import de.keyboardsurfer.android.widget.crouton.Crouton; import de.keyboardsurfer.android.widget.crouton.Style; + import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.util.UIHandler; -public class Notificator -{ +public class Notificator { // ------------------------------ FIELDS ------------------------------ @@ -45,35 +46,29 @@ public class Notificator // -------------------------- STATIC METHODS -------------------------- - public Notificator(Activity activity, int resID) - { + public Notificator(Activity activity, int resID) { this(activity, resID, NotificationType.INFO); } - public Notificator(Activity activity, String text) - { + public Notificator(Activity activity, String text) { this(activity, text, NotificationType.INFO); } - public Notificator(Activity activity, int resID, NotificationType type) - { + public Notificator(Activity activity, int resID, NotificationType type) { this(activity, activity.getString(resID), type); } - public Notificator(Activity activity, String text, NotificationType type) - { + public Notificator(Activity activity, String text, NotificationType type) { this.activity = activity; this.text = text; this.type = type; } - public static void startNotification() - { + public static void startNotification() { isRunning = true; } - public static void stopNotification() - { + public static void stopNotification() { isRunning = false; Crouton.cancelAllCroutons(); } @@ -83,43 +78,35 @@ public class Notificator /** * Notify self on cronton or toast. */ - public static void publish(Activity activity, int resID) - { + public static void publish(Activity activity, int resID) { publish(activity, activity.getString(resID)); } - public static void publish(Activity activity, String text) - { + public static void publish(Activity activity, String text) { new Notificator(activity, text, NotificationType.INFO).publish(); } - public static void publish(Activity activity, int resID, NotificationType type) - { + public static void publish(Activity activity, int resID, NotificationType type) { publish(activity, activity.getString(resID), type); } - public static void publish(Activity activity, String text, NotificationType type) - { + public static void publish(Activity activity, String text, NotificationType type) { new Notificator(activity, text, type).publish(); } // --------------------- GETTER / SETTER METHODS --------------------- - private Style getStyle() - { + private Style getStyle() { Configuration.Builder conf = new Configuration.Builder(); conf.setDuration(DURATION); Style.Builder style = new Style.Builder(); style.setConfiguration(conf.build()); - switch(type) - { - case INFO: - { + switch (type) { + case INFO: { style.setBackgroundColorValue(Style.holoBlueLight); break; } - case ALERT: - { + case ALERT: { style.setBackgroundColorValue(Style.holoRedLight); break; } @@ -129,37 +116,28 @@ public class Notificator // -------------------------- OTHER METHODS -------------------------- - public Crouton makeCrouton() - { + public Crouton makeCrouton() { return Crouton.makeText(activity, text, getStyle()); } - public Toast makeToast() - { + public Toast makeToast() { return Toast.makeText(activity, text, Toast.LENGTH_LONG); } /** * Notify self on cronton or toast. */ - public void publish() - { - if(activity == null || activity.isFinishing()) - { + public void publish() { + if (activity == null || activity.isFinishing()) { return; } - new UIHandler() - { + new UIHandler() { @Override - public void run() - { - if(isRunning) - { + public void run() { + if (isRunning) { Logger.debug(String.format("notify by crouton %s", text)); makeCrouton().show(); - } - else - { + } else { Logger.debug(String.format("notify by toast %s", text)); makeToast().show(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/preference/AppPreferenceHelper.java b/app/src/main/java/net/lacolaco/smileessence/preference/AppPreferenceHelper.java index be492c14..a5dd9b9d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/preference/AppPreferenceHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/preference/AppPreferenceHelper.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.preference; import android.content.Context; -public class AppPreferenceHelper extends SharedPreferenceHelper -{ +public class AppPreferenceHelper extends SharedPreferenceHelper { // ------------------------------ FIELDS ------------------------------ @@ -35,8 +34,7 @@ public class AppPreferenceHelper extends SharedPreferenceHelper // --------------------------- CONSTRUCTORS --------------------------- - public AppPreferenceHelper(Context context) - { + public AppPreferenceHelper(Context context) { super(context, FILE_NAME); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/preference/SharedPreferenceHelper.java b/app/src/main/java/net/lacolaco/smileessence/preference/SharedPreferenceHelper.java index 7b26d200..47d58dfb 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/preference/SharedPreferenceHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/preference/SharedPreferenceHelper.java @@ -29,8 +29,7 @@ import android.content.SharedPreferences; import java.util.Set; -public class SharedPreferenceHelper -{ +public class SharedPreferenceHelper { // ------------------------------ FIELDS ------------------------------ @@ -39,88 +38,74 @@ public class SharedPreferenceHelper // --------------------------- CONSTRUCTORS --------------------------- - public SharedPreferenceHelper(Context context, String fileName) - { + public SharedPreferenceHelper(Context context, String fileName) { this.context = context; this.fileName = fileName; } // --------------------- GETTER / SETTER METHODS --------------------- - protected SharedPreferences getPref() - { + protected SharedPreferences getPref() { return context.getSharedPreferences(fileName, Context.MODE_PRIVATE); } // -------------------------- OTHER METHODS -------------------------- - public boolean getValue(String key, boolean defaultValue) - { + public boolean getValue(String key, boolean defaultValue) { return getPref().getBoolean(key, defaultValue); } - public int getValue(String key, int defaultValue) - { + public int getValue(String key, int defaultValue) { return Integer.valueOf(getPref().getString(key, String.valueOf(defaultValue))); } - public float getValue(String key, float defaultValue) - { + public float getValue(String key, float defaultValue) { return Float.valueOf(getPref().getString(key, String.valueOf(defaultValue))); } - public long getValue(String key, long defaultValue) - { + public long getValue(String key, long defaultValue) { return Long.valueOf(getPref().getString(key, String.valueOf(defaultValue))); } - public String getValue(String key, String defaultValue) - { + public String getValue(String key, String defaultValue) { return getPref().getString(key, defaultValue); } - public Set<String> getValue(String key, Set<String> defaultValue) - { + public Set<String> getValue(String key, Set<String> defaultValue) { return getPref().getStringSet(key, defaultValue); } - public boolean putValue(String key, boolean value) - { + public boolean putValue(String key, boolean value) { SharedPreferences.Editor editor = getPref().edit(); editor.putBoolean(key, value); return editor.commit(); } - public boolean putValue(String key, int value) - { + public boolean putValue(String key, int value) { SharedPreferences.Editor editor = getPref().edit(); editor.putString(key, String.valueOf(value)); return editor.commit(); } - public boolean putValue(String key, float value) - { + public boolean putValue(String key, float value) { SharedPreferences.Editor editor = getPref().edit(); editor.putString(key, String.valueOf(value)); return editor.commit(); } - public boolean putValue(String key, long value) - { + public boolean putValue(String key, long value) { SharedPreferences.Editor editor = getPref().edit(); editor.putString(key, String.valueOf(value)); return editor.commit(); } - public boolean putValue(String key, String value) - { + public boolean putValue(String key, String value) { SharedPreferences.Editor editor = getPref().edit(); editor.putString(key, value); return editor.commit(); } - public boolean putValue(String key, Set<String> value) - { + public boolean putValue(String key, Set<String> value) { SharedPreferences.Editor editor = getPref().edit(); editor.putStringSet(key, value); return editor.commit(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/preference/UserPreferenceHelper.java b/app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java index c65cdea8..67c02c37 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/preference/UserPreferenceHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java @@ -30,8 +30,7 @@ import android.preference.PreferenceManager; import java.util.Set; -public class UserPreferenceHelper extends SharedPreferenceHelper -{ +public class UserPreferenceHelper extends SharedPreferenceHelper { // ------------------------------ FIELDS ------------------------------ @@ -42,113 +41,89 @@ public class UserPreferenceHelper extends SharedPreferenceHelper // --------------------------- CONSTRUCTORS --------------------------- - public UserPreferenceHelper(Context context) - { + public UserPreferenceHelper(Context context) { super(context, null); } // --------------------- GETTER / SETTER METHODS --------------------- @Override - protected SharedPreferences getPref() - { + protected SharedPreferences getPref() { return PreferenceManager.getDefaultSharedPreferences(context); } // -------------------------- OTHER METHODS -------------------------- - public boolean getValue(int keyID, boolean defaultValue) - { + public boolean getValue(int keyID, boolean defaultValue) { return getString(keyID) != null ? super.getValue(getString(keyID), defaultValue) : defaultValue; } - public int getValue(int keyID, int defaultValue) - { + public int getValue(int keyID, int defaultValue) { return getString(keyID) != null ? super.getValue(getString(keyID), defaultValue) : defaultValue; } - public float getValue(int keyID, float defaultValue) - { + public float getValue(int keyID, float defaultValue) { return getString(keyID) != null ? super.getValue(getString(keyID), defaultValue) : defaultValue; } - public long getValue(int keyID, long defaultValue) - { + public long getValue(int keyID, long defaultValue) { return getString(keyID) != null ? super.getValue(getString(keyID), defaultValue) : defaultValue; } - public String getValue(int keyID, String defaultValue) - { + public String getValue(int keyID, String defaultValue) { return getString(keyID) != null ? super.getValue(getString(keyID), defaultValue) : defaultValue; } - public Set<String> getValue(int keyID, Set<String> defaultValue) - { + public Set<String> getValue(int keyID, Set<String> defaultValue) { return getString(keyID) != null ? super.getValue(getString(keyID), defaultValue) : defaultValue; } - public boolean putValue(int keyID, boolean value) - { - if(getString(keyID) == null) - { + public boolean putValue(int keyID, boolean value) { + if (getString(keyID) == null) { return false; } return super.putValue(getString(keyID), value); } - public boolean putValue(int keyID, int value) - { - if(getString(keyID) == null) - { + public boolean putValue(int keyID, int value) { + if (getString(keyID) == null) { return false; } return super.putValue(getString(keyID), value); } - public boolean putValue(int keyID, float value) - { - if(getString(keyID) == null) - { + public boolean putValue(int keyID, float value) { + if (getString(keyID) == null) { return false; } return super.putValue(getString(keyID), value); } - public boolean putValue(int keyID, long value) - { - if(getString(keyID) == null) - { + public boolean putValue(int keyID, long value) { + if (getString(keyID) == null) { return false; } return super.putValue(getString(keyID), value); } - public boolean putValue(int keyID, String value) - { - if(getString(keyID) == null) - { + public boolean putValue(int keyID, String value) { + if (getString(keyID) == null) { return false; } return super.putValue(getString(keyID), value); } - public boolean putValue(int keyID, Set<String> value) - { - if(getString(keyID) == null) - { + public boolean putValue(int keyID, Set<String> value) { + if (getString(keyID) == null) { return false; } return super.putValue(getString(keyID), value); } - protected String getString(int resID) - { - try - { + protected String getString(int resID) { + try { return context.getString(resID); - } - catch(Exception e) - { + } catch (Exception e) { return null; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/OAuthSession.java b/app/src/main/java/net/lacolaco/smileessence/twitter/OAuthSession.java index 4e7950ea..c7b475cc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/OAuthSession.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/OAuthSession.java @@ -24,9 +24,11 @@ package net.lacolaco.smileessence.twitter; +import net.lacolaco.smileessence.BuildConfig; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.twitter.task.AccessTokenTask; import net.lacolaco.smileessence.twitter.task.RequestTokenTask; + import twitter4j.Twitter; import twitter4j.TwitterFactory; import twitter4j.auth.AccessToken; @@ -34,8 +36,7 @@ import twitter4j.auth.RequestToken; import java.util.concurrent.ExecutionException; -public class OAuthSession -{ +public class OAuthSession { // ------------------------------ FIELDS ------------------------------ @@ -49,18 +50,14 @@ public class OAuthSession // --------------------- GETTER / SETTER METHODS --------------------- - public String getAuthorizationURL() - { - Twitter twitter = new TwitterFactory().getInstance(); + public String getAuthorizationURL() { + Twitter twitter = new TwitterFactory(TwitterApi.getConf()).getInstance(); RequestTokenTask task = new RequestTokenTask(twitter); task.execute(); - try - { + try { requestToken = task.get(); return requestToken.getAuthorizationURL(); - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); Logger.error(e.getMessage()); return null; @@ -69,17 +66,13 @@ public class OAuthSession // -------------------------- OTHER METHODS -------------------------- - public AccessToken getAccessToken(String pinCode) - { - Twitter twitter = new TwitterFactory().getInstance(); + public AccessToken getAccessToken(String pinCode) { + Twitter twitter = new TwitterFactory(TwitterApi.getConf()).getInstance(); AccessTokenTask task = new AccessTokenTask(twitter, requestToken, pinCode); task.execute(); - try - { + try { return task.get(); - } - catch(InterruptedException | ExecutionException e) - { + } catch (Exception e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/StatusFilter.java b/app/src/main/java/net/lacolaco/smileessence/twitter/StatusFilter.java index 082ed20b..855be687 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/StatusFilter.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/StatusFilter.java @@ -31,35 +31,28 @@ import net.lacolaco.smileessence.viewmodel.StatusViewModel; import java.util.regex.Pattern; -public class StatusFilter -{ +public class StatusFilter { // -------------------------- STATIC METHODS -------------------------- - public static void filter(MainActivity activity, StatusViewModel status) - { + public static void filter(MainActivity activity, StatusViewModel status) { extract(activity, status); } - private static void extract(MainActivity activity, StatusViewModel status) - { - if(status.isRetweet()) - { + private static void extract(MainActivity activity, StatusViewModel status) { + if (status.isRetweet()) { return; } Pattern pattern; - for(ExtractionWord word : ExtractionWord.getAll()) - { + for (ExtractionWord word : ExtractionWord.getAll()) { pattern = Pattern.compile(word.text); - if(pattern.matcher(status.getText()).find()) - { + if (pattern.matcher(status.getText()).find()) { addToMentions(activity, status); } } } - private static void addToMentions(MainActivity activity, StatusViewModel status) - { + private static void addToMentions(MainActivity activity, StatusViewModel status) { StatusListAdapter adapter = (StatusListAdapter) activity.getListAdapter(MainActivity.ADAPTER_MENTIONS); adapter.addToTop(status); adapter.update(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/TweetBuilder.java b/app/src/main/java/net/lacolaco/smileessence/twitter/TweetBuilder.java index 957bbbe6..4fe692c8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/TweetBuilder.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/TweetBuilder.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.twitter; import android.text.TextUtils; + import twitter4j.Status; import twitter4j.StatusUpdate; @@ -32,8 +33,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; -public class TweetBuilder -{ +public class TweetBuilder { // ------------------------------ FIELDS ------------------------------ @@ -44,80 +44,66 @@ public class TweetBuilder // --------------------- GETTER / SETTER METHODS --------------------- - public TweetBuilder setInReplyToStatusID(long inReplyToStatusID) - { + public TweetBuilder setInReplyToStatusID(long inReplyToStatusID) { this.inReplyToStatusID = inReplyToStatusID; return this; } - public TweetBuilder setMediaPath(String mediaPath) - { + public TweetBuilder setMediaPath(String mediaPath) { this.mediaPath = mediaPath; return this; } - public TweetBuilder setQuotation(Status status) - { + public TweetBuilder setQuotation(Status status) { return setText(String.format(" RT @%s: %s", status.getUser().getScreenName(), status.getText())); } - public TweetBuilder setText(String text) - { + public TweetBuilder setText(String text) { this.text = text; return this; } // -------------------------- OTHER METHODS -------------------------- - public TweetBuilder addScreenName(String screenName) - { + public TweetBuilder addScreenName(String screenName) { screenNameList.add(screenName); return this; } - public TweetBuilder addScreenNames(Collection<String> screenNames) - { + public TweetBuilder addScreenNames(Collection<String> screenNames) { screenNameList.addAll(screenNames); return this; } - public TweetBuilder appendText(String str) - { + public TweetBuilder appendText(String str) { return setText(text + str); } - public StatusUpdate build() - { + public StatusUpdate build() { StatusUpdate statusUpdate = new StatusUpdate(buildText()); - if(inReplyToStatusID >= 0) - { + if (inReplyToStatusID >= 0) { statusUpdate.setInReplyToStatusId(inReplyToStatusID); } - if(!TextUtils.isEmpty(mediaPath)) - { + if (!TextUtils.isEmpty(mediaPath)) { File media = new File(mediaPath); - if(media.exists()) - { + if (media.exists()) { statusUpdate.setMedia(media); } } return statusUpdate; } - public String buildText() - { + public String buildText() { StringBuilder builder = new StringBuilder(); - for(String screenName : screenNameList) - { + for (String screenName : screenNameList) { builder.append(String.format("@%s ", screenName)); } builder.append(text); return builder.toString(); } - public TweetBuilder setQuotation(Status status, String text) - { + public TweetBuilder setQuotation(Status status, String text) { return setText(String.format("%s RT @%s: %s", text, status.getUser().getScreenName(), status.getText())); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/TwitterApi.java b/app/src/main/java/net/lacolaco/smileessence/twitter/TwitterApi.java index fb642801..4b940fb1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/TwitterApi.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/TwitterApi.java @@ -24,15 +24,18 @@ package net.lacolaco.smileessence.twitter; +import net.lacolaco.smileessence.BuildConfig; import net.lacolaco.smileessence.entity.Account; + import twitter4j.Twitter; import twitter4j.TwitterFactory; import twitter4j.TwitterStream; import twitter4j.TwitterStreamFactory; import twitter4j.auth.AccessToken; +import twitter4j.conf.Configuration; +import twitter4j.conf.ConfigurationBuilder; -public class TwitterApi -{ +public class TwitterApi { // ------------------------------ FIELDS ------------------------------ @@ -42,37 +45,40 @@ public class TwitterApi // -------------------------- STATIC METHODS -------------------------- - public TwitterApi(Account account) - { + public TwitterApi(Account account) { this.token = account.accessToken; this.tokenSecret = account.accessSecret; } // --------------------------- CONSTRUCTORS --------------------------- - public TwitterApi(String token, String tokenSecret) - { + public TwitterApi(String token, String tokenSecret) { this.token = token; this.tokenSecret = tokenSecret; } - public static Twitter getTwitter(Account account) - { + public static Configuration getConf() { + ConfigurationBuilder conf = new ConfigurationBuilder(); + conf.setOAuthConsumerKey(BuildConfig.CONSUMER_KEY); + conf.setOAuthConsumerSecret(BuildConfig.CONSUMER_SECRET); + conf.setDebugEnabled(true); + return conf.build(); + } + + public static Twitter getTwitter(Account account) { return new TwitterApi(account).getTwitter(); } // --------------------- GETTER / SETTER METHODS --------------------- - public Twitter getTwitter() - { - Twitter twitter = new TwitterFactory().getInstance(); + public Twitter getTwitter() { + Twitter twitter = new TwitterFactory(getConf()).getInstance(); twitter.setOAuthAccessToken(new AccessToken(token, tokenSecret)); return twitter; } - public TwitterStream getTwitterStream() - { - TwitterStream stream = new TwitterStreamFactory().getInstance(); + public TwitterStream getTwitterStream() { + TwitterStream stream = new TwitterStreamFactory(getConf()).getInstance(); stream.setOAuthAccessToken(new AccessToken(token, tokenSecret)); return stream; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/UserStreamListener.java b/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java index 6dee87e5..0661d78a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/UserStreamListener.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java @@ -29,16 +29,17 @@ import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.*; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; +import net.lacolaco.smileessence.view.adapter.EventListAdapter; import net.lacolaco.smileessence.view.adapter.MessageListAdapter; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; import net.lacolaco.smileessence.viewmodel.EnumEvent; import net.lacolaco.smileessence.viewmodel.EventViewModel; import net.lacolaco.smileessence.viewmodel.MessageViewModel; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.*; -public class UserStreamListener implements twitter4j.UserStreamListener, ConnectionLifeCycleListener -{ +public class UserStreamListener implements twitter4j.UserStreamListener, ConnectionLifeCycleListener { // ------------------------------ FIELDS ------------------------------ @@ -46,20 +47,17 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect // --------------------------- CONSTRUCTORS --------------------------- - public UserStreamListener(MainActivity activity) - { + public UserStreamListener(MainActivity activity) { this.activity = activity; } // --------------------- GETTER / SETTER METHODS --------------------- - private long getMyID() - { + private long getMyID() { return activity.getCurrentAccount().userID; } - private int getPagerCount() - { + private int getPagerCount() { return activity.getPagerAdapter().getCount(); } @@ -69,45 +67,36 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect // --------------------- Interface ConnectionLifeCycleListener --------------------- @Override - public void onConnect() - { + public void onConnect() { activity.setStreaming(true); new Notificator(activity, R.string.notice_stream_connect).publish(); } @Override - public void onDisconnect() - { + public void onDisconnect() { activity.setStreaming(false); new Notificator(activity, R.string.notice_stream_disconnect).publish(); } @Override - public void onCleanUp() - { + public void onCleanUp() { } // --------------------- Interface StatusListener --------------------- @Override - public void onStatus(Status status) - { + public void onStatus(Status status) { StatusCache.getInstance().put(status); - if(isIgnoredStatus(status)) - { + if (isIgnoredStatus(status)) { return; } StatusViewModel viewModel = new StatusViewModel(status, activity.getCurrentAccount()); addToHome(viewModel); - if(status.isRetweet()) - { - if(viewModel.isRetweetOfMe()) - { + if (status.isRetweet()) { + if (viewModel.isRetweetOfMe()) { addToHistory(new EventViewModel(EnumEvent.RETWEETED, status.getUser(), status)); } - } - else if(viewModel.isMention()) - { + } else if (viewModel.isMention()) { addToMentions(viewModel); EventViewModel mentioned = new EventViewModel(EnumEvent.MENTIONED, status.getUser(), status); Notificator.publish(activity, mentioned.getFormattedString(activity)); @@ -117,12 +106,9 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect } @Override - public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) - { - for(CustomListAdapter<?> adapter : activity.getListAdapters()) - { - if(adapter != null && adapter instanceof StatusListAdapter) - { + public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { + for (CustomListAdapter<?> adapter : activity.getListAdapters()) { + if (adapter != null && adapter instanceof StatusListAdapter) { StatusListAdapter statusListAdapter = (StatusListAdapter) adapter; statusListAdapter.removeByStatusID(statusDeletionNotice.getStatusId()); statusListAdapter.updateForce(); @@ -132,33 +118,28 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect } @Override - public void onTrackLimitationNotice(int numberOfLimitedStatuses) - { + public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } @Override - public void onScrubGeo(long userId, long upToStatusId) - { + public void onScrubGeo(long userId, long upToStatusId) { } @Override - public void onStallWarning(StallWarning warning) - { + public void onStallWarning(StallWarning warning) { } // --------------------- Interface StreamListener --------------------- @Override - public void onException(Exception ex) - { + public void onException(Exception ex) { net.lacolaco.smileessence.logging.Logger.error(ex.toString()); } // --------------------- Interface UserStreamListener --------------------- @Override - public void onDeletionNotice(long directMessageId, long userId) - { + public void onDeletionNotice(long directMessageId, long userId) { MessageListAdapter messages = (MessageListAdapter) activity.getListAdapter(MainActivity.ADAPTER_MESSAGES); messages.removeByMessageID(directMessageId); messages.updateForce(); @@ -166,20 +147,16 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect } @Override - public void onFriendList(long[] friendIds) - { + public void onFriendList(long[] friendIds) { } @Override - public void onFavorite(User source, User target, Status favoritedStatus) - { + public void onFavorite(User source, User target, Status favoritedStatus) { StatusCache.getInstance().put(favoritedStatus); - if(isMe(target)) - { + if (isMe(target)) { addToHistory(new EventViewModel(EnumEvent.FAVORITED, source, favoritedStatus)); } - if(isMe(source)) - { + if (isMe(source)) { FavoriteCache.getInstance().put(favoritedStatus, true); activity.getListAdapter(MainActivity.ADAPTER_HOME).update(); activity.getListAdapter(MainActivity.ADAPTER_MENTIONS).update(); @@ -187,16 +164,13 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect } @Override - public void onUnfavorite(User source, User target, Status unfavoritedStatus) - { + public void onUnfavorite(User source, User target, Status unfavoritedStatus) { StatusCache.getInstance().put(unfavoritedStatus); boolean unfavNoticeEnabled = activity.getUserPreferenceHelper().getValue(R.string.key_setting_notify_on_unfavorited, true); - if(isMe(target) && unfavNoticeEnabled) - { + if (isMe(target) && unfavNoticeEnabled) { addToHistory(new EventViewModel(EnumEvent.UNFAVORITED, source, unfavoritedStatus)); } - if(isMe(source)) - { + if (isMe(source)) { FavoriteCache.getInstance().put(unfavoritedStatus, false); activity.getListAdapter(MainActivity.ADAPTER_HOME).update(); activity.getListAdapter(MainActivity.ADAPTER_MENTIONS).update(); @@ -204,27 +178,22 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect } @Override - public void onFollow(User source, User followedUser) - { + public void onFollow(User source, User followedUser) { UserCache.getInstance().put(source); UserCache.getInstance().put(followedUser); - if(isMe(followedUser)) - { + if (isMe(followedUser)) { addToHistory(new EventViewModel(EnumEvent.FOLLOWED, source)); } } @Override - public void onUnfollow(User source, User unfollowedUser) - { + public void onUnfollow(User source, User unfollowedUser) { } @Override - public void onDirectMessage(DirectMessage directMessage) - { + public void onDirectMessage(DirectMessage directMessage) { DirectMessageCache.getInstance().put(directMessage); - if(isMe(directMessage.getRecipient())) - { + if (isMe(directMessage.getRecipient())) { addToHistory(new EventViewModel(EnumEvent.RECEIVE_MESSAGE, directMessage.getSender())); } MessageViewModel message = new MessageViewModel(directMessage, activity.getCurrentAccount()); @@ -232,103 +201,93 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect } @Override - public void onUserListMemberAddition(User addedMember, User listOwner, UserList list) - { + public void onUserListMemberAddition(User addedMember, User listOwner, UserList list) { } @Override - public void onUserListMemberDeletion(User deletedMember, User listOwner, UserList list) - { + public void onUserListMemberDeletion(User deletedMember, User listOwner, UserList list) { } @Override - public void onUserListSubscription(User subscriber, User listOwner, UserList list) - { + public void onUserListSubscription(User subscriber, User listOwner, UserList list) { UserListCache.getInstance().put(list.getFullName()); } @Override - public void onUserListUnsubscription(User subscriber, User listOwner, UserList list) - { + public void onUserListUnsubscription(User subscriber, User listOwner, UserList list) { UserListCache.getInstance().remove(list.getFullName()); } @Override - public void onUserListCreation(User listOwner, UserList list) - { + public void onUserListCreation(User listOwner, UserList list) { UserListCache.getInstance().put(list.getFullName()); } @Override - public void onUserListUpdate(User listOwner, UserList list) - { + public void onUserListUpdate(User listOwner, UserList list) { } @Override - public void onUserListDeletion(User listOwner, UserList list) - { + public void onUserListDeletion(User listOwner, UserList list) { UserListCache.getInstance().remove(list.getFullName()); } @Override - public void onUserProfileUpdate(User updatedUser) - { + public void onUserProfileUpdate(User updatedUser) { + } + + @Override + public void onUserSuspension(long suspendedUser) { + } + + @Override + public void onUserDeletion(long deletedUser) { } @Override - public void onBlock(User source, User blockedUser) - { - if(isMe(blockedUser)) - { + public void onBlock(User source, User blockedUser) { + if (isMe(blockedUser)) { addToHistory(new EventViewModel(EnumEvent.BLOCKED, source)); } } @Override - public void onUnblock(User source, User unblockedUser) - { - if(isMe(unblockedUser)) - { + public void onUnblock(User source, User unblockedUser) { + if (isMe(unblockedUser)) { addToHistory(new EventViewModel(EnumEvent.UNBLOCKED, source)); } } - private void addToHistory(EventViewModel mentioned) - { - CustomListAdapter<?> history = activity.getListAdapter(MainActivity.ADAPTER_HISTORY); + private void addToHistory(EventViewModel mentioned) { + EventListAdapter history = (EventListAdapter) activity.getListAdapter(MainActivity.ADAPTER_HISTORY); Notificator.publish(activity, mentioned.getFormattedString(activity)); history.addToTop(mentioned); history.update(); } - private void addToHome(StatusViewModel viewModel) - { + private void addToHome(StatusViewModel viewModel) { StatusListAdapter home = (StatusListAdapter) activity.getListAdapter(MainActivity.ADAPTER_HOME); home.addToTop(viewModel); home.update(); } - private void addToMentions(StatusViewModel viewModel) - { + private void addToMentions(StatusViewModel viewModel) { StatusListAdapter mentions = (StatusListAdapter) activity.getListAdapter(MainActivity.ADAPTER_MENTIONS); mentions.addToTop(viewModel); mentions.update(); } - private void addToMessages(MessageViewModel message) - { + private void addToMessages(MessageViewModel message) { MessageListAdapter messages = (MessageListAdapter) activity.getListAdapter(MainActivity.ADAPTER_MESSAGES); messages.addToTop(message); messages.update(); } - private boolean isIgnoredStatus(Status status) - { + private boolean isIgnoredStatus(Status status) { return status.isRetweet() && StatusCache.getInstance().isIgnored(status.getRetweetedStatus().getId()); } - private boolean isMe(User user) - { + private boolean isMe(User user) { return user.getId() == getMyID(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/AccessTokenTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/AccessTokenTask.java index f6b59658..ea549fc4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/AccessTokenTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/AccessTokenTask.java @@ -29,8 +29,7 @@ import twitter4j.TwitterException; import twitter4j.auth.AccessToken; import twitter4j.auth.RequestToken; -public class AccessTokenTask extends TwitterTask<AccessToken> -{ +public class AccessTokenTask extends TwitterTask<AccessToken> { // ------------------------------ FIELDS ------------------------------ @@ -39,22 +38,17 @@ public class AccessTokenTask extends TwitterTask<AccessToken> // --------------------------- CONSTRUCTORS --------------------------- - public AccessTokenTask(Twitter twitter, RequestToken requestToken, String pinCode) - { + public AccessTokenTask(Twitter twitter, RequestToken requestToken, String pinCode) { super(twitter); this.requestToken = requestToken; this.pinCode = pinCode; } @Override - protected AccessToken doInBackground(Void... params) - { - try - { + protected AccessToken doInBackground(Void... params) { + try { return twitter.getOAuthAccessToken(requestToken, pinCode); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); return null; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/BlockIDsTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockIDsTask.java index df5155d5..cf57fb80 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/BlockIDsTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockIDsTask.java @@ -26,6 +26,7 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.IDs; import twitter4j.Twitter; import twitter4j.TwitterException; @@ -33,49 +34,39 @@ import twitter4j.TwitterException; import java.util.ArrayList; import java.util.List; -public class BlockIDsTask extends TwitterTask<Long[]> -{ +public class BlockIDsTask extends TwitterTask<Long[]> { // --------------------------- CONSTRUCTORS --------------------------- - public BlockIDsTask(Twitter twitter) - { + public BlockIDsTask(Twitter twitter) { super(twitter); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(Long[] blockIDs) - { - for(Long blockID : blockIDs) - { + protected void onPostExecute(Long[] blockIDs) { + for (Long blockID : blockIDs) { UserCache.getInstance().putInvisibleUser(blockID); } } @Override - protected Long[] doInBackground(Void... params) - { - try - { + protected Long[] doInBackground(Void... params) { + try { List<Long> idList = new ArrayList<>(); long cursor = -1; - do - { + do { IDs blocksIDs = twitter.getBlocksIDs(cursor); cursor = blocksIDs.getNextCursor(); - for(long id : blocksIDs.getIDs()) - { + for (long id : blocksIDs.getIDs()) { idList.add(id); } } - while(cursor != 0); + while (cursor != 0); return idList.toArray(new Long[idList.size()]); - } - catch(TwitterException e) - { + } catch (TwitterException e) { Logger.error(e); return new Long[0]; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/BlockTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java index 96244d3c..70f59a21 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/BlockTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; -public class BlockTask extends TwitterTask<User> -{ +public class BlockTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class BlockTask extends TwitterTask<User> // --------------------------- CONSTRUCTORS --------------------------- - public BlockTask(Twitter twitter, long userID, Activity activity) - { + public BlockTask(Twitter twitter, long userID, Activity activity) { super(twitter); this.userID = userID; this.activity = activity; @@ -54,28 +54,20 @@ public class BlockTask extends TwitterTask<User> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(User user) - { - if(user != null) - { + protected void onPostExecute(User user) { + if (user != null) { UserCache.getInstance().put(user); new Notificator(activity, R.string.notice_block_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_block_failed, NotificationType.ALERT).publish(); } } @Override - protected User doInBackground(Void... params) - { - try - { + protected User doInBackground(Void... params) { + try { return twitter.users().createBlock(userID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DeleteMessageTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java index 40dd20cd..c218cfe5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DeleteMessageTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.DirectMessageCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.DirectMessage; import twitter4j.Twitter; import twitter4j.TwitterException; -public class DeleteMessageTask extends TwitterTask<DirectMessage> -{ +public class DeleteMessageTask extends TwitterTask<DirectMessage> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class DeleteMessageTask extends TwitterTask<DirectMessage> // --------------------------- CONSTRUCTORS --------------------------- - public DeleteMessageTask(Twitter twitter, long messageID, Activity activity) - { + public DeleteMessageTask(Twitter twitter, long messageID, Activity activity) { super(twitter); this.messageID = messageID; this.activity = activity; @@ -54,28 +54,20 @@ public class DeleteMessageTask extends TwitterTask<DirectMessage> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(DirectMessage message) - { - if(message != null) - { + protected void onPostExecute(DirectMessage message) { + if (message != null) { DirectMessageCache.getInstance().put(message); new Notificator(activity, R.string.notice_message_delete_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_message_delete_failed, NotificationType.ALERT).publish(); } } @Override - protected DirectMessage doInBackground(Void... params) - { - try - { + protected DirectMessage doInBackground(Void... params) { + try { return twitter.directMessages().destroyDirectMessage(messageID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DeleteStatusTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java index e4f4a19a..7dcc7b07 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DeleteStatusTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; -public class DeleteStatusTask extends TwitterTask<Status> -{ +public class DeleteStatusTask extends TwitterTask<Status> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class DeleteStatusTask extends TwitterTask<Status> // --------------------------- CONSTRUCTORS --------------------------- - public DeleteStatusTask(Twitter twitter, long statusID, Activity activity) - { + public DeleteStatusTask(Twitter twitter, long statusID, Activity activity) { super(twitter); this.statusID = statusID; this.activity = activity; @@ -54,28 +54,20 @@ public class DeleteStatusTask extends TwitterTask<Status> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status status) - { - if(status != null) - { + protected void onPostExecute(twitter4j.Status status) { + if (status != null) { StatusCache.getInstance().remove(status.getId()); new Notificator(activity, R.string.notice_status_delete_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_status_delete_failed, NotificationType.ALERT).publish(); } } @Override - protected twitter4j.Status doInBackground(Void... params) - { - try - { + protected twitter4j.Status doInBackground(Void... params) { + try { return twitter.tweets().destroyStatus(statusID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DirectMessagesTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java index f8a574fa..13b69255 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/DirectMessagesTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java @@ -25,15 +25,16 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.DirectMessageCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.*; -public class DirectMessagesTask extends TwitterTask<DirectMessage[]> -{ +public class DirectMessagesTask extends TwitterTask<DirectMessage[]> { // ------------------------------ FIELDS ------------------------------ @@ -42,13 +43,11 @@ public class DirectMessagesTask extends TwitterTask<DirectMessage[]> // --------------------------- CONSTRUCTORS --------------------------- - protected DirectMessagesTask(Twitter twitter, Activity activity) - { + protected DirectMessagesTask(Twitter twitter, Activity activity) { this(twitter, activity, null); } - public DirectMessagesTask(Twitter twitter, Activity activity, Paging paging) - { + public DirectMessagesTask(Twitter twitter, Activity activity, Paging paging) { super(twitter); this.activity = activity; this.paging = paging; @@ -57,42 +56,29 @@ public class DirectMessagesTask extends TwitterTask<DirectMessage[]> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(DirectMessage[] directMessages) - { - if(directMessages.length != 0) - { - for(DirectMessage message : directMessages) - { + protected void onPostExecute(DirectMessage[] directMessages) { + if (directMessages.length != 0) { + for (DirectMessage message : directMessages) { DirectMessageCache.getInstance().put(message); } } } @Override - protected DirectMessage[] doInBackground(Void... params) - { + protected DirectMessage[] doInBackground(Void... params) { ResponseList<DirectMessage> responseList; - try - { - if(paging == null) - { + try { + if (paging == null) { responseList = twitter.directMessages().getDirectMessages(); - } - else - { + } else { responseList = twitter.directMessages().getDirectMessages(paging); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); - if(e.exceededRateLimitation()) - { + if (e.exceededRateLimitation()) { Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); - } - else - { + } else { Notificator.publish(activity, R.string.notice_error_get_messages, NotificationType.ALERT); } return new DirectMessage[0]; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/FavoriteTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java index 8e509ba5..d0ee13c5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/FavoriteTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; -public class FavoriteTask extends TwitterTask<Status> -{ +public class FavoriteTask extends TwitterTask<Status> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class FavoriteTask extends TwitterTask<Status> // --------------------------- CONSTRUCTORS --------------------------- - public FavoriteTask(Twitter twitter, long statusID, Activity activity) - { + public FavoriteTask(Twitter twitter, long statusID, Activity activity) { super(twitter); this.statusID = statusID; this.activity = activity; @@ -54,28 +54,20 @@ public class FavoriteTask extends TwitterTask<Status> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status status) - { - if(status != null) - { + protected void onPostExecute(twitter4j.Status status) { + if (status != null) { StatusCache.getInstance().put(status); new Notificator(activity, R.string.notice_favorite_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_favorite_failed, NotificationType.ALERT).publish(); } } @Override - protected twitter4j.Status doInBackground(Void... params) - { - try - { + protected twitter4j.Status doInBackground(Void... params) { + try { return twitter.favorites().createFavorite(statusID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/FollowTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java index bea00f8c..ecd6fe17 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/FollowTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; -public class FollowTask extends TwitterTask<User> -{ +public class FollowTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class FollowTask extends TwitterTask<User> // --------------------------- CONSTRUCTORS --------------------------- - public FollowTask(Twitter twitter, long userID, Activity activity) - { + public FollowTask(Twitter twitter, long userID, Activity activity) { super(twitter); this.userID = userID; this.activity = activity; @@ -54,28 +54,20 @@ public class FollowTask extends TwitterTask<User> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(User user) - { - if(user != null) - { + protected void onPostExecute(User user) { + if (user != null) { UserCache.getInstance().put(user); new Notificator(activity, R.string.notice_follow_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_follow_failed, NotificationType.ALERT).publish(); } } @Override - protected User doInBackground(Void... params) - { - try - { + protected User doInBackground(Void... params) { + try { return twitter.friendsFollowers().createFriendship(userID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/GetUserListsTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/GetUserListsTask.java index dbc80637..dafbc0d0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/GetUserListsTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/GetUserListsTask.java @@ -26,6 +26,7 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.UserListCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.UserList; @@ -33,39 +34,31 @@ import twitter4j.UserList; import java.util.ArrayList; import java.util.List; -public class GetUserListsTask extends TwitterTask<UserList[]> -{ +public class GetUserListsTask extends TwitterTask<UserList[]> { // --------------------------- CONSTRUCTORS --------------------------- - public GetUserListsTask(Twitter twitter) - { + public GetUserListsTask(Twitter twitter) { super(twitter); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(UserList[] lists) - { - for(UserList list : lists) - { + protected void onPostExecute(UserList[] lists) { + for (UserList list : lists) { UserListCache.getInstance().put(list.getFullName()); } } @Override - protected UserList[] doInBackground(Void... params) - { - try - { + protected UserList[] doInBackground(Void... params) { + try { List<UserList> userLists = new ArrayList<>(); userLists.addAll(twitter.list().getUserLists(twitter.getId())); return userLists.toArray(new UserList[userLists.size()]); - } - catch(TwitterException e) - { + } catch (TwitterException e) { Logger.error(e); return new UserList[0]; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/HomeTimelineTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java index 59dfdeb0..9b435f74 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/HomeTimelineTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java @@ -25,16 +25,17 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.FavoriteCache; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.*; -public class HomeTimelineTask extends TwitterTask<Status[]> -{ +public class HomeTimelineTask extends TwitterTask<Status[]> { // ------------------------------ FIELDS ------------------------------ @@ -43,13 +44,11 @@ public class HomeTimelineTask extends TwitterTask<Status[]> // --------------------------- CONSTRUCTORS --------------------------- - public HomeTimelineTask(Twitter twitter, Activity activity) - { + public HomeTimelineTask(Twitter twitter, Activity activity) { this(twitter, activity, null); } - public HomeTimelineTask(Twitter twitter, Activity activity, Paging paging) - { + public HomeTimelineTask(Twitter twitter, Activity activity, Paging paging) { super(twitter); this.activity = activity; this.paging = paging; @@ -58,12 +57,9 @@ public class HomeTimelineTask extends TwitterTask<Status[]> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { - if(statuses.length != 0) - { - for(twitter4j.Status status : statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { + if (statuses.length != 0) { + for (twitter4j.Status status : statuses) { StatusCache.getInstance().put(status); FavoriteCache.getInstance().put(status); } @@ -71,30 +67,20 @@ public class HomeTimelineTask extends TwitterTask<Status[]> } @Override - protected twitter4j.Status[] doInBackground(Void... params) - { + protected twitter4j.Status[] doInBackground(Void... params) { ResponseList<twitter4j.Status> responseList; - try - { - if(paging == null) - { + try { + if (paging == null) { responseList = twitter.timelines().getHomeTimeline(); - } - else - { + } else { responseList = twitter.timelines().getHomeTimeline(paging); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); - if(e.exceededRateLimitation()) - { + if (e.exceededRateLimitation()) { Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); - } - else - { + } else { Notificator.publish(activity, R.string.notice_error_get_home, NotificationType.ALERT); } return new twitter4j.Status[0]; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/MentionsTimelineTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java index be9378d3..87d9aacf 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/MentionsTimelineTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java @@ -25,16 +25,17 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.FavoriteCache; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.*; -public class MentionsTimelineTask extends TwitterTask<Status[]> -{ +public class MentionsTimelineTask extends TwitterTask<Status[]> { // ------------------------------ FIELDS ------------------------------ @@ -43,13 +44,11 @@ public class MentionsTimelineTask extends TwitterTask<Status[]> // --------------------------- CONSTRUCTORS --------------------------- - protected MentionsTimelineTask(Twitter twitter, Activity activity) - { + protected MentionsTimelineTask(Twitter twitter, Activity activity) { this(twitter, activity, null); } - public MentionsTimelineTask(Twitter twitter, Activity activity, Paging paging) - { + public MentionsTimelineTask(Twitter twitter, Activity activity, Paging paging) { super(twitter); this.activity = activity; this.paging = paging; @@ -58,12 +57,9 @@ public class MentionsTimelineTask extends TwitterTask<Status[]> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { - if(statuses.length != 0) - { - for(twitter4j.Status status : statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { + if (statuses.length != 0) { + for (twitter4j.Status status : statuses) { StatusCache.getInstance().put(status); FavoriteCache.getInstance().put(status); } @@ -71,30 +67,20 @@ public class MentionsTimelineTask extends TwitterTask<Status[]> } @Override - protected twitter4j.Status[] doInBackground(Void... params) - { + protected twitter4j.Status[] doInBackground(Void... params) { ResponseList<twitter4j.Status> responseList; - try - { - if(paging == null) - { + try { + if (paging == null) { responseList = twitter.timelines().getMentionsTimeline(); - } - else - { + } else { responseList = twitter.timelines().getMentionsTimeline(paging); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); - if(e.exceededRateLimitation()) - { + if (e.exceededRateLimitation()) { Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); - } - else - { + } else { Notificator.publish(activity, R.string.notice_error_get_mentions, NotificationType.ALERT); } return new twitter4j.Status[0]; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/MutesIDsTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/MutesIDsTask.java index 86c6effe..d65b4bce 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/MutesIDsTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/MutesIDsTask.java @@ -26,6 +26,7 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.IDs; import twitter4j.Twitter; import twitter4j.TwitterException; @@ -33,49 +34,39 @@ import twitter4j.TwitterException; import java.util.ArrayList; import java.util.List; -public class MutesIDsTask extends TwitterTask<Long[]> -{ +public class MutesIDsTask extends TwitterTask<Long[]> { // --------------------------- CONSTRUCTORS --------------------------- - public MutesIDsTask(Twitter twitter) - { + public MutesIDsTask(Twitter twitter) { super(twitter); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(Long[] mutesIDs) - { - for(Long mutesID : mutesIDs) - { + protected void onPostExecute(Long[] mutesIDs) { + for (Long mutesID : mutesIDs) { UserCache.getInstance().putInvisibleUser(mutesID); } } @Override - protected Long[] doInBackground(Void... params) - { - try - { + protected Long[] doInBackground(Void... params) { + try { List<Long> idList = new ArrayList<>(); long cursor = -1; - do - { + do { IDs mutesIDs = twitter.getMutesIDs(cursor); cursor = mutesIDs.getNextCursor(); - for(long id : mutesIDs.getIDs()) - { + for (long id : mutesIDs.getIDs()) { idList.add(id); } } - while(cursor != 0); + while (cursor != 0); return idList.toArray(new Long[idList.size()]); - } - catch(TwitterException e) - { + } catch (TwitterException e) { Logger.error(e); return new Long[0]; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ReportForSpamTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java index cdb04158..35e71fbc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ReportForSpamTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; -public class ReportForSpamTask extends TwitterTask<User> -{ +public class ReportForSpamTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class ReportForSpamTask extends TwitterTask<User> // --------------------------- CONSTRUCTORS --------------------------- - public ReportForSpamTask(Twitter twitter, long userID, Activity activity) - { + public ReportForSpamTask(Twitter twitter, long userID, Activity activity) { super(twitter); this.userID = userID; this.activity = activity; @@ -54,28 +54,20 @@ public class ReportForSpamTask extends TwitterTask<User> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(User user) - { - if(user != null) - { + protected void onPostExecute(User user) { + if (user != null) { UserCache.getInstance().put(user); new Notificator(activity, R.string.notice_r4s_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_r4s_failed, NotificationType.ALERT).publish(); } } @Override - protected User doInBackground(Void... params) - { - try - { + protected User doInBackground(Void... params) { + try { return twitter.spamReporting().reportSpam(userID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/RequestTokenTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/RequestTokenTask.java index ed79b0eb..bee6484b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/RequestTokenTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/RequestTokenTask.java @@ -25,32 +25,27 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.auth.RequestToken; -public class RequestTokenTask extends TwitterTask<RequestToken> -{ +public class RequestTokenTask extends TwitterTask<RequestToken> { // ------------------------------ FIELDS ------------------------------ // --------------------------- CONSTRUCTORS --------------------------- - public RequestTokenTask(Twitter twitter) - { + public RequestTokenTask(Twitter twitter) { super(twitter); } @Override - protected RequestToken doInBackground(Void... params) - { - try - { + protected RequestToken doInBackground(Void... params) { + try { return twitter.getOAuthRequestToken(); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/RetweetTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java index a3073026..ffd780a6 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/RetweetTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; -public class RetweetTask extends TwitterTask<Status> -{ +public class RetweetTask extends TwitterTask<Status> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class RetweetTask extends TwitterTask<Status> // --------------------------- CONSTRUCTORS --------------------------- - public RetweetTask(Twitter twitter, long statusID, Activity activity) - { + public RetweetTask(Twitter twitter, long statusID, Activity activity) { super(twitter); this.statusID = statusID; this.activity = activity; @@ -54,28 +54,20 @@ public class RetweetTask extends TwitterTask<Status> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status status) - { - if(status != null) - { + protected void onPostExecute(twitter4j.Status status) { + if (status != null) { StatusCache.getInstance().put(status); new Notificator(activity, R.string.notice_retweet_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_retweet_failed, NotificationType.ALERT).publish(); } } @Override - protected twitter4j.Status doInBackground(Void... params) - { - try - { + protected twitter4j.Status doInBackground(Void... params) { + try { return twitter.tweets().retweetStatus(statusID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SearchTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java index 10649bf9..121b8ac1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SearchTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.twitter.task; import android.content.res.Configuration; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.FavoriteCache; @@ -33,13 +34,13 @@ import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.twitter.util.TwitterUtils; + import twitter4j.Query; import twitter4j.QueryResult; import twitter4j.Twitter; import twitter4j.TwitterException; -public class SearchTask extends TwitterTask<QueryResult> -{ +public class SearchTask extends TwitterTask<QueryResult> { // ------------------------------ FIELDS ------------------------------ @@ -48,25 +49,23 @@ public class SearchTask extends TwitterTask<QueryResult> // -------------------------- STATIC METHODS -------------------------- - public SearchTask(Twitter twitter, String queryString, MainActivity activity) - { + public SearchTask(Twitter twitter, String queryString, MainActivity activity) { this(twitter, getBaseQuery(activity, queryString), activity); } // --------------------------- CONSTRUCTORS --------------------------- - public SearchTask(Twitter twitter, Query query, MainActivity activity) - { + public SearchTask(Twitter twitter, Query query, MainActivity activity) { super(twitter); this.activity = activity; this.query = query; } - public static Query getBaseQuery(MainActivity activity, String queryString) - { + public static Query getBaseQuery(MainActivity activity, String queryString) { Configuration config = activity.getResources().getConfiguration(); Query query = new Query(); query.setQuery(queryString); + query.setLang(config.locale.getLanguage()); query.setCount(TwitterUtils.getPagingCount(activity)); query.setResultType(Query.RECENT); return query; @@ -75,12 +74,9 @@ public class SearchTask extends TwitterTask<QueryResult> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(QueryResult queryResult) - { - if(queryResult != null) - { - for(twitter4j.Status status : queryResult.getTweets()) - { + protected void onPostExecute(QueryResult queryResult) { + if (queryResult != null) { + for (twitter4j.Status status : queryResult.getTweets()) { StatusCache.getInstance().put(status); FavoriteCache.getInstance().put(status); } @@ -88,22 +84,15 @@ public class SearchTask extends TwitterTask<QueryResult> } @Override - protected QueryResult doInBackground(Void... params) - { - try - { + protected QueryResult doInBackground(Void... params) { + try { return twitter.search(query); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.debug(e); - if(e.exceededRateLimitation()) - { + if (e.exceededRateLimitation()) { Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); - } - else - { + } else { Notificator.publish(activity, R.string.notice_error_search, NotificationType.ALERT); } return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SendMessageTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java index b394f960..c3338e63 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SendMessageTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.DirectMessageCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.DirectMessage; import twitter4j.Twitter; import twitter4j.TwitterException; -public class SendMessageTask extends TwitterTask<DirectMessage> -{ +public class SendMessageTask extends TwitterTask<DirectMessage> { // ------------------------------ FIELDS ------------------------------ @@ -45,8 +46,7 @@ public class SendMessageTask extends TwitterTask<DirectMessage> // --------------------------- CONSTRUCTORS --------------------------- - public SendMessageTask(Twitter twitter, String screenName, String text, Activity activity) - { + public SendMessageTask(Twitter twitter, String screenName, String text, Activity activity) { super(twitter); this.userID = screenName; this.text = text; @@ -56,28 +56,20 @@ public class SendMessageTask extends TwitterTask<DirectMessage> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(DirectMessage message) - { - if(message != null) - { + protected void onPostExecute(DirectMessage message) { + if (message != null) { DirectMessageCache.getInstance().put(message); new Notificator(activity, R.string.notice_message_send_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_message_send_failed, NotificationType.ALERT).publish(); } } @Override - protected DirectMessage doInBackground(Void... params) - { - try - { + protected DirectMessage doInBackground(Void... params) { + try { return twitter.directMessages().sendDirectMessage(userID, text); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SentDirectMessagesTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java index 10711c01..5cbb6700 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/SentDirectMessagesTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java @@ -25,15 +25,16 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.DirectMessageCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.*; -public class SentDirectMessagesTask extends TwitterTask<DirectMessage[]> -{ +public class SentDirectMessagesTask extends TwitterTask<DirectMessage[]> { // ------------------------------ FIELDS ------------------------------ @@ -42,13 +43,11 @@ public class SentDirectMessagesTask extends TwitterTask<DirectMessage[]> // --------------------------- CONSTRUCTORS --------------------------- - protected SentDirectMessagesTask(Twitter twitter, Activity activity) - { + protected SentDirectMessagesTask(Twitter twitter, Activity activity) { this(twitter, activity, null); } - public SentDirectMessagesTask(Twitter twitter, Activity activity, Paging paging) - { + public SentDirectMessagesTask(Twitter twitter, Activity activity, Paging paging) { super(twitter); this.activity = activity; this.paging = paging; @@ -57,42 +56,29 @@ public class SentDirectMessagesTask extends TwitterTask<DirectMessage[]> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(DirectMessage[] directMessages) - { - if(directMessages.length != 0) - { - for(DirectMessage message : directMessages) - { + protected void onPostExecute(DirectMessage[] directMessages) { + if (directMessages.length != 0) { + for (DirectMessage message : directMessages) { DirectMessageCache.getInstance().put(message); } } } @Override - protected DirectMessage[] doInBackground(Void... params) - { + protected DirectMessage[] doInBackground(Void... params) { ResponseList<DirectMessage> responseList; - try - { - if(paging == null) - { + try { + if (paging == null) { responseList = twitter.directMessages().getSentDirectMessages(); - } - else - { + } else { responseList = twitter.directMessages().getSentDirectMessages(paging); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); - if(e.exceededRateLimitation()) - { + if (e.exceededRateLimitation()) { Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); - } - else - { + } else { Notificator.publish(activity, R.string.notice_error_get_messages, NotificationType.ALERT); } return new DirectMessage[0]; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowDirectMessageTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowDirectMessageTask.java index f2ba8432..f48f1510 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowDirectMessageTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowDirectMessageTask.java @@ -26,12 +26,12 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.DirectMessageCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.DirectMessage; import twitter4j.Twitter; import twitter4j.TwitterException; -public class ShowDirectMessageTask extends TwitterTask<DirectMessage> -{ +public class ShowDirectMessageTask extends TwitterTask<DirectMessage> { // ------------------------------ FIELDS ------------------------------ @@ -39,8 +39,7 @@ public class ShowDirectMessageTask extends TwitterTask<DirectMessage> // --------------------------- CONSTRUCTORS --------------------------- - public ShowDirectMessageTask(Twitter twitter, long messageID) - { + public ShowDirectMessageTask(Twitter twitter, long messageID) { super(twitter); this.messageID = messageID; } @@ -48,23 +47,17 @@ public class ShowDirectMessageTask extends TwitterTask<DirectMessage> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(DirectMessage directMessage) - { - if(directMessage != null) - { + protected void onPostExecute(DirectMessage directMessage) { + if (directMessage != null) { DirectMessageCache.getInstance().put(directMessage); } } @Override - protected DirectMessage doInBackground(Void... params) - { - try - { + protected DirectMessage doInBackground(Void... params) { + try { return twitter.directMessages().showDirectMessage(messageID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowFriendshipTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowFriendshipTask.java index f013288c..48547d68 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowFriendshipTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowFriendshipTask.java @@ -25,12 +25,12 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.Relationship; import twitter4j.Twitter; import twitter4j.TwitterException; -public class ShowFriendshipTask extends TwitterTask<Relationship> -{ +public class ShowFriendshipTask extends TwitterTask<Relationship> { // ------------------------------ FIELDS ------------------------------ @@ -39,36 +39,27 @@ public class ShowFriendshipTask extends TwitterTask<Relationship> // --------------------------- CONSTRUCTORS --------------------------- - public ShowFriendshipTask(Twitter twitter, long userID) - { + public ShowFriendshipTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; this.screenName = null; } - public ShowFriendshipTask(Twitter twitter, String screenName) - { + public ShowFriendshipTask(Twitter twitter, String screenName) { super(twitter); this.screenName = screenName; this.userID = -1; } @Override - protected Relationship doInBackground(Void... params) - { - try - { - if(screenName != null) - { + protected Relationship doInBackground(Void... params) { + try { + if (screenName != null) { return twitter.friendsFollowers().showFriendship(twitter.getScreenName(), screenName); - } - else - { + } else { return twitter.friendsFollowers().showFriendship(twitter.getId(), userID); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowStatusTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowStatusTask.java index 8206e6bf..89066553 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowStatusTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowStatusTask.java @@ -26,12 +26,12 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; -public class ShowStatusTask extends TwitterTask<Status> -{ +public class ShowStatusTask extends TwitterTask<Status> { // ------------------------------ FIELDS ------------------------------ @@ -39,8 +39,7 @@ public class ShowStatusTask extends TwitterTask<Status> // --------------------------- CONSTRUCTORS --------------------------- - public ShowStatusTask(Twitter twitter, long id) - { + public ShowStatusTask(Twitter twitter, long id) { super(twitter); this.id = id; } @@ -48,23 +47,17 @@ public class ShowStatusTask extends TwitterTask<Status> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status status) - { - if(status != null) - { + protected void onPostExecute(twitter4j.Status status) { + if (status != null) { StatusCache.getInstance().put(status); } } @Override - protected twitter4j.Status doInBackground(Void... params) - { - try - { + protected twitter4j.Status doInBackground(Void... params) { + try { return twitter.tweets().showStatus(id); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowUserTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowUserTask.java index 555bdfd1..71706edf 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/ShowUserTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ShowUserTask.java @@ -26,12 +26,12 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; -public class ShowUserTask extends TwitterTask<User> -{ +public class ShowUserTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ @@ -40,15 +40,13 @@ public class ShowUserTask extends TwitterTask<User> // --------------------------- CONSTRUCTORS --------------------------- - public ShowUserTask(Twitter twitter, long userID) - { + public ShowUserTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; this.screenName = null; } - public ShowUserTask(Twitter twitter, String screenName) - { + public ShowUserTask(Twitter twitter, String screenName) { super(twitter); this.screenName = screenName; this.userID = -1; @@ -57,30 +55,21 @@ public class ShowUserTask extends TwitterTask<User> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(User user) - { - if(user != null) - { + protected void onPostExecute(User user) { + if (user != null) { UserCache.getInstance().put(user); } } @Override - protected User doInBackground(Void... params) - { - try - { - if(screenName != null) - { + protected User doInBackground(Void... params) { + try { + if (screenName != null) { return twitter.users().showUser(screenName); - } - else - { + } else { return twitter.users().showUser(userID); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/TweetTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java index 9f769dc7..3cec661b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/TweetTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java @@ -29,6 +29,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Environment; import android.text.TextUtils; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; @@ -36,6 +37,7 @@ import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.TwitterApi; + import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; @@ -45,8 +47,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -public class TweetTask extends TwitterTask<Status> -{ +public class TweetTask extends TwitterTask<Status> { // ------------------------------ FIELDS ------------------------------ @@ -57,13 +58,11 @@ public class TweetTask extends TwitterTask<Status> // --------------------------- CONSTRUCTORS --------------------------- - public TweetTask(Twitter twitter, StatusUpdate update, Activity activity) - { + public TweetTask(Twitter twitter, StatusUpdate update, Activity activity) { this(twitter, update, null, activity); } - public TweetTask(Twitter twitter, StatusUpdate update, String mediaPath, Activity activity) - { + public TweetTask(Twitter twitter, StatusUpdate update, String mediaPath, Activity activity) { super(twitter); this.update = update; this.mediaPath = mediaPath; @@ -72,20 +71,17 @@ public class TweetTask extends TwitterTask<Status> // --------------------- GETTER / SETTER METHODS --------------------- - public File getMediaFile() - { + public File getMediaFile() { File file = new File(mediaPath); boolean resizeFlag = new UserPreferenceHelper(activity).getValue(R.string.key_setting_resize_post_image, false); - if(file.length() >= TwitterApi.MEDIA_SIZE_LIMIT && resizeFlag) - { + if (file.length() >= TwitterApi.MEDIA_SIZE_LIMIT && resizeFlag) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; //decoder is not return bitmap but set option BitmapFactory.decodeFile(mediaPath, opt); tempFilePath = Environment.getExternalStorageDirectory() + "/temp.jpg"; File compressedFile = new File(tempFilePath); FileOutputStream fos = null; - try - { + try { fos = new FileOutputStream(compressedFile); float ratio = (float) file.length() / (float) TwitterApi.MEDIA_SIZE_LIMIT; BitmapFactory.Options resizeOpt = new BitmapFactory.Options(); @@ -95,20 +91,13 @@ public class TweetTask extends TwitterTask<Status> bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); bitmap.recycle(); return compressedFile; - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); Logger.error(e); - } - finally - { - try - { + } finally { + try { fos.close(); - } - catch(IOException e) - { + } catch (IOException e) { e.printStackTrace(); Logger.error(e); } @@ -120,45 +109,32 @@ public class TweetTask extends TwitterTask<Status> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status status) - { - if(status != null) - { + protected void onPostExecute(twitter4j.Status status) { + if (status != null) { StatusCache.getInstance().put(status); new Notificator(activity, R.string.notice_tweet_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_tweet_failed, NotificationType.ALERT).publish(); } } @Override - protected twitter4j.Status doInBackground(Void... params) - { - try - { - if(TextUtils.isEmpty(mediaPath)) - { + protected twitter4j.Status doInBackground(Void... params) { + try { + if (TextUtils.isEmpty(mediaPath)) { return twitter.tweets().updateStatus(update); - } - else - { + } else { File mediaFile = getMediaFile(); - if(mediaFile.exists()) - { + if (mediaFile.exists()) { update.setMedia(mediaFile); } twitter4j.Status status = twitter.tweets().updateStatus(update); - if(tempFilePath != null) - { + if (tempFilePath != null) { new File(tempFilePath).delete(); } return status; } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/TwitterTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/TwitterTask.java index f9dfdca1..b62e6770 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/TwitterTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/TwitterTask.java @@ -25,10 +25,10 @@ package net.lacolaco.smileessence.twitter.task; import android.os.AsyncTask; + import twitter4j.Twitter; -public abstract class TwitterTask<T> extends AsyncTask<Void, Void, T> -{ +public abstract class TwitterTask<T> extends AsyncTask<Void, Void, T> { // ------------------------------ FIELDS ------------------------------ @@ -36,8 +36,7 @@ public abstract class TwitterTask<T> extends AsyncTask<Void, Void, T> // --------------------------- CONSTRUCTORS --------------------------- - protected TwitterTask(Twitter twitter) - { + protected TwitterTask(Twitter twitter) { this.twitter = twitter; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnblockTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java index 1c0cb6bf..9199a136 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnblockTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; -public class UnblockTask extends TwitterTask<User> -{ +public class UnblockTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class UnblockTask extends TwitterTask<User> // --------------------------- CONSTRUCTORS --------------------------- - public UnblockTask(Twitter twitter, long userID, Activity activity) - { + public UnblockTask(Twitter twitter, long userID, Activity activity) { super(twitter); this.userID = userID; this.activity = activity; @@ -54,28 +54,20 @@ public class UnblockTask extends TwitterTask<User> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(User user) - { - if(user != null) - { + protected void onPostExecute(User user) { + if (user != null) { UserCache.getInstance().put(user); new Notificator(activity, R.string.notice_unblock_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_unblock_failed, NotificationType.ALERT).publish(); } } @Override - protected User doInBackground(Void... params) - { - try - { + protected User doInBackground(Void... params) { + try { return twitter.users().destroyBlock(userID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnfavoriteTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java index ef2a660b..93eb8623 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnfavoriteTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; -public class UnfavoriteTask extends TwitterTask<Status> -{ +public class UnfavoriteTask extends TwitterTask<Status> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class UnfavoriteTask extends TwitterTask<Status> // --------------------------- CONSTRUCTORS --------------------------- - public UnfavoriteTask(Twitter twitter, long statusID, Activity activity) - { + public UnfavoriteTask(Twitter twitter, long statusID, Activity activity) { super(twitter); this.statusID = statusID; this.activity = activity; @@ -54,28 +54,20 @@ public class UnfavoriteTask extends TwitterTask<Status> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status status) - { - if(status != null) - { + protected void onPostExecute(twitter4j.Status status) { + if (status != null) { StatusCache.getInstance().put(status); new Notificator(activity, R.string.notice_unfavorite_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_unfavorite_failed, NotificationType.ALERT).publish(); } } @Override - protected twitter4j.Status doInBackground(Void... params) - { - try - { + protected twitter4j.Status doInBackground(Void... params) { + try { return twitter.favorites().destroyFavorite(statusID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnfollowTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java index b75a1043..8c5f7dc5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UnfollowTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java @@ -25,17 +25,18 @@ package net.lacolaco.smileessence.twitter.task; import android.app.Activity; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; + import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; -public class UnfollowTask extends TwitterTask<User> -{ +public class UnfollowTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ @@ -44,8 +45,7 @@ public class UnfollowTask extends TwitterTask<User> // --------------------------- CONSTRUCTORS --------------------------- - public UnfollowTask(Twitter twitter, long userID, Activity activity) - { + public UnfollowTask(Twitter twitter, long userID, Activity activity) { super(twitter); this.userID = userID; this.activity = activity; @@ -54,28 +54,20 @@ public class UnfollowTask extends TwitterTask<User> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(User user) - { - if(user != null) - { + protected void onPostExecute(User user) { + if (user != null) { UserCache.getInstance().put(user); new Notificator(activity, R.string.notice_unfollow_succeeded).publish(); - } - else - { + } else { new Notificator(activity, R.string.notice_unfollow_failed, NotificationType.ALERT).publish(); } } @Override - protected User doInBackground(Void... params) - { - try - { + protected User doInBackground(Void... params) { + try { return twitter.friendsFollowers().destroyFriendship(userID); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return null; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UserListStatusesTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserListStatusesTask.java index 4ece998e..8d56463e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UserListStatusesTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserListStatusesTask.java @@ -29,10 +29,10 @@ import net.lacolaco.smileessence.data.FavoriteCache; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.twitter.util.TwitterUtils; + import twitter4j.*; -public class UserListStatusesTask extends TwitterTask<Status[]> -{ +public class UserListStatusesTask extends TwitterTask<Status[]> { // ------------------------------ FIELDS ------------------------------ @@ -42,13 +42,11 @@ public class UserListStatusesTask extends TwitterTask<Status[]> // --------------------------- CONSTRUCTORS --------------------------- - public UserListStatusesTask(Twitter twitter, String listFullName, MainActivity activity) - { + public UserListStatusesTask(Twitter twitter, String listFullName, MainActivity activity) { this(twitter, listFullName, activity, TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity))); } - public UserListStatusesTask(Twitter twitter, String listFullName, MainActivity activity, Paging paging) - { + public UserListStatusesTask(Twitter twitter, String listFullName, MainActivity activity, Paging paging) { super(twitter); this.listFullName = listFullName; this.activity = activity; @@ -58,26 +56,20 @@ public class UserListStatusesTask extends TwitterTask<Status[]> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { - for(twitter4j.Status status : statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { + for (twitter4j.Status status : statuses) { StatusCache.getInstance().put(status); FavoriteCache.getInstance().put(status); } } @Override - protected twitter4j.Status[] doInBackground(Void... params) - { + protected twitter4j.Status[] doInBackground(Void... params) { ResponseList<twitter4j.Status> responseList; - try - { + try { String[] strings = listFullName.split("/"); responseList = twitter.list().getUserListStatuses(strings[0], strings[1], paging); - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return new twitter4j.Status[0]; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UserTimelineTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java index 0426c2a9..6950c563 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/task/UserTimelineTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java @@ -26,10 +26,10 @@ package net.lacolaco.smileessence.twitter.task; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.logging.Logger; + import twitter4j.*; -public class UserTimelineTask extends TwitterTask<Status[]> -{ +public class UserTimelineTask extends TwitterTask<Status[]> { // ------------------------------ FIELDS ------------------------------ @@ -38,13 +38,11 @@ public class UserTimelineTask extends TwitterTask<Status[]> // --------------------------- CONSTRUCTORS --------------------------- - public UserTimelineTask(Twitter twitter, long userID) - { + public UserTimelineTask(Twitter twitter, long userID) { this(twitter, userID, null); } - public UserTimelineTask(Twitter twitter, long userID, Paging paging) - { + public UserTimelineTask(Twitter twitter, long userID, Paging paging) { super(twitter); this.userID = userID; this.paging = paging; @@ -53,32 +51,23 @@ public class UserTimelineTask extends TwitterTask<Status[]> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { - for(twitter4j.Status status : statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { + for (twitter4j.Status status : statuses) { StatusCache.getInstance().put(status); } } @Override - protected twitter4j.Status[] doInBackground(Void... params) - { + protected twitter4j.Status[] doInBackground(Void... params) { ResponseList<twitter4j.Status> responseList; - try - { - if(paging == null) - { + try { + if (paging == null) { responseList = twitter.timelines().getUserTimeline(userID); - } - else - { + } else { responseList = twitter.timelines().getUserTimeline(userID, paging); } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e.toString()); return new twitter4j.Status[0]; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/util/TwitterUtils.java b/app/src/main/java/net/lacolaco/smileessence/twitter/util/TwitterUtils.java index 0c9c4966..95d06575 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/twitter/util/TwitterUtils.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/util/TwitterUtils.java @@ -25,7 +25,9 @@ package net.lacolaco.smileessence.twitter.util; import android.text.TextUtils; + import com.twitter.Validator; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.DirectMessageCache; @@ -36,13 +38,13 @@ import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.ShowDirectMessageTask; import net.lacolaco.smileessence.twitter.task.ShowStatusTask; import net.lacolaco.smileessence.twitter.task.ShowUserTask; + import twitter4j.*; import java.util.ArrayList; import java.util.Collection; -public class TwitterUtils -{ +public class TwitterUtils { // -------------------------- STATIC METHODS -------------------------- @@ -51,8 +53,7 @@ public class TwitterUtils * * @return length */ - public static int getFixedTextLength(String str) - { + public static int getFixedTextLength(String str) { Validator validator = new Validator(); return validator.getTweetLength(str); } @@ -60,30 +61,21 @@ public class TwitterUtils /** * Get status from api if not cached */ - public static void tryGetStatus(Account account, long statusID, final StatusCallback callback) - { + public static void tryGetStatus(Account account, long statusID, final StatusCallback callback) { Status status = StatusCache.getInstance().get(statusID); - if(status != null) - { + if (status != null) { callback.success(status); //update cache ShowStatusTask task = new ShowStatusTask(new TwitterApi(account).getTwitter(), statusID); task.execute(); - } - else - { - ShowStatusTask task = new ShowStatusTask(new TwitterApi(account).getTwitter(), statusID) - { + } else { + ShowStatusTask task = new ShowStatusTask(new TwitterApi(account).getTwitter(), statusID) { @Override - protected void onPostExecute(twitter4j.Status status) - { + protected void onPostExecute(twitter4j.Status status) { super.onPostExecute(status); - if(status != null) - { + if (status != null) { callback.success(status); - } - else - { + } else { callback.error(); } } @@ -95,29 +87,20 @@ public class TwitterUtils /** * Get status from api if not cached */ - public static void tryGetUser(Account account, long userID, final UserCallback callback) - { + public static void tryGetUser(Account account, long userID, final UserCallback callback) { User user = UserCache.getInstance().get(userID); - if(user != null) - { + if (user != null) { callback.success(user); ShowUserTask task = new ShowUserTask(new TwitterApi(account).getTwitter(), userID); task.execute(); - } - else - { - ShowUserTask task = new ShowUserTask(new TwitterApi(account).getTwitter(), userID) - { + } else { + ShowUserTask task = new ShowUserTask(new TwitterApi(account).getTwitter(), userID) { @Override - protected void onPostExecute(User user) - { + protected void onPostExecute(User user) { super.onPostExecute(user); - if(user != null) - { + if (user != null) { callback.success(user); - } - else - { + } else { callback.error(); } @@ -130,29 +113,20 @@ public class TwitterUtils /** * Get direct message from api if not cached */ - public static void tryGetMessage(Account account, long messageID, final MessageCallback callback) - { + public static void tryGetMessage(Account account, long messageID, final MessageCallback callback) { DirectMessage message = DirectMessageCache.getInstance().get(messageID); - if(message != null) - { + if (message != null) { callback.success(message); ShowDirectMessageTask task = new ShowDirectMessageTask(new TwitterApi(account).getTwitter(), messageID); task.execute(); - } - else - { - ShowDirectMessageTask task = new ShowDirectMessageTask(new TwitterApi(account).getTwitter(), messageID) - { + } else { + ShowDirectMessageTask task = new ShowDirectMessageTask(new TwitterApi(account).getTwitter(), messageID) { @Override - protected void onPostExecute(DirectMessage directMessage) - { + protected void onPostExecute(DirectMessage directMessage) { super.onPostExecute(directMessage); - if(directMessage != null) - { + if (directMessage != null) { callback.success(directMessage); - } - else - { + } else { callback.error(); } } @@ -168,71 +142,56 @@ public class TwitterUtils * @param excludeScreenName * @return */ - public static Collection<String> getScreenNames(Status status, String excludeScreenName) - { + public static Collection<String> getScreenNames(Status status, String excludeScreenName) { ArrayList<String> names = new ArrayList<>(); names.add(status.getUser().getScreenName()); - if(status.getUserMentionEntities() != null) - { - for(UserMentionEntity entity : status.getUserMentionEntities()) - { - if(names.contains(entity.getScreenName())) - { + if (status.getUserMentionEntities() != null) { + for (UserMentionEntity entity : status.getUserMentionEntities()) { + if (names.contains(entity.getScreenName())) { continue; } names.add(entity.getScreenName()); } } - if(excludeScreenName != null) - { + if (excludeScreenName != null) { names.remove(excludeScreenName); } return names; } - public static Collection<String> getScreenNames(DirectMessage message, String excludeScreenName) - { + public static Collection<String> getScreenNames(DirectMessage message, String excludeScreenName) { ArrayList<String> names = new ArrayList<>(); names.add(message.getSenderScreenName()); - if(!message.getRecipientScreenName().equals(message.getSenderScreenName())) - { + if (!message.getRecipientScreenName().equals(message.getSenderScreenName())) { names.add(message.getRecipientScreenName()); } - if(message.getUserMentionEntities() != null) - { - for(UserMentionEntity entity : message.getUserMentionEntities()) - { - if(names.contains(entity.getScreenName())) - { + if (message.getUserMentionEntities() != null) { + for (UserMentionEntity entity : message.getUserMentionEntities()) { + if (names.contains(entity.getScreenName())) { continue; } names.add(entity.getScreenName()); } } - if(excludeScreenName != null) - { + if (excludeScreenName != null) { names.remove(excludeScreenName); } return names; } - public static String getUserHomeURL(String screenName) - { + public static String getUserHomeURL(String screenName) { return String.format("https://twitter.com/%s", screenName); } - public static String getAclogTimelineURL(String screenName) - { + public static String getAclogTimelineURL(String screenName) { return String.format("http://aclog.koba789.com/%s/timeline", screenName); } - public static String getFavstarRecentURL(String screenName) - { + public static String getFavstarRecentURL(String screenName) { return String.format("http://favstar.fm/users/%s/recent", screenName); } - public static String getTwilogURL(String screenName) - { + public static String getTwilogURL(String screenName) { return String.format("http://twilog.org/%s", screenName); } @@ -242,8 +201,7 @@ public class TwitterUtils * @param status status * @return url string */ - public static String getStatusURL(Status status) - { + public static String getStatusURL(Status status) { return String.format("https://twitter.com/%s/status/%s", getOriginalStatus(status).getUser().getScreenName(), getOriginalStatus(status).getId()); } @@ -253,8 +211,7 @@ public class TwitterUtils * @param status status * @return summary string */ - public static String getStatusSummary(Status status) - { + public static String getStatusSummary(Status status) { return String.format("@%s: %s", status.getUser().getScreenName(), status.getText()); } @@ -266,22 +223,16 @@ public class TwitterUtils * @param expand if true, use expanded url * @return replaced text */ - public static String replaceURLEntities(String text, URLEntity[] entities, boolean expand) - { - if(TextUtils.isEmpty(text)) - { + public static String replaceURLEntities(String text, URLEntity[] entities, boolean expand) { + if (TextUtils.isEmpty(text)) { return ""; - } - else if(entities == null) - { + } else if (entities == null) { return text; } - if(entities.length == 0) - { + if (entities.length == 0) { return text; } - for(URLEntity entity : entities) - { + for (URLEntity entity : entities) { text = text.replace(entity.getURL(), expand ? entity.getExpandedURL() : entity.getDisplayURL()); } return text; @@ -293,51 +244,43 @@ public class TwitterUtils * @param status * @return */ - public static String getOriginalStatusText(Status status) - { + public static String getOriginalStatusText(Status status) { return status.isRetweet() ? status.getRetweetedStatus().getText() : status.getText(); } - public static Paging getPaging(int count) - { + public static Paging getPaging(int count) { return new Paging(1).count(count); } - public static int getPagingCount(MainActivity activity) - { + public static int getPagingCount(MainActivity activity) { return activity.getUserPreferenceHelper().getValue(R.string.key_setting_timelines, 20); } - public static Status getOriginalStatus(Status status) - { + public static Status getOriginalStatus(Status status) { return StatusCache.getInstance().get((status.isRetweet() ? status.getRetweetedStatus() : status).getId()); } - public static String getMessageSummary(DirectMessage message) - { + public static String getMessageSummary(DirectMessage message) { return String.format("@%s: %s", message.getSender().getScreenName(), message.getText()); } // -------------------------- INNER CLASSES -------------------------- - public interface StatusCallback - { + public interface StatusCallback { void success(Status status); void error(); } - public interface UserCallback - { + public interface UserCallback { void success(User user); void error(); } - public interface MessageCallback - { + public interface MessageCallback { void success(DirectMessage message); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapOptimizer.java b/app/src/main/java/net/lacolaco/smileessence/util/BitmapOptimizer.java index 6971f48e..850d1f8d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapOptimizer.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/BitmapOptimizer.java @@ -30,6 +30,7 @@ import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.media.ExifInterface; import android.os.Environment; + import net.lacolaco.smileessence.logging.Logger; import java.io.File; @@ -37,22 +38,18 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -public class BitmapOptimizer -{ +public class BitmapOptimizer { // -------------------------- STATIC METHODS -------------------------- - public static String rotateImageByExif(Activity activity, String filePath) - { + public static String rotateImageByExif(Activity activity, String filePath) { filePath = filePath.replace("file://", ""); int degree = getRotateDegreeFromExif(filePath); - if(degree > 0) - { + if (degree > 0) { OutputStream out = null; Bitmap bitmap = null; Bitmap rotatedImage = null; - try - { + try { Matrix mat = new Matrix(); mat.postRotate(degree); BitmapFactory.Options opt = new BitmapFactory.Options(); @@ -60,8 +57,7 @@ public class BitmapOptimizer BitmapFactory.decodeFile(filePath, opt); int width = 480; int scale = 1; - if(opt.outWidth > width) - { + if (opt.outWidth > width) { scale = opt.outWidth / width + 2; } opt.inJustDecodeBounds = false; @@ -74,32 +70,22 @@ public class BitmapOptimizer out = new FileOutputStream(outPath); rotatedImage.compress(Bitmap.CompressFormat.JPEG, 100, out); return outPath; - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); Logger.error(e); - } - finally - { - if(out != null) - { - try - { + } finally { + if (out != null) { + try { out.close(); - } - catch(IOException e) - { + } catch (IOException e) { e.printStackTrace(); Logger.error(e); } } - if(bitmap != null) - { + if (bitmap != null) { bitmap.recycle(); } - if(rotatedImage != null) - { + if (rotatedImage != null) { rotatedImage.recycle(); } } @@ -107,33 +93,23 @@ public class BitmapOptimizer return filePath; } - private static int getRotateDegreeFromExif(String filePath) - { + private static int getRotateDegreeFromExif(String filePath) { int degree = 0; - try - { + try { ExifInterface exifInterface = new ExifInterface(filePath); int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); - if(orientation == ExifInterface.ORIENTATION_ROTATE_90) - { + if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { degree = 90; - } - else if(orientation == ExifInterface.ORIENTATION_ROTATE_180) - { + } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) { degree = 180; - } - else if(orientation == ExifInterface.ORIENTATION_ROTATE_270) - { + } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { degree = 270; } - if(degree != 0) - { + if (degree != 0) { exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION, "0"); exifInterface.saveAttributes(); } - } - catch(IOException e) - { + } catch (IOException e) { degree = -1; e.printStackTrace(); Logger.error(e); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapThumbnailTask.java b/app/src/main/java/net/lacolaco/smileessence/util/BitmapThumbnailTask.java index 8416651a..beb43602 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapThumbnailTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/BitmapThumbnailTask.java @@ -31,8 +31,7 @@ import android.media.ThumbnailUtils; import android.os.AsyncTask; import android.widget.ImageView; -public class BitmapThumbnailTask extends AsyncTask<Void, Void, Bitmap> -{ +public class BitmapThumbnailTask extends AsyncTask<Void, Void, Bitmap> { // ------------------------------ FIELDS ------------------------------ @@ -42,8 +41,7 @@ public class BitmapThumbnailTask extends AsyncTask<Void, Void, Bitmap> // --------------------------- CONSTRUCTORS --------------------------- - public BitmapThumbnailTask(Activity activity, String filePath, ImageView imageView) - { + public BitmapThumbnailTask(Activity activity, String filePath, ImageView imageView) { this.activity = activity; this.filePath = filePath; this.imageView = imageView; @@ -52,17 +50,14 @@ public class BitmapThumbnailTask extends AsyncTask<Void, Void, Bitmap> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(Bitmap bitmap) - { - if(bitmap != null && imageView != null) - { + protected void onPostExecute(Bitmap bitmap) { + if (bitmap != null && imageView != null) { imageView.setImageBitmap(bitmap); } } @Override - protected Bitmap doInBackground(Void... params) - { + protected Bitmap doInBackground(Void... params) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPurgeable = true; // GC可能にする opt.inSampleSize = 2; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapURLTask.java b/app/src/main/java/net/lacolaco/smileessence/util/BitmapURLTask.java index b9563c36..7831f10e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/BitmapURLTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/BitmapURLTask.java @@ -33,8 +33,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; -public class BitmapURLTask extends AsyncTask<Void, Void, Bitmap> -{ +public class BitmapURLTask extends AsyncTask<Void, Void, Bitmap> { // ------------------------------ FIELDS ------------------------------ @@ -43,8 +42,7 @@ public class BitmapURLTask extends AsyncTask<Void, Void, Bitmap> // --------------------------- CONSTRUCTORS --------------------------- - public BitmapURLTask(String url, ImageView imageView) - { + public BitmapURLTask(String url, ImageView imageView) { this.url = url; this.imageView = imageView; } @@ -52,38 +50,27 @@ public class BitmapURLTask extends AsyncTask<Void, Void, Bitmap> // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void onPostExecute(Bitmap bitmap) - { - if(imageView != null) - { + protected void onPostExecute(Bitmap bitmap) { + if (imageView != null) { imageView.setImageBitmap(bitmap); } } @Override - protected Bitmap doInBackground(Void... params) - { + protected Bitmap doInBackground(Void... params) { InputStream inputStream = null; - try - { + try { inputStream = new URL(url).openStream(); BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPurgeable = true; // GC可能にする return BitmapFactory.decodeStream(inputStream, null, opt); - } - catch(IOException e) - { + } catch (IOException e) { e.printStackTrace(); return null; - } - finally - { - try - { + } finally { + try { inputStream.close(); - } - catch(IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/IntentUtils.java b/app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java index ac4fb4b6..580db527 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/IntentUtils.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java @@ -28,14 +28,14 @@ import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; import java.util.List; -public class IntentUtils -{ +public class IntentUtils { // -------------------------- STATIC METHODS -------------------------- @@ -46,15 +46,11 @@ public class IntentUtils * @param intent * @return */ - public static boolean startActivityIfFound(Activity activity, Intent intent) - { - if(canStartActivity(activity, intent)) - { + public static boolean startActivityIfFound(Activity activity, Intent intent) { + if (canStartActivity(activity, intent)) { activity.startActivity(intent); return true; - } - else - { + } else { new Notificator(activity, R.string.notice_error_start_activity, NotificationType.ALERT).publish(); } return false; @@ -67,8 +63,7 @@ public class IntentUtils * @param intent * @return */ - public static boolean canStartActivity(Activity activity, Intent intent) - { + public static boolean canStartActivity(Activity activity, Intent intent) { PackageManager packageManager = activity.getPackageManager(); List<ResolveInfo> infos = packageManager.queryIntentActivities(intent, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT); return !infos.isEmpty(); @@ -82,15 +77,11 @@ public class IntentUtils * @param requestCode * @return */ - public static boolean startActivityForResultIfFound(Activity activity, Intent intent, int requestCode) - { - if(canStartActivity(activity, intent)) - { + public static boolean startActivityForResultIfFound(Activity activity, Intent intent, int requestCode) { + if (canStartActivity(activity, intent)) { activity.startActivityForResult(intent, requestCode); return true; - } - else - { + } else { new Notificator(activity, R.string.notice_error_start_activity, NotificationType.ALERT).publish(); } return false; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/Morse.java b/app/src/main/java/net/lacolaco/smileessence/util/Morse.java index bbcee557..6c9bef55 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/Morse.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/Morse.java @@ -29,8 +29,7 @@ import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class Morse -{ +public class Morse { // ------------------------------ FIELDS ------------------------------ @@ -45,25 +44,18 @@ public class Morse * @param mc 判定する文字列 * @return モールスを含むならtrue, そうでなければfalse */ - public static boolean isMorse(String mc) - { + public static boolean isMorse(String mc) { Pattern pattern = Pattern.compile("[-・]+"); Matcher matcher = pattern.matcher(mc); ArrayList<String> list = new ArrayList<String>(); - while(matcher.find()) - { + while (matcher.find()) { list.add(matcher.group()); } - if(list.size() <= 2) - { + if (list.size() <= 2) { return false; - } - else - { - for(String s : list) - { - if(!s.equals("・・・") && !s.equals("・・") && !s.equals("・")) - { + } else { + for (String s : list) { + if (!s.equals("・・・") && !s.equals("・・") && !s.equals("・")) { return true; } } @@ -77,12 +69,10 @@ public class Morse * @param str 復元したい文字列 * @return 復元部分が置換された文字列 */ - public static String morseToJa(String str) - { + public static String morseToJa(String str) { String[] strArr = toRightMorse(str).split(" "); StringBuilder sb = new StringBuilder(); - for(String tok : strArr) - { + for (String tok : strArr) { sb.append(mcJa.containsKey(tok) ? mcJa.get(tok) : tok); } return sb.toString(); @@ -94,41 +84,33 @@ public class Morse * @param str 変換したい文字列 * @return 変換部分が置換された文字列 */ - public static String jaToMorse(String str) - { + public static String jaToMorse(String str) { StringBuilder sb = new StringBuilder(); - for(int i = 0; i < str.length(); i++) - { + for (int i = 0; i < str.length(); i++) { String tok = String.valueOf(str.charAt(i)); - if(jaMc.containsKey(tok)) - { + if (jaMc.containsKey(tok)) { sb.append(jaMc.get(tok)); sb.append(" "); - } - else - { + } else { sb.append(tok); } } return sb.toString(); } - private static String toRightMorse(String str) - { + private static String toRightMorse(String str) { str = str.replace("‐", "-").replace(" ", " ").trim(); Pattern pattern = Pattern.compile("[^・- ][・-]"); StringBuilder sb = new StringBuilder(str); Matcher matcher = pattern.matcher(str); - while(matcher.find()) - { + while (matcher.find()) { int i = matcher.start(); sb.insert(i + 1, " "); matcher.reset(sb); } pattern = Pattern.compile("[・-][^・- ]"); matcher = pattern.matcher(sb); - while(matcher.find()) - { + while (matcher.find()) { int i = matcher.start(); sb.insert(i + 1, " "); matcher.reset(sb); @@ -136,20 +118,18 @@ public class Morse return sb.toString(); } - static - { + static { jaMc = new HashMap<String, String>(); mcJa = new HashMap<String, String>(); String[][] ja2 = {{"・-", "イ"}, {"・-・-", "ロ"}, {"-・・・", "ハ"}, {"-・-・", "ニ"}, {"-・・", "ホ"}, {"・", "ヘ"}, {"・・-・・", "ト"}, {"・・-・", "チ"}, {"--・", "リ"}, {"・・・・", "ヌ"}, {"-・--・", "ル"}, {"・---", "ヲ"}, {"-・-", "ワ"}, {"・-・・", "カ"}, {"--", "ヨ"}, {"-・", "タ"}, {"---", "レ"}, {"---・", "ソ"}, {"・--・", "ツ"}, {"--・-", "ネ"}, {"・-・", "ナ"}, {"・・・", "ラ"}, {"-", "ム"}, {"・・-", "ウ"}, {"・-・・-", "ヰ"}, {"・・--", "ノ"}, {"・-・・・", "オ"}, {"・・・-", "ク"}, {"・--", "ヤ"}, {"-・・-", "マ"}, {"-・--", "ケ"}, {"--・・", "フ"}, {"----", "コ"}, {"-・---", "エ"}, {"・-・--", "テ"}, {"--・--", "ア"}, {"-・-・-", "サ"}, {"-・-・・", "キ"}, {"-・・--", "ユ"}, {"-・・・-", "メ"}, {"・・-・-", "ミ"}, {"--・-・", "シ"}, {"・--・・", "ヱ"}, {"--・・-", "ヒ"}, {"-・・-・", "モ"}, {"・---・", "セ"}, {"---・-", "ス"}, {"・-・-・", "ン"}, {"・・", "゛"}, {"・・--・", "゜"}, {"・--・-", "ー"}, {"・-・-・-", "、"}, {"-・--・-", "("}, {"・-・・-・", ")"}, {"・----", "1"}, {"・・---", "2"}, {"・・・--", "3"}, {"・・・・-", "4"}, {"・・・・・", "5"}, {"-・・・・", "6"}, {"--・・・", "7"}, {"---・・", "8"}, {"----・", "9"}, {"-----", "0"}, {"", ""}}; - for(String[] pr : ja2) - { + for (String[] pr : ja2) { mcJa.put(pr[0], pr[1]); jaMc.put(pr[1], pr[0]); } String[][] ja1 = {{"い", "・-"}, {"ィ", "・-"}, {"ぃ", "・-"}, {"ろ", "・-・-"}, {"は", "-・・・"}, {"に", "-・-・"}, {"ほ", "-・・"}, {"へ", "・"}, {"と", "・・-・・"}, {"ち", "・・-・"}, {"り", "--・"}, {"ぬ", "・・・・"}, {"る", "-・--・"}, {"を", "・---"}, {"わ", "-・-"}, {"ヮ", "-・-"}, {"ゎ", "-・-"}, {"か", "・-・・"}, {"ヵ", "・-・・"}, {"よ", "--"}, {"ョ", "--"}, {"ょ", "--"}, {"た", "-・"}, {"れ", "---"}, {"そ", "---・"}, {"つ", "・--・"}, {"ッ", "・--・"}, {"っ", "・--・"}, {"ね", "--・-"}, {"な", "・-・"}, {"ら", "・・・"}, {"む", "-"}, {"う", "・・-"}, {"ゥ", "・・-"}, {"ぅ", "・・-"}, {"ゐ", "・-・・-"}, {"の", "・・--"}, {"お", "・-・・・"}, {"ォ", "・-・・・"}, {"ぉ", "・-・・・"}, {"く", "・・・-"}, {"や", "・--"}, {"ャ", "・--"}, {"ゃ", "・--"}, {"ま", "-・・-"}, {"け", "-・--"}, {"ヶ", "-・--"}, {"ふ", "--・・"}, {"こ", "----"}, {"え", "-・---"}, {"ェ", "-・---"}, {"ぇ", "-・---"}, {"て", "・-・--"}, {"あ", "--・--"}, {"ァ", "--・--"}, {"ぁ", "--・--"}, {"さ", "-・-・-"}, {"き", "-・-・・"}, {"ゆ", "-・・--"}, {"ュ", "-・・--"}, {"ゅ", "-・・--"}, {"め", "-・・・-"}, {"み", "・・-・-"}, {"し", "--・-・"}, {"ゑ", "・--・・"}, {"ひ", "--・・-"}, {"も", "-・・-・"}, {"せ", "・---・"}, {"す", "---・-"}, {"ん", "・-・-・"}, {"ガ", "・-・・ ・・"}, {"が", "・-・・ ・・"}, {"ギ", "-・-・・ ・・"}, {"ぎ", "-・-・・ ・・"}, {"グ", "・・・- ・・"}, {"ぐ", "・・・- ・・"}, {"ゲ", "-・-- ・・"}, {"げ", "-・-- ・・"}, {"ゴ", "---- ・・"}, {"ご", "---- ・・"}, {"ザ", "-・-・- ・・"}, {"ざ", "-・-・- ・・"}, {"ジ", "--・-・ ・・"}, {"じ", "--・-・ ・・"}, {"ズ", "---・- ・・"}, {"ず", "---・- ・・"}, {"ゼ", "・---・ ・・"}, {"ぜ", "・---・ ・・"}, {"ゾ", "---・ ・・"}, {"ぞ", "---・ ・・"}, {"ダ", "-・ ・・"}, {"だ", "-・ ・・"}, {"ヂ", "・・-・ ・・"}, {"ぢ", "・・-・ ・・"}, {"ヅ", "・--・ ・・"}, {"づ", "・--・ ・・"}, {"デ", "・-・-- ・・"}, {"で", "・-・-- ・・"}, {"ド", "・・-・・ ・・"}, {"ど", "・・-・・ ・・"}, {"バ", "-・・・ ・・"}, {"ば", "-・・・ ・・"}, {"ビ", "--・・- ・・"}, {"び", "--・・- ・・"}, {"ブ", "--・・ ・・"}, {"ぶ", "--・・ ・・"}, {"ベ", "・ ・・"}, {"べ", "・ ・・"}, {"ボ", "-・・ ・・"}, {"ぼ", "-・・ ・・"}, {"パ", "-・・・ ・・--・"}, {"ぱ", "-・・・ ・・--・"}, {"ピ", "--・・- ・・--・"}, {"ぴ", "--・・- ・・--・"}, {"プ", "--・・ ・・--・"}, {"ぷ", "--・・ ・・--・"}, {"ペ", "・ ・・--・"}, {"ぺ", "・ ・・--・"}, {"ポ", "-・・ ・・--・"}, {"ぽ", "-・・ ・・--・"}, {"ヴ", "・・- ・・"}}; - for(String[] to : ja1) + for (String[] to : ja1) jaMc.put(to[0], to[1]); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/NameStyles.java b/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java index 8506c3cc..31c56324 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/NameStyles.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java @@ -24,29 +24,22 @@ package net.lacolaco.smileessence.util; -public class NameStyles -{ +public class NameStyles { // -------------------------- STATIC METHODS -------------------------- - public static String getNameString(int style, String screenName, String name) - { - switch(style) - { - case 1: - { + public static String getNameString(int style, String screenName, String name) { + switch (style) { + case 1: { return String.format("%s / %s", name, screenName); } - case 2: - { + case 2: { return String.format("%s", screenName); } - case 3: - { + case 3: { return String.format("%s", name); } - default: - { + default: { return String.format("%s / %s", screenName, name); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/NetworkHelper.java b/app/src/main/java/net/lacolaco/smileessence/util/NetworkHelper.java index 0836417e..75062a4f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/NetworkHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/NetworkHelper.java @@ -28,8 +28,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; -public class NetworkHelper -{ +public class NetworkHelper { // ------------------------------ FIELDS ------------------------------ @@ -37,15 +36,13 @@ public class NetworkHelper // --------------------------- CONSTRUCTORS --------------------------- - public NetworkHelper(Context context) - { + public NetworkHelper(Context context) { this.context = context; } // -------------------------- OTHER METHODS -------------------------- - public boolean canConnect() - { + public boolean canConnect() { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isConnected(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/StringUtils.java b/app/src/main/java/net/lacolaco/smileessence/util/StringUtils.java index efd160c4..a032f9f7 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/StringUtils.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/StringUtils.java @@ -28,41 +28,31 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -public class StringUtils -{ +public class StringUtils { // -------------------------- STATIC METHODS -------------------------- - public static String dateToString(Date date) - { + public static String dateToString(Date date) { Calendar current = Calendar.getInstance(); Calendar cal = Calendar.getInstance(); cal.setTime(date); - if(isSameYear(current, cal)) - { - if(isSameDay(current, cal)) - { + if (isSameYear(current, cal)) { + if (isSameDay(current, cal)) { return new SimpleDateFormat("HH:mm:ss").format(date); - } - else - { + } else { return new SimpleDateFormat("MM/dd HH:mm:ss").format(date); } - } - else - { + } else { return new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(date); } } - private static boolean isSameDay(Calendar current, Calendar cal) - { + private static boolean isSameDay(Calendar current, Calendar cal) { return cal.get(Calendar.DAY_OF_YEAR) == current.get(Calendar.DAY_OF_YEAR); } - private static boolean isSameYear(Calendar current, Calendar cal) - { + private static boolean isSameYear(Calendar current, Calendar cal) { return cal.get(Calendar.YEAR) == current.get(Calendar.YEAR); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/Themes.java b/app/src/main/java/net/lacolaco/smileessence/util/Themes.java index 07458b7f..de608060 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/Themes.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/Themes.java @@ -27,11 +27,11 @@ package net.lacolaco.smileessence.util; import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.logging.Logger; -public class Themes -{ +public class Themes { // ------------------------------ FIELDS ------------------------------ @@ -40,30 +40,24 @@ public class Themes // -------------------------- STATIC METHODS -------------------------- - public static int getTheme(int index) - { - switch(index) - { - case THEME_DARK: - { + public static int getTheme(int index) { + switch (index) { + case THEME_DARK: { Logger.debug("Theme:Dark"); return R.style.theme_dark; } - case THEME_LIGHT: - { + case THEME_LIGHT: { Logger.debug("Theme:Light"); return R.style.theme_light; } - default: - { + default: { Logger.debug("Theme:Default"); return R.style.theme_dark; } } } - public static int getStyledColor(Context context, int theme, int attribute, int defaultColor) - { + public static int getStyledColor(Context context, int theme, int attribute, int defaultColor) { int styleResID = theme == THEME_LIGHT ? R.style.theme_light : R.style.theme_dark; TypedArray array = context.obtainStyledAttributes(styleResID, new int[]{attribute}); int color = array.getColor(0, defaultColor); @@ -71,8 +65,7 @@ public class Themes return color; } - public static Drawable getStyledDrawable(Context context, int theme, int attribute) - { + public static Drawable getStyledDrawable(Context context, int theme, int attribute) { int styleResID = theme == THEME_LIGHT ? R.style.theme_light : R.style.theme_dark; TypedArray array = context.obtainStyledAttributes(styleResID, new int[]{attribute}); Drawable drawable = array.getDrawable(0); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/UIHandler.java b/app/src/main/java/net/lacolaco/smileessence/util/UIHandler.java index 1688c622..2beb2d8e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/util/UIHandler.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/UIHandler.java @@ -27,18 +27,15 @@ package net.lacolaco.smileessence.util; import android.os.Handler; import android.os.Looper; -public abstract class UIHandler extends Handler implements Runnable -{ +public abstract class UIHandler extends Handler implements Runnable { // --------------------------- CONSTRUCTORS --------------------------- - public UIHandler() - { + public UIHandler() { super(Looper.getMainLooper()); } - public UIHandler(Handler.Callback callback) - { + public UIHandler(Callback callback) { super(Looper.getMainLooper(), callback); } @@ -52,28 +49,23 @@ public abstract class UIHandler extends Handler implements Runnable // -------------------------- OTHER METHODS -------------------------- - public boolean post() - { + public boolean post() { return post(this); } - public boolean postAtFrontOfQueue() - { + public boolean postAtFrontOfQueue() { return postAtFrontOfQueue(this); } - public boolean postAtTime(long uptimeMillis) - { + public boolean postAtTime(long uptimeMillis) { return postAtTime(this, uptimeMillis); } - public boolean postAtTime(Object token, long uptimeMillis) - { + public boolean postAtTime(Object token, long uptimeMillis) { return postAtTime(this, token, uptimeMillis); } - public boolean postDelayed(long delayMillis) - { + public boolean postDelayed(long delayMillis) { return postDelayed(this, delayMillis); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/CustomListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java index d4535f2c..f6a683fe 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/CustomListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java @@ -32,16 +32,17 @@ import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.ListAdapter; import android.widget.ListView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; import com.handmark.pulltorefresh.library.PullToRefreshListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; public class CustomListFragment extends Fragment implements AbsListView.OnScrollListener, - PullToRefreshBase.OnRefreshListener2<ListView> -{ + PullToRefreshBase.OnRefreshListener2<ListView> { // ------------------------------ FIELDS ------------------------------ @@ -52,8 +53,7 @@ public class CustomListFragment extends Fragment implements AbsListView.OnScroll // --------------------- GETTER / SETTER METHODS --------------------- - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.DISABLED; } @@ -63,54 +63,46 @@ public class CustomListFragment extends Fragment implements AbsListView.OnScroll // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { } @Override - public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { } // --------------------- Interface OnScrollListener --------------------- @Override - public void onScrollStateChanged(AbsListView absListView, int scrollState) - { + public void onScrollStateChanged(AbsListView absListView, int scrollState) { Bundle args = getArguments(); fragmentIndex = args.getInt(ADAPTER_INDEX); CustomListAdapter<?> adapter = getListAdapter(fragmentIndex); adapter.setNotifiable(false); - if(absListView.getFirstVisiblePosition() == 0 && absListView.getChildAt(0) != null && absListView.getChildAt(0).getTop() == 0) - { - if(scrollState == SCROLL_STATE_IDLE) - { + if (absListView.getFirstVisiblePosition() == 0 && absListView.getChildAt(0) != null && absListView.getChildAt(0).getTop() == 0) { + if (scrollState == SCROLL_STATE_IDLE) { updateListViewWithNotice(absListView, adapter, true); } } } @Override - public void onScroll(AbsListView absListView, int i, int i2, int i3) - { + public void onScroll(AbsListView absListView, int i, int i2, int i3) { } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); fragmentIndex = args.getInt(ADAPTER_INDEX); } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View page = inflater.inflate(R.layout.fragment_list, container, false); Bundle args = getArguments(); int fragmentIndex = args.getInt(ADAPTER_INDEX); @@ -124,65 +116,51 @@ public class CustomListFragment extends Fragment implements AbsListView.OnScroll } @Override - public void onSaveInstanceState(Bundle outState) - { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(ADAPTER_INDEX, fragmentIndex); } @Override - public void onViewStateRestored(Bundle savedInstanceState) - { + public void onViewStateRestored(Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); - if(savedInstanceState != null) - { + if (savedInstanceState != null) { fragmentIndex = savedInstanceState.getInt(ADAPTER_INDEX); } } - protected CustomListAdapter<?> getListAdapter(int fragmentIndex) - { + protected CustomListAdapter<?> getListAdapter(int fragmentIndex) { return ((MainActivity) getActivity()).getListAdapter(fragmentIndex); } - protected PullToRefreshListView getListView(View page) - { + protected PullToRefreshListView getListView(View page) { return (PullToRefreshListView) page.findViewById(R.id.fragment_list_listview); } - protected void notifyListUpdated(int increments) - { + protected void notifyListUpdated(int increments) { Notificator.publish(getActivity(), getString(R.string.notice_timeline_new, increments)); } - protected void updateListViewWithNotice(AbsListView absListView, CustomListAdapter<?> adapter, boolean addedToTop) - { + protected void updateListViewWithNotice(AbsListView absListView, CustomListAdapter<?> adapter, boolean addedToTop) { int before = adapter.getCount(); adapter.notifyDataSetChanged(); // synchronized call (not adapter#updateForce()) int after = adapter.getCount(); int increments = after - before; - if(increments > 0) - { + if (increments > 0) { adapter.setNotifiable(false); notifyListUpdated(increments); - if(addedToTop) - { + if (addedToTop) { absListView.setSelection(increments + 1); absListView.smoothScrollToPositionFromTop(increments, 0); absListView.setSelection(increments); - } - else - { + } else { absListView.smoothScrollToPositionFromTop(before, 0); } - if(increments == 1) - { + if (increments == 1) { adapter.setNotifiable(true); } - } - else - { + } else { adapter.setNotifiable(true); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/HistoryFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java index 64965176..3bdb001d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/HistoryFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java @@ -25,19 +25,18 @@ package net.lacolaco.smileessence.view; import android.widget.ListView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; /** * Fragment for notice history */ -public class HistoryFragment extends CustomListFragment -{ +public class HistoryFragment extends CustomListFragment { // --------------------- GETTER / SETTER METHODS --------------------- @Override - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.DISABLED; } @@ -47,12 +46,10 @@ public class HistoryFragment extends CustomListFragment // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { } @Override - public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/HomeFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java index d3cdabc8..0cc3b77f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/HomeFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java @@ -25,7 +25,9 @@ package net.lacolaco.smileessence.view; import android.widget.ListView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.StatusFilter; @@ -35,17 +37,16 @@ import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.util.UIHandler; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.Paging; import twitter4j.Twitter; -public class HomeFragment extends CustomListFragment -{ +public class HomeFragment extends CustomListFragment { // --------------------- GETTER / SETTER METHODS --------------------- @Override - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.BOTH; } @@ -55,16 +56,12 @@ public class HomeFragment extends CustomListFragment // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); - if(activity.isStreaming()) - { - new UIHandler() - { + if (activity.isStreaming()) { + new UIHandler() { @Override - public void run() - { + public void run() { StatusListAdapter adapter = getListAdapter(activity); updateListViewWithNotice(refreshView.getRefreshableView(), adapter, true); refreshView.onRefreshComplete(); @@ -76,18 +73,14 @@ public class HomeFragment extends CustomListFragment Twitter twitter = TwitterApi.getTwitter(currentAccount); final StatusListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new HomeTimelineTask(twitter, activity, paging) - { + new HomeTimelineTask(twitter, activity, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(int i = statuses.length - 1; i >= 0; i--) - { + for (int i = statuses.length - 1; i >= 0; i--) { twitter4j.Status status = statuses[i]; StatusViewModel viewModel = new StatusViewModel(status, currentAccount); adapter.addToTop(viewModel); @@ -100,25 +93,20 @@ public class HomeFragment extends CustomListFragment } @Override - public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final StatusListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new HomeTimelineTask(twitter, activity, paging) - { + new HomeTimelineTask(twitter, activity, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { StatusViewModel viewModel = new StatusViewModel(status, currentAccount); adapter.addToBottom(viewModel); StatusFilter.filter(activity, viewModel); @@ -129,8 +117,7 @@ public class HomeFragment extends CustomListFragment }.execute(); } - private StatusListAdapter getListAdapter(MainActivity activity) - { + private StatusListAdapter getListAdapter(MainActivity activity) { return (StatusListAdapter) activity.getListAdapter(MainActivity.ADAPTER_HOME); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/MentionsFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java index 31a4c006..d47d9552 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/MentionsFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java @@ -25,7 +25,9 @@ package net.lacolaco.smileessence.view; import android.widget.ListView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; @@ -33,17 +35,16 @@ import net.lacolaco.smileessence.twitter.task.MentionsTimelineTask; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.Paging; import twitter4j.Twitter; -public class MentionsFragment extends CustomListFragment -{ +public class MentionsFragment extends CustomListFragment { // --------------------- GETTER / SETTER METHODS --------------------- @Override - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.BOTH; } @@ -53,25 +54,20 @@ public class MentionsFragment extends CustomListFragment // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final StatusListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new MentionsTimelineTask(twitter, activity, paging) - { + new MentionsTimelineTask(twitter, activity, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(int i = statuses.length - 1; i >= 0; i--) - { + for (int i = statuses.length - 1; i >= 0; i--) { twitter4j.Status status = statuses[i]; adapter.addToTop(new StatusViewModel(status, currentAccount)); } @@ -82,25 +78,20 @@ public class MentionsFragment extends CustomListFragment } @Override - public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final StatusListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new MentionsTimelineTask(twitter, activity, paging) - { + new MentionsTimelineTask(twitter, activity, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { adapter.addToBottom(new StatusViewModel(status, currentAccount)); } updateListViewWithNotice(refreshView.getRefreshableView(), adapter, false); @@ -109,8 +100,7 @@ public class MentionsFragment extends CustomListFragment }.execute(); } - private StatusListAdapter getListAdapter(MainActivity activity) - { + private StatusListAdapter getListAdapter(MainActivity activity) { return (StatusListAdapter) activity.getListAdapter(MainActivity.ADAPTER_MENTIONS); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/MessagesFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java index 430c29a0..eccea631 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/MessagesFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java @@ -25,7 +25,9 @@ package net.lacolaco.smileessence.view; import android.widget.ListView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; + import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.TwitterApi; @@ -33,6 +35,7 @@ import net.lacolaco.smileessence.twitter.task.DirectMessagesTask; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.MessageListAdapter; import net.lacolaco.smileessence.viewmodel.MessageViewModel; + import twitter4j.DirectMessage; import twitter4j.Paging; import twitter4j.Twitter; @@ -40,14 +43,12 @@ import twitter4j.Twitter; /** * Fragment of messages list */ -public class MessagesFragment extends CustomListFragment -{ +public class MessagesFragment extends CustomListFragment { // --------------------- GETTER / SETTER METHODS --------------------- @Override - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.BOTH; } @@ -57,25 +58,20 @@ public class MessagesFragment extends CustomListFragment // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final MessageListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new DirectMessagesTask(twitter, activity, paging) - { + new DirectMessagesTask(twitter, activity, paging) { @Override - protected void onPostExecute(DirectMessage[] directMessages) - { + protected void onPostExecute(DirectMessage[] directMessages) { super.onPostExecute(directMessages); - for(int i = directMessages.length - 1; i >= 0; i--) - { + for (int i = directMessages.length - 1; i >= 0; i--) { adapter.addToTop(new MessageViewModel(directMessages[i], currentAccount)); } updateListViewWithNotice(refreshView.getRefreshableView(), adapter, true); @@ -85,25 +81,20 @@ public class MessagesFragment extends CustomListFragment } @Override - public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final MessageListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new DirectMessagesTask(twitter, activity, paging) - { + new DirectMessagesTask(twitter, activity, paging) { @Override - protected void onPostExecute(DirectMessage[] directMessages) - { + protected void onPostExecute(DirectMessage[] directMessages) { super.onPostExecute(directMessages); - for(DirectMessage directMessage : directMessages) - { + for (DirectMessage directMessage : directMessages) { adapter.addToBottom(new MessageViewModel(directMessage, currentAccount)); } updateListViewWithNotice(refreshView.getRefreshableView(), adapter, false); @@ -112,8 +103,7 @@ public class MessagesFragment extends CustomListFragment }.execute(); } - private MessageListAdapter getListAdapter(MainActivity activity) - { + private MessageListAdapter getListAdapter(MainActivity activity) { return (MessageListAdapter) activity.getListAdapter(MainActivity.ADAPTER_MESSAGES); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/PostFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java index f0636fe0..9c8a255b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/PostFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java @@ -37,7 +37,9 @@ import android.text.method.ArrowKeyMovementMethod; import android.view.*; import android.view.inputmethod.InputMethodManager; import android.widget.*; + import com.twitter.Validator; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; @@ -54,14 +56,14 @@ import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.PostMenuDialogFragment; import net.lacolaco.smileessence.view.dialog.SelectImageDialogFragment; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.Status; import twitter4j.StatusUpdate; import java.io.File; public class PostFragment extends Fragment implements TextWatcher, View.OnFocusChangeListener, View.OnClickListener, - PostState.OnPostStateChangeListener -{ + PostState.OnPostStateChangeListener { // ------------------------------ FIELDS ------------------------------ @@ -77,42 +79,33 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(View v) - { - switch(v.getId()) - { - case R.id.button_post_delete: - { + public void onClick(View v) { + switch (v.getId()) { + case R.id.button_post_delete: { deletePost(); break; } - case R.id.button_post_media: - { + case R.id.button_post_media: { setImage(); break; } - case R.id.button_post_menu: - { + case R.id.button_post_menu: { openPostMenu(); break; } - case R.id.button_post_tweet: - { + case R.id.button_post_tweet: { submitPost(); break; } - case R.id.button_post_reply_delete: - { + case R.id.button_post_reply_delete: { deleteReply(); break; } - case R.id.button_post_media_delete: - { + case R.id.button_post_media_delete: { removeImage(); break; } - case R.id.image_post_media: - { + case R.id.image_post_media: { displayImage(); break; } @@ -122,14 +115,10 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC // --------------------- Interface OnFocusChangeListener --------------------- @Override - public void onFocusChange(View v, boolean hasFocus) - { - if(hasFocus) - { + public void onFocusChange(View v, boolean hasFocus) { + if (hasFocus) { showIME(); - } - else - { + } else { hideIME(); } } @@ -138,38 +127,30 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC @Override - public void onPostStateChange(final PostState postState) - { + public void onPostStateChange(final PostState postState) { Logger.debug("PostFragment PostStateChange"); final MainActivity activity = (MainActivity) getActivity(); - if(editText != null) - { + if (editText != null) { final int start = postState.getSelectionStart(); final int end = postState.getSelectionEnd(); editText.removeTextChangedListener(this); editText.setTextKeepState(postState.getText()); editText.addTextChangedListener(this); updateTextCount(editText.getText()); - new UIHandler() - { + new UIHandler() { @Override - public void run() - { + public void run() { editText.setSelection(start, end); } }.postAtFrontOfQueue(); } - if(viewGroupReply != null) - { - if(postState.getInReplyToStatusID() >= 0) - { + if (viewGroupReply != null) { + if (postState.getInReplyToStatusID() >= 0) { viewGroupReply.setVisibility(View.VISIBLE); final Account account = activity.getCurrentAccount(); - TwitterUtils.tryGetStatus(account, postState.getInReplyToStatusID(), new TwitterUtils.StatusCallback() - { + TwitterUtils.tryGetStatus(account, postState.getInReplyToStatusID(), new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { View header = viewGroupReply.findViewById(R.id.layout_post_reply_status); header = new StatusViewModel(status, account).getView(activity, activity.getLayoutInflater(), header); header.setBackgroundColor(getResources().getColor(R.color.transparent)); @@ -177,28 +158,21 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC } @Override - public void error() - { + public void error() { viewGroupReply.setVisibility(View.GONE); } }); ImageButton imageButtonDeleteReply = (ImageButton) viewGroupReply.findViewById(R.id.button_post_reply_delete); imageButtonDeleteReply.setOnClickListener(this); - } - else - { + } else { viewGroupReply.setVisibility(View.GONE); } } - if(viewGroupMedia != null) - { + if (viewGroupMedia != null) { ImageView imageViewMedia = (ImageView) viewGroupMedia.findViewById(R.id.image_post_media); - if(TextUtils.isEmpty(postState.getMediaFilePath())) - { + if (TextUtils.isEmpty(postState.getMediaFilePath())) { viewGroupMedia.setVisibility(View.GONE); - } - else - { + } else { viewGroupMedia.setVisibility(View.VISIBLE); } @@ -209,36 +183,27 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC // --------------------- Interface TextWatcher --------------------- @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) - { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) - { + public void onTextChanged(CharSequence s, int start, int before, int count) { updateTextCount(s); } - public void updateTextCount(CharSequence s) - { + public void updateTextCount(CharSequence s) { int remainingCount = 140 - TwitterUtils.getFixedTextLength(s.toString()); - if(!TextUtils.isEmpty(PostState.getState().getMediaFilePath())) - { + if (!TextUtils.isEmpty(PostState.getState().getMediaFilePath())) { remainingCount -= new Validator().getShortUrlLength(); } textViewCount.setText(String.valueOf(remainingCount)); - if(remainingCount == 140) - { + if (remainingCount == 140) { textViewCount.setTextColor(getResources().getColor(R.color.red)); buttonTweet.setEnabled(false); - } - else if(remainingCount < 0) - { + } else if (remainingCount < 0) { textViewCount.setTextColor(getResources().getColor(R.color.red)); buttonTweet.setEnabled(false); - } - else - { + } else { textViewCount.setTextAppearance(getActivity(), android.R.style.TextAppearance_Widget_TextView); buttonTweet.setEnabled(true); } @@ -246,30 +211,26 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { Logger.debug("PostFragment Create"); super.onCreate(savedInstanceState); setHasOptionsMenu(true); } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) - { + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.removeItem(R.id.actionbar_post); showIME(); } - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Logger.debug("PostFragment CreateView"); MainActivity activity = (MainActivity) getActivity(); PostState.getState().setListener(this); @@ -283,11 +244,9 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC editText.addTextChangedListener(this); editText.setOnFocusChangeListener(this); editText.setTextSize(textSize + 4); - editText.setMovementMethod(new ArrowKeyMovementMethod() - { + editText.setMovementMethod(new ArrowKeyMovementMethod() { @Override - protected boolean right(TextView widget, Spannable buffer) - { + protected boolean right(TextView widget, Spannable buffer) { //Don't back to Home return widget.getSelectionEnd() == widget.length() || super.right(widget, buffer); } @@ -313,8 +272,7 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC } @Override - public void onDestroyView() - { + public void onDestroyView() { Logger.debug("PostFragment DestroyView"); super.onDestroyView(); setStateFromView(); @@ -322,29 +280,25 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC } @Override - public void onViewStateRestored(Bundle savedInstanceState) - { + public void onViewStateRestored(Bundle savedInstanceState) { Logger.debug("PostFragment ViewStateRestored"); super.onViewStateRestored(savedInstanceState); PostState state = PostState.getState(); onPostStateChange(state); } - private void deletePost() - { + private void deletePost() { editText.setText(""); PostState.getState().beginTransaction().setText("").setCursor(0).commit(); deleteReply(); } - private void deleteReply() - { + private void deleteReply() { viewGroupReply.setVisibility(View.GONE); PostState.getState().beginTransaction().setInReplyToStatusID(-1).commit(); } - private void displayImage() - { + private void displayImage() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); @@ -352,81 +306,67 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC IntentUtils.startActivityIfFound(getActivity(), intent); } - private TextView getCountTextView(View v) - { + private TextView getCountTextView(View v) { return (TextView) v.findViewById(R.id.post_text_count); } - private EditText getEditText(View v) - { + private EditText getEditText(View v) { return (EditText) v.findViewById(R.id.post_edit_text); } - private ViewGroup getMediaViewGroup(View v) - { + private ViewGroup getMediaViewGroup(View v) { return (ViewGroup) v.findViewById(R.id.post_media_parent); } - private ViewGroup getReplyViewGroup(View v) - { + private ViewGroup getReplyViewGroup(View v) { return (ViewGroup) v.findViewById(R.id.post_inreplyto_parent); } - private Button getTweetButton(View v) - { + private Button getTweetButton(View v) { return (Button) v.findViewById(R.id.button_post_tweet); } - private void hideIME() - { + private void hideIME() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); } - private void openPostMenu() - { + private void openPostMenu() { setStateFromView(); hideIME(); PostMenuDialogFragment menuDialogFragment = new PostMenuDialogFragment(); DialogHelper.showDialog(getActivity(), menuDialogFragment, PostMenuDialogFragment.TAG); } - private void removeImage() - { + private void removeImage() { hideIME(); viewGroupMedia.setVisibility(View.GONE); ((ImageView) viewGroupMedia.findViewById(R.id.image_post_media)).setImageBitmap(null); PostState.getState().beginTransaction().setMediaFilePath("").commit(); } - private void setImage() - { + private void setImage() { setStateFromView(); hideIME(); SelectImageDialogFragment selectImageDialogFragment = new SelectImageDialogFragment(); DialogHelper.showDialog(getActivity(), selectImageDialogFragment); } - private void setStateFromView() - { + private void setStateFromView() { PostState state = PostState.getState(); state.removeListener(); state.beginTransaction() - .setText(editText.getText().toString()) - .setSelection(editText.getSelectionStart(), editText.getSelectionEnd()) - .commit(); + .setText(editText.getText().toString()) + .setSelection(editText.getSelectionStart(), editText.getSelectionEnd()) + .commit(); state.setListener(this); } - private void showIME() - { - if(editText != null) - { - new UIHandler() - { + private void showIME() { + if (editText != null) { + new UIHandler() { @Override - public void run() - { + public void run() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, 0); } @@ -434,8 +374,7 @@ public class PostFragment extends Fragment implements TextWatcher, View.OnFocusC } } - private void submitPost() - { + private void submitPost() { hideIME(); setStateFromView(); PostState state = PostState.getState(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/SearchFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java index ace8fc36..4da3fd46 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/SearchFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java @@ -35,8 +35,10 @@ import android.widget.EditText; import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; import com.handmark.pulltorefresh.library.PullToRefreshListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -53,6 +55,7 @@ import net.lacolaco.smileessence.view.adapter.SearchListAdapter; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.SelectSearchQueryDialogFragment; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.Query; import twitter4j.QueryResult; import twitter4j.Twitter; @@ -60,8 +63,7 @@ import twitter4j.Twitter; import java.util.List; public class SearchFragment extends CustomListFragment implements View.OnClickListener, View.OnFocusChangeListener, - SearchListAdapter.OnQueryChangeListener -{ + SearchListAdapter.OnQueryChangeListener { // ------------------------------ FIELDS ------------------------------ @@ -70,19 +72,16 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi // --------------------- GETTER / SETTER METHODS --------------------- - private int getAdapterIndex() - { + private int getAdapterIndex() { return getArguments().getInt(ADAPTER_INDEX); } - private MainActivity getMainActivity() - { + private MainActivity getMainActivity() { return (MainActivity) getActivity(); } @Override - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.BOTH; } @@ -92,22 +91,17 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(View v) - { - switch(v.getId()) - { - case R.id.button_search_queries: - { + public void onClick(View v) { + switch (v.getId()) { + case R.id.button_search_queries: { openSearchQueryDialog(getMainActivity()); break; } - case R.id.button_search_execute: - { + case R.id.button_search_execute: { search(); break; } - case R.id.button_search_save: - { + case R.id.button_search_save: { saveQuery(); } } @@ -116,10 +110,8 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi // --------------------- Interface OnFocusChangeListener --------------------- @Override - public void onFocusChange(View v, boolean hasFocus) - { - if(!hasFocus) - { + public void onFocusChange(View v, boolean hasFocus) { + if (!hasFocus) { hideIME(); } } @@ -127,10 +119,8 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi // --------------------- Interface OnQueryChangeListener --------------------- @Override - public void onQueryChange(String newQuery) - { - if(editText != null) - { + public void onQueryChange(String newQuery) { + if (editText != null) { editText.setText(newQuery); } } @@ -138,20 +128,16 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = getMainActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final SearchListAdapter adapter = getListAdapter(activity); String queryString = adapter.getQuery(); - if(TextUtils.isEmpty(queryString)) - { - new UIHandler() - { + if (TextUtils.isEmpty(queryString)) { + new UIHandler() { @Override - public void run() - { + public void run() { notifyTextEmpty(activity); refreshView.onRefreshComplete(); } @@ -159,24 +145,18 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi return; } final Query query = SearchTask.getBaseQuery(activity, queryString); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { query.setSinceId(adapter.getTopID()); } - new SearchTask(twitter, query, activity) - { + new SearchTask(twitter, query, activity) { @Override - protected void onPostExecute(QueryResult queryResult) - { + protected void onPostExecute(QueryResult queryResult) { super.onPostExecute(queryResult); - if(queryResult != null) - { - java.util.List<twitter4j.Status> tweets = queryResult.getTweets(); - for(int i = tweets.size() - 1; i >= 0; i--) - { + if (queryResult != null) { + List<twitter4j.Status> tweets = queryResult.getTweets(); + for (int i = tweets.size() - 1; i >= 0; i--) { twitter4j.Status status = tweets.get(i); - if(!status.isRetweet()) - { + if (!status.isRetweet()) { StatusViewModel viewModel = new StatusViewModel(status, currentAccount); adapter.addToTop(viewModel); StatusFilter.filter(activity, viewModel); @@ -191,20 +171,16 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi } @Override - public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = getMainActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final SearchListAdapter adapter = getListAdapter(activity); String queryString = adapter.getQuery(); - if(TextUtils.isEmpty(queryString)) - { - new UIHandler() - { + if (TextUtils.isEmpty(queryString)) { + new UIHandler() { @Override - public void run() - { + public void run() { notifyTextEmpty(activity); refreshView.onRefreshComplete(); } @@ -212,23 +188,17 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi return; } final Query query = SearchTask.getBaseQuery(activity, queryString); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { query.setMaxId(adapter.getLastID() - 1); } - new SearchTask(twitter, query, activity) - { + new SearchTask(twitter, query, activity) { @Override - protected void onPostExecute(QueryResult queryResult) - { + protected void onPostExecute(QueryResult queryResult) { super.onPostExecute(queryResult); - if(queryResult != null) - { + if (queryResult != null) { List<twitter4j.Status> tweets = queryResult.getTweets(); - for(twitter4j.Status status : tweets) - { - if(!status.isRetweet()) - { + for (twitter4j.Status status : tweets) { + if (!status.isRetweet()) { StatusViewModel viewModel = new StatusViewModel(status, currentAccount); adapter.addToBottom(viewModel); StatusFilter.filter(activity, viewModel); @@ -244,28 +214,24 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected PullToRefreshListView getListView(View page) - { + protected PullToRefreshListView getListView(View page) { return (PullToRefreshListView) page.findViewById(R.id.listview_search); } @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) - { + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.removeItem(R.id.actionbar_search); } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View page = inflater.inflate(R.layout.fragment_search, container, false); int fragmentIndex = getAdapterIndex(); PullToRefreshListView listView = getListView(page); @@ -283,18 +249,15 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi editText = getEditText(page); editText.setOnFocusChangeListener(this); editText.setText(adapter.getQuery()); - editText.setMovementMethod(new ArrowKeyMovementMethod() - { + editText.setMovementMethod(new ArrowKeyMovementMethod() { @Override - protected boolean right(TextView widget, Spannable buffer) - { + protected boolean right(TextView widget, Spannable buffer) { //Don't move page return widget.getSelectionEnd() == widget.length() || super.right(widget, buffer); } @Override - protected boolean left(TextView widget, Spannable buffer) - { + protected boolean left(TextView widget, Spannable buffer) { //Don't move page return widget.getSelectionStart() == 0 || super.left(widget, buffer); } @@ -303,69 +266,54 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi return page; } - private EditText getEditText(View page) - { + private EditText getEditText(View page) { return (EditText) page.findViewById(R.id.edittext_search); } - private ImageButton getExecuteButton(View page) - { + private ImageButton getExecuteButton(View page) { return (ImageButton) page.findViewById(R.id.button_search_execute); } - private SearchListAdapter getListAdapter(MainActivity activity) - { + private SearchListAdapter getListAdapter(MainActivity activity) { return (SearchListAdapter) activity.getListAdapter(MainActivity.ADAPTER_SEARCH); } - private ImageButton getQueriesButton(View page) - { + private ImageButton getQueriesButton(View page) { return (ImageButton) page.findViewById(R.id.button_search_queries); } - private ImageButton getSaveButton(View page) - { + private ImageButton getSaveButton(View page) { return (ImageButton) page.findViewById(R.id.button_search_save); } - private void hideIME() - { + private void hideIME() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); } - private void notifyTextEmpty(MainActivity activity) - { + private void notifyTextEmpty(MainActivity activity) { Notificator.publish(activity, R.string.notice_search_text_empty); } - private void openSearchQueryDialog(final MainActivity mainActivity) - { - if(SearchQuery.getAll().size() == 0) - { + private void openSearchQueryDialog(final MainActivity mainActivity) { + if (SearchQuery.getAll().size() == 0) { Notificator.publish(mainActivity, R.string.notice_no_query_exists); return; } - DialogHelper.showDialog(mainActivity, new SelectSearchQueryDialogFragment() - { + DialogHelper.showDialog(mainActivity, new SelectSearchQueryDialogFragment() { @Override - protected void deleteQuery(CommandOpenSearch command) - { + protected void deleteQuery(CommandOpenSearch command) { super.deleteQuery(command); - if(editText.getText().toString().contentEquals(command.getQuery().query)) - { + if (editText.getText().toString().contentEquals(command.getQuery().query)) { editText.setText(""); mainActivity.setLastSearch(""); - } - else - { + } else { mainActivity.setLastSearch(editText.getText().toString()); } } @Override - protected void executeCommand(Command command) - { + protected void executeCommand(Command command) { super.executeCommand(command); SearchQuery query = ((CommandOpenSearch) command).getQuery(); editText.setText(query.query); @@ -374,31 +322,22 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi }, SEARCH_QUERY_DIALOG); } - private void saveQuery() - { + private void saveQuery() { String text = editText.getText().toString(); - if(TextUtils.isEmpty(text)) - { + if (TextUtils.isEmpty(text)) { Notificator.publish(getMainActivity(), R.string.notice_query_is_empty, NotificationType.ALERT); - } - else - { + } else { SearchQuery.saveIfNotFound(text); Notificator.publish(getMainActivity(), R.string.notice_query_saved); } } - private void search() - { - if(editText != null) - { + private void search() { + if (editText != null) { String text = editText.getText().toString(); - if(TextUtils.isEmpty(text)) - { + if (TextUtils.isEmpty(text)) { Notificator.publish(getMainActivity(), R.string.notice_query_is_empty, NotificationType.ALERT); - } - else - { + } else { getMainActivity().openSearchPage(text); hideIME(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/SettingFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java index ebb1c290..006a43ba 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/SettingFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java @@ -32,6 +32,7 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; import android.text.TextUtils; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.LicenseActivity; import net.lacolaco.smileessence.entity.Account; @@ -44,8 +45,7 @@ import net.lacolaco.smileessence.view.dialog.SimpleDialogFragment; import static android.content.SharedPreferences.OnSharedPreferenceChangeListener; public class SettingFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener, - Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener -{ + Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener { // ------------------------ INTERFACE METHODS ------------------------ @@ -53,45 +53,31 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe // --------------------- Interface OnPreferenceChangeListener --------------------- @Override - public boolean onPreferenceChange(Preference preference, Object newValue) - { + public boolean onPreferenceChange(Preference preference, Object newValue) { String newValueStr = String.valueOf(newValue); - if(preference.getKey().contentEquals(getString(R.string.key_setting_text_size))) - { - if(TextUtils.isDigitsOnly(newValueStr)) - { + if (preference.getKey().contentEquals(getString(R.string.key_setting_text_size))) { + if (TextUtils.isDigitsOnly(newValueStr)) { int newTextSize = Integer.parseInt(newValueStr); - if(UserPreferenceHelper.TEXT_SIZE_MIN <= newTextSize && newTextSize <= UserPreferenceHelper.TEXT_SIZE_MAX) - { + if (UserPreferenceHelper.TEXT_SIZE_MIN <= newTextSize && newTextSize <= UserPreferenceHelper.TEXT_SIZE_MAX) { return true; } Notificator.publish(getActivity(), R.string.error_setting_text_size_range); - } - else - { + } else { Notificator.publish(getActivity(), R.string.error_setting_text_size_not_number); } return false; - } - else if(preference.getKey().contentEquals(getString(R.string.key_setting_timelines))) - { - if(TextUtils.isDigitsOnly(newValueStr)) - { + } else if (preference.getKey().contentEquals(getString(R.string.key_setting_timelines))) { + if (TextUtils.isDigitsOnly(newValueStr)) { int newTextSize = Integer.parseInt(newValueStr); - if(UserPreferenceHelper.TIMELINES_MIN <= newTextSize && newTextSize <= UserPreferenceHelper.TIMELINES_MAX) - { + if (UserPreferenceHelper.TIMELINES_MIN <= newTextSize && newTextSize <= UserPreferenceHelper.TIMELINES_MAX) { return true; } Notificator.publish(getActivity(), R.string.error_setting_timelines_range); - } - else - { + } else { Notificator.publish(getActivity(), R.string.error_setting_timelines_not_number); } return false; - } - else if(preference.getKey().contentEquals(getString(R.string.key_setting_theme))) - { + } else if (preference.getKey().contentEquals(getString(R.string.key_setting_theme))) { Notificator.publish(getActivity(), R.string.notice_theme_changed); } return true; @@ -100,31 +86,23 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe // --------------------- Interface OnPreferenceClickListener --------------------- @Override - public boolean onPreferenceClick(Preference preference) - { + public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); - if(key.contentEquals(getString(R.string.key_setting_application_information))) - { + if (key.contentEquals(getString(R.string.key_setting_application_information))) { SimpleDialogFragment informationDialog = SimpleDialogFragment.newInstance( R.layout.dialog_app_info, getString(R.string.dialog_title_about)); DialogHelper.showDialog(getActivity(), informationDialog); - } - else if(key.contentEquals(getString(R.string.key_setting_clear_account))) - { - ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_clear_account), new Runnable() - { + } else if (key.contentEquals(getString(R.string.key_setting_clear_account))) { + ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_clear_account), new Runnable() { @Override - public void run() - { + public void run() { Notificator.publish(getActivity(), R.string.notice_cleared_account); Account.deleteAll(); finishActivity(); } }, false); - } - else if(key.contentEquals(getString(R.string.key_setting_licenses))) - { + } else if (key.contentEquals(getString(R.string.key_setting_licenses))) { openLicenseActivity(); } return true; @@ -133,16 +111,14 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe // --------------------- Interface OnSharedPreferenceChangeListener --------------------- @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) - { + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { setSummaryCurrentValue(); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.setting); EditTextPreference textSizePreference = (EditTextPreference) findPreference(R.string.key_setting_text_size); @@ -165,16 +141,14 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe } @Override - public void onPause() - { + public void onPause() { super.onPause(); SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); sharedPreferences.unregisterOnSharedPreferenceChangeListener(this); } @Override - public void onResume() - { + public void onResume() { super.onResume(); SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); sharedPreferences.registerOnSharedPreferenceChangeListener(this); @@ -182,24 +156,20 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe // -------------------------- OTHER METHODS -------------------------- - public Preference findPreference(int preferenceResID) - { + public Preference findPreference(int preferenceResID) { return findPreference(getString(preferenceResID)); } - private void finishActivity() - { + private void finishActivity() { getActivity().finish(); } - private void openLicenseActivity() - { + private void openLicenseActivity() { Intent intent = new Intent(getActivity(), LicenseActivity.class); getActivity().startActivity(intent); } - private void setSummaryCurrentValue() - { + private void setSummaryCurrentValue() { EditTextPreference textSizePreference = (EditTextPreference) findPreference(R.string.key_setting_text_size); textSizePreference.setSummary(textSizePreference.getText()); ListPreference themePreference = (ListPreference) findPreference(R.string.key_setting_theme); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/TextFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/TextFragment.java index f0fec169..1293da28 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/TextFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/TextFragment.java @@ -32,8 +32,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -public class TextFragment extends Fragment -{ +public class TextFragment extends Fragment { // ------------------------------ FIELDS ------------------------------ @@ -42,15 +41,12 @@ public class TextFragment extends Fragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TextView textView = new TextView(getActivity()); Bundle args = getArguments(); - if(args != null) - { + if (args != null) { String text = args.getString(ARG_TEXT); - if(!TextUtils.isEmpty(text)) - { + if (!TextUtils.isEmpty(text)) { textView.setText(text); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/UserListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java index f2aaa823..6f8f1420 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/UserListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java @@ -33,8 +33,10 @@ import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; + import com.handmark.pulltorefresh.library.PullToRefreshBase; import com.handmark.pulltorefresh.library.PullToRefreshListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; @@ -48,11 +50,11 @@ import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.SelectUserListDialogFragment; import net.lacolaco.smileessence.viewmodel.StatusViewModel; import net.lacolaco.smileessence.viewmodel.UserListListAdapter; + import twitter4j.Paging; import twitter4j.Twitter; -public class UserListFragment extends CustomListFragment implements View.OnClickListener -{ +public class UserListFragment extends CustomListFragment implements View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -60,14 +62,12 @@ public class UserListFragment extends CustomListFragment implements View.OnClick // --------------------- GETTER / SETTER METHODS --------------------- - private MainActivity getMainActivity() - { + private MainActivity getMainActivity() { return (MainActivity) getActivity(); } @Override - protected PullToRefreshBase.Mode getRefreshMode() - { + protected PullToRefreshBase.Mode getRefreshMode() { return PullToRefreshBase.Mode.BOTH; } @@ -77,13 +77,10 @@ public class UserListFragment extends CustomListFragment implements View.OnClick // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(View v) - { + public void onClick(View v) { int id = v.getId(); - switch(id) - { - case R.id.button_userlist_lists: - { + switch (id) { + case R.id.button_userlist_lists: { openUserListsDialog(getMainActivity()); break; } @@ -93,20 +90,16 @@ public class UserListFragment extends CustomListFragment implements View.OnClick // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = getMainActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final UserListListAdapter adapter = getListAdapter(activity); String listFullName = adapter.getListFullName(); - if(TextUtils.isEmpty(listFullName)) - { - new UIHandler() - { + if (TextUtils.isEmpty(listFullName)) { + new UIHandler() { @Override - public void run() - { + public void run() { notifyTextEmpty(activity); refreshView.onRefreshComplete(); } @@ -114,18 +107,14 @@ public class UserListFragment extends CustomListFragment implements View.OnClick return; } Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new UserListStatusesTask(twitter, listFullName, activity, paging) - { + new UserListStatusesTask(twitter, listFullName, activity, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(int i = statuses.length - 1; i >= 0; i--) - { + for (int i = statuses.length - 1; i >= 0; i--) { twitter4j.Status status = statuses[i]; StatusViewModel statusViewModel = new StatusViewModel(status, activity.getCurrentAccount()); adapter.addToTop(statusViewModel); @@ -138,20 +127,16 @@ public class UserListFragment extends CustomListFragment implements View.OnClick } @Override - public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = getMainActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final UserListListAdapter adapter = getListAdapter(activity); String listFullName = adapter.getListFullName(); - if(TextUtils.isEmpty(listFullName)) - { - new UIHandler() - { + if (TextUtils.isEmpty(listFullName)) { + new UIHandler() { @Override - public void run() - { + public void run() { notifyTextEmpty(activity); refreshView.onRefreshComplete(); } @@ -159,18 +144,14 @@ public class UserListFragment extends CustomListFragment implements View.OnClick return; } Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new UserListStatusesTask(twitter, listFullName, activity, paging) - { + new UserListStatusesTask(twitter, listFullName, activity, paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(int i = 0; i < statuses.length; i++) - { + for (int i = 0; i < statuses.length; i++) { twitter4j.Status status = statuses[i]; StatusViewModel statusViewModel = new StatusViewModel(status, activity.getCurrentAccount()); adapter.addToBottom(statusViewModel); @@ -185,14 +166,12 @@ public class UserListFragment extends CustomListFragment implements View.OnClick // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected PullToRefreshListView getListView(View page) - { + protected PullToRefreshListView getListView(View page) { return (PullToRefreshListView) page.findViewById(R.id.listview_userlist); } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View page = inflater.inflate(R.layout.fragment_userlist, container, false); PullToRefreshListView listView = getListView(page); UserListListAdapter adapter = getListAdapter((MainActivity) getActivity()); @@ -207,33 +186,26 @@ public class UserListFragment extends CustomListFragment implements View.OnClick return page; } - private UserListListAdapter getListAdapter(MainActivity activity) - { + private UserListListAdapter getListAdapter(MainActivity activity) { return (UserListListAdapter) getListAdapter(MainActivity.ADAPTER_USERLIST); } - private TextView getTextListName(View page) - { + private TextView getTextListName(View page) { return (TextView) page.findViewById(R.id.textview_userlist_name); } - private ImageButton getUserListsButton(View page) - { + private ImageButton getUserListsButton(View page) { return (ImageButton) page.findViewById(R.id.button_userlist_lists); } - private void notifyTextEmpty(MainActivity activity) - { + private void notifyTextEmpty(MainActivity activity) { Notificator.publish(activity, R.string.notice_userlist_not_selected); } - private void openUserListsDialog(final MainActivity mainActivity) - { - DialogHelper.showDialog(mainActivity, new SelectUserListDialogFragment() - { + private void openUserListsDialog(final MainActivity mainActivity) { + DialogHelper.showDialog(mainActivity, new SelectUserListDialogFragment() { @Override - public void onDismiss(DialogInterface dialog) - { + public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); textListName.setText(getListAdapter(mainActivity).getListFullName()); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/CustomListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java index 3e598941..69c893e5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/CustomListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/CustomListAdapter.java @@ -28,7 +28,9 @@ import android.app.Activity; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; + import com.google.common.collect.Iterables; + import net.lacolaco.smileessence.util.UIHandler; import net.lacolaco.smileessence.viewmodel.IViewModel; @@ -37,8 +39,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -public class CustomListAdapter<T extends IViewModel> extends BaseAdapter -{ +public class CustomListAdapter<T extends IViewModel> extends BaseAdapter { // ------------------------------ FIELDS ------------------------------ @@ -52,37 +53,30 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter // --------------------------- CONSTRUCTORS --------------------------- - public CustomListAdapter(Activity activity, Class<T> clss) - { + public CustomListAdapter(Activity activity, Class<T> clss) { this.activity = activity; this.clss = clss; } // --------------------- GETTER / SETTER METHODS --------------------- - public Activity getActivity() - { + public Activity getActivity() { return activity; } @Override - public int getCount() - { + public int getCount() { return count; } - public boolean isNotifiable() - { - synchronized(LOCK) - { + public boolean isNotifiable() { + synchronized (LOCK) { return isNotifiable; } } - public void setNotifiable(boolean notifiable) - { - synchronized(LOCK) - { + public void setNotifiable(boolean notifiable) { + synchronized (LOCK) { isNotifiable = notifiable; } } @@ -93,28 +87,24 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter // --------------------- Interface Adapter --------------------- @Override - public Object getItem(int position) - { + public Object getItem(int position) { return array[position]; } @Override - public long getItemId(int position) - { + public long getItemId(int position) { return position; } @Override - public View getView(int position, View convertView, ViewGroup parent) - { + public View getView(int position, View convertView, ViewGroup parent) { return ((T) getItem(position)).getView(activity, activity.getLayoutInflater(), convertView); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void notifyDataSetChanged() - { + public void notifyDataSetChanged() { sort(); array = Iterables.toArray(list, clss); count = array.length; @@ -123,15 +113,11 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter // -------------------------- OTHER METHODS -------------------------- - public void addToBottom(T... items) - { - synchronized(LOCK) - { + public void addToBottom(T... items) { + synchronized (LOCK) { List<T> buffer = Arrays.asList(items); - for(T item : buffer) - { - if(list.contains(item)) - { + for (T item : buffer) { + if (list.contains(item)) { list.remove(item); } list.add(item); @@ -139,16 +125,12 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter } } - public void addToTop(T... items) - { - synchronized(LOCK) - { + public void addToTop(T... items) { + synchronized (LOCK) { List<T> buffer = Arrays.asList(items); Collections.reverse(buffer); - for(T item : buffer) - { - if(list.contains(item)) - { + for (T item : buffer) { + if (list.contains(item)) { list.remove(item); } list.add(0, item); @@ -156,51 +138,38 @@ public class CustomListAdapter<T extends IViewModel> extends BaseAdapter } } - public void clear() - { - synchronized(LOCK) - { + public void clear() { + synchronized (LOCK) { list.clear(); } } - public T removeItem(int position) - { - synchronized(LOCK) - { + public T removeItem(int position) { + synchronized (LOCK) { return list.remove(position); } } - public boolean removeItem(T item) - { - synchronized(LOCK) - { + public boolean removeItem(T item) { + synchronized (LOCK) { return list.remove(item); } } - public void sort() - { + public void sort() { } - public void update() - { - if(isNotifiable) - { + public void update() { + if (isNotifiable) { updateForce(); } } - public void updateForce() - { - synchronized(LOCK) - { - new UIHandler() - { + public void updateForce() { + synchronized (LOCK) { + new UIHandler() { @Override - public void run() - { + public void run() { notifyDataSetChanged(); } }.post(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/EventListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java index 5949d9b5..94762845 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/EventListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/EventListAdapter.java @@ -25,15 +25,14 @@ package net.lacolaco.smileessence.view.adapter; import android.app.Activity; + import net.lacolaco.smileessence.viewmodel.EventViewModel; -public class EventListAdapter extends CustomListAdapter<EventViewModel> -{ +public class EventListAdapter extends CustomListAdapter<EventViewModel> { // --------------------------- CONSTRUCTORS --------------------------- - public EventListAdapter(Activity activity) - { + public EventListAdapter(Activity activity) { super(activity, EventViewModel.class); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/MessageListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java index f88a8cb0..7c6b992d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/MessageListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/MessageListAdapter.java @@ -25,43 +25,37 @@ package net.lacolaco.smileessence.view.adapter; import android.app.Activity; + import net.lacolaco.smileessence.viewmodel.MessageViewModel; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; -public class MessageListAdapter extends CustomListAdapter<MessageViewModel> -{ +public class MessageListAdapter extends CustomListAdapter<MessageViewModel> { // --------------------------- CONSTRUCTORS --------------------------- - public MessageListAdapter(Activity activity) - { + public MessageListAdapter(Activity activity) { super(activity, MessageViewModel.class); } // --------------------- GETTER / SETTER METHODS --------------------- - public long getLastID() - { + public long getLastID() { return ((MessageViewModel) getItem(getCount() - 1)).getID(); } - public long getTopID() - { + public long getTopID() { return ((MessageViewModel) getItem(0)).getID(); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void addToBottom(MessageViewModel... items) - { - for(MessageViewModel item : items) - { - if(!preAdd(item)) - { + public void addToBottom(MessageViewModel... items) { + for (MessageViewModel item : items) { + if (!preAdd(item)) { continue; } super.addToBottom(items); @@ -69,12 +63,9 @@ public class MessageListAdapter extends CustomListAdapter<MessageViewModel> } @Override - public void addToTop(MessageViewModel... items) - { - for(MessageViewModel item : items) - { - if(!preAdd(item)) - { + public void addToTop(MessageViewModel... items) { + for (MessageViewModel item : items) { + if (!preAdd(item)) { continue; } super.addToTop(items); @@ -82,15 +73,11 @@ public class MessageListAdapter extends CustomListAdapter<MessageViewModel> } @Override - public void sort() - { - synchronized(LOCK) - { - Collections.sort(list, new Comparator<MessageViewModel>() - { + public void sort() { + synchronized (LOCK) { + Collections.sort(list, new Comparator<MessageViewModel>() { @Override - public int compare(MessageViewModel lhs, MessageViewModel rhs) - { + public int compare(MessageViewModel lhs, MessageViewModel rhs) { return rhs.getCreatedAt().compareTo(lhs.getCreatedAt()); } }); @@ -99,16 +86,12 @@ public class MessageListAdapter extends CustomListAdapter<MessageViewModel> // -------------------------- OTHER METHODS -------------------------- - public MessageViewModel removeByMessageID(long messageID) - { - synchronized(this.LOCK) - { + public MessageViewModel removeByMessageID(long messageID) { + synchronized (this.LOCK) { Iterator<MessageViewModel> iterator = this.list.iterator(); - while(iterator.hasNext()) - { + while (iterator.hasNext()) { MessageViewModel message = iterator.next(); - if(message.getID() == messageID) - { + if (message.getID() == messageID) { iterator.remove(); return message; } @@ -117,8 +100,7 @@ public class MessageListAdapter extends CustomListAdapter<MessageViewModel> } } - private boolean preAdd(MessageViewModel item) - { + private boolean preAdd(MessageViewModel item) { removeByMessageID(item.getID()); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/PageListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java index c1966a00..7c6cab9a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/PageListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java @@ -30,6 +30,7 @@ import android.os.Bundle; import android.support.v13.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.widget.ArrayAdapter; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.logging.Logger; @@ -37,8 +38,7 @@ import net.lacolaco.smileessence.logging.Logger; import java.util.ArrayList; public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPager.OnPageChangeListener, - ActionBar.OnNavigationListener -{ + ActionBar.OnNavigationListener { // ------------------------------ FIELDS ------------------------------ @@ -49,8 +49,7 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa // --------------------------- CONSTRUCTORS --------------------------- - public PageListAdapter(MainActivity activity, ViewPager viewPager) - { + public PageListAdapter(MainActivity activity, ViewPager viewPager) { super(activity.getFragmentManager()); this.context = activity; this.actionBar = activity.getActionBar(); @@ -62,8 +61,7 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa // --------------------- GETTER / SETTER METHODS --------------------- @Override - public synchronized int getCount() - { + public synchronized int getCount() { return pages.size(); } @@ -73,8 +71,7 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa // --------------------- Interface OnNavigationListener --------------------- @Override - public synchronized boolean onNavigationItemSelected(int itemPosition, long itemId) - { + public synchronized boolean onNavigationItemSelected(int itemPosition, long itemId) { viewPager.setCurrentItem(itemPosition, true); return true; } @@ -82,21 +79,18 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa // --------------------- Interface OnPageChangeListener --------------------- @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) - { + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override - public synchronized void onPageSelected(int position) - { + public synchronized void onPageSelected(int position) { //Synchronize pager and navigation. Logger.debug(String.format("Page selected:%d", position)); actionBar.setSelectedNavigationItem(position); } @Override - public void onPageScrollStateChanged(int state) - { + public void onPageScrollStateChanged(int state) { } // -------------------------- OTHER METHODS -------------------------- @@ -109,10 +103,8 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa * @param args Bundle for Fragment instantiate * @return True if adding is complete successfully */ - public synchronized boolean addPage(String name, Class<? extends Fragment> clss, Bundle args) - { - if(addPageWithoutNotify(name, clss, args)) - { + public synchronized boolean addPage(String name, Class<? extends Fragment> clss, Bundle args) { + if (addPageWithoutNotify(name, clss, args)) { refreshListNavigation(); return true; } @@ -128,29 +120,24 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa * @param args Bundle for Fragment instantiate * @return True if adding is complete successfully */ - public synchronized boolean addPageWithoutNotify(String name, Class<? extends Fragment> clss, Bundle args) - { + public synchronized boolean addPageWithoutNotify(String name, Class<? extends Fragment> clss, Bundle args) { PageInfo info = new PageInfo(name, clss, args); return pages.add(info); } @Override - public synchronized Fragment getItem(int position) - { + public synchronized Fragment getItem(int position) { PageInfo info = pages.get(position); return Fragment.instantiate(context, info.fragmentClass.getName(), info.args); } - public synchronized PageInfo getPage(int position) - { + public synchronized PageInfo getPage(int position) { return pages.get(position); } - public synchronized void refreshListNavigation() - { + public synchronized void refreshListNavigation() { ArrayList<String> itemList = new ArrayList<>(); - for(PageInfo page : pages) - { + for (PageInfo page : pages) { itemList.add(page.name); } ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.navigation_list_item, R.id.navigation_list_item_text, itemList); @@ -158,49 +145,41 @@ public class PageListAdapter extends FragmentStatePagerAdapter implements ViewPa notifyDataSetChanged(); } - public synchronized boolean removePage(int position) - { - if(removePageWithoutNotify(position)) - { + public synchronized boolean removePage(int position) { + if (removePageWithoutNotify(position)) { refreshListNavigation(); return true; } return false; } - private synchronized boolean removePageWithoutNotify(int position) - { + private synchronized boolean removePageWithoutNotify(int position) { return pages.remove(position) != null; } // -------------------------- INNER CLASSES -------------------------- - public static final class PageInfo - { + public static final class PageInfo { private final String name; private final Class<? extends Fragment> fragmentClass; private final Bundle args; - PageInfo(String name, Class<? extends Fragment> clss, Bundle args) - { + PageInfo(String name, Class<? extends Fragment> clss, Bundle args) { this.name = name; this.fragmentClass = clss; this.args = args; } - public String getName() - { + public String getName() { return name; } - public Class<? extends Fragment> getFragmentClass() - { + public Class<? extends Fragment> getFragmentClass() { return fragmentClass; } - public Bundle getArgs() - { + public Bundle getArgs() { return args; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/PostState.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/PostState.java index f7e0fa0f..c3810408 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/PostState.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/PostState.java @@ -26,10 +26,10 @@ package net.lacolaco.smileessence.view.adapter; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.view.dialog.DialogHelper; + import twitter4j.StatusUpdate; -public class PostState -{ +public class PostState { // ------------------------------ FIELDS ------------------------------ @@ -46,72 +46,59 @@ public class PostState // -------------------------- STATIC METHODS -------------------------- - private PostState() - { + private PostState() { } - public static PostState getState() - { + public static PostState getState() { return instance; } // --------------------------- CONSTRUCTORS --------------------------- - public static PostState newState() - { + public static PostState newState() { return instance = new PostState().setListener(instance.listener); } // --------------------- GETTER / SETTER METHODS --------------------- - public long getInReplyToStatusID() - { + public long getInReplyToStatusID() { return inReplyToStatusID; } - public String getMediaFilePath() - { + public String getMediaFilePath() { return mediaFilePath; } - public int getSelectionEnd() - { - if(selectionEnd < 0) - { + public int getSelectionEnd() { + if (selectionEnd < 0) { return text.length(); } return selectionEnd; } - public int getSelectionStart() - { - if(selectionStart < 0) - { + public int getSelectionStart() { + if (selectionStart < 0) { return text.length(); } return selectionStart; } - public String getText() - { + public String getText() { return text; } - public PostState setListener(OnPostStateChangeListener listener) - { + public PostState setListener(OnPostStateChangeListener listener) { this.listener = listener; return this; } // -------------------------- OTHER METHODS -------------------------- - public PostStateTransaction beginTransaction() - { + public PostStateTransaction beginTransaction() { return new PostStateTransaction(this); } - public void removeListener() - { + public void removeListener() { this.listener = null; } @@ -120,14 +107,12 @@ public class PostState * * @return StatusUpdate */ - public StatusUpdate toStatusUpdate() - { + public StatusUpdate toStatusUpdate() { return new StatusUpdate(getText()) .inReplyToStatusId(getInReplyToStatusID()); } - private PostState copy(PostState another) - { + private PostState copy(PostState another) { this.text = another.text; this.inReplyToStatusID = another.inReplyToStatusID; this.inReplyToScreenName = another.inReplyToScreenName; @@ -140,91 +125,76 @@ public class PostState return this; } - private void postStateChange() - { - if(listener != null) - { + private void postStateChange() { + if (listener != null) { listener.onPostStateChange(this); } } // -------------------------- INNER CLASSES -------------------------- - public static interface OnPostStateChangeListener - { + public static interface OnPostStateChangeListener { void onPostStateChange(PostState postState); } - public static class PostStateTransaction - { + public static class PostStateTransaction { private PostState state; - private PostStateTransaction(PostState state) - { + private PostStateTransaction(PostState state) { this.state = new PostState().copy(state); } - public PostStateTransaction setText(String text) - { + public PostStateTransaction setText(String text) { state.text = text; return this; } - public PostStateTransaction appendText(String text) - { + public PostStateTransaction appendText(String text) { state.text = state.text + text; return this; } - public PostStateTransaction insertText(int index, String text) - { + public PostStateTransaction insertText(int index, String text) { StringBuilder builder = new StringBuilder(state.text); builder.insert(index, text); state.text = builder.toString(); return this; } - public PostStateTransaction setInReplyToStatusID(long inReplyToStatusID) - { + public PostStateTransaction setInReplyToStatusID(long inReplyToStatusID) { state.inReplyToStatusID = inReplyToStatusID; return this; } - public PostStateTransaction setMediaFilePath(String mediaFilePath) - { + public PostStateTransaction setMediaFilePath(String mediaFilePath) { state.mediaFilePath = mediaFilePath; return this; } - public PostStateTransaction setCursor(int cursor) - { + public PostStateTransaction setCursor(int cursor) { state.selectionStart = state.selectionEnd = cursor; return this; } - public PostStateTransaction setSelection(int start, int end) - { + public PostStateTransaction setSelection(int start, int end) { state.selectionStart = start; state.selectionEnd = end; return this; } - public void commit() - { + public void commit() { PostState.getState().copy(state).postStateChange(); } - public void commitWithOpen(MainActivity activity) - { + public void commitWithOpen(MainActivity activity) { DialogHelper.closeAll(activity); PostState.getState().copy(state).postStateChange(); activity.openPostPage(); } - public PostStateTransaction moveCursor(int length) - { + public PostStateTransaction moveCursor(int length) { int cursor = state.selectionEnd + length; return setCursor(cursor); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/SearchListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/SearchListAdapter.java index 178bb7f1..20a5971a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/SearchListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/SearchListAdapter.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.view.adapter; import android.app.Activity; -public class SearchListAdapter extends StatusListAdapter -{ +public class SearchListAdapter extends StatusListAdapter { // ------------------------------ FIELDS ------------------------------ @@ -37,55 +36,46 @@ public class SearchListAdapter extends StatusListAdapter // --------------------------- CONSTRUCTORS --------------------------- - public SearchListAdapter(Activity activity) - { + public SearchListAdapter(Activity activity) { super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- - public OnQueryChangeListener getListener() - { + public OnQueryChangeListener getListener() { return listener; } - public String getQuery() - { + public String getQuery() { return query; } @Override - public long getTopID() - { + public long getTopID() { return topID; } - public void setTopID(long topID) - { + public void setTopID(long topID) { this.topID = topID; } - public void setOnQueryChangeListener(OnQueryChangeListener listener) - { + public void setOnQueryChangeListener(OnQueryChangeListener listener) { this.listener = listener; } // -------------------------- OTHER METHODS -------------------------- - public void initSearch(String query) - { + public void initSearch(String query) { this.query = query; topID = 0; - if(listener != null) - { + if (listener != null) { listener.onQueryChange(query); } } // -------------------------- INNER CLASSES -------------------------- - public static interface OnQueryChangeListener - { + public static interface OnQueryChangeListener { void onQueryChange(String newQuery); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/StatusListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java index 7ab5287f..80c60b94 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/adapter/StatusListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/StatusListAdapter.java @@ -25,6 +25,7 @@ package net.lacolaco.smileessence.view.adapter; import android.app.Activity; + import net.lacolaco.smileessence.data.UserCache; import net.lacolaco.smileessence.viewmodel.StatusViewModel; @@ -32,37 +33,30 @@ import java.util.Collections; import java.util.Comparator; import java.util.Iterator; -public class StatusListAdapter extends CustomListAdapter<StatusViewModel> -{ +public class StatusListAdapter extends CustomListAdapter<StatusViewModel> { // --------------------------- CONSTRUCTORS --------------------------- - public StatusListAdapter(Activity activity) - { + public StatusListAdapter(Activity activity) { super(activity, StatusViewModel.class); } // --------------------- GETTER / SETTER METHODS --------------------- - public long getLastID() - { + public long getLastID() { return ((StatusViewModel) getItem(getCount() - 1)).getID(); } - public long getTopID() - { + public long getTopID() { return ((StatusViewModel) getItem(0)).getID(); } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void addToBottom(StatusViewModel... items) - { - for(StatusViewModel item : items) - { - if(!preAdd(item)) - { + public void addToBottom(StatusViewModel... items) { + for (StatusViewModel item : items) { + if (!preAdd(item)) { continue; } super.addToBottom(item); @@ -70,12 +64,9 @@ public class StatusListAdapter extends CustomListAdapter<StatusViewModel> } @Override - public void addToTop(StatusViewModel... items) - { - for(StatusViewModel item : items) - { - if(!preAdd(item)) - { + public void addToTop(StatusViewModel... items) { + for (StatusViewModel item : items) { + if (!preAdd(item)) { continue; } super.addToTop(item); @@ -86,15 +77,11 @@ public class StatusListAdapter extends CustomListAdapter<StatusViewModel> * Sort list by Status#createdAt */ @Override - public void sort() - { - synchronized(LOCK) - { - Collections.sort(list, new Comparator<StatusViewModel>() - { + public void sort() { + synchronized (LOCK) { + Collections.sort(list, new Comparator<StatusViewModel>() { @Override - public int compare(StatusViewModel lhs, StatusViewModel rhs) - { + public int compare(StatusViewModel lhs, StatusViewModel rhs) { return Long.valueOf(rhs.getID()).compareTo(lhs.getID()); } }); @@ -103,29 +90,23 @@ public class StatusListAdapter extends CustomListAdapter<StatusViewModel> // -------------------------- OTHER METHODS -------------------------- - public void removeByStatusID(long statusID) - { - synchronized(this.LOCK) - { + public void removeByStatusID(long statusID) { + synchronized (this.LOCK) { Iterator<StatusViewModel> iterator = this.list.iterator(); - while(iterator.hasNext()) - { + while (iterator.hasNext()) { StatusViewModel statusViewModel = iterator.next(); - if(statusViewModel.getID() == statusID || statusViewModel.getOriginal().getID() == statusID) - { + if (statusViewModel.getID() == statusID || statusViewModel.getOriginal().getID() == statusID) { iterator.remove(); } } } } - private boolean isBlockUser(StatusViewModel item) - { + private boolean isBlockUser(StatusViewModel item) { return UserCache.getInstance().isInvisibleUserID(item.getOriginalUserID()); } - private boolean preAdd(StatusViewModel item) - { + private boolean preAdd(StatusViewModel item) { removeByStatusID(item.getID()); return !isBlockUser(item); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ChooseTemplateDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/ChooseTemplateDialogFragment.java index ceceb6e8..425e95c7 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ChooseTemplateDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/ChooseTemplateDialogFragment.java @@ -30,6 +30,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -41,14 +42,12 @@ import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import java.util.ArrayList; import java.util.List; -public class ChooseTemplateDialogFragment extends MenuDialogFragment -{ +public class ChooseTemplateDialogFragment extends MenuDialogFragment { // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); Account account = activity.getCurrentAccount(); List<Command> commands = getCommands(activity); @@ -56,8 +55,7 @@ public class ChooseTemplateDialogFragment extends MenuDialogFragment ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); listView.setAdapter(adapter); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); @@ -71,12 +69,10 @@ public class ChooseTemplateDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(Activity activity) - { + public List<Command> getCommands(Activity activity) { ArrayList<Command> list = new ArrayList<>(); List<Template> templates = Template.getAll(); - for(Template template : templates) - { + for (Template template : templates) { list.add(new PostCommandUseTemplate(activity, template)); } return list; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ConfirmDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/ConfirmDialogFragment.java index 822f607f..ec9c512a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ConfirmDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/ConfirmDialogFragment.java @@ -30,21 +30,19 @@ import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; import android.os.Bundle; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.preference.UserPreferenceHelper; -public abstract class ConfirmDialogFragment extends DialogFragment -{ +public abstract class ConfirmDialogFragment extends DialogFragment { // ------------------------------ FIELDS ------------------------------ public static final String ARG_TEXT = "text"; public static final String TAG = "confirmDialog"; - private final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() - { + private final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) - { + public void onClick(DialogInterface dialog, int which) { onButtonClick(which); dialog.dismiss(); } @@ -54,44 +52,33 @@ public abstract class ConfirmDialogFragment extends DialogFragment // -------------------------- STATIC METHODS -------------------------- - public static void show(Activity activity, String text, final Runnable onYes) - { + public static void show(Activity activity, String text, final Runnable onYes) { show(activity, text, onYes, null, true); } - public static void show(Activity activity, String text, final Runnable onYes, boolean ignorable) - { + public static void show(Activity activity, String text, final Runnable onYes, boolean ignorable) { show(activity, text, onYes, null, ignorable); } - public static void show(Activity activity, String text, final Runnable onOK, final Runnable onCancel, boolean ignorable) - { + public static void show(Activity activity, String text, final Runnable onOK, final Runnable onCancel, boolean ignorable) { boolean confirm = new UserPreferenceHelper(activity).getValue(R.string.key_setting_show_confirm_dialog, true); - if(!confirm && ignorable) - { + if (!confirm && ignorable) { onOK.run(); return; } - final ConfirmDialogFragment fragment = new ConfirmDialogFragment() - { + final ConfirmDialogFragment fragment = new ConfirmDialogFragment() { @Override - public void onButtonClick(int which) - { - switch(which) - { - case DialogInterface.BUTTON_POSITIVE: - { - if(onOK != null) - { + public void onButtonClick(int which) { + switch (which) { + case DialogInterface.BUTTON_POSITIVE: { + if (onOK != null) { this.dismiss(); onOK.run(); } break; } - case DialogInterface.BUTTON_NEGATIVE: - { - if(onCancel != null) - { + case DialogInterface.BUTTON_NEGATIVE: { + if (onCancel != null) { this.dismiss(); onCancel.run(); } @@ -106,8 +93,7 @@ public abstract class ConfirmDialogFragment extends DialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - public void setText(String text) - { + public void setText(String text) { Bundle args = new Bundle(); args.putString(ARG_TEXT, text); setArguments(args); @@ -116,24 +102,21 @@ public abstract class ConfirmDialogFragment extends DialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - if(args != null) - { + if (args != null) { text = args.getString(ARG_TEXT); } } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()).setTitle(text) - .setCancelable(false) - .setPositiveButton(R.string.alert_dialog_ok, listener) - .setNegativeButton(R.string.alert_dialog_cancel, listener) - .create(); + .setCancelable(false) + .setPositiveButton(R.string.alert_dialog_ok, listener) + .setNegativeButton(R.string.alert_dialog_cancel, listener) + .create(); } // -------------------------- OTHER METHODS -------------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/DialogHelper.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/DialogHelper.java index fa87f681..20e229e2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/DialogHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/DialogHelper.java @@ -30,8 +30,7 @@ import android.app.FragmentTransaction; import java.util.Stack; -public class DialogHelper -{ +public class DialogHelper { // ------------------------------ FIELDS ------------------------------ @@ -43,39 +42,33 @@ public class DialogHelper // -------------------------- STATIC METHODS -------------------------- - public DialogHelper(Activity activity, DialogFragment dialogFragment) - { + public DialogHelper(Activity activity, DialogFragment dialogFragment) { this.activity = activity; this.dialogFragment = dialogFragment; } - public static void closeDialog(Activity activity) - { + public static void closeDialog(Activity activity) { close(activity, TAG_DIALOG); } /** * Close all stacked dialog */ - public static void closeAll(Activity activity) - { - while(dialogStack.size() > 0) - { + public static void closeAll(Activity activity) { + while (dialogStack.size() > 0) { String tag = dialogStack.pop(); close(activity, tag); } } - public static void showDialog(Activity activity, DialogFragment dialogFragment) - { + public static void showDialog(Activity activity, DialogFragment dialogFragment) { showDialog(activity, dialogFragment, TAG_DIALOG); } /** * Please expressly closing */ - public static void showDialog(Activity activity, DialogFragment dialogFragment, String tag) - { + public static void showDialog(Activity activity, DialogFragment dialogFragment, String tag) { close(activity, tag); dialogStack.push(tag); dialogFragment.show(activity.getFragmentManager().beginTransaction(), tag); @@ -83,14 +76,11 @@ public class DialogHelper // --------------------------- CONSTRUCTORS --------------------------- - public static void close(Activity activity, String tag) - { - if(activity != null) - { + public static void close(Activity activity, String tag) { + if (activity != null) { FragmentTransaction transaction = activity.getFragmentManager().beginTransaction(); DialogFragment oldDialog = (DialogFragment) activity.getFragmentManager().findFragmentByTag(tag); - if(oldDialog != null) - { + if (oldDialog != null) { transaction.remove(oldDialog); // oldDialog.dismiss(); } @@ -101,8 +91,7 @@ public class DialogHelper // -------------------------- OTHER METHODS -------------------------- - public void show() - { + public void show() { showDialog(activity, dialogFragment); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/DisposeDialog.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/DisposeDialog.java index 1d9ef1d0..1dbbf057 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/DisposeDialog.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/DisposeDialog.java @@ -30,27 +30,22 @@ import android.content.Context; /** * Dialog for dispose soon. */ -public final class DisposeDialog extends Dialog -{ +public final class DisposeDialog extends Dialog { - public DisposeDialog(Context context) - { + public DisposeDialog(Context context) { super(context); } - public DisposeDialog(Context context, int theme) - { + public DisposeDialog(Context context, int theme) { super(context, theme); } - protected DisposeDialog(Context context, boolean cancelable, OnCancelListener cancelListener) - { + protected DisposeDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { super(context, cancelable, cancelListener); } @Override - public void show() - { + public void show() { dismiss(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/EditTextDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/EditTextDialogFragment.java index 763467ba..23211a8d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/EditTextDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/EditTextDialogFragment.java @@ -31,10 +31,10 @@ import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.EditText; + import net.lacolaco.smileessence.R; -public abstract class EditTextDialogFragment extends DialogFragment -{ +public abstract class EditTextDialogFragment extends DialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -46,8 +46,7 @@ public abstract class EditTextDialogFragment extends DialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); text = args.getString(textKey); @@ -55,28 +54,23 @@ public abstract class EditTextDialogFragment extends DialogFragment } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.part_edittext, null); - final EditText editText = (EditText) view.findViewById(R.id.part_editText); + final EditText editText = (EditText) view.findViewById(R.id.part_edittext); editText.setText(text); return new AlertDialog.Builder(getActivity()) .setTitle(title) .setView(view) - .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() - { + .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) - { + public void onClick(DialogInterface dialog, int which) { onTextInput(editText.getText().toString()); dialog.dismiss(); } }) - .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() - { + .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) - { + public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) @@ -87,8 +81,7 @@ public abstract class EditTextDialogFragment extends DialogFragment public abstract void onTextInput(String text); - public void setParams(String title, String text) - { + public void setParams(String title, String text) { Bundle args = new Bundle(); args.putString(titleKey, title); args.putString(textKey, text); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/HashtagDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/HashtagDialogFragment.java index 7a38c855..3ba8ee5e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/HashtagDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/HashtagDialogFragment.java @@ -30,6 +30,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -42,8 +43,7 @@ import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import java.util.ArrayList; import java.util.List; -public class HashtagDialogFragment extends MenuDialogFragment -{ +public class HashtagDialogFragment extends MenuDialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -51,13 +51,11 @@ public class HashtagDialogFragment extends MenuDialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - private String getHashtagText() - { + private String getHashtagText() { return "#" + (String) getArguments().get(KEY_TEXT); } - public void setText(String text) - { + public void setText(String text) { Bundle bundle = new Bundle(); bundle.putString(KEY_TEXT, text); setArguments(bundle); @@ -66,8 +64,7 @@ public class HashtagDialogFragment extends MenuDialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); Account account = activity.getCurrentAccount(); String text = getHashtagText(); @@ -77,8 +74,7 @@ public class HashtagDialogFragment extends MenuDialogFragment ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); listView.setAdapter(adapter); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); @@ -89,8 +85,7 @@ public class HashtagDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(Activity activity, String text) - { + public List<Command> getCommands(Activity activity, String text) { ArrayList<Command> commands = new ArrayList<>(); commands.add(new CommandSaveAsTemplate(activity, text)); commands.add(new CommandPasteToPost(activity, text)); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java index 7282e366..63d06bb1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MenuDialogFragment.java @@ -27,51 +27,40 @@ package net.lacolaco.smileessence.view.dialog; import android.app.DialogFragment; import android.view.View; import android.widget.AdapterView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.command.Command; import net.lacolaco.smileessence.command.IConfirmable; -public abstract class MenuDialogFragment extends DialogFragment -{ +public abstract class MenuDialogFragment extends DialogFragment { // ------------------------------ FIELDS ------------------------------ - protected final AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() - { + protected final AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() { @Override - public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) - { + public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { MenuDialogFragment.this.onItemClick(adapterView, i); } }; - protected void executeCommand(Command command) - { - if(command.execute()) - { + protected void executeCommand(Command command) { + if (command.execute()) { dismiss(); DialogHelper.closeAll(getActivity()); } } - protected void onItemClick(AdapterView<?> adapterView, int i) - { + protected void onItemClick(AdapterView<?> adapterView, int i) { final Command command = (Command) adapterView.getItemAtPosition(i); - if(command != null) - { - if(command instanceof IConfirmable) - { - ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_commands), new Runnable() - { + if (command != null) { + if (command instanceof IConfirmable) { + ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_commands), new Runnable() { @Override - public void run() - { + public void run() { executeCommand(command); } }); - } - else - { + } else { executeCommand(command); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MessageDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java index bc4193c2..eb846196 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MessageDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java @@ -34,7 +34,9 @@ import android.view.View; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.ListView; + import com.google.common.collect.Lists; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -48,6 +50,7 @@ import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.MessageListAdapter; import net.lacolaco.smileessence.view.listener.ListItemClickListener; import net.lacolaco.smileessence.viewmodel.MessageViewModel; + import twitter4j.DirectMessage; import twitter4j.MediaEntity; import twitter4j.URLEntity; @@ -56,8 +59,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -public class MessageDetailDialogFragment extends DialogFragment implements View.OnClickListener -{ +public class MessageDetailDialogFragment extends DialogFragment implements View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -65,13 +67,11 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. // --------------------- GETTER / SETTER METHODS --------------------- - public long getMessageID() - { + public long getMessageID() { return getArguments().getLong(KEY_MESSAGE_ID); } - public void setMessageID(long messageID) - { + public void setMessageID(long messageID) { Bundle args = new Bundle(); args.putLong(KEY_MESSAGE_ID, messageID); setArguments(args); @@ -83,42 +83,33 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(final View v) - { + public void onClick(final View v) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); - TwitterUtils.tryGetMessage(account, getMessageID(), new TwitterUtils.MessageCallback() - { + TwitterUtils.tryGetMessage(account, getMessageID(), new TwitterUtils.MessageCallback() { @Override - public void success(DirectMessage message) - { - switch(v.getId()) - { - case R.id.button_status_detail_reply: - { + public void success(DirectMessage message) { + switch (v.getId()) { + case R.id.button_status_detail_reply: { openSendMessageDialog(message); break; } - case R.id.button_status_detail_delete: - { + case R.id.button_status_detail_delete: { deleteMessage(account, message); break; } - case R.id.button_status_detail_menu: - { + case R.id.button_status_detail_menu: { openMenu(activity); break; } - default: - { + default: { dismiss(); } } } @Override - public void error() - { + public void error() { } }); @@ -127,14 +118,12 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); DirectMessage selectedMessage = DirectMessageCache.getInstance().get(getMessageID()); - if(selectedMessage == null) - { + if (selectedMessage == null) { Notificator.publish(getActivity(), R.string.notice_error_get_messages); return new DisposeDialog(getActivity()); } @@ -144,49 +133,37 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. listView.setAdapter(adapter); long replyToMessageId = -1; ArrayList<DirectMessage> allMessages = Lists.newArrayList(DirectMessageCache.getInstance().all()); - Collections.sort(allMessages, new Comparator<DirectMessage>() - { + Collections.sort(allMessages, new Comparator<DirectMessage>() { @Override - public int compare(DirectMessage lhs, DirectMessage rhs) - { + public int compare(DirectMessage lhs, DirectMessage rhs) { return rhs.getCreatedAt().compareTo(lhs.getCreatedAt()); } }); - for(DirectMessage directMessage : allMessages) - { - if(selectedMessage.getId() == directMessage.getId()) - { + for (DirectMessage directMessage : allMessages) { + if (selectedMessage.getId() == directMessage.getId()) { continue; } - if(directMessage.getCreatedAt().getTime() > selectedMessage.getCreatedAt().getTime()) - { + if (directMessage.getCreatedAt().getTime() > selectedMessage.getCreatedAt().getTime()) { continue; } - if(directMessage.getSenderId() == selectedMessage.getRecipientId() && directMessage.getRecipientId() == selectedMessage.getSenderId()) - { + if (directMessage.getSenderId() == selectedMessage.getRecipientId() && directMessage.getRecipientId() == selectedMessage.getSenderId()) { replyToMessageId = directMessage.getId(); break; } } - if(replyToMessageId == -1) - { + if (replyToMessageId == -1) { listView.setVisibility(View.GONE); - } - else - { - TwitterUtils.tryGetMessage(account, replyToMessageId, new TwitterUtils.MessageCallback() - { + } else { + TwitterUtils.tryGetMessage(account, replyToMessageId, new TwitterUtils.MessageCallback() { @Override - public void success(DirectMessage message) - { + public void success(DirectMessage message) { adapter.addToTop(new MessageViewModel(message, account)); adapter.updateForce(); } @Override - public void error() - { + public void error() { } }); @@ -196,59 +173,46 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. // -------------------------- OTHER METHODS -------------------------- - public void deleteMessage(final Account account, final DirectMessage message) - { - ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_commands), new Runnable() - { + public void deleteMessage(final Account account, final DirectMessage message) { + ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_commands), new Runnable() { @Override - public void run() - { + public void run() { new DeleteMessageTask(new TwitterApi(account).getTwitter(), message.getId(), getActivity()).execute(); dismiss(); } }); } - public void openSendMessageDialog(DirectMessage message) - { + public void openSendMessageDialog(DirectMessage message) { SendMessageDialogFragment dialogFragment = new SendMessageDialogFragment(); dialogFragment.setScreenName(message.getSenderScreenName()); DialogHelper.showDialog(getActivity(), dialogFragment); } - private ArrayList<Command> getCommands(Activity activity, DirectMessage message, Account account) - { + private ArrayList<Command> getCommands(Activity activity, DirectMessage message, Account account) { ArrayList<Command> commands = new ArrayList<>(); // URL - if(message.getURLEntities() != null) - { - for(URLEntity urlEntity : message.getURLEntities()) - { + if (message.getURLEntities() != null) { + for (URLEntity urlEntity : message.getURLEntities()) { commands.add(new CommandOpenURL(activity, urlEntity.getExpandedURL())); } } - for(MediaEntity mediaEntity : getMediaEntities(message)) - { + for (MediaEntity mediaEntity : getMediaEntities(message)) { commands.add(new CommandOpenURL(activity, mediaEntity.getMediaURL())); } return commands; } - private MediaEntity[] getMediaEntities(DirectMessage message) - { - if(message.getExtendedMediaEntities().length == 0) - { + private MediaEntity[] getMediaEntities(DirectMessage message) { + if (message.getExtendedMediaEntities().length == 0) { // direct message's media is contained also in url entities. return new MediaEntity[0]; - } - else - { + } else { return message.getExtendedMediaEntities(); } } - private View getTitleView(MainActivity activity, Account account, DirectMessage message) - { + private View getTitleView(MainActivity activity, Account account, DirectMessage message) { View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null); View messageHeader = view.findViewById(R.id.layout_status_header); MessageViewModel statusViewModel = new MessageViewModel(message, account); @@ -268,15 +232,12 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. // commands ArrayList<Command> commands = getCommands(activity, message, account); Command.filter(commands); - for(final Command command : commands) - { + for (final Command command : commands) { View commandView = command.getView(activity, activity.getLayoutInflater(), null); commandView.setBackgroundColor(getResources().getColor(R.color.transparent)); - commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() - { + commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override - public void run() - { + public void run() { command.execute(); dismiss(); } @@ -291,13 +252,11 @@ public class MessageDetailDialogFragment extends DialogFragment implements View. return view; } - private boolean isDeletable(Account account, DirectMessage message) - { + private boolean isDeletable(Account account, DirectMessage message) { return message.getSenderId() == account.userID; } - private void openMenu(MainActivity activity) - { + private void openMenu(MainActivity activity) { MessageMenuDialogFragment fragment = new MessageMenuDialogFragment(); fragment.setMessageID(getMessageID()); DialogHelper.showDialog(activity, fragment, "messageMenuDialog"); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MessageMenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageMenuDialogFragment.java index 6e375048..51282b35 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/MessageMenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageMenuDialogFragment.java @@ -30,6 +30,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.*; @@ -37,6 +38,7 @@ import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import net.lacolaco.smileessence.viewmodel.MessageViewModel; + import twitter4j.DirectMessage; import twitter4j.HashtagEntity; import twitter4j.MediaEntity; @@ -45,8 +47,7 @@ import twitter4j.URLEntity; import java.util.ArrayList; import java.util.List; -public class MessageMenuDialogFragment extends MenuDialogFragment -{ +public class MessageMenuDialogFragment extends MenuDialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -54,13 +55,11 @@ public class MessageMenuDialogFragment extends MenuDialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - public long getMessageID() - { + public long getMessageID() { return getArguments().getLong(KEY_MESSAGE_ID); } - public void setMessageID(long messageID) - { + public void setMessageID(long messageID) { Bundle args = new Bundle(); args.putLong(KEY_MESSAGE_ID, messageID); setArguments(args); @@ -69,18 +68,15 @@ public class MessageMenuDialogFragment extends MenuDialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - protected void executeCommand(Command command) - { - if(command.execute()) - { + protected void executeCommand(Command command) { + if (command.execute()) { dismiss(); DialogHelper.close(getActivity(), MessageViewModel.DETAIL_DIALOG); } } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); @@ -91,23 +87,19 @@ public class MessageMenuDialogFragment extends MenuDialogFragment listView.setOnItemClickListener(onItemClickListener); final AlertDialog alertDialog = new AlertDialog.Builder(activity).setView(body).create(); - TwitterUtils.tryGetMessage(account, getMessageID(), new TwitterUtils.MessageCallback() - { + TwitterUtils.tryGetMessage(account, getMessageID(), new TwitterUtils.MessageCallback() { @Override - public void success(DirectMessage message) - { + public void success(DirectMessage message) { List<Command> commands = getCommands(activity, message, account); Command.filter(commands); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -116,52 +108,41 @@ public class MessageMenuDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public void addBottomCommands(Activity activity, DirectMessage message, Account account, ArrayList<Command> commands) - { + public void addBottomCommands(Activity activity, DirectMessage message, Account account, ArrayList<Command> commands) { commands.add(new CommandSaveAsTemplate(activity, message.getText())); //User - for(String screenName : TwitterUtils.getScreenNames(message, null)) - { + for (String screenName : TwitterUtils.getScreenNames(message, null)) { commands.add(new CommandOpenUserDetail(activity, screenName, account)); } - for(Command command : getHashtagCommands(activity, message)) - { + for (Command command : getHashtagCommands(activity, message)) { commands.add(command); } // Media - if(message.getURLEntities() != null) - { - for(URLEntity urlEntity : message.getURLEntities()) - { + if (message.getURLEntities() != null) { + for (URLEntity urlEntity : message.getURLEntities()) { commands.add(new CommandOpenURL(activity, urlEntity.getExpandedURL())); } } - for(MediaEntity mediaEntity : message.getExtendedMediaEntities().length == 0 ? message.getMediaEntities() : message.getExtendedMediaEntities()) - { + for (MediaEntity mediaEntity : message.getExtendedMediaEntities().length == 0 ? message.getMediaEntities() : message.getExtendedMediaEntities()) { commands.add(new CommandOpenURL(activity, mediaEntity.getMediaURL())); } } - public boolean addMainCommands(Activity activity, DirectMessage message, Account account, ArrayList<Command> commands) - { + public boolean addMainCommands(Activity activity, DirectMessage message, Account account, ArrayList<Command> commands) { return commands.addAll(Command.getMessageCommands(activity, message, account)); } - public List<Command> getCommands(Activity activity, DirectMessage message, Account account) - { + public List<Command> getCommands(Activity activity, DirectMessage message, Account account) { ArrayList<Command> commands = new ArrayList<>(); addMainCommands(activity, message, account, commands); addBottomCommands(activity, message, account, commands); return commands; } - private ArrayList<Command> getHashtagCommands(Activity activity, DirectMessage status) - { + private ArrayList<Command> getHashtagCommands(Activity activity, DirectMessage status) { ArrayList<Command> commands = new ArrayList<>(); - if(status.getHashtagEntities() != null) - { - for(HashtagEntity hashtagEntity : status.getHashtagEntities()) - { + if (status.getHashtagEntities() != null) { + for (HashtagEntity hashtagEntity : status.getHashtagEntities()) { commands.add(new CommandOpenHashtagDialog(activity, hashtagEntity)); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/PostMenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java index a9f134a6..aca73f33 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/PostMenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java @@ -30,6 +30,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -44,22 +45,19 @@ import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import java.util.ArrayList; import java.util.List; -public class PostMenuDialogFragment extends MenuDialogFragment -{ +public class PostMenuDialogFragment extends MenuDialogFragment { public static final String TAG = "postMenu"; // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); Account account = activity.getCurrentAccount(); List<Command> commands = getCommands(activity); Command.filter(commands); - if(commands.isEmpty()) - { + if (commands.isEmpty()) { Notificator.publish(getActivity(), R.string.notice_no_command_exists); return new DisposeDialog(getActivity()); } @@ -67,8 +65,7 @@ public class PostMenuDialogFragment extends MenuDialogFragment ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); listView.setAdapter(adapter); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); @@ -81,10 +78,8 @@ public class PostMenuDialogFragment extends MenuDialogFragment } @Override - protected void executeCommand(Command command) - { - if(command.execute()) - { + protected void executeCommand(Command command) { + if (command.execute()) { dismiss(); DialogHelper.close(getActivity(), TAG); } @@ -92,8 +87,7 @@ public class PostMenuDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(Activity activity) - { + public List<Command> getCommands(Activity activity) { ArrayList<Command> commands = new ArrayList<>(); commands.add(new CommandOpenTemplateList(activity)); commands.add(new PostCommandMorse(activity)); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/QuoteDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/QuoteDialogFragment.java index d53a59f1..ba8240b6 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/QuoteDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/QuoteDialogFragment.java @@ -30,6 +30,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -38,13 +39,13 @@ import net.lacolaco.smileessence.command.status.StatusCommandURLQuote; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; + import twitter4j.Status; import java.util.ArrayList; import java.util.List; -public class QuoteDialogFragment extends MenuDialogFragment -{ +public class QuoteDialogFragment extends MenuDialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -52,13 +53,11 @@ public class QuoteDialogFragment extends MenuDialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - private long getStatusID() - { + private long getStatusID() { return getArguments().getLong(KEY_STATUS_ID); } - public void setStatusID(long id) - { + public void setStatusID(long id) { Bundle bundle = new Bundle(); bundle.putLong(KEY_STATUS_ID, id); setArguments(bundle); @@ -67,8 +66,7 @@ public class QuoteDialogFragment extends MenuDialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { final MainActivity activity = (MainActivity) getActivity(); View body = activity.getLayoutInflater().inflate(R.layout.dialog_menu_list, null); @@ -78,23 +76,19 @@ public class QuoteDialogFragment extends MenuDialogFragment listView.setOnItemClickListener(onItemClickListener); Account account = activity.getCurrentAccount(); long statusID = getStatusID(); - TwitterUtils.tryGetStatus(account, statusID, new TwitterUtils.StatusCallback() - { + TwitterUtils.tryGetStatus(account, statusID, new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { List<Command> commands = getCommands(activity, status); Command.filter(commands); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -103,8 +97,7 @@ public class QuoteDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(Activity activity, Status status) - { + public List<Command> getCommands(Activity activity, Status status) { ArrayList<Command> commands = new ArrayList<>(); commands.add(new StatusCommandTextQuote(activity, status)); commands.add(new StatusCommandURLQuote(activity, status)); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ReviewDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java index 6adc9124..8b4e8cee 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/ReviewDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java @@ -33,15 +33,16 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.RatingBar; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.StatusCache; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.Status; -public class ReviewDialogFragment extends DialogFragment implements View.OnClickListener -{ +public class ReviewDialogFragment extends DialogFragment implements View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -51,8 +52,7 @@ public class ReviewDialogFragment extends DialogFragment implements View.OnClick // --------------------- GETTER / SETTER METHODS --------------------- - public void setStatusID(long statusID) - { + public void setStatusID(long statusID) { Bundle args = new Bundle(); args.putLong(statusIDKey, statusID); setArguments(args); @@ -64,13 +64,10 @@ public class ReviewDialogFragment extends DialogFragment implements View.OnClick // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(View v) - { + public void onClick(View v) { int id = v.getId(); - switch(id) - { - case R.id.button_submit: - { + switch (id) { + case R.id.button_submit: { execute(); break; } @@ -80,16 +77,14 @@ public class ReviewDialogFragment extends DialogFragment implements View.OnClick // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); statusID = args.getLong(statusIDKey); } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_review, null); ratingBar = (RatingBar) view.findViewById(R.id.rating_review); Button button = (Button) view.findViewById(R.id.button_submit); @@ -99,43 +94,36 @@ public class ReviewDialogFragment extends DialogFragment implements View.OnClick .create(); } - private void hideIME() - { + private void hideIME() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(ratingBar.getWindowToken(), 0); } - private void execute() - { + private void execute() { hideIME(); Status status = StatusCache.getInstance().get(statusID); int star = (int) ratingBar.getRating(); StringBuilder builder = new StringBuilder(); - for(int i = 0; i < 5; i++) - { - if(i < star) - { + for (int i = 0; i < 5; i++) { + if (i < star) { builder.append("★"); - } - else - { + } else { builder.append("☆"); } } String formatString = getFormatString(); String str = String.format(formatString, - builder.toString(), - TwitterUtils.getOriginalStatus(status).getUser().getScreenName(), - TwitterUtils.getStatusURL(status)); + builder.toString(), + TwitterUtils.getOriginalStatus(status).getUser().getScreenName(), + TwitterUtils.getStatusURL(status)); PostState.newState().beginTransaction() - .setText(str) - .setInReplyToStatusID(statusID) - .setCursor(str.indexOf(":") + 2) - .commitWithOpen((MainActivity) getActivity()); + .setText(str) + .setInReplyToStatusID(statusID) + .setCursor(str.indexOf(":") + 2) + .commitWithOpen((MainActivity) getActivity()); } - private String getFormatString() - { + private String getFormatString() { return getString(R.string.format_status_review); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SearchOnGoogleDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SearchOnGoogleDialogFragment.java index c31b5316..ca8655be 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SearchOnGoogleDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SearchOnGoogleDialogFragment.java @@ -38,10 +38,10 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; + import net.lacolaco.smileessence.R; -public class SearchOnGoogleDialogFragment extends DialogFragment implements TextWatcher, View.OnClickListener -{ +public class SearchOnGoogleDialogFragment extends DialogFragment implements TextWatcher, View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -52,8 +52,7 @@ public class SearchOnGoogleDialogFragment extends DialogFragment implements Text // --------------------- GETTER / SETTER METHODS --------------------- - public void setText(String text) - { + public void setText(String text) { Bundle args = new Bundle(); args.putString(textKey, text); setArguments(args); @@ -65,13 +64,10 @@ public class SearchOnGoogleDialogFragment extends DialogFragment implements Text // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(View v) - { + public void onClick(View v) { int id = v.getId(); - switch(id) - { - case R.id.button_submit: - { + switch (id) { + case R.id.button_submit: { execute(); break; } @@ -81,43 +77,35 @@ public class SearchOnGoogleDialogFragment extends DialogFragment implements Text // --------------------- Interface TextWatcher --------------------- @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) - { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) - { - if(TextUtils.isEmpty(text)) - { + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (TextUtils.isEmpty(text)) { button.setEnabled(false); - } - else - { + } else { button.setEnabled(true); } } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); text = args.getString(textKey); } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_search_on_google, null); editText = (EditText) view.findViewById(R.id.edittext_search_on_google); editText.addTextChangedListener(this); @@ -129,14 +117,12 @@ public class SearchOnGoogleDialogFragment extends DialogFragment implements Text .create(); } - private void hideIME() - { + private void hideIME() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); } - private void execute() - { + private void execute() { hideIME(); Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, editText.getText().toString()); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectImageDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectImageDialogFragment.java index 5b4089b8..9d01f6ca 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectImageDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectImageDialogFragment.java @@ -33,6 +33,7 @@ import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -43,14 +44,12 @@ import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import java.util.ArrayList; import java.util.List; -public class SelectImageDialogFragment extends MenuDialogFragment -{ +public class SelectImageDialogFragment extends MenuDialogFragment { // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); Account account = activity.getCurrentAccount(); List<Command> commands = getCommands(activity); @@ -58,8 +57,7 @@ public class SelectImageDialogFragment extends MenuDialogFragment ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); listView.setAdapter(adapter); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); @@ -70,56 +68,46 @@ public class SelectImageDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(final MainActivity activity) - { + public List<Command> getCommands(final MainActivity activity) { ArrayList<Command> commands = new ArrayList<>(); - commands.add(new Command(-1, activity) - { + commands.add(new Command(-1, activity) { @Override - public boolean execute() - { + public boolean execute() { startGallery(activity); return true; } @Override - public String getText() - { + public String getText() { return activity.getString(R.string.command_select_image_from_gallery); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } }); - commands.add(new Command(-1, activity) - { + commands.add(new Command(-1, activity) { @Override - public boolean execute() - { + public boolean execute() { startCamera(activity); return true; } @Override - public String getText() - { + public String getText() { return activity.getString(R.string.command_select_image_from_camera); } @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } }); return commands; } - private void startCamera(MainActivity activity) - { + private void startCamera(MainActivity activity) { ContentValues values = new ContentValues(); String filename = System.currentTimeMillis() + ".jpg"; values.put(MediaStore.MediaColumns.TITLE, filename); @@ -134,8 +122,7 @@ public class SelectImageDialogFragment extends MenuDialogFragment IntentUtils.startActivityForResultIfFound(activity, intent, MainActivity.REQUEST_GET_PICTURE_FROM_CAMERA); } - private void startGallery(MainActivity activity) - { + private void startGallery(MainActivity activity) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); IntentUtils.startActivityForResultIfFound(activity, intent, MainActivity.REQUEST_GET_PICTURE_FROM_GALLERY); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectSearchQueryDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java index afd40e43..637a0d37 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectSearchQueryDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java @@ -30,6 +30,7 @@ import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -42,8 +43,7 @@ import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import java.util.ArrayList; import java.util.List; -public class SelectSearchQueryDialogFragment extends MenuDialogFragment implements AdapterView.OnItemLongClickListener -{ +public class SelectSearchQueryDialogFragment extends MenuDialogFragment implements AdapterView.OnItemLongClickListener { // ------------------------ INTERFACE METHODS ------------------------ @@ -51,14 +51,11 @@ public class SelectSearchQueryDialogFragment extends MenuDialogFragment implemen // --------------------- Interface OnItemLongClickListener --------------------- @Override - public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) - { + public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final CommandOpenSearch command = (CommandOpenSearch) parent.getItemAtPosition(position); - ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_delete_query), new Runnable() - { + ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_delete_query), new Runnable() { @Override - public void run() - { + public void run() { deleteQuery(command); } }, false); @@ -68,8 +65,7 @@ public class SelectSearchQueryDialogFragment extends MenuDialogFragment implemen // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); Account account = activity.getCurrentAccount(); List<Command> commands = getCommands(activity); @@ -78,8 +74,7 @@ public class SelectSearchQueryDialogFragment extends MenuDialogFragment implemen ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); listView.setAdapter(adapter); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); @@ -91,22 +86,18 @@ public class SelectSearchQueryDialogFragment extends MenuDialogFragment implemen // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(final MainActivity activity) - { + public List<Command> getCommands(final MainActivity activity) { ArrayList<Command> commands = new ArrayList<>(); final List<SearchQuery> queries = SearchQuery.getAll(); - if(queries != null) - { - for(final SearchQuery query : queries) - { + if (queries != null) { + for (final SearchQuery query : queries) { commands.add(new CommandOpenSearch(activity, query)); } } return commands; } - protected void deleteQuery(CommandOpenSearch command) - { + protected void deleteQuery(CommandOpenSearch command) { command.getQuery().delete(); Notificator.publish(getActivity(), R.string.notice_search_query_deleted); ((MainActivity) getActivity()).openSearchPage(""); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectUserListDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectUserListDialogFragment.java index 9fdcdf16..b38f941b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SelectUserListDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectUserListDialogFragment.java @@ -29,6 +29,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -40,14 +41,12 @@ import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import java.util.ArrayList; import java.util.List; -public class SelectUserListDialogFragment extends MenuDialogFragment -{ +public class SelectUserListDialogFragment extends MenuDialogFragment { // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); Account account = activity.getCurrentAccount(); List<Command> commands = getCommands(activity); @@ -56,8 +55,7 @@ public class SelectUserListDialogFragment extends MenuDialogFragment ListView listView = (ListView) body.findViewById(R.id.listview_dialog_menu_list); CustomListAdapter<Command> adapter = new CustomListAdapter<>(activity, Command.class); listView.setAdapter(adapter); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); @@ -68,14 +66,11 @@ public class SelectUserListDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public List<Command> getCommands(final MainActivity activity) - { + public List<Command> getCommands(final MainActivity activity) { ArrayList<Command> commands = new ArrayList<>(); final String[] lists = UserListCache.getInstance().getAll(); - if(lists != null) - { - for(final String list : lists) - { + if (lists != null) { + for (final String list : lists) { commands.add(new CommandOpenUserList(activity, list)); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SendMessageDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java index d765765d..def91eb1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SendMessageDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java @@ -38,17 +38,19 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; + import com.twitter.Validator; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.SendMessageTask; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.PostState; + import twitter4j.Twitter; -public class SendMessageDialogFragment extends DialogFragment implements TextWatcher, View.OnClickListener -{ +public class SendMessageDialogFragment extends DialogFragment implements TextWatcher, View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -60,8 +62,7 @@ public class SendMessageDialogFragment extends DialogFragment implements TextWat // --------------------- GETTER / SETTER METHODS --------------------- - public void setScreenName(String screenName) - { + public void setScreenName(String screenName) { Bundle args = new Bundle(); args.putString(screenNameKey, screenName); setArguments(args); @@ -73,18 +74,14 @@ public class SendMessageDialogFragment extends DialogFragment implements TextWat // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(View v) - { + public void onClick(View v) { int id = v.getId(); - switch(id) - { - case R.id.button_send_message: - { + switch (id) { + case R.id.button_send_message: { sendMessage(); break; } - case R.id.button_send_message_delete: - { + case R.id.button_send_message_delete: { deleteMessage(); } } @@ -93,56 +90,45 @@ public class SendMessageDialogFragment extends DialogFragment implements TextWat // --------------------- Interface TextWatcher --------------------- @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) - { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) - { + public void onTextChanged(CharSequence s, int start, int before, int count) { int remainingCount = 140 - TwitterUtils.getFixedTextLength(s.toString()); - if(!TextUtils.isEmpty(PostState.getState().getMediaFilePath())) - { + if (!TextUtils.isEmpty(PostState.getState().getMediaFilePath())) { remainingCount -= new Validator().getShortUrlLength(); } textViewCount.setText(String.valueOf(remainingCount)); - if(remainingCount == 140) - { + if (remainingCount == 140) { textViewCount.setTextColor(getResources().getColor(R.color.red)); buttonSend.setEnabled(false); - } - else if(remainingCount < 0) - { + } else if (remainingCount < 0) { textViewCount.setTextColor(getResources().getColor(R.color.red)); buttonSend.setEnabled(false); - } - else - { + } else { textViewCount.setTextAppearance(getActivity(), android.R.style.TextAppearance_Widget_TextView); buttonSend.setEnabled(true); } } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); screenName = args.getString(screenNameKey); } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_send_message, null); TextView textViewName = (TextView) view.findViewById(R.id.textview_send_message_name); textViewName.setText("To: @" + screenName); @@ -159,19 +145,16 @@ public class SendMessageDialogFragment extends DialogFragment implements TextWat .create(); } - private void deleteMessage() - { + private void deleteMessage() { editText.setText(""); } - private void hideIME() - { + private void hideIME() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); } - private void sendMessage() - { + private void sendMessage() { MainActivity activity = (MainActivity) getActivity(); Twitter twitter = TwitterApi.getTwitter(activity.getCurrentAccount()); String text = editText.getText().toString(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SimpleDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SimpleDialogFragment.java index ec10e70c..3c7d4d10 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/SimpleDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SimpleDialogFragment.java @@ -31,10 +31,10 @@ import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; + import net.lacolaco.smileessence.R; -public class SimpleDialogFragment extends DialogFragment -{ +public class SimpleDialogFragment extends DialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -45,8 +45,7 @@ public class SimpleDialogFragment extends DialogFragment // -------------------------- STATIC METHODS -------------------------- - public static SimpleDialogFragment newInstance(int layoutResourceID, String title) - { + public static SimpleDialogFragment newInstance(int layoutResourceID, String title) { SimpleDialogFragment fragment = new SimpleDialogFragment(); Bundle args = new Bundle(); args.putInt(ARG_LAYOUT, layoutResourceID); @@ -58,8 +57,7 @@ public class SimpleDialogFragment extends DialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); layoutResourceID = args.getInt(ARG_LAYOUT); @@ -67,19 +65,16 @@ public class SimpleDialogFragment extends DialogFragment } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); View contentView = inflater.inflate(layoutResourceID, null); return new AlertDialog.Builder(getActivity()) .setTitle(title) .setView(contentView) - .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() - { + .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) - { + public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/StatusDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java index 074e1c98..4f7e0358 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/StatusDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java @@ -32,6 +32,7 @@ import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.view.View; import android.widget.*; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -49,6 +50,7 @@ import net.lacolaco.smileessence.view.adapter.PostState; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; import net.lacolaco.smileessence.view.listener.ListItemClickListener; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.MediaEntity; import twitter4j.Status; import twitter4j.URLEntity; @@ -56,8 +58,7 @@ import twitter4j.User; import java.util.ArrayList; -public class StatusDetailDialogFragment extends DialogFragment implements View.OnClickListener -{ +public class StatusDetailDialogFragment extends DialogFragment implements View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -65,13 +66,11 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O // --------------------- GETTER / SETTER METHODS --------------------- - public long getStatusID() - { + public long getStatusID() { return getArguments().getLong(KEY_STATUS_ID); } - public void setStatusID(long statusID) - { + public void setStatusID(long statusID) { Bundle args = new Bundle(); args.putLong(KEY_STATUS_ID, statusID); setArguments(args); @@ -83,54 +82,43 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(final View v) - { + public void onClick(final View v) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); - TwitterUtils.tryGetStatus(account, getStatusID(), new TwitterUtils.StatusCallback() - { + TwitterUtils.tryGetStatus(account, getStatusID(), new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { - switch(v.getId()) - { - case R.id.button_status_detail_reply: - { + public void success(Status status) { + switch (v.getId()) { + case R.id.button_status_detail_reply: { replyToStatus(activity, account, status); break; } - case R.id.button_status_detail_retweet: - { + case R.id.button_status_detail_retweet: { final Long retweetID = (Long) v.getTag(); toggleRetweet(activity, account, status, retweetID); break; } - case R.id.button_status_detail_favorite: - { + case R.id.button_status_detail_favorite: { Boolean isFavorited = (Boolean) v.getTag(); toggleFavorite(activity, account, status, isFavorited); break; } - case R.id.button_status_detail_delete: - { + case R.id.button_status_detail_delete: { deleteStatus(activity, account, status); break; } - case R.id.button_status_detail_menu: - { + case R.id.button_status_detail_menu: { openMenu(activity); break; } - default: - { + default: { dismiss(); } } } @Override - public void error() - { + public void error() { } }); @@ -139,8 +127,7 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); @@ -150,24 +137,18 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O final StatusListAdapter adapter = new StatusListAdapter(getActivity()); listView.setAdapter(adapter); long inReplyToStatusId = TwitterUtils.getOriginalStatus(status).getInReplyToStatusId(); - if(inReplyToStatusId == -1) - { + if (inReplyToStatusId == -1) { listView.setVisibility(View.GONE); - } - else - { - TwitterUtils.tryGetStatus(account, inReplyToStatusId, new TwitterUtils.StatusCallback() - { + } else { + TwitterUtils.tryGetStatus(account, inReplyToStatusId, new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { adapter.addToTop(new StatusViewModel(status, account)); adapter.updateForce(); } @Override - public void error() - { + public void error() { } }); @@ -175,26 +156,21 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O return new AlertDialog.Builder(getActivity()).setView(header).create(); } - private void confirm(MainActivity activity, Runnable onYes) - { + private void confirm(MainActivity activity, Runnable onYes) { ConfirmDialogFragment.show(activity, getString(R.string.dialog_confirm_commands), onYes); } - private void deleteStatus(final MainActivity activity, final Account account, final Status status) - { - confirm(activity, new Runnable() - { + private void deleteStatus(final MainActivity activity, final Account account, final Status status) { + confirm(activity, new Runnable() { @Override - public void run() - { + public void run() { new DeleteStatusTask(TwitterApi.getTwitter(account), TwitterUtils.getOriginalStatus(status).getId(), activity).execute(); dismiss(); } }); } - private View getTitleView(MainActivity activity, Account account, Status status) - { + private View getTitleView(MainActivity activity, Account account, Status status) { View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null); View statusHeader = view.findViewById(R.id.layout_status_header); StatusViewModel statusViewModel = new StatusViewModel(status, account); @@ -207,23 +183,17 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O TextView favCountText = (TextView) view.findViewById(R.id.textview_status_detail_fav_count); TextView rtCountText = (TextView) view.findViewById(R.id.textview_status_detail_rt_count); int favoriteCount = TwitterUtils.getOriginalStatus(status).getFavoriteCount(); - if(favoriteCount == 0) - { + if (favoriteCount == 0) { favCountIcon.setVisibility(View.GONE); favCountText.setVisibility(View.GONE); - } - else - { + } else { favCountText.setText(Integer.toString(favoriteCount)); } int retweetCount = TwitterUtils.getOriginalStatus(status).getRetweetCount(); - if(retweetCount == 0) - { + if (retweetCount == 0) { rtCountIcon.setVisibility(View.GONE); rtCountText.setVisibility(View.GONE); - } - else - { + } else { rtCountText.setText(Integer.toString(retweetCount)); } ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu); @@ -236,22 +206,16 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O retweet.setOnClickListener(this); favorite.setOnClickListener(this); delete.setOnClickListener(this); - if(isNotRetweetable(account, status)) - { + if (isNotRetweetable(account, status)) { retweet.setVisibility(View.GONE); - } - else if(isRetweetDeletable(account, status)) - { + } else if (isRetweetDeletable(account, status)) { retweet.setImageDrawable(getResources().getDrawable(R.drawable.icon_retweet_on)); retweet.setTag(status.getId()); - } - else - { + } else { retweet.setTag(-1L); } favorite.setTag(statusViewModel.isFavorited()); - if(statusViewModel.isFavorited()) - { + if (statusViewModel.isFavorited()) { favorite.setImageDrawable(getResources().getDrawable(R.drawable.icon_favorite_on)); } boolean deletable = isDeletable(account, status); @@ -260,15 +224,12 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O commandsLayout.setClickable(true); ArrayList<Command> commands = getCommands(activity, status, account); Command.filter(commands); - for(final Command command : commands) - { + for (final Command command : commands) { View commandView = command.getView(activity, activity.getLayoutInflater(), null); commandView.setBackgroundColor(getResources().getColor(R.color.transparent)); - commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() - { + commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override - public void run() - { + public void run() { command.execute(); dismiss(); } @@ -279,74 +240,57 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O } - private MediaEntity[] getMediaEntities(Status status) - { - if(status.getExtendedMediaEntities().length == 0) - { + private MediaEntity[] getMediaEntities(Status status) { + if (status.getExtendedMediaEntities().length == 0) { return status.getMediaEntities(); - } - else - { + } else { return status.getExtendedMediaEntities(); } } - private ArrayList<Command> getCommands(Activity activity, Status status, Account account) - { + private ArrayList<Command> getCommands(Activity activity, Status status, Account account) { ArrayList<Command> commands = new ArrayList<>(); // URL - if(status.getURLEntities() != null) - { - for(URLEntity urlEntity : status.getURLEntities()) - { + if (status.getURLEntities() != null) { + for (URLEntity urlEntity : status.getURLEntities()) { commands.add(new CommandOpenURL(activity, urlEntity.getExpandedURL())); } } - for(MediaEntity mediaEntity : getMediaEntities(status)) - { + for (MediaEntity mediaEntity : getMediaEntities(status)) { commands.add(new CommandOpenURL(activity, mediaEntity.getMediaURL())); } return commands; } - private boolean isDeletable(Account account, Status status) - { + private boolean isDeletable(Account account, Status status) { boolean deletable; - if(!status.isRetweet()) - { + if (!status.isRetweet()) { deletable = status.getUser().getId() == account.userID; - } - else - { + } else { deletable = status.getRetweetedStatus().getUser().getId() == account.userID; } return deletable; } - private boolean isNotRetweetable(Account account, Status status) - { + private boolean isNotRetweetable(Account account, Status status) { User user = TwitterUtils.getOriginalStatus(status).getUser(); return user.isProtected() || user.getId() == account.userID; } - private boolean isRetweetDeletable(Account account, Status status) - { + private boolean isRetweetDeletable(Account account, Status status) { return status.isRetweet() && status.getUser().getId() == account.userID; } - private void openMenu(MainActivity activity) - { + private void openMenu(MainActivity activity) { StatusMenuDialogFragment fragment = new StatusMenuDialogFragment(); fragment.setStatusID(getStatusID()); DialogHelper.showDialog(activity, fragment, "statusMenuDialog"); } - private void replyToStatus(MainActivity activity, Account account, Status status) - { + private void replyToStatus(MainActivity activity, Account account, Status status) { Status originalStatus = TwitterUtils.getOriginalStatus(status); TweetBuilder builder = new TweetBuilder(); - if(account.userID == originalStatus.getUser().getId()) - { + if (account.userID == originalStatus.getUser().getId()) { builder.addScreenName(account.screenName); } builder.addScreenNames(TwitterUtils.getScreenNames(originalStatus, account.screenName)); @@ -355,39 +299,29 @@ public class StatusDetailDialogFragment extends DialogFragment implements View.O int selStart = originalStatus.getUser().getScreenName().length() + 2; // "@" and " " PostState.newState().beginTransaction() - .insertText(0, text) - .setInReplyToStatusID(originalStatus.getId()) - .setSelection(selStart, text.length()) - .commitWithOpen(activity); + .insertText(0, text) + .setInReplyToStatusID(originalStatus.getId()) + .setSelection(selStart, text.length()) + .commitWithOpen(activity); } - private void toggleFavorite(MainActivity activity, Account account, Status status, Boolean isFavorited) - { + private void toggleFavorite(MainActivity activity, Account account, Status status, Boolean isFavorited) { long statusID = status.isRetweet() ? status.getRetweetedStatus().getId() : status.getId(); - if(isFavorited) - { + if (isFavorited) { new UnfavoriteTask(TwitterApi.getTwitter(account), statusID, activity).execute(); - } - else - { + } else { new FavoriteTask(TwitterApi.getTwitter(account), statusID, activity).execute(); } dismiss(); } - private void toggleRetweet(final MainActivity activity, final Account account, final Status status, final Long retweetID) - { - confirm(activity, new Runnable() - { + private void toggleRetweet(final MainActivity activity, final Account account, final Status status, final Long retweetID) { + confirm(activity, new Runnable() { @Override - public void run() - { - if(retweetID != -1L) - { + public void run() { + if (retweetID != -1L) { new DeleteStatusTask(TwitterApi.getTwitter(account), retweetID, activity).execute(); - } - else - { + } else { new RetweetTask(TwitterApi.getTwitter(account), TwitterUtils.getOriginalStatus(status).getId(), activity).execute(); } dismiss(); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/StatusMenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusMenuDialogFragment.java index a284b10e..6572c49a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/StatusMenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusMenuDialogFragment.java @@ -30,6 +30,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.*; @@ -37,6 +38,7 @@ import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.HashtagEntity; import twitter4j.MediaEntity; import twitter4j.Status; @@ -45,8 +47,7 @@ import twitter4j.URLEntity; import java.util.ArrayList; import java.util.List; -public class StatusMenuDialogFragment extends MenuDialogFragment -{ +public class StatusMenuDialogFragment extends MenuDialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -54,13 +55,11 @@ public class StatusMenuDialogFragment extends MenuDialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - public long getStatusID() - { + public long getStatusID() { return getArguments().getLong(KEY_STATUS_ID); } - public void setStatusID(long statusID) - { + public void setStatusID(long statusID) { Bundle args = new Bundle(); args.putLong(KEY_STATUS_ID, statusID); setArguments(args); @@ -70,18 +69,15 @@ public class StatusMenuDialogFragment extends MenuDialogFragment @Override - protected void executeCommand(Command command) - { - if(command.execute()) - { + protected void executeCommand(Command command) { + if (command.execute()) { dismiss(); DialogHelper.close(getActivity(), StatusViewModel.STATUS_DIALOG); } } @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); @@ -92,23 +88,19 @@ public class StatusMenuDialogFragment extends MenuDialogFragment listView.setOnItemClickListener(onItemClickListener); final AlertDialog alertDialog = new AlertDialog.Builder(activity).setView(body).create(); - TwitterUtils.tryGetStatus(account, getStatusID(), new TwitterUtils.StatusCallback() - { + TwitterUtils.tryGetStatus(account, getStatusID(), new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { List<Command> commands = getCommands(activity, status, account); Command.filter(commands); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -117,52 +109,41 @@ public class StatusMenuDialogFragment extends MenuDialogFragment // -------------------------- OTHER METHODS -------------------------- - public void addBottomCommands(Activity activity, Status status, Account account, ArrayList<Command> commands) - { + public void addBottomCommands(Activity activity, Status status, Account account, ArrayList<Command> commands) { commands.add(new CommandSaveAsTemplate(activity, TwitterUtils.getOriginalStatusText(status))); //User - for(String screenName : TwitterUtils.getScreenNames(status, null)) - { + for (String screenName : TwitterUtils.getScreenNames(status, null)) { commands.add(new CommandOpenUserDetail(activity, screenName, account)); } - for(Command command : getHashtagCommands(activity, status)) - { + for (Command command : getHashtagCommands(activity, status)) { commands.add(command); } // Media - if(status.getURLEntities() != null) - { - for(URLEntity urlEntity : status.getURLEntities()) - { + if (status.getURLEntities() != null) { + for (URLEntity urlEntity : status.getURLEntities()) { commands.add(new CommandOpenURL(activity, urlEntity.getExpandedURL())); } } - for(MediaEntity mediaEntity : status.getExtendedMediaEntities().length == 0 ? status.getMediaEntities() : status.getExtendedMediaEntities()) - { + for (MediaEntity mediaEntity : status.getExtendedMediaEntities().length == 0 ? status.getMediaEntities() : status.getExtendedMediaEntities()) { commands.add(new CommandOpenURL(activity, mediaEntity.getMediaURL())); } } - public boolean addMainCommands(Activity activity, Status status, Account account, ArrayList<Command> commands) - { + public boolean addMainCommands(Activity activity, Status status, Account account, ArrayList<Command> commands) { return commands.addAll(Command.getStatusCommands(activity, status, account)); } - public List<Command> getCommands(Activity activity, Status status, Account account) - { + public List<Command> getCommands(Activity activity, Status status, Account account) { ArrayList<Command> commands = new ArrayList<>(); addMainCommands(activity, status, account, commands); addBottomCommands(activity, status, account, commands); return commands; } - private ArrayList<Command> getHashtagCommands(Activity activity, Status status) - { + private ArrayList<Command> getHashtagCommands(Activity activity, Status status) { ArrayList<Command> commands = new ArrayList<>(); - if(status.getHashtagEntities() != null) - { - for(HashtagEntity hashtagEntity : status.getHashtagEntities()) - { + if (status.getHashtagEntities() != null) { + for (HashtagEntity hashtagEntity : status.getHashtagEntities()) { commands.add(new CommandOpenHashtagDialog(activity, hashtagEntity)); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/TalkChainDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/TalkChainDialogFragment.java index bfed7d81..0f7d8667 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/TalkChainDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/TalkChainDialogFragment.java @@ -31,6 +31,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.view.View; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.StatusCache; @@ -40,12 +41,12 @@ import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; -public class TalkChainDialogFragment extends DialogFragment -{ +public class TalkChainDialogFragment extends DialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -53,13 +54,11 @@ public class TalkChainDialogFragment extends DialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - private long getStatusID() - { + private long getStatusID() { return getArguments().getLong(KEY_STATUS_ID); } - public void setStatusID(long id) - { + public void setStatusID(long id) { Bundle bundle = new Bundle(); bundle.putLong(KEY_STATUS_ID, id); setArguments(bundle); @@ -68,8 +67,7 @@ public class TalkChainDialogFragment extends DialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); @@ -77,11 +75,9 @@ public class TalkChainDialogFragment extends DialogFragment ListView listView = (ListView) view.findViewById(R.id.listview_dialog_talk_list); final StatusListAdapter adapter = new StatusListAdapter(getActivity()); listView.setAdapter(adapter); - TwitterUtils.tryGetStatus(account, getStatusID(), new TwitterUtils.StatusCallback() - { + TwitterUtils.tryGetStatus(account, getStatusID(), new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { adapter.addToTop(new StatusViewModel(status, account)); adapter.updateForce(); Twitter twitter = TwitterApi.getTwitter(account); @@ -89,8 +85,7 @@ public class TalkChainDialogFragment extends DialogFragment } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -104,16 +99,14 @@ public class TalkChainDialogFragment extends DialogFragment // -------------------------- INNER CLASSES -------------------------- - private class GetTalkTask extends AsyncTask<Void, Void, Void> - { + private class GetTalkTask extends AsyncTask<Void, Void, Void> { private final Twitter twitter; private final Account account; private final StatusListAdapter adapter; private final long inReplyToStatusId; - public GetTalkTask(Twitter twitter, Account account, StatusListAdapter adapter, long inReplyToStatusId) - { + public GetTalkTask(Twitter twitter, Account account, StatusListAdapter adapter, long inReplyToStatusId) { this.twitter = twitter; this.account = account; this.adapter = adapter; @@ -121,29 +114,21 @@ public class TalkChainDialogFragment extends DialogFragment } @Override - protected Void doInBackground(Void... params) - { - try - { + protected Void doInBackground(Void... params) { + try { long id = inReplyToStatusId; - while(id != -1) - { + while (id != -1) { final twitter4j.Status status = twitter.showStatus(id); - if(status != null) - { + if (status != null) { StatusCache.getInstance().put(status); adapter.addToBottom(new StatusViewModel(status, account)); adapter.updateForce(); id = status.getInReplyToStatusId(); - } - else - { + } else { break; } } - } - catch(TwitterException e) - { + } catch (TwitterException e) { e.printStackTrace(); Logger.error(e); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/UserDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java index f36fa059..77e92604 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/UserDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java @@ -35,9 +35,11 @@ import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.view.View; import android.widget.*; + import com.android.volley.toolbox.NetworkImageView; import com.handmark.pulltorefresh.library.PullToRefreshBase; import com.handmark.pulltorefresh.library.PullToRefreshListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -56,14 +58,14 @@ import net.lacolaco.smileessence.util.UIHandler; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; import net.lacolaco.smileessence.viewmodel.StatusViewModel; + import twitter4j.Paging; import twitter4j.Relationship; import twitter4j.Twitter; import twitter4j.User; public class UserDetailDialogFragment extends DialogFragment implements View.OnClickListener, - PullToRefreshBase.OnRefreshListener2<ListView> -{ + PullToRefreshBase.OnRefreshListener2<ListView> { // ------------------------------ FIELDS ------------------------------ @@ -89,13 +91,11 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC // --------------------- GETTER / SETTER METHODS --------------------- - public long getUserID() - { + public long getUserID() { return getArguments().getLong(KEY_USER_ID); } - public void setUserID(long userID) - { + public void setUserID(long userID) { Bundle args = new Bundle(); args.putLong(KEY_USER_ID, userID); setArguments(args); @@ -107,59 +107,45 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(final View v) - { + public void onClick(final View v) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); - TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() - { + TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() { @Override - public void success(final User user) - { - switch(v.getId()) - { - case R.id.imageview_user_detail_menu: - { + public void success(final User user) { + switch (v.getId()) { + case R.id.imageview_user_detail_menu: { openUserMenu(activity, user); break; } - case R.id.imageview_user_detail_icon: - { + case R.id.imageview_user_detail_icon: { openUrl(user.getBiggerProfileImageURLHttps()); break; } - case R.id.textview_user_detail_screenname: - { + case R.id.textview_user_detail_screenname: { openUrl(TwitterUtils.getUserHomeURL(user.getScreenName())); break; } - case R.id.textview_user_detail_tweet_count: - { + case R.id.textview_user_detail_tweet_count: { openUrl(TwitterUtils.getUserHomeURL(user.getScreenName())); break; } - case R.id.textview_user_detail_friend_count: - { + case R.id.textview_user_detail_friend_count: { openUrl(String.format("%s/following", TwitterUtils.getUserHomeURL(user.getScreenName()))); break; } - case R.id.textview_user_detail_follower_count: - { + case R.id.textview_user_detail_follower_count: { openUrl(String.format("%s/followers", TwitterUtils.getUserHomeURL(user.getScreenName()))); break; } - case R.id.textview_user_detail_favorite_count: - { + case R.id.textview_user_detail_favorite_count: { openUrl(String.format("%s/favorites", TwitterUtils.getUserHomeURL(user.getScreenName()))); break; } - case R.id.button_user_detail_follow: - { - ConfirmDialogFragment.show(activity, getString(R.string.dialog_confirm_commands), new Runnable() - { + case R.id.button_user_detail_follow: { + ConfirmDialogFragment.show(activity, getString(R.string.dialog_confirm_commands), new Runnable() { @Override - public void run() - { + public void run() { toggleFollowing(user, account, activity); } }); @@ -169,8 +155,7 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -179,25 +164,20 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC // --------------------- Interface OnRefreshListener2 --------------------- @Override - public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final StatusListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new UserTimelineTask(twitter, getUserID(), paging) - { + new UserTimelineTask(twitter, getUserID(), paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(int i = statuses.length - 1; i >= 0; i--) - { + for (int i = statuses.length - 1; i >= 0; i--) { twitter4j.Status status = statuses[i]; adapter.addToTop(new StatusViewModel(status, currentAccount)); } @@ -208,25 +188,20 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC } @Override - public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) - { + public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { final MainActivity activity = (MainActivity) getActivity(); final Account currentAccount = activity.getCurrentAccount(); Twitter twitter = TwitterApi.getTwitter(currentAccount); final StatusListAdapter adapter = getListAdapter(activity); Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity)); - if(adapter.getCount() > 0) - { + if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new UserTimelineTask(twitter, getUserID(), paging) - { + new UserTimelineTask(twitter, getUserID(), paging) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { adapter.addToBottom(new StatusViewModel(status, currentAccount)); } updateListView(refreshView.getRefreshableView(), adapter, false); @@ -238,8 +213,7 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); View v = activity.getLayoutInflater().inflate(R.layout.dialog_user_detail, null); View menu = v.findViewById(R.id.imageview_user_detail_menu); @@ -276,25 +250,19 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC tabHost.setCurrentTab(0); final Account account = activity.getCurrentAccount(); - TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() - { + TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() { @Override - public void success(User user) - { - try - { + public void success(User user) { + try { initUserData(user, account); - } - catch(Exception e) - { + } catch (Exception e) { Logger.error(e); error(); } } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -304,18 +272,14 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC .create(); } - private void executeUserTimelineTask(final User user, final Account account, final StatusListAdapter adapter) - { + private void executeUserTimelineTask(final User user, final Account account, final StatusListAdapter adapter) { tabHost.getTabWidget().getChildTabViewAt(1).setVisibility(View.GONE); Twitter twitter = TwitterApi.getTwitter(account); - new UserTimelineTask(twitter, user.getId()) - { + new UserTimelineTask(twitter, user.getId()) { @Override - protected void onPostExecute(twitter4j.Status[] statuses) - { + protected void onPostExecute(twitter4j.Status[] statuses) { super.onPostExecute(statuses); - for(twitter4j.Status status : statuses) - { + for (twitter4j.Status status : statuses) { adapter.addToBottom(new StatusViewModel(status, account)); } adapter.updateForce(); @@ -324,10 +288,8 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC }.execute(); } - private String getHtmlDescription(String description) - { - if(TextUtils.isEmpty(description)) - { + private String getHtmlDescription(String description) { + if (TextUtils.isEmpty(description)) { return ""; } String html = description; @@ -337,29 +299,21 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC return html; } - private StatusListAdapter getListAdapter(MainActivity activity) - { + private StatusListAdapter getListAdapter(MainActivity activity) { return (StatusListAdapter) activity.getListAdapter(ADAPTER_INDEX); } - private void initUserData(User user, final Account account) - { + private void initUserData(User user, final Account account) { textViewName.setText(user.getName()); textViewScreenName.setText(user.getScreenName()); - if(TextUtils.isEmpty(user.getLocation())) - { + if (TextUtils.isEmpty(user.getLocation())) { textViewLocate.setVisibility(View.GONE); - } - else - { + } else { textViewLocate.setText(user.getLocation()); } - if(TextUtils.isEmpty(user.getURL())) - { + if (TextUtils.isEmpty(user.getURL())) { textViewURL.setVisibility(View.GONE); - } - else - { + } else { textViewURL.setText(user.getURL()); } textViewTweetCount.setText(String.valueOf(user.getStatusesCount())); @@ -381,33 +335,25 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC updateRelationship(activity, user.getId()); } - private void lockFollowButton(Activity activity) - { + private void lockFollowButton(Activity activity) { buttonFollow.setText(R.string.user_detail_loading); buttonFollow.setBackground(activity.getResources().getDrawable(R.drawable.button_round_gray)); buttonFollow.setEnabled(false); } - private void openUrl(String url) - { + private void openUrl(String url) { new CommandOpenURL(getActivity(), url).execute(); } - private void openUserMenu(final MainActivity activity, final User user) - { - UserMenuDialogFragment menuFragment = new UserMenuDialogFragment() - { + private void openUserMenu(final MainActivity activity, final User user) { + UserMenuDialogFragment menuFragment = new UserMenuDialogFragment() { @Override - protected void executeCommand(Command command) - { + protected void executeCommand(Command command) { super.executeCommand(command); - new UIHandler() - { + new UIHandler() { @Override - public void run() - { - if(UserDetailDialogFragment.this.isDetached()) - { + public void run() { + if (UserDetailDialogFragment.this.isDetached()) { return; } updateRelationship(activity, user.getId()); @@ -419,39 +365,30 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC DialogHelper.showDialog(activity, menuFragment, USER_MENU_DIALOG); } - private void setFollowButtonState(boolean isFollowing, Drawable unfollowColor, Drawable followColor) - { + private void setFollowButtonState(boolean isFollowing, Drawable unfollowColor, Drawable followColor) { buttonFollow.setText(isFollowing ? R.string.user_detail_unfollow : R.string.user_detail_follow); buttonFollow.setBackground(isFollowing ? unfollowColor : followColor); buttonFollow.setTag(isFollowing); buttonFollow.setEnabled(true); } - private void toggleFollowing(final User user, final Account account, final Activity activity) - { + private void toggleFollowing(final User user, final Account account, final Activity activity) { lockFollowButton(activity); Boolean isFollowing = buttonFollow.getTag() != null ? (Boolean) buttonFollow.getTag() : false; Twitter twitter = new TwitterApi(account).getTwitter(); - if(isFollowing) - { - new UnfollowTask(twitter, user.getId(), activity) - { + if (isFollowing) { + new UnfollowTask(twitter, user.getId(), activity) { @Override - public void onPostExecute(User result) - { + public void onPostExecute(User result) { super.onPostExecute(result); updateRelationship(activity, user.getId()); buttonFollow.setEnabled(true); } }.execute(); - } - else - { - new FollowTask(twitter, user.getId(), activity) - { + } else { + new FollowTask(twitter, user.getId(), activity) { @Override - public void onPostExecute(User result) - { + public void onPostExecute(User result) { super.onPostExecute(result); updateRelationship(activity, user.getId()); buttonFollow.setEnabled(true); @@ -460,61 +397,46 @@ public class UserDetailDialogFragment extends DialogFragment implements View.OnC } } - protected void updateListView(AbsListView absListView, CustomListAdapter<?> adapter, boolean addedToTop) - { + protected void updateListView(AbsListView absListView, CustomListAdapter<?> adapter, boolean addedToTop) { int before = adapter.getCount(); adapter.notifyDataSetChanged(); // synchronized call (not adapter#updateForce()) int after = adapter.getCount(); int increments = after - before; - if(increments > 0) - { + if (increments > 0) { adapter.setNotifiable(false); - if(addedToTop) - { + if (addedToTop) { absListView.setSelection(increments + 1); absListView.smoothScrollToPositionFromTop(increments, 0); absListView.setSelection(increments); - } - else - { + } else { absListView.smoothScrollToPositionFromTop(before, 0); } - if(increments == 1) - { + if (increments == 1) { adapter.setNotifiable(true); } - } - else - { + } else { adapter.setNotifiable(true); } } - private void updateRelationship(Activity activity, final long userId) - { + private void updateRelationship(Activity activity, final long userId) { MainActivity mainActivity = (MainActivity) activity; Account account = mainActivity.getCurrentAccount(); Twitter twitter = new TwitterApi(account).getTwitter(); - if(userId == account.userID) - { + if (userId == account.userID) { textViewFollowed.setText(R.string.user_detail_followed_is_me); buttonFollow.setVisibility(View.GONE); - } - else - { + } else { int theme = mainActivity.getThemeIndex(); lockFollowButton(activity); textViewFollowed.setText(R.string.user_detail_loading); final Drawable red = Themes.getStyledDrawable(activity, theme, R.attr.button_round_red); final Drawable blue = Themes.getStyledDrawable(activity, theme, R.attr.button_round_blue); - new ShowFriendshipTask(twitter, userId) - { + new ShowFriendshipTask(twitter, userId) { @Override - protected void onPostExecute(Relationship relationship) - { - if(relationship != null) - { + protected void onPostExecute(Relationship relationship) { + if (relationship != null) { boolean isFollowing = relationship.isSourceFollowingTarget(); boolean isFollowed = relationship.isSourceFollowedByTarget(); setFollowButtonState(isFollowing, red, blue); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/UserMenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserMenuDialogFragment.java index 92d226e4..96f2cc30 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/dialog/UserMenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserMenuDialogFragment.java @@ -31,6 +31,7 @@ import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.command.Command; @@ -38,13 +39,13 @@ import net.lacolaco.smileessence.command.CommandSearchOnTwitter; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.CustomListAdapter; + import twitter4j.User; import java.util.ArrayList; import java.util.List; -public class UserMenuDialogFragment extends MenuDialogFragment -{ +public class UserMenuDialogFragment extends MenuDialogFragment { // ------------------------------ FIELDS ------------------------------ @@ -52,13 +53,11 @@ public class UserMenuDialogFragment extends MenuDialogFragment // --------------------- GETTER / SETTER METHODS --------------------- - public long getUserID() - { + public long getUserID() { return getArguments().getLong(KEY_USER_ID); } - public void setUserID(long userID) - { + public void setUserID(long userID) { Bundle args = new Bundle(); args.putLong(KEY_USER_ID, userID); setArguments(args); @@ -67,8 +66,7 @@ public class UserMenuDialogFragment extends MenuDialogFragment // ------------------------ OVERRIDE METHODS ------------------------ @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { + public Dialog onCreateDialog(Bundle savedInstanceState) { final MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); View body = activity.getLayoutInflater().inflate(R.layout.dialog_menu_list, null); @@ -77,23 +75,19 @@ public class UserMenuDialogFragment extends MenuDialogFragment listView.setAdapter(adapter); listView.setOnItemClickListener(onItemClickListener); - TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() - { + TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() { @Override - public void success(User user) - { + public void success(User user) { List<Command> commands = getCommands(activity, user, account); Command.filter(commands); - for(Command command : commands) - { + for (Command command : commands) { adapter.addToBottom(command); } adapter.update(); } @Override - public void error() - { + public void error() { dismiss(); } }); @@ -105,26 +99,22 @@ public class UserMenuDialogFragment extends MenuDialogFragment } @Override - protected void onItemClick(AdapterView<?> adapterView, int i) - { + protected void onItemClick(AdapterView<?> adapterView, int i) { super.onItemClick(adapterView, i); dismiss(); } // -------------------------- OTHER METHODS -------------------------- - public boolean addBottomCommands(Activity activity, User user, ArrayList<Command> commands) - { + public boolean addBottomCommands(Activity activity, User user, ArrayList<Command> commands) { return commands.add(new CommandSearchOnTwitter(activity, user.getScreenName())); } - public boolean addMainCommands(Activity activity, User user, Account account, ArrayList<Command> commands) - { + public boolean addMainCommands(Activity activity, User user, Account account, ArrayList<Command> commands) { return commands.addAll(Command.getUserCommands(activity, user, account)); } - public List<Command> getCommands(Activity activity, User user, Account account) - { + public List<Command> getCommands(Activity activity, User user, Account account) { ArrayList<Command> commands = new ArrayList<>(); addMainCommands(activity, user, account, commands); addBottomCommands(activity, user, commands); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/listener/ListItemClickListener.java b/app/src/main/java/net/lacolaco/smileessence/view/listener/ListItemClickListener.java index 697e995c..bfb3573f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/view/listener/ListItemClickListener.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/listener/ListItemClickListener.java @@ -27,11 +27,11 @@ package net.lacolaco.smileessence.view.listener; import android.app.Activity; import android.graphics.drawable.ColorDrawable; import android.view.View; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.util.UIHandler; -public class ListItemClickListener implements View.OnClickListener -{ +public class ListItemClickListener implements View.OnClickListener { // ------------------------------ FIELDS ------------------------------ @@ -40,8 +40,7 @@ public class ListItemClickListener implements View.OnClickListener // --------------------------- CONSTRUCTORS --------------------------- - public ListItemClickListener(Activity activity, Runnable callback) - { + public ListItemClickListener(Activity activity, Runnable callback) { this.activity = activity; this.callback = callback; } @@ -52,17 +51,14 @@ public class ListItemClickListener implements View.OnClickListener // --------------------- Interface OnClickListener --------------------- @Override - public void onClick(final View v) - { + public void onClick(final View v) { final int currentBgColor = ((ColorDrawable) v.getBackground()).getColor(); v.setBackgroundColor(activity.getResources().getColor(R.color.metro_blue)); v.invalidate(); - new UIHandler() - { + new UIHandler() { @Override - public void run() - { + public void run() { v.setBackgroundColor(currentBgColor); callback.run(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/CheckBoxModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/CheckBoxModel.java index b43bcb9a..08b3ad7e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/CheckBoxModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/CheckBoxModel.java @@ -29,10 +29,10 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; + import net.lacolaco.smileessence.R; -public class CheckBoxModel implements IViewModel -{ +public class CheckBoxModel implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -41,21 +41,18 @@ public class CheckBoxModel implements IViewModel // --------------------------- CONSTRUCTORS --------------------------- - public CheckBoxModel(String text, boolean isChecked) - { + public CheckBoxModel(String text, boolean isChecked) { this.text = text; checked = isChecked; } // --------------------- GETTER / SETTER METHODS --------------------- - public boolean isChecked() - { + public boolean isChecked() { return checked; } - public void setChecked(boolean checked) - { + public void setChecked(boolean checked) { this.checked = checked; } @@ -65,19 +62,15 @@ public class CheckBoxModel implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.menu_item_checkbox, null); } CheckBox checkBox = (CheckBox) convertedView.findViewById(R.id.checkBox_menuItem); checkBox.setText(this.text); - checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() - { + checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) - { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { CheckBoxModel.this.checked = isChecked; } }); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EditableCheckBoxModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EditableCheckBoxModel.java index 3694aee1..ccfd9e70 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EditableCheckBoxModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EditableCheckBoxModel.java @@ -32,10 +32,10 @@ import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; + import net.lacolaco.smileessence.R; -public class EditableCheckBoxModel implements IViewModel -{ +public class EditableCheckBoxModel implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -46,42 +46,35 @@ public class EditableCheckBoxModel implements IViewModel // --------------------------- CONSTRUCTORS --------------------------- - public EditableCheckBoxModel(String text) - { + public EditableCheckBoxModel(String text) { this.text = text; } // --------------------- GETTER / SETTER METHODS --------------------- - public String getInputText() - { + public String getInputText() { return inputText; } - public EditableCheckBoxModel setInputText(String inputText) - { + public EditableCheckBoxModel setInputText(String inputText) { this.inputText = inputText; return this; } - public boolean isChecked() - { + public boolean isChecked() { return checked; } - public EditableCheckBoxModel setChecked(boolean checked) - { + public EditableCheckBoxModel setChecked(boolean checked) { this.checked = checked; return this; } - public boolean isFreezing() - { + public boolean isFreezing() { return freezing; } - public EditableCheckBoxModel setFreezing(boolean freezing) - { + public EditableCheckBoxModel setFreezing(boolean freezing) { this.freezing = freezing; return this; } @@ -92,41 +85,33 @@ public class EditableCheckBoxModel implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.menu_item_editable_checkbox, null); } CheckBox checkBox = (CheckBox) convertedView.findViewById(R.id.checkBox_menuItem); checkBox.setText(this.text); checkBox.setChecked(checked); checkBox.setEnabled(!isFreezing()); - checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() - { + checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) - { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { EditableCheckBoxModel.this.setChecked(isChecked); } }); EditText editText = (EditText) convertedView.findViewById(R.id.edittext_editable_checkbox); - editText.addTextChangedListener(new TextWatcher() - { + editText.addTextChangedListener(new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) - { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) - { + public void onTextChanged(CharSequence s, int start, int before, int count) { EditableCheckBoxModel.this.setInputText(s.toString()); } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { } }); return convertedView; diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EnumEvent.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EnumEvent.java index 7a019492..a241c9bc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EnumEvent.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EnumEvent.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.viewmodel; import net.lacolaco.smileessence.R; -public enum EnumEvent -{ +public enum EnumEvent { FAVORITED(R.string.format_event_favorited), UNFAVORITED(R.string.format_event_unfavorited), @@ -44,15 +43,13 @@ public enum EnumEvent // --------------------------- CONSTRUCTORS --------------------------- - private EnumEvent(int textFormatResourceID) - { + private EnumEvent(int textFormatResourceID) { this.textFormatResourceID = textFormatResourceID; } // --------------------- GETTER / SETTER METHODS --------------------- - public int getTextFormatResourceID() - { + public int getTextFormatResourceID() { return textFormatResourceID; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EventViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java index 1d59b1b1..79e9e505 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/EventViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java @@ -30,7 +30,9 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; import android.widget.TextView; + import com.android.volley.toolbox.NetworkImageView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.ImageCache; @@ -40,13 +42,13 @@ import net.lacolaco.smileessence.util.Themes; import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.UserDetailDialogFragment; import net.lacolaco.smileessence.view.listener.ListItemClickListener; + import twitter4j.Status; import twitter4j.User; import java.util.Date; -public class EventViewModel implements IViewModel -{ +public class EventViewModel implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -61,13 +63,11 @@ public class EventViewModel implements IViewModel // --------------------------- CONSTRUCTORS --------------------------- - public EventViewModel(EnumEvent event, User source) - { + public EventViewModel(EnumEvent event, User source) { this(event, source, null); } - public EventViewModel(EnumEvent event, User source, Status status) - { + public EventViewModel(EnumEvent event, User source, Status status) { this.event = event; this.createdAt = new Date(); this.sourceUserID = source.getId(); @@ -75,21 +75,15 @@ public class EventViewModel implements IViewModel this.sourceName = source.getName(); this.iconURL = source.getProfileImageURL(); - if(status != null) - { - if(event == EnumEvent.RETWEETED) - { + if (status != null) { + if (event == EnumEvent.RETWEETED) { this.targetStatusID = status.getRetweetedStatus().getId(); this.targetText = status.getRetweetedStatus().getText(); - } - else - { + } else { this.targetStatusID = status.getId(); this.targetText = status.getText(); } - } - else - { + } else { this.targetStatusID = -1L; this.targetText = ""; } @@ -97,48 +91,39 @@ public class EventViewModel implements IViewModel // --------------------- GETTER / SETTER METHODS --------------------- - public Date getCreatedAt() - { + public Date getCreatedAt() { return createdAt; } - public EnumEvent getEvent() - { + public EnumEvent getEvent() { return event; } - public String getIconURL() - { + public String getIconURL() { return iconURL; } - public String getSourceName() - { + public String getSourceName() { return sourceName; } - public String getSourceScreenName() - { + public String getSourceScreenName() { return sourceScreenName; } - public long getSourceUserID() - { + public long getSourceUserID() { return sourceUserID; } - public long getTargetStatusID() - { + public long getTargetStatusID() { return targetStatusID; } - public String getTargetText() - { + public String getTargetText() { return targetText; } - public boolean isStatusEvent() - { + public boolean isStatusEvent() { return targetStatusID != -1L; } @@ -148,10 +133,8 @@ public class EventViewModel implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(final Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(final Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.list_item_status, null); } UserPreferenceHelper preferenceHelper = new UserPreferenceHelper(activity); @@ -179,11 +162,9 @@ public class EventViewModel implements IViewModel favorited.setVisibility(View.GONE); int colorBgNormal = Themes.getStyledColor(activity, theme, R.attr.color_status_bg_normal, 0); convertedView.setBackgroundColor(colorBgNormal); - convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() - { + convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override - public void run() - { + public void run() { UserDetailDialogFragment fragment = new UserDetailDialogFragment(); fragment.setUserID(getSourceUserID()); DialogHelper.showDialog(activity, fragment); @@ -194,8 +175,7 @@ public class EventViewModel implements IViewModel // -------------------------- OTHER METHODS -------------------------- - public String getFormattedString(Context context) - { + public String getFormattedString(Context context) { return context.getString(event.getTextFormatResourceID(), sourceScreenName); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/IViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/IViewModel.java index f4dee60d..6de694d0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/IViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/IViewModel.java @@ -28,8 +28,7 @@ import android.app.Activity; import android.view.LayoutInflater; import android.view.View; -public interface IViewModel -{ +public interface IViewModel { // -------------------------- OTHER METHODS -------------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/MessageViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java index 6210ee3e..12d57b0b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/MessageViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java @@ -29,7 +29,9 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; import android.widget.TextView; + import com.android.volley.toolbox.NetworkImageView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.ImageCache; @@ -43,12 +45,12 @@ import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.MessageDetailDialogFragment; import net.lacolaco.smileessence.view.dialog.UserDetailDialogFragment; import net.lacolaco.smileessence.view.listener.ListItemClickListener; + import twitter4j.DirectMessage; import java.util.Date; -public class MessageViewModel implements IViewModel -{ +public class MessageViewModel implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -66,8 +68,7 @@ public class MessageViewModel implements IViewModel // --------------------------- CONSTRUCTORS --------------------------- - public MessageViewModel(DirectMessage directMessage, Account account) - { + public MessageViewModel(DirectMessage directMessage, Account account) { id = directMessage.getId(); UserCache.getInstance().put(directMessage.getSender()); senderID = directMessage.getSenderId(); @@ -83,63 +84,51 @@ public class MessageViewModel implements IViewModel // --------------------- GETTER / SETTER METHODS --------------------- - public Date getCreatedAt() - { + public Date getCreatedAt() { return createdAt; } - private String getFooterText() - { + private String getFooterText() { String s = StringUtils.dateToString(getCreatedAt()); - if(isMyMessage()) - { + if (isMyMessage()) { s = String.format("%s to @%s", s, recipientScreenName); } return s; } - public long getID() - { + public long getID() { return id; } - public long getRecipientId() - { + public long getRecipientId() { return recipientId; } - public String getRecipientScreenName() - { + public String getRecipientScreenName() { return recipientScreenName; } - public String getSenderIconURL() - { + public String getSenderIconURL() { return senderIconURL; } - public long getSenderID() - { + public long getSenderID() { return senderID; } - public String getSenderName() - { + public String getSenderName() { return senderName; } - public String getSenderScreenName() - { + public String getSenderScreenName() { return senderScreenName; } - public String getText() - { + public String getText() { return text; } - public boolean isMyMessage() - { + public boolean isMyMessage() { return myMessage; } @@ -149,10 +138,8 @@ public class MessageViewModel implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(final Activity activity, LayoutInflater inflater, View convertedView) - { - if(convertedView == null) - { + public View getView(final Activity activity, LayoutInflater inflater, View convertedView) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.list_item_status, null); } UserPreferenceHelper preferenceHelper = new UserPreferenceHelper(activity); @@ -161,11 +148,9 @@ public class MessageViewModel implements IViewModel int theme = ((MainActivity) activity).getThemeIndex(); NetworkImageView icon = (NetworkImageView) convertedView.findViewById(R.id.imageview_status_icon); ImageCache.getInstance().setImageToView(getSenderIconURL(), icon); - icon.setOnClickListener(new View.OnClickListener() - { + icon.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View v) - { + public void onClick(View v) { UserDetailDialogFragment dialogFragment = new UserDetailDialogFragment(); dialogFragment.setUserID(senderID); DialogHelper.showDialog(activity, dialogFragment); @@ -190,11 +175,9 @@ public class MessageViewModel implements IViewModel favorited.setVisibility(View.GONE); int colorBgMessage = Themes.getStyledColor(activity, theme, R.attr.color_message_bg_normal, 0); convertedView.setBackgroundColor(colorBgMessage); - convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() - { + convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override - public void run() - { + public void run() { MessageDetailDialogFragment dialogFragment = new MessageDetailDialogFragment(); dialogFragment.setMessageID(getID()); DialogHelper.showDialog(activity, dialogFragment); @@ -203,13 +186,11 @@ public class MessageViewModel implements IViewModel return convertedView; } - private String getNameString(int nameStyle) - { + private String getNameString(int nameStyle) { return NameStyles.getNameString(nameStyle, getSenderScreenName(), getSenderName()); } - private boolean isMyMessage(Account account) - { + private boolean isMyMessage(Account account) { return senderID == account.userID; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/StatusViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java index 3a11737a..e65de8df 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/StatusViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java @@ -32,7 +32,9 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; + import com.android.volley.toolbox.NetworkImageView; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.data.FavoriteCache; @@ -49,14 +51,14 @@ import net.lacolaco.smileessence.view.dialog.DialogHelper; import net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment; import net.lacolaco.smileessence.view.dialog.UserDetailDialogFragment; import net.lacolaco.smileessence.view.listener.ListItemClickListener; + import twitter4j.*; import java.util.ArrayList; import java.util.Date; import java.util.List; -public class StatusViewModel implements IViewModel -{ +public class StatusViewModel implements IViewModel { // ------------------------------ FIELDS ------------------------------ @@ -82,10 +84,8 @@ public class StatusViewModel implements IViewModel // --------------------------- CONSTRUCTORS --------------------------- - public StatusViewModel(Status status, Account account) - { - if(status.isRetweet()) - { + public StatusViewModel(Status status, Account account) { + if (status.isRetweet()) { retweetedStatus = new StatusViewModel(status.getRetweetedStatus(), account); } id = status.getId(); @@ -111,26 +111,20 @@ public class StatusViewModel implements IViewModel // --------------------- GETTER / SETTER METHODS --------------------- - public Date getCreatedAt() - { - if(isRetweet()) - { + public Date getCreatedAt() { + if (isRetweet()) { return retweetedStatus.createdAt; } return createdAt; } - private List<Long> getEmbeddedStatusIDs() - { + private List<Long> getEmbeddedStatusIDs() { ArrayList<Long> list = new ArrayList<>(); - for(URLEntity url : urls) - { + for (URLEntity url : urls) { Uri uri = Uri.parse(url.getExpandedURL()); - if(uri.getHost().equals("twitter.com")) - { + if (uri.getHost().equals("twitter.com")) { String[] arr = uri.toString().split("/"); - if(arr[arr.length - 2].equals("status")) - { + if (arr[arr.length - 2].equals("status")) { list.add(Long.parseLong(arr[arr.length - 1].split("\\?")[0])); } } @@ -138,11 +132,9 @@ public class StatusViewModel implements IViewModel return list; } - private String getFooterText() - { + private String getFooterText() { StringBuilder builder = new StringBuilder(); - if(isRetweet()) - { + if (isRetweet()) { builder.append("(RT: ").append(this.screenName).append(") "); } builder.append(StringUtils.dateToString(getCreatedAt())); @@ -151,171 +143,135 @@ public class StatusViewModel implements IViewModel return builder.toString(); } - public HashtagEntity[] getHashtags() - { - if(isRetweet()) - { + public HashtagEntity[] getHashtags() { + if (isRetweet()) { return retweetedStatus.hashtags; } return hashtags; } - public String getIconURL() - { - if(isRetweet()) - { + public String getIconURL() { + if (isRetweet()) { return retweetedStatus.iconURL; } return iconURL; } - public long getID() - { + public long getID() { return id; } - public MediaEntity[] getMedia() - { - if(isRetweet()) - { + public MediaEntity[] getMedia() { + if (isRetweet()) { return retweetedStatus.media; } return media; } - public UserMentionEntity[] getMentions() - { - if(isRetweet()) - { + public UserMentionEntity[] getMentions() { + if (isRetweet()) { return retweetedStatus.mentions; } return mentions; } - public String getName() - { - if(isRetweet()) - { + public String getName() { + if (isRetweet()) { return retweetedStatus.name; } return name; } - public StatusViewModel getOriginal() - { + public StatusViewModel getOriginal() { return isRetweet() ? retweetedStatus : this; } - public long getOriginalUserID() - { + public long getOriginalUserID() { return isRetweet() ? getRetweetedStatus().getUserID() : getUserID(); } - public StatusViewModel getRetweetedStatus() - { + public StatusViewModel getRetweetedStatus() { return retweetedStatus; } - public String getScreenName() - { - if(isRetweet()) - { + public String getScreenName() { + if (isRetweet()) { return retweetedStatus.screenName; } return screenName; } - public String getSource() - { - if(isRetweet()) - { + public String getSource() { + if (isRetweet()) { return retweetedStatus.source; } return source; } - public SymbolEntity[] getSymbols() - { + public SymbolEntity[] getSymbols() { return symbols; } - public String getText() - { - if(isRetweet()) - { + public String getText() { + if (isRetweet()) { return retweetedStatus.text; } return text; } - public URLEntity[] getURLs() - { + public URLEntity[] getURLs() { return urls; } - public long getUserID() - { + public long getUserID() { return userID; } - public boolean isFavorited() - { - if(isRetweet()) - { + public boolean isFavorited() { + if (isRetweet()) { return FavoriteCache.getInstance().get(retweetedStatus.id); } return FavoriteCache.getInstance().get(id); } - public boolean isMention() - { - if(isRetweet()) - { + public boolean isMention() { + if (isRetweet()) { return retweetedStatus.isMention; } return isMention; } - public void setMention(boolean mention) - { + public void setMention(boolean mention) { isMention = mention; } - public boolean isMyStatus() - { - if(isRetweet()) - { + public boolean isMyStatus() { + if (isRetweet()) { return retweetedStatus.isMyStatus; } return isMyStatus; } - public void setMyStatus(boolean myStatus) - { + public void setMyStatus(boolean myStatus) { isMyStatus = myStatus; } - public boolean isProtected() - { - if(isRetweet()) - { + public boolean isProtected() { + if (isRetweet()) { return retweetedStatus.isProtected; } return isProtected; } - public boolean isRetweet() - { + public boolean isRetweet() { return retweetedStatus != null; } - public boolean isRetweetOfMe() - { + public boolean isRetweetOfMe() { return isRetweetOfMe; } - public void setRetweetOfMe(boolean retweet) - { + public void setRetweetOfMe(boolean retweet) { this.isRetweetOfMe = retweet; } @@ -325,18 +281,15 @@ public class StatusViewModel implements IViewModel // --------------------- Interface IViewModel --------------------- @Override - public View getView(final Activity activity, final LayoutInflater inflater, View convertedView) - { + public View getView(final Activity activity, final LayoutInflater inflater, View convertedView) { boolean extendStatusURL = new UserPreferenceHelper(activity).getValue(R.string.key_setting_extend_status_url, true); return getView(activity, inflater, convertedView, extendStatusURL); } // -------------------------- OTHER METHODS -------------------------- - public View getView(final Activity activity, final LayoutInflater inflater, View convertedView, boolean extendStatusURL) - { - if(convertedView == null) - { + public View getView(final Activity activity, final LayoutInflater inflater, View convertedView, boolean extendStatusURL) { + if (convertedView == null) { convertedView = inflater.inflate(R.layout.list_item_status, null); } UserPreferenceHelper preferenceHelper = new UserPreferenceHelper(activity); @@ -345,11 +298,9 @@ public class StatusViewModel implements IViewModel int theme = ((MainActivity) activity).getThemeIndex(); NetworkImageView icon = (NetworkImageView) convertedView.findViewById(R.id.imageview_status_icon); ImageCache.getInstance().setImageToView(getIconURL(), icon); - icon.setOnClickListener(new View.OnClickListener() - { + icon.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View v) - { + public void onClick(View v) { onIconClick(activity); } }); @@ -364,12 +315,9 @@ public class StatusViewModel implements IViewModel int colorNormal = Themes.getStyledColor(activity, theme, R.attr.color_status_text_normal, 0); content.setTextColor(colorNormal); String rawText = getText(); - if(isReadMorseEnabled((MainActivity) activity) && Morse.isMorse(rawText)) - { + if (isReadMorseEnabled((MainActivity) activity) && Morse.isMorse(rawText)) { content.setText(String.format("%s\n(%s)", rawText, Morse.morseToJa(rawText))); - } - else - { + } else { content.setText(rawText); } TextView footer = (TextView) convertedView.findViewById(R.id.textview_status_footer); @@ -379,48 +327,36 @@ public class StatusViewModel implements IViewModel footer.setText(getFooterText()); ImageView favorited = (ImageView) convertedView.findViewById(R.id.imageview_status_favorited); favorited.setVisibility(isFavorited() ? View.VISIBLE : View.GONE); - if(isRetweet()) - { + if (isRetweet()) { int colorBgRetweet = Themes.getStyledColor(activity, theme, R.attr.color_status_bg_retweet, 0); convertedView.setBackgroundColor(colorBgRetweet); - } - else if(isMention()) - { + } else if (isMention()) { int colorBgMention = Themes.getStyledColor(activity, theme, R.attr.color_status_bg_mention, 0); convertedView.setBackgroundColor(colorBgMention); - } - else - { + } else { int colorBgNormal = Themes.getStyledColor(activity, theme, R.attr.color_status_bg_normal, 0); convertedView.setBackgroundColor(colorBgNormal); } - convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() - { + convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override - public void run() - { + public void run() { onClick(activity); } })); final ViewGroup embeddedStatus = (ViewGroup) convertedView.findViewById(R.id.view_status_embedded_status); embeddedStatus.removeAllViews(); - if(extendStatusURL) - { - if(containsStatusURL()) - { + if (extendStatusURL) { + if (containsStatusURL()) { embeddedStatus.setVisibility(View.VISIBLE); final Account account = ((MainActivity) activity).getCurrentAccount(); List<Long> embeddedStatusIDs = getEmbeddedStatusIDs(); - for(int i = 0; i < embeddedStatusIDs.size(); i++) - { + for (int i = 0; i < embeddedStatusIDs.size(); i++) { long id = embeddedStatusIDs.get(i); final int index = i; final View finalConvertedView = convertedView; - TwitterUtils.tryGetStatus(account, id, new TwitterUtils.StatusCallback() - { + TwitterUtils.tryGetStatus(account, id, new TwitterUtils.StatusCallback() { @Override - public void success(Status status) - { + public void success(Status status) { StatusViewModel viewModel = new StatusViewModel(status, account); View embeddedHolder = viewModel.getView(activity, inflater, null, false); embeddedStatus.addView(embeddedHolder); @@ -428,67 +364,54 @@ public class StatusViewModel implements IViewModel } @Override - public void error() - { + public void error() { } }); } } - } - else - { + } else { embeddedStatus.setVisibility(View.GONE); } return convertedView; } - public boolean isMention(String screenName) - { - if(mentions == null) - { + public boolean isMention(String screenName) { + if (mentions == null) { return false; } - for(UserMentionEntity mention : mentions) - { - if(mention.getScreenName().equals(screenName)) - { + for (UserMentionEntity mention : mentions) { + if (mention.getScreenName().equals(screenName)) { return true; } } return false; } - public boolean isMyStatus(long userID) - { + public boolean isMyStatus(long userID) { return this.userID == userID; } - public boolean isRetweetOfMe(long userID) - { + public boolean isRetweetOfMe(long userID) { return retweetedStatus != null && retweetedStatus.getUserID() == userID; } - private boolean containsStatusURL() - { + private boolean containsStatusURL() { return getEmbeddedStatusIDs().size() > 0; } - private boolean isReadMorseEnabled(MainActivity activity) - { + private boolean isReadMorseEnabled(MainActivity activity) { return activity.getUserPreferenceHelper().getValue(R.string.key_setting_read_morse, true); } - private void onClick(Activity activity) - { + private void onClick(Activity activity) { StatusDetailDialogFragment fragment = new StatusDetailDialogFragment(); fragment.setStatusID(getID()); DialogHelper.showDialog(activity, fragment, STATUS_DIALOG); } - private void onIconClick(Activity activity) - { + private void onIconClick(Activity activity) { DialogHelper.close(activity, STATUS_DIALOG); UserDetailDialogFragment dialogFragment = new UserDetailDialogFragment(); dialogFragment.setUserID(isRetweet() ? getRetweetedStatus().userID : userID); diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/UserListListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserListListAdapter.java index 588829ec..2d4bb6f8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/UserListListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserListListAdapter.java @@ -25,10 +25,10 @@ package net.lacolaco.smileessence.viewmodel; import android.app.Activity; + import net.lacolaco.smileessence.view.adapter.StatusListAdapter; -public class UserListListAdapter extends StatusListAdapter -{ +public class UserListListAdapter extends StatusListAdapter { // ------------------------------ FIELDS ------------------------------ @@ -36,34 +36,29 @@ public class UserListListAdapter extends StatusListAdapter // --------------------------- CONSTRUCTORS --------------------------- - public UserListListAdapter(Activity activity) - { + public UserListListAdapter(Activity activity) { super(activity); } // --------------------- GETTER / SETTER METHODS --------------------- - public String getListFullName() - { + public String getListFullName() { return listFullName; } - public void setListFullName(String listFullName) - { + public void setListFullName(String listFullName) { this.listFullName = listFullName; } // ------------------------ OVERRIDE METHODS ------------------------ @Override - public void addToBottom(StatusViewModel... items) - { + public void addToBottom(StatusViewModel... items) { super.addToBottom(items); } @Override - public void addToTop(StatusViewModel... items) - { + public void addToTop(StatusViewModel... items) { super.addToTop(items); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/UserViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java index 99757e5e..0b8e9ad4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/UserViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java @@ -26,8 +26,7 @@ package net.lacolaco.smileessence.viewmodel; import twitter4j.User; -public class UserViewModel -{ +public class UserViewModel { // ------------------------------ FIELDS ------------------------------ @@ -48,8 +47,7 @@ public class UserViewModel // --------------------------- CONSTRUCTORS --------------------------- - public UserViewModel(User user) - { + public UserViewModel(User user) { id = user.getId(); screenName = user.getScreenName(); name = user.getName(); @@ -68,73 +66,59 @@ public class UserViewModel // --------------------- GETTER / SETTER METHODS --------------------- - public String getBannerURL() - { + public String getBannerURL() { return bannerURL; } - public String getDescription() - { + public String getDescription() { return description; } - public int getFavoritesCount() - { + public int getFavoritesCount() { return favoritesCount; } - public int getFollowersCount() - { + public int getFollowersCount() { return followersCount; } - public int getFriendsCount() - { + public int getFriendsCount() { return friendsCount; } - public String getIconURL() - { + public String getIconURL() { return iconURL; } - public long getID() - { + public long getID() { return id; } - public String getLocation() - { + public String getLocation() { return location; } - public String getName() - { + public String getName() { return name; } - public String getScreenName() - { + public String getScreenName() { return screenName; } - public int getStatusesCount() - { + public int getStatusesCount() { return statusesCount; } - public String getURL() - { + public String getURL() { return url; } - public boolean isProtected() - { + public boolean isProtected() { return isProtected; } - public boolean isVerified() - { + public boolean isVerified() { return isVerified; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/menu/MainActivityMenuHelper.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/menu/MainActivityMenuHelper.java index 63d2bc43..1b421582 100644 --- a/app/src/main/java/net/lacolaco/smileessence/smileessence/viewmodel/menu/MainActivityMenuHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/menu/MainActivityMenuHelper.java @@ -28,19 +28,18 @@ import android.content.Intent; import android.view.Menu; import android.view.MenuItem; import android.view.SubMenu; + import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.activity.*; import net.lacolaco.smileessence.command.CommandOpenURL; import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.view.adapter.PostState; -public class MainActivityMenuHelper -{ +public class MainActivityMenuHelper { // -------------------------- STATIC METHODS -------------------------- - public static void addItemsToMenu(MainActivity activity, Menu menu) - { + public static void addItemsToMenu(MainActivity activity, Menu menu) { //Post button MenuItem postButton = menu.add(Menu.NONE, R.id.actionbar_post, Menu.NONE, activity.getString(R.string.actionbar_post)); postButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); @@ -71,86 +70,70 @@ public class MainActivityMenuHelper report.setIcon(R.drawable.icon_email); } - public static boolean onItemSelected(MainActivity activity, MenuItem item) - { - switch(item.getItemId()) - { - case R.id.actionbar_post: - { + public static boolean onItemSelected(MainActivity activity, MenuItem item) { + switch (item.getItemId()) { + case R.id.actionbar_post: { openPostPage(activity); return true; } - case R.id.actionbar_search: - { + case R.id.actionbar_search: { openSearchPage(activity); return true; } - case R.id.actionbar_setting: - { + case R.id.actionbar_setting: { Intent intent = new Intent(activity, SettingActivity.class); activity.startActivity(intent); return true; } - case R.id.actionbar_edit_templates: - { + case R.id.actionbar_edit_templates: { Intent intent = new Intent(activity, EditTemplateActivity.class); activity.startActivity(intent); return true; } - case R.id.actionbar_edit_extraction: - { + case R.id.actionbar_edit_extraction: { Intent intent = new Intent(activity, EditExtractionActivity.class); activity.startActivity(intent); return true; } - case R.id.actionbar_edit_commands: - { + case R.id.actionbar_edit_commands: { Intent intent = new Intent(activity, EditCommandActivity.class); activity.startActivity(intent); return true; } - case R.id.actionbar_edit_tabs: - { + case R.id.actionbar_edit_tabs: { Intent intent = new Intent(activity, EditTabActivity.class); activity.startActivity(intent); return true; } - case R.id.actionbar_favstar: - { + case R.id.actionbar_favstar: { new CommandOpenURL(activity, TwitterUtils.getFavstarRecentURL(activity.getCurrentAccount().screenName)).execute(); return true; } - case R.id.actionbar_aclog: - { + case R.id.actionbar_aclog: { new CommandOpenURL(activity, TwitterUtils.getAclogTimelineURL(activity.getCurrentAccount().screenName)).execute(); return true; } - case R.id.actionbar_twilog: - { + case R.id.actionbar_twilog: { new CommandOpenURL(activity, TwitterUtils.getTwilogURL(activity.getCurrentAccount().screenName)).execute(); return true; } - case R.id.actionbar_report: - { + case R.id.actionbar_report: { PostState.getState().beginTransaction() - .appendText(activity.getString(R.string.text_message_to_author, activity.getVersion())) - .commitWithOpen(activity); + .appendText(activity.getString(R.string.text_message_to_author, activity.getVersion())) + .commitWithOpen(activity); return true; } - default: - { + default: { return false; } } } - private static void openPostPage(MainActivity activity) - { + private static void openPostPage(MainActivity activity) { activity.openPostPage(); } - private static void openSearchPage(MainActivity activity) - { + private static void openSearchPage(MainActivity activity) { activity.openSearchPage(); } diff --git a/app/src/main/res/drawable/button_round_blue.xml b/app/src/main/res/drawable/button_round_blue.xml index 302a2172..1bf67afc 100644 --- a/app/src/main/res/drawable/button_round_blue.xml +++ b/app/src/main/res/drawable/button_round_blue.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> <stroke - android:color="@android:color/holo_blue_dark" - android:width="1dp"/> - <solid android:color="@color/gray_dark_dark"/> + android:width="1dp" + android:color="@android:color/holo_blue_dark" /> + <solid android:color="@color/gray_dark_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_blue_light.xml b/app/src/main/res/drawable/button_round_blue_light.xml index e4e4e35c..9454a2ad 100644 --- a/app/src/main/res/drawable/button_round_blue_light.xml +++ b/app/src/main/res/drawable/button_round_blue_light.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> <stroke - android:color="@color/white" - android:width="1dp"/> - <solid android:color="@android:color/holo_blue_dark"/> + android:width="1dp" + android:color="@color/white" /> + <solid android:color="@android:color/holo_blue_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_gray.xml b/app/src/main/res/drawable/button_round_gray.xml index 9704f209..90269bf1 100644 --- a/app/src/main/res/drawable/button_round_gray.xml +++ b/app/src/main/res/drawable/button_round_gray.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> <stroke - android:color="@color/gray_dark_light" - android:width="1dp"/> - <solid android:color="@color/gray_dark_dark"/> + android:width="1dp" + android:color="@color/gray_dark_light" /> + <solid android:color="@color/gray_dark_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_gray_light.xml b/app/src/main/res/drawable/button_round_gray_light.xml index 38f8669e..5040c600 100644 --- a/app/src/main/res/drawable/button_round_gray_light.xml +++ b/app/src/main/res/drawable/button_round_gray_light.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> <stroke - android:color="@color/white" - android:width="1dp"/> - <solid android:color="@color/gray_dark_dark"/> + android:width="1dp" + android:color="@color/white" /> + <solid android:color="@color/gray_dark_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_orange.xml b/app/src/main/res/drawable/button_round_orange.xml index 82452c2b..fdeebb9e 100644 --- a/app/src/main/res/drawable/button_round_orange.xml +++ b/app/src/main/res/drawable/button_round_orange.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - xmlns:android="http://schemas.android.com/apk/res/android" +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke - android:color="@color/orange" - android:width="1dp"/> - <solid android:color="@color/gray_dark_dark"/> + android:width="1dp" + android:color="@color/orange" /> + <solid android:color="@color/gray_dark_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_orange_light.xml b/app/src/main/res/drawable/button_round_orange_light.xml index 6d88166d..df53b207 100644 --- a/app/src/main/res/drawable/button_round_orange_light.xml +++ b/app/src/main/res/drawable/button_round_orange_light.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - xmlns:android="http://schemas.android.com/apk/res/android" +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke - android:color="@color/white" - android:width="1dp"/> - <solid android:color="@color/orange_light"/> + android:width="1dp" + android:color="@color/white" /> + <solid android:color="@color/orange_light" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_red.xml b/app/src/main/res/drawable/button_round_red.xml index 541db696..c0bd29b7 100644 --- a/app/src/main/res/drawable/button_round_red.xml +++ b/app/src/main/res/drawable/button_round_red.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> <stroke - android:color="@android:color/holo_red_dark" - android:width="1dp"/> - <solid android:color="@color/gray_dark_dark"/> + android:width="1dp" + android:color="@android:color/holo_red_dark" /> + <solid android:color="@color/gray_dark_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_red_light.xml b/app/src/main/res/drawable/button_round_red_light.xml index 33f4856f..b97adcc6 100644 --- a/app/src/main/res/drawable/button_round_red_light.xml +++ b/app/src/main/res/drawable/button_round_red_light.xml @@ -24,11 +24,10 @@ ~ SOFTWARE. --> -<shape - android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> <stroke - android:color="@color/white" - android:width="1dp"/> - <solid android:color="@android:color/holo_red_dark"/> + android:width="1dp" + android:color="@color/white" /> + <solid android:color="@android:color/holo_red_dark" /> </shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable/button_selector_transparent.xml b/app/src/main/res/drawable/button_selector_transparent.xml index a1fef967..0b70811f 100644 --- a/app/src/main/res/drawable/button_selector_transparent.xml +++ b/app/src/main/res/drawable/button_selector_transparent.xml @@ -27,15 +27,15 @@ <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false"> - <color android:color="@color/gray_dark"/> + <color android:color="@color/gray_dark" /> </item> <item android:state_enabled="true" android:state_pressed="true"> - <color android:color="@color/metro_blue"/> + <color android:color="@color/metro_blue" /> </item> <item android:state_enabled="true" android:state_pressed="false"> - <color android:color="@color/transparent"/> + <color android:color="@color/transparent" /> </item> <item android:state_enabled="true"> - <color android:color="@color/transparent"/> + <color android:color="@color/transparent" /> </item> </selector>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_app_info.xml b/app/src/main/res/layout/dialog_app_info.xml index 696e32a1..78a64347 100644 --- a/app/src/main/res/layout/dialog_app_info.xml +++ b/app/src/main/res/layout/dialog_app_info.xml @@ -25,9 +25,9 @@ --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" @@ -38,49 +38,47 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" + android:gravity="center_horizontal" android:orientation="horizontal" - android:paddingBottom="15dp" - android:gravity="center_horizontal"> + android:paddingBottom="15dp"> <ImageView - android:src="@drawable/icon_application" android:layout_width="80dp" android:layout_height="80dp" - android:layout_gravity="center_vertical"/> + android:layout_gravity="center_vertical" + android:src="@drawable/icon_application" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" + android:gravity="center_vertical" android:orientation="vertical" - android:padding="10dp" - android:gravity="center_vertical"> + android:padding="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name" - android:textSize="20sp"/> + android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_version_full" - android:textSize="16sp"/> + android:textSize="16sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_author" - android:textSize="16sp" - /> + android:textSize="16sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/app_url" - android:textSize="12sp" android:autoLink="web" - /> + android:text="@string/app_url" + android:textSize="12sp" /> </LinearLayout> @@ -91,15 +89,15 @@ android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/app_thanks_to" - android:textStyle="bold" - android:textSize="16sp"/> + android:textSize="16sp" + android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/thanks_to" - android:textSize="16sp"/> + android:textSize="16sp" /> </LinearLayout> </ScrollView>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_menu_list.xml b/app/src/main/res/layout/dialog_menu_list.xml index 0e048b69..f6ca50e8 100644 --- a/app/src/main/res/layout/dialog_menu_list.xml +++ b/app/src/main/res/layout/dialog_menu_list.xml @@ -25,12 +25,12 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?attr/page_background"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?attr/page_background"> <ListView android:id="@+id/listview_dialog_menu_list" android:layout_width="match_parent" - android:layout_height="wrap_content"/> + android:layout_height="wrap_content" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_review.xml b/app/src/main/res/layout/dialog_review.xml index 79a348a1..4a8fcc56 100644 --- a/app/src/main/res/layout/dialog_review.xml +++ b/app/src/main/res/layout/dialog_review.xml @@ -24,13 +24,12 @@ ~ SOFTWARE. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="?attr/page_background" android:orientation="vertical" - android:padding="15dp" - android:background="?attr/page_background"> + android:padding="15dp"> <TextView android:layout_width="wrap_content" @@ -38,7 +37,7 @@ android:layout_marginLeft="5dp" android:layout_marginTop="5dp" android:text="@string/dialog_review_rating_text" - android:textAppearance="?android:attr/textAppearanceMedium"/> + android:textAppearance="?android:attr/textAppearanceMedium" /> <RatingBar android:id="@+id/rating_review" @@ -46,7 +45,7 @@ android:layout_height="wrap_content" android:max="5" android:rating="1" - android:stepSize="1"/> + android:stepSize="1" /> <FrameLayout android:layout_width="match_parent" @@ -56,12 +55,12 @@ <Button android:id="@+id/button_submit" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" - style="?attr/custom_button_transparent" android:text="@string/alert_dialog_ok" - android:textStyle="bold" - android:textColor="?attr/button_blue_foreground"/> + android:textColor="?attr/button_blue_foreground" + android:textStyle="bold" /> </FrameLayout> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_search_on_google.xml b/app/src/main/res/layout/dialog_search_on_google.xml index 20fbc5dc..781adbfa 100644 --- a/app/src/main/res/layout/dialog_search_on_google.xml +++ b/app/src/main/res/layout/dialog_search_on_google.xml @@ -24,20 +24,19 @@ ~ SOFTWARE. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="?attr/page_background" android:orientation="vertical" - android:padding="15dp" - android:background="?attr/page_background"> + android:padding="15dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" android:layout_marginBottom="10dp" - android:baselineAligned="false"> + android:baselineAligned="false" + android:orientation="horizontal"> <EditText android:id="@+id/edittext_search_on_google" @@ -46,7 +45,7 @@ android:gravity="top" android:inputType="text|textMultiLine"> - <requestFocus/> + <requestFocus /> </EditText> </LinearLayout> @@ -58,12 +57,12 @@ <Button android:id="@+id/button_submit" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" - style="?attr/custom_button_transparent" android:text="@string/command_search_on_google" - android:textStyle="bold" - android:textColor="?attr/button_blue_foreground"/> + android:textColor="?attr/button_blue_foreground" + android:textStyle="bold" /> </FrameLayout> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_send_message.xml b/app/src/main/res/layout/dialog_send_message.xml index 1d1e128c..4b7e4cba 100644 --- a/app/src/main/res/layout/dialog_send_message.xml +++ b/app/src/main/res/layout/dialog_send_message.xml @@ -24,33 +24,32 @@ ~ SOFTWARE. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="?attr/page_background" android:orientation="vertical" - android:padding="15dp" - android:background="?attr/page_background"> + android:padding="15dp"> <TextView android:id="@+id/textview_send_message_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp" - android:textAppearance="@android:style/TextAppearance.DeviceDefault"/> + android:textAppearance="@android:style/TextAppearance.DeviceDefault" /> <FrameLayout android:layout_width="match_parent" android:layout_height="2dp" - android:background="@color/metro_blue"/> + android:background="@color/metro_blue" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:layout_marginTop="10dp" android:layout_marginBottom="10dp" - android:baselineAligned="false"> + android:layout_marginTop="10dp" + android:baselineAligned="false" + android:orientation="horizontal"> <FrameLayout android:layout_width="match_parent" @@ -65,7 +64,7 @@ android:inputType="text|textMultiLine" android:minHeight="60dp"> - <requestFocus/> + <requestFocus /> </EditText> </FrameLayout> @@ -76,21 +75,21 @@ <ImageButton android:id="@+id/button_send_message_delete" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignParentTop="true" - style="?attr/custom_button_transparent" - android:src="?attr/icon_post_delete" - android:scaleType="fitCenter"/> + android:scaleType="fitCenter" + android:src="?attr/icon_post_delete" /> <TextView android:id="@+id/textview_send_message_count" android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignParentBottom="true" - android:textAppearance="@android:style/TextAppearance.Widget.TextView" + android:freezesText="true" android:gravity="center_horizontal|center_vertical" - android:freezesText="true"/> + android:textAppearance="@android:style/TextAppearance.Widget.TextView" /> </RelativeLayout> </LinearLayout> @@ -103,12 +102,12 @@ <Button android:id="@+id/button_send_message" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" - style="?attr/custom_button_transparent" android:text="@string/post_button_send_message" - android:textStyle="bold" - android:textColor="?attr/button_blue_foreground"/> + android:textColor="?attr/button_blue_foreground" + android:textStyle="bold" /> </FrameLayout> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_status_detail.xml b/app/src/main/res/layout/dialog_status_detail.xml index f85ec7b3..474e9e04 100644 --- a/app/src/main/res/layout/dialog_status_detail.xml +++ b/app/src/main/res/layout/dialog_status_detail.xml @@ -25,8 +25,7 @@ --> -<ScrollView - xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -40,70 +39,70 @@ android:id="@+id/listview_status_detail_reply_to" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="100dp"/> + android:minHeight="100dp" /> <FrameLayout android:layout_width="match_parent" android:layout_height="1px" - android:background="?attr/color_list_divider"/> + android:background="?attr/color_list_divider" /> <include android:id="@+id/layout_status_header" layout="@layout/list_item_status" android:layout_width="fill_parent" - android:layout_height="wrap_content"/> + android:layout_height="wrap_content" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingTop="2dp" + android:layout_gravity="right" android:baselineAligned="false" - android:layout_gravity="right"> + android:orientation="horizontal" + android:paddingTop="2dp"> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" - android:orientation="horizontal" - android:paddingTop="2dp" + android:layout_gravity="left|center_vertical" android:baselineAligned="false" - android:layout_gravity="left|center_vertical"> + android:orientation="horizontal" + android:paddingTop="2dp"> <ImageView android:id="@+id/image_status_detail_fav_count" style="?attr/custom_button_transparent" android:layout_width="24dp" android:layout_height="match_parent" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="@drawable/icon_favorite_on" - android:contentDescription=""/> + android:src="@drawable/icon_favorite_on" /> <TextView android:id="@+id/textview_status_detail_fav_count" android:layout_width="wrap_content" android:layout_height="match_parent" - android:textColor="@color/orange" - android:gravity="center_vertical"/> + android:gravity="center_vertical" + android:textColor="@color/orange" /> <ImageView android:id="@+id/image_status_detail_rt_count" style="?attr/custom_button_transparent" android:layout_width="24dp" android:layout_height="match_parent" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="@drawable/icon_retweet_on" - android:contentDescription=""/> + android:src="@drawable/icon_retweet_on" /> <TextView android:id="@+id/textview_status_detail_rt_count" android:layout_width="wrap_content" android:layout_height="match_parent" - android:textColor="@color/green" - android:gravity="center_vertical"/> + android:gravity="center_vertical" + android:textColor="@color/green" /> </LinearLayout> <ImageButton @@ -111,69 +110,68 @@ style="?attr/custom_button_transparent" android:layout_width="45dp" android:layout_height="40dp" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="?attr/icon_message" - android:contentDescription=""/> + android:src="?attr/icon_message" /> <ImageButton android:id="@+id/button_status_detail_retweet" style="?attr/custom_button_transparent" android:layout_width="45dp" android:layout_height="40dp" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="?attr/icon_retweet_off" - android:contentDescription=""/> + android:src="?attr/icon_retweet_off" /> <ImageButton android:id="@+id/button_status_detail_favorite" style="?attr/custom_button_transparent" android:layout_width="45dp" android:layout_height="40dp" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="?attr/icon_favorite_off" - android:contentDescription=""/> + android:src="?attr/icon_favorite_off" /> <ImageButton android:id="@+id/button_status_detail_delete" style="?attr/custom_button_transparent" android:layout_width="45dp" android:layout_height="40dp" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="?attr/icon_garbage" - android:contentDescription=""/> + android:src="?attr/icon_garbage" /> <ImageButton android:id="@+id/button_status_detail_menu" style="?attr/custom_button_transparent" android:layout_width="45dp" android:layout_height="40dp" - android:padding="0dp" android:layout_weight="1" + android:contentDescription="" + android:padding="0dp" android:scaleType="fitCenter" - android:src="?attr/icon_post_row" - android:contentDescription=""/> + android:src="?attr/icon_post_row" /> </LinearLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="1px" - android:background="?attr/color_list_divider"/> + android:background="?attr/color_list_divider" /> <LinearLayout android:id="@+id/linearlayout_status_detail_menu" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical" android:background="?attr/page_background" - style="?attr/custom_button_transparent"> - </LinearLayout> + android:orientation="vertical"></LinearLayout> </LinearLayout> </ScrollView> diff --git a/app/src/main/res/layout/dialog_talk_list.xml b/app/src/main/res/layout/dialog_talk_list.xml index e2c82765..4fc2f10d 100644 --- a/app/src/main/res/layout/dialog_talk_list.xml +++ b/app/src/main/res/layout/dialog_talk_list.xml @@ -25,15 +25,15 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <ListView android:id="@+id/listview_dialog_talk_list" android:layout_width="match_parent" android:layout_height="match_parent" - android:overScrollMode="never" - android:fastScrollEnabled="true" + android:divider="?attr/color_list_divider" android:dividerHeight="1px" - android:divider="?attr/color_list_divider"/> + android:fastScrollEnabled="true" + android:overScrollMode="never" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/dialog_user_detail.xml b/app/src/main/res/layout/dialog_user_detail.xml index 2abda02e..943fa014 100644 --- a/app/src/main/res/layout/dialog_user_detail.xml +++ b/app/src/main/res/layout/dialog_user_detail.xml @@ -24,12 +24,11 @@ ~ SOFTWARE. --> -<TabHost - xmlns:android="http://schemas.android.com/apk/res/android" +<TabHost xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/page_background" - android:id="@android:id/tabhost"> + android:background="?attr/page_background"> <LinearLayout android:layout_width="match_parent" @@ -39,7 +38,7 @@ <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" - android:layout_height="wrap_content"/> + android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" @@ -64,18 +63,18 @@ android:id="@+id/imageview_user_detail_header" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="fitCenter" - android:layout_gravity="top"/> + android:layout_gravity="top" + android:scaleType="fitCenter" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" + android:background="#a018181a" + android:gravity="center_horizontal" android:orientation="vertical" - android:paddingTop="10dp" android:paddingBottom="10dp" - android:gravity="center_horizontal" - android:background="#a018181a"> + android:paddingTop="10dp"> <com.android.volley.toolbox.NetworkImageView android:id="@+id/imageview_user_detail_icon" @@ -83,13 +82,13 @@ android:layout_height="72dp" android:layout_margin="5dp" android:background="@android:color/background_light" - android:clickable="true"/> + android:clickable="true" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="vertical" android:gravity="center_horizontal" + android:orientation="vertical" android:padding="5dp"> <TextView @@ -98,16 +97,16 @@ android:layout_height="wrap_content" android:text="name" android:textColor="@android:color/background_light" - android:textSize="20dp"/> + android:textSize="20dp" /> <TextView android:id="@+id/textview_user_detail_screenname" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:clickable="true" android:text="screen_name" android:textColor="@android:color/holo_blue_light" - android:textSize="16dp" - android:clickable="true"/> + android:textSize="16dp" /> <TextView android:id="@+id/textview_user_detail_locate" @@ -115,15 +114,15 @@ android:layout_height="wrap_content" android:gravity="center" android:text="locate" - android:textColor="@android:color/background_light"/> + android:textColor="@android:color/background_light" /> <TextView android:id="@+id/textview_user_detail_url" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:autoLink="web" android:gravity="center" - android:text="url" - android:autoLink="web"/> + android:text="url" /> </LinearLayout> </LinearLayout> @@ -132,18 +131,18 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|bottom" - android:paddingBottom="10dp" + android:gravity="right" android:orientation="vertical" - android:gravity="right"> + android:paddingBottom="10dp"> <ImageView android:id="@+id/imageview_user_detail_menu" + style="?attr/custom_button_transparent" android:layout_width="45dp" android:layout_height="45dp" - android:src="@drawable/icon_row_w" - style="?attr/custom_button_transparent" android:clickable="true" - android:contentDescription=""/> + android:contentDescription="" + android:src="@drawable/icon_row_w" /> </LinearLayout> </FrameLayout> @@ -151,13 +150,13 @@ <FrameLayout android:layout_width="fill_parent" android:layout_height="1px" - android:background="?attr/color_list_divider"/> + android:background="?attr/color_list_divider" /> <TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:stretchColumns="0,1,2,3" - android:paddingTop="5dp"> + android:paddingTop="5dp" + android:stretchColumns="0,1,2,3"> <TableRow android:layout_width="match_parent" @@ -168,44 +167,44 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="0" + android:clickable="true" android:gravity="center_horizontal" android:text="0" - android:textSize="20dp" android:textColor="@android:color/holo_blue_light" - android:clickable="true"/> + android:textSize="20dp" /> <TextView android:id="@+id/textview_user_detail_friend_count" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="1" + android:clickable="true" android:gravity="center_horizontal" android:text="0" - android:textSize="20dp" android:textColor="@android:color/holo_blue_light" - android:clickable="true"/> + android:textSize="20dp" /> <TextView android:id="@+id/textview_user_detail_follower_count" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="2" + android:clickable="true" android:gravity="center_horizontal" android:text="0" - android:textSize="20dp" android:textColor="@android:color/holo_blue_light" - android:clickable="true"/> + android:textSize="20dp" /> <TextView android:id="@+id/textview_user_detail_favorite_count" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="3" + android:clickable="true" android:gravity="center_horizontal" android:text="0" - android:textSize="20dp" android:textColor="@android:color/holo_blue_light" - android:clickable="true"/> + android:textSize="20dp" /> </TableRow> @@ -216,28 +215,28 @@ android:layout_height="wrap_content" android:layout_column="0" android:gravity="center_horizontal" - android:text="@string/user_detail_tweets"/> + android:text="@string/user_detail_tweets" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="1" android:gravity="center_horizontal" - android:text="@string/user_detail_following"/> + android:text="@string/user_detail_following" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="2" android:gravity="center_horizontal" - android:text="@string/user_detail_followers"/> + android:text="@string/user_detail_followers" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="3" android:gravity="center_horizontal" - android:text="@string/user_detail_favorites"/> + android:text="@string/user_detail_favorites" /> </TableRow> </TableLayout> @@ -246,70 +245,70 @@ android:layout_width="fill_parent" android:layout_height="1px" android:layout_marginTop="5dp" - android:background="?attr/color_list_divider"/> + android:background="?attr/color_list_divider" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:paddingRight="10dp" - android:paddingLeft="10dp"> + android:paddingLeft="10dp" + android:paddingRight="10dp"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="vertical" android:layout_alignParentLeft="true" + android:layout_centerVertical="true" android:layout_marginTop="15dp" - android:layout_centerVertical="true"> + android:orientation="vertical"> <TextView android:id="@+id/textview_user_detail_followed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" - android:text="followed"/> + android:text="followed" /> <TextView android:id="@+id/texttview_user_detail_protected" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" - android:text="@string/user_detail_protected"/> + android:text="@string/user_detail_protected" /> </LinearLayout> <Button android:id="@+id/button_user_detail_follow" + style="?attr/custom_button_transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/user_detail_follow" - android:textColor="@color/white" - android:textSize="15dp" - android:paddingLeft="15dp" - android:paddingRight="15dp" - android:layout_marginTop="15dp" - android:background="?attr/button_round_blue" android:layout_alignParentRight="true" android:layout_centerVertical="true" - style="?attr/custom_button_transparent"/> + android:layout_marginTop="15dp" + android:background="?attr/button_round_blue" + android:paddingLeft="15dp" + android:paddingRight="15dp" + android:text="@string/user_detail_follow" + android:textColor="@color/white" + android:textSize="15dp" /> </RelativeLayout> <FrameLayout android:layout_width="fill_parent" android:layout_height="1px" - android:background="?attr/color_list_divider"/> + android:background="?attr/color_list_divider" /> <TextView android:id="@+id/textview_user_detail_description" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:minLines="4" + android:paddingBottom="5dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="5dp" - android:paddingBottom="5dp" - android:text="bio" - android:minLines="4"/> + android:text="bio" /> </LinearLayout> </ScrollView> @@ -318,17 +317,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - <com.handmark.pulltorefresh.library.PullToRefreshListView - xmlns:ptr="http://schemas.android.com/apk/res-auto" + <com.handmark.pulltorefresh.library.PullToRefreshListView xmlns:ptr="http://schemas.android.com/apk/res/net.lacolaco.smileessence" android:id="@+id/listview_user_detail_timeline" android:layout_width="match_parent" android:layout_height="wrap_content" - ptr:ptrMode="both" - ptr:ptrShowIndicator="false" - android:overScrollMode="never" - android:fastScrollEnabled="true" + android:divider="?attr/color_list_divider" android:dividerHeight="1px" - android:divider="?attr/color_list_divider"/> + android:fastScrollEnabled="true" + android:overScrollMode="never" + ptr:ptrMode="both" + ptr:ptrShowIndicator="false" /> </FrameLayout> </FrameLayout> </LinearLayout> diff --git a/app/src/main/res/layout/fragment_list.xml b/app/src/main/res/layout/fragment_list.xml index ac705eed..4ba72486 100644 --- a/app/src/main/res/layout/fragment_list.xml +++ b/app/src/main/res/layout/fragment_list.xml @@ -25,18 +25,17 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> - <com.handmark.pulltorefresh.library.PullToRefreshListView - xmlns:ptr="http://schemas.android.com/apk/res-auto" + <com.handmark.pulltorefresh.library.PullToRefreshListView xmlns:ptr="http://schemas.android.com/apk/res/net.lacolaco.smileessence" android:id="@+id/fragment_list_listview" android:layout_width="match_parent" android:layout_height="match_parent" - ptr:ptrMode="both" - ptr:ptrShowIndicator="false" - android:overScrollMode="never" - android:fastScrollEnabled="true" + android:divider="?attr/color_list_divider" android:dividerHeight="1px" - android:divider="?attr/color_list_divider"/> + android:fastScrollEnabled="true" + android:overScrollMode="never" + ptr:ptrMode="both" + ptr:ptrShowIndicator="false" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_post.xml b/app/src/main/res/layout/fragment_post.xml index 992cf37d..f2795126 100644 --- a/app/src/main/res/layout/fragment_post.xml +++ b/app/src/main/res/layout/fragment_post.xml @@ -25,9 +25,9 @@ --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?attr/page_background"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?attr/page_background"> <LinearLayout android:layout_width="match_parent" @@ -40,33 +40,33 @@ android:id="@+id/post_inreplyto_parent" android:layout_width="match_parent" android:layout_height="wrap_content" - android:visibility="gone" - android:background="?attr/button_round_orange"> + android:background="?attr/button_round_orange" + android:visibility="gone"> <include android:id="@+id/layout_post_reply_status" layout="@layout/list_item_status" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1"/> + android:layout_weight="1" /> <ImageButton android:id="@+id/button_post_reply_delete" + style="?attr/custom_button_transparent" android:layout_width="50dp" android:layout_height="match_parent" android:layout_weight="1" - style="?attr/custom_button_transparent" - android:src="?attr/icon_post_delete" - android:scaleType="fitStart"/> + android:scaleType="fitStart" + android:src="?attr/icon_post_delete" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:layout_marginTop="10dp" android:layout_marginBottom="10dp" - android:baselineAligned="false"> + android:layout_marginTop="10dp" + android:baselineAligned="false" + android:orientation="horizontal"> <FrameLayout android:layout_width="match_parent" @@ -81,7 +81,7 @@ android:inputType="text|textMultiLine" android:minHeight="60dp"> - <requestFocus/> + <requestFocus /> </EditText> </FrameLayout> @@ -90,23 +90,23 @@ android:layout_height="match_parent" android:layout_weight="1"> - <ImageButton + <ImageButton android:id="@+id/button_post_delete" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignParentTop="true" - style="?attr/custom_button_transparent" - android:src="?attr/icon_post_delete" - android:scaleType="fitCenter"/> + android:scaleType="fitCenter" + android:src="?attr/icon_post_delete" /> <TextView android:id="@+id/post_text_count" android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignParentBottom="true" - android:textAppearance="@android:style/TextAppearance.Widget.TextView" + android:freezesText="true" android:gravity="center_horizontal|center_vertical" - android:freezesText="true"/> + android:textAppearance="@android:style/TextAppearance.Widget.TextView" /> </RelativeLayout> </LinearLayout> @@ -114,64 +114,64 @@ <GridLayout android:layout_width="match_parent" android:layout_height="40dp" + android:alignmentMode="alignBounds" android:baselineAligned="false" - android:orientation="horizontal" android:columnCount="8" - android:rowCount="1" - android:alignmentMode="alignBounds"> + android:orientation="horizontal" + android:rowCount="1"> <ImageButton android:id="@+id/button_post_media" + style="?attr/custom_button_transparent" android:layout_width="40dp" android:layout_height="match_parent" - style="?attr/custom_button_transparent" - android:scaleType="centerCrop" - android:src="?attr/icon_post_picture" android:layout_column="0" - android:layout_row="0" android:layout_gravity="fill" - android:adjustViewBounds="false"/> + android:layout_row="0" + android:adjustViewBounds="false" + android:scaleType="centerCrop" + android:src="?attr/icon_post_picture" /> <Space android:layout_width="10dp" android:layout_height="match_parent" - android:layout_column="1"/> + android:layout_column="1" /> <ImageButton android:id="@+id/button_post_menu" + style="?attr/custom_button_transparent" android:layout_width="40dp" android:layout_height="match_parent" - style="?attr/custom_button_transparent" - android:scaleType="centerCrop" - android:src="?attr/icon_post_row" android:layout_column="2" - android:layout_row="0" android:layout_gravity="fill" - android:adjustViewBounds="false"/> + android:layout_row="0" + android:adjustViewBounds="false" + android:scaleType="centerCrop" + android:src="?attr/icon_post_row" /> <Space android:layout_width="10dp" android:layout_height="match_parent" - android:layout_column="3"/> + android:layout_column="3" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_gravity="fill" android:layout_column="4" android:layout_columnSpan="4" + android:layout_gravity="fill" android:layout_row="0" android:background="?attr/button_round_blue"> <Button android:id="@+id/button_post_tweet" + style="?attr/custom_button_transparent" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" - style="?attr/custom_button_transparent" android:text="@string/post_button_tweet" - android:textStyle="bold" - android:textColor="?attr/button_blue_foreground"/> + android:textColor="?attr/button_blue_foreground" + android:textStyle="bold" /> </FrameLayout> </GridLayout> @@ -186,16 +186,16 @@ android:id="@+id/image_post_media" android:layout_width="100dp" android:layout_height="100dp" - android:clickable="true"/> + android:clickable="true" /> <ImageButton android:id="@+id/button_post_media_delete" + style="?attr/custom_button_transparent" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginLeft="10dp" - style="?attr/custom_button_transparent" - android:src="?attr/icon_post_delete" - android:scaleType="fitStart"/> + android:scaleType="fitStart" + android:src="?attr/icon_post_delete" /> </LinearLayout> </LinearLayout> diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index af9291cd..02b212ef 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -25,77 +25,76 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> <RelativeLayout android:id="@+id/layout_search_config" android:layout_width="match_parent" android:layout_height="40dp" - android:layout_marginTop="10dp" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" - android:layout_marginRight="5dp"> + android:layout_marginRight="5dp" + android:layout_marginTop="10dp"> <ImageButton android:id="@+id/button_search_queries" + style="?attr/custom_button_transparent" android:layout_width="40dp" android:layout_height="match_parent" android:layout_alignParentLeft="true" - style="?attr/custom_button_transparent" - android:scaleType="centerCrop" - android:src="?attr/icon_labels" android:layout_gravity="fill" - android:adjustViewBounds="false"/> + android:adjustViewBounds="false" + android:scaleType="centerCrop" + android:src="?attr/icon_labels" /> <EditText android:id="@+id/edittext_search" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_toRightOf="@+id/button_search_queries" android:layout_toLeftOf="@+id/button_search_execute" - android:inputType="text"/> + android:layout_toRightOf="@+id/button_search_queries" + android:inputType="text" /> <ImageButton android:id="@+id/button_search_execute" + style="?attr/custom_button_transparent" android:layout_width="40dp" android:layout_height="match_parent" + android:layout_gravity="fill" android:layout_toLeftOf="@+id/button_search_save" - style="?attr/custom_button_transparent" + android:adjustViewBounds="false" android:scaleType="centerCrop" - android:src="?attr/icon_search" - android:layout_gravity="fill" - android:adjustViewBounds="false"/> + android:src="?attr/icon_search" /> <ImageButton android:id="@+id/button_search_save" + style="?attr/custom_button_transparent" android:layout_width="40dp" android:layout_height="match_parent" android:layout_alignParentRight="true" - style="?attr/custom_button_transparent" - android:scaleType="centerCrop" - android:src="?attr/icon_save" android:layout_gravity="fill" - android:adjustViewBounds="false"/> + android:adjustViewBounds="false" + android:scaleType="centerCrop" + android:src="?attr/icon_save" /> </RelativeLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="1dp" android:background="?attr/color_list_divider" - android:paddingTop="2dp" - android:paddingBottom="2dp"/> + android:paddingBottom="2dp" + android:paddingTop="2dp" /> - <com.handmark.pulltorefresh.library.PullToRefreshListView - xmlns:ptr="http://schemas.android.com/apk/res-auto" + <com.handmark.pulltorefresh.library.PullToRefreshListView xmlns:ptr="http://schemas.android.com/apk/res/net.lacolaco.smileessence" android:id="@+id/listview_search" android:layout_width="match_parent" android:layout_height="match_parent" - ptr:ptrMode="both" - ptr:ptrShowIndicator="false" - android:overScrollMode="never" - android:fastScrollEnabled="true" + android:divider="?attr/color_list_divider" android:dividerHeight="1px" - android:divider="?attr/color_list_divider"/> + android:fastScrollEnabled="true" + android:overScrollMode="never" + ptr:ptrMode="both" + ptr:ptrShowIndicator="false" /> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_userlist.xml b/app/src/main/res/layout/fragment_userlist.xml index f836cdc4..b7351dff 100644 --- a/app/src/main/res/layout/fragment_userlist.xml +++ b/app/src/main/res/layout/fragment_userlist.xml @@ -25,29 +25,29 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> <RelativeLayout android:id="@+id/layout_search_config" android:layout_width="match_parent" android:layout_height="40dp" - android:layout_marginTop="10dp" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" - android:layout_marginRight="5dp"> + android:layout_marginRight="5dp" + android:layout_marginTop="10dp"> <ImageButton android:id="@+id/button_userlist_lists" + style="?attr/custom_button_transparent" android:layout_width="40dp" android:layout_height="match_parent" android:layout_alignParentLeft="true" - style="?attr/custom_button_transparent" - android:scaleType="centerCrop" - android:src="?attr/icon_labels" android:layout_gravity="fill" - android:adjustViewBounds="false"/> + android:adjustViewBounds="false" + android:scaleType="centerCrop" + android:src="?attr/icon_labels" /> <TextView android:id="@+id/textview_userlist_name" @@ -56,25 +56,24 @@ android:layout_alignParentRight="true" android:layout_toRightOf="@+id/button_userlist_lists" android:gravity="center_vertical" - android:textAppearance="@android:style/TextAppearance.DeviceDefault"/> + android:textAppearance="@android:style/TextAppearance.DeviceDefault" /> </RelativeLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="1dp" android:background="?attr/color_list_divider" - android:paddingTop="2dp" - android:paddingBottom="2dp"/> + android:paddingBottom="2dp" + android:paddingTop="2dp" /> - <com.handmark.pulltorefresh.library.PullToRefreshListView - xmlns:ptr="http://schemas.android.com/apk/res-auto" + <com.handmark.pulltorefresh.library.PullToRefreshListView xmlns:ptr="http://schemas.android.com/apk/res/net.lacolaco.smileessence" android:id="@+id/listview_userlist" android:layout_width="match_parent" android:layout_height="match_parent" - ptr:ptrMode="both" - ptr:ptrShowIndicator="false" - android:overScrollMode="never" - android:fastScrollEnabled="true" + android:divider="?attr/color_list_divider" android:dividerHeight="1px" - android:divider="?attr/color_list_divider"/> + android:fastScrollEnabled="true" + android:overScrollMode="never" + ptr:ptrMode="both" + ptr:ptrShowIndicator="false" /> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/layout_edit_list.xml b/app/src/main/res/layout/layout_edit_list.xml index 8057a7d0..9e223060 100644 --- a/app/src/main/res/layout/layout_edit_list.xml +++ b/app/src/main/res/layout/layout_edit_list.xml @@ -25,9 +25,9 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?attr/page_background"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?attr/page_background"> <ListView android:id="@+id/listview_edit_list" diff --git a/app/src/main/res/layout/layout_license.xml b/app/src/main/res/layout/layout_license.xml index 879856d7..b4595e12 100644 --- a/app/src/main/res/layout/layout_license.xml +++ b/app/src/main/res/layout/layout_license.xml @@ -25,36 +25,35 @@ --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:padding="10dp"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="10dp"> <TextView + android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Notices of files:" - android:id="@+id/textView" android:layout_gravity="left|center_vertical" + android:text="Notices of files:" android:textSize="20dp" - android:textStyle="bold"/> + android:textStyle="bold" /> <LinearLayout android:id="@+id/linear_license_files" - android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="left|center_vertical" + android:orientation="vertical" + android:paddingBottom="10dp" android:paddingLeft="10dp" - android:paddingTop="10dp" - android:paddingBottom="10dp"> - </LinearLayout> + android:paddingTop="10dp"></LinearLayout> <FrameLayout android:layout_width="match_parent" @@ -63,14 +62,14 @@ android:padding="10dp"> <TextView + android:id="@+id/textView4" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/apache" - android:id="@+id/textView4" android:layout_gravity="center_vertical|left" + android:text="@string/apache" android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small" android:textColor="@color/gray_dark_dark" - android:typeface="monospace"/> + android:typeface="monospace" /> </FrameLayout> diff --git a/app/src/main/res/layout/layout_oauth.xml b/app/src/main/res/layout/layout_oauth.xml index 5898ae59..bdd67be8 100644 --- a/app/src/main/res/layout/layout_oauth.xml +++ b/app/src/main/res/layout/layout_oauth.xml @@ -25,16 +25,16 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_vertical|center_horizontal" - android:layout_margin="15dp"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_margin="15dp" + android:gravity="center_vertical|center_horizontal" + android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/message_oauth_text"/> + android:text="@string/message_oauth_text" /> <TextView android:id="@+id/textView_oauth_link" @@ -42,23 +42,23 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="10dp" - android:autoLink="web"/> + android:autoLink="web" /> <EditText android:id="@+id/editText_oauth_pin" android:layout_width="200sp" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_marginTop="10dp" android:layout_marginBottom="10dp" + android:layout_marginTop="10dp" + android:hint="@string/message_oauth_hint" android:inputType="number" - android:maxLength="7" - android:hint="@string/message_oauth_hint"/> + android:maxLength="7" /> <Button android:id="@+id/button_oauth_auth" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_gravity="center" - android:text="@string/message_oauth_authenticate"/> + android:text="@string/message_oauth_authenticate" /> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/list_item_status.xml b/app/src/main/res/layout/list_item_status.xml index b8d2999b..92905d47 100644 --- a/app/src/main/res/layout/list_item_status.xml +++ b/app/src/main/res/layout/list_item_status.xml @@ -25,16 +25,16 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:padding="5dp"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="5dp"> <com.android.volley.toolbox.NetworkImageView android:id="@+id/imageview_status_icon" android:layout_width="36dp" android:layout_height="36dp" android:layout_alignParentLeft="true" - android:layout_alignParentTop="true"/> + android:layout_alignParentTop="true" /> <TextView android:id="@+id/textview_status_header" @@ -43,25 +43,25 @@ android:layout_alignParentTop="true" android:layout_marginLeft="5dp" android:layout_toRightOf="@+id/imageview_status_icon" - android:gravity="top"/> + android:gravity="top" /> <TextView android:id="@+id/textview_status_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@+id/textview_status_header" android:layout_alignLeft="@+id/textview_status_header" android:layout_alignParentRight="true" + android:layout_below="@+id/textview_status_header" android:layout_marginBottom="3dp" - android:layout_marginTop="1dp"/> + android:layout_marginTop="1dp" /> <TextView android:id="@+id/textview_status_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@+id/textview_status_text" android:layout_alignLeft="@+id/textview_status_text" - android:layout_marginRight="2dp"/> + android:layout_below="@+id/textview_status_text" + android:layout_marginRight="2dp" /> <ImageView android:id="@+id/imageview_status_favorited" @@ -71,17 +71,17 @@ android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_alignTop="@+id/textview_status_header" - android:src="?attr/icon_status_favorite_on" - android:contentDescription=""/> + android:contentDescription="" + android:src="?attr/icon_status_favorite_on" /> <LinearLayout android:id="@+id/view_status_embedded_status" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical" - android:layout_below="@+id/textview_status_footer" android:layout_alignLeft="@+id/textview_status_text" - android:layout_marginTop="3dp" + android:layout_below="@+id/textview_status_footer" android:layout_marginRight="1dp" - android:visibility="gone"/> + android:layout_marginTop="3dp" + android:orientation="vertical" + android:visibility="gone" /> </RelativeLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index 8376458f..ade639f7 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net @@ -23,13 +22,12 @@ ~ SOFTWARE. --> -<android.support.v4.view.ViewPager - xmlns:android="http://schemas.android.com/apk/res/android" +<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/viewPager" - android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" - tools:context=".MainActivity"/> + android:orientation="vertical" + tools:context=".MainActivity" /> diff --git a/app/src/main/res/layout/menu_item_checkbox.xml b/app/src/main/res/layout/menu_item_checkbox.xml index 25247d35..baea3bfa 100644 --- a/app/src/main/res/layout/menu_item_checkbox.xml +++ b/app/src/main/res/layout/menu_item_checkbox.xml @@ -25,10 +25,10 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?android:attr/activatedBackgroundIndicator"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?android:attr/activatedBackgroundIndicator" + android:orientation="vertical"> <CheckBox android:id="@+id/checkBox_menuItem" @@ -37,5 +37,5 @@ android:layout_marginBottom="16dp" android:layout_marginTop="16dp" android:paddingLeft="10dp" - android:textAppearance="?android:attr/textAppearanceMedium"/> + android:textAppearance="?android:attr/textAppearanceMedium" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/menu_item_editable_checkbox.xml b/app/src/main/res/layout/menu_item_editable_checkbox.xml index 2d9833af..ca076598 100644 --- a/app/src/main/res/layout/menu_item_editable_checkbox.xml +++ b/app/src/main/res/layout/menu_item_editable_checkbox.xml @@ -25,29 +25,29 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?android:attr/activatedBackgroundIndicator" - android:baselineAligned="true"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?android:attr/activatedBackgroundIndicator" + android:baselineAligned="true" + android:orientation="horizontal"> <CheckBox android:id="@+id/checkBox_menuItem" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingTop="16dp" - android:paddingLeft="10dp" - android:paddingBottom="16dp" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/edittext_editable_checkbox" - android:textAppearance="?android:attr/textAppearanceMedium"/> + android:paddingBottom="16dp" + android:paddingLeft="10dp" + android:paddingTop="16dp" + android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@+id/edittext_editable_checkbox" android:layout_width="0dp" android:layout_height="wrap_content" - android:paddingTop="16dp" - android:paddingRight="16dp" + android:layout_alignParentRight="true" android:paddingBottom="16dp" - android:layout_alignParentRight="true"/> + android:paddingRight="16dp" + android:paddingTop="16dp" /> </RelativeLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/menu_item_simple_text.xml b/app/src/main/res/layout/menu_item_simple_text.xml index 9fbf7551..ec3a576e 100644 --- a/app/src/main/res/layout/menu_item_simple_text.xml +++ b/app/src/main/res/layout/menu_item_simple_text.xml @@ -25,10 +25,10 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="?android:attr/activatedBackgroundIndicator"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?android:attr/activatedBackgroundIndicator" + android:orientation="vertical"> <TextView android:id="@+id/textView_menuItem_simple" @@ -37,5 +37,5 @@ android:layout_marginBottom="14dp" android:layout_marginTop="14dp" android:paddingLeft="10dp" - android:textAppearance="?android:attr/textAppearanceSmall"/> + android:textAppearance="?android:attr/textAppearanceSmall" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/navigation_list_item.xml b/app/src/main/res/layout/navigation_list_item.xml index a8057d22..fd9f37f8 100644 --- a/app/src/main/res/layout/navigation_list_item.xml +++ b/app/src/main/res/layout/navigation_list_item.xml @@ -25,20 +25,20 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@android:color/transparent" - android:paddingTop="6dp" - android:paddingBottom="6dp" - android:paddingLeft="5dp"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/transparent" + android:orientation="vertical" + android:paddingBottom="6dp" + android:paddingLeft="5dp" + android:paddingTop="6dp"> <TextView android:id="@+id/navigation_list_item_text" android:layout_width="match_parent" android:layout_height="match_parent" + android:gravity="left|center_vertical" android:textAppearance="@android:style/TextAppearance.Holo.Medium.Inverse" - android:textColor="@color/white" - android:gravity="left|center_vertical"/> + android:textColor="@color/white" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/part_edittext.xml b/app/src/main/res/layout/part_edittext.xml index afc10725..6cde5a01 100644 --- a/app/src/main/res/layout/part_edittext.xml +++ b/app/src/main/res/layout/part_edittext.xml @@ -25,15 +25,15 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_width="match_parent" + android:layout_height="wrap_content"> <EditText - android:id="@+id/part_editText" + android:id="@+id/part_edittext" android:layout_width="match_parent" android:layout_height="match_parent" android:inputType="text" - android:paddingTop="20dp" - android:paddingBottom="10dp"/> + android:paddingBottom="10dp" + android:paddingTop="20dp" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/setting.xml b/app/src/main/res/layout/setting.xml index 387723e0..628f8825 100644 --- a/app/src/main/res/layout/setting.xml +++ b/app/src/main/res/layout/setting.xml @@ -25,12 +25,12 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <fragment android:id="@id/fragment_setting" android:name="net.lacolaco.smileessence.view.SettingFragment" android:layout_width="match_parent" - android:layout_height="match_parent"/> + android:layout_height="match_parent" /> </FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/menu/edit_list.xml b/app/src/main/res/menu/edit_list.xml index d45221a2..97fb02b7 100644 --- a/app/src/main/res/menu/edit_list.xml +++ b/app/src/main/res/menu/edit_list.xml @@ -28,5 +28,5 @@ <item android:id="@+id/menu_edit_list_delete" android:icon="@android:drawable/ic_menu_delete" - android:showAsAction="always"/> + android:showAsAction="always" /> </menu>
\ No newline at end of file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index bed3b46f..3d1b0441 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/values/app_info.xml b/app/src/main/res/values/app_info.xml index 1ee75da7..af3f4dc6 100644 --- a/app/src/main/res/values/app_info.xml +++ b/app/src/main/res/values/app_info.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2015 lacolaco.net @@ -24,13 +23,12 @@ --> <resources> - <string name="app_name">rSmileEssence</string> - <string name="app_version">1.0.11.1</string> + <string name="app_name">SmileEssence</string> <string name="app_version_full">1.0.11 \"Dolphin\"</string> <string name="app_url">http://smileessence.lacolaco.net</string> <string name="app_author">Developed by laco0416</string> <string name="app_thanks_to">Thanks to</string> - <string name="thanks_to">miz_hi, yaplus, firstspring1845, ahiru3net, unyuho123, karno, ret156, vividtomato_, hoyo203, brsywe, NTTrf</string> + <string name="thanks_to">miz_hi, yaplus, firstspring1845, ahiru3net, unyuho123, karno, ret156, vividtomato_, hoyo203, brsywe, NTTrf, mikamikafever</string> <string name="library_name_activeandroid">ActiveAndroid</string> <string name="library_name_guava">Guava</string> <string name="library_name_twitter_text">twitter-text</string> @@ -38,4 +36,4 @@ <string name="library_name_crouton">Crouton</string> <string name="library_name_volley">Volley</string> <string name="library_name_pull_to_refresh">PullToRefresh</string> -</resources> +</resources>
\ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index eec53137..15c09f3c 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index eb29f391..31733695 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net @@ -24,34 +23,34 @@ --> <resources> - <attr name="page_background" format="color"/> - <attr name="icon_post_delete" format="reference"/> - <attr name="icon_post_picture" format="reference"/> - <attr name="icon_post_row" format="reference"/> - <attr name="button_blue_background" format="color"/> - <attr name="button_blue_foreground" format="color"/> - <attr name="button_round_blue" format="reference"/> - <attr name="button_red_background" format="color"/> - <attr name="button_red_foreground" format="color"/> - <attr name="button_round_red" format="reference"/> - <attr name="button_round_orange" format="reference"/> - <attr name="custom_button_transparent" format="reference"/> - <attr name="icon_status_favorite_on" format="reference"/> - <attr name="color_status_text_header" format="color"/> - <attr name="color_status_text_normal" format="color"/> - <attr name="color_status_text_footer" format="color"/> - <attr name="color_status_text_mine" format="color"/> - <attr name="color_status_bg_retweet" format="color"/> - <attr name="color_status_bg_mention" format="color"/> - <attr name="color_status_bg_normal" format="color"/> - <attr name="color_list_divider" format="color"/> - <attr name="color_message_text_header" format="color"/> - <attr name="color_message_bg_normal" format="color"/> - <attr name="icon_message" format="reference"/> - <attr name="icon_retweet_off" format="reference"/> - <attr name="icon_favorite_off" format="reference"/> - <attr name="icon_garbage" format="reference"/> - <attr name="icon_search" format="reference"/> - <attr name="icon_labels" format="reference"/> - <attr name="icon_save" format="reference"/> + <attr name="page_background" format="color" /> + <attr name="icon_post_delete" format="reference" /> + <attr name="icon_post_picture" format="reference" /> + <attr name="icon_post_row" format="reference" /> + <attr name="button_blue_background" format="color" /> + <attr name="button_blue_foreground" format="color" /> + <attr name="button_round_blue" format="reference" /> + <attr name="button_red_background" format="color" /> + <attr name="button_red_foreground" format="color" /> + <attr name="button_round_red" format="reference" /> + <attr name="button_round_orange" format="reference" /> + <attr name="custom_button_transparent" format="reference" /> + <attr name="icon_status_favorite_on" format="reference" /> + <attr name="color_status_text_header" format="color" /> + <attr name="color_status_text_normal" format="color" /> + <attr name="color_status_text_footer" format="color" /> + <attr name="color_status_text_mine" format="color" /> + <attr name="color_status_bg_retweet" format="color" /> + <attr name="color_status_bg_mention" format="color" /> + <attr name="color_status_bg_normal" format="color" /> + <attr name="color_list_divider" format="color" /> + <attr name="color_message_text_header" format="color" /> + <attr name="color_message_bg_normal" format="color" /> + <attr name="icon_message" format="reference" /> + <attr name="icon_retweet_off" format="reference" /> + <attr name="icon_favorite_off" format="reference" /> + <attr name="icon_garbage" format="reference" /> + <attr name="icon_search" format="reference" /> + <attr name="icon_labels" format="reference" /> + <attr name="icon_save" format="reference" /> </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 30e2ff8f..66b6fa98 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/values/commands.xml b/app/src/main/res/values/commands.xml index 3addc01c..78dadd16 100644 --- a/app/src/main/res/values/commands.xml +++ b/app/src/main/res/values/commands.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net @@ -24,33 +23,33 @@ --> <resources> - <item name="key_command_status_fav_and_rt" type="id"/> - <item name="key_command_status_quote" type="id"/> - <item name="key_command_status_copy_text_to_clipboard" type="id"/> - <item name="key_command_status_copy_url_to_clipboard" type="id"/> - <item name="key_command_status_share" type="id"/> - <item name="key_command_status_open_in_browser" type="id"/> - <item name="key_command_status_nanigaja" type="id"/> - <item name="key_command_status_make_anonymous" type="id"/> - <item name="key_command_status_tofubuster" type="id"/> - <item name="key_command_user_reply" type="id"/> - <item name="key_command_user_add_to_reply" type="id"/> - <item name="key_command_user_open_favstar" type="id"/> - <item name="key_command_user_open_aclog" type="id"/> - <item name="key_command_user_open_twilog" type="id"/> - <item name="key_command_user_block" type="id"/> - <item name="key_command_user_unblock" type="id"/> - <item name="key_command_user_r4s" type="id"/> - <item name="key_command_user_introduce" type="id"/> - <item name="key_command_user_send_message" type="id"/> - <item name="key_command_status_add_to_reply" type="id"/> - <item name="key_command_status_open_chain" type="id"/> - <item name="key_command_status_add_to_ignore" type="id"/> - <item name="key_command_status_search_on_google" type="id"/> - <item name="key_command_status_copy" type="id"/> - <item name="key_command_status_congratulate" type="id"/> - <item name="key_command_status_review" type="id"/> - <item name="key_command_message_share" type="id"/> - <item name="key_command_message_search_on_google" type="id"/> - <item name="key_command_message_tofubuster" type="id"/> + <item name="key_command_status_fav_and_rt" type="id" /> + <item name="key_command_status_quote" type="id" /> + <item name="key_command_status_copy_text_to_clipboard" type="id" /> + <item name="key_command_status_copy_url_to_clipboard" type="id" /> + <item name="key_command_status_share" type="id" /> + <item name="key_command_status_open_in_browser" type="id" /> + <item name="key_command_status_nanigaja" type="id" /> + <item name="key_command_status_make_anonymous" type="id" /> + <item name="key_command_status_tofubuster" type="id" /> + <item name="key_command_user_reply" type="id" /> + <item name="key_command_user_add_to_reply" type="id" /> + <item name="key_command_user_open_favstar" type="id" /> + <item name="key_command_user_open_aclog" type="id" /> + <item name="key_command_user_open_twilog" type="id" /> + <item name="key_command_user_block" type="id" /> + <item name="key_command_user_unblock" type="id" /> + <item name="key_command_user_r4s" type="id" /> + <item name="key_command_user_introduce" type="id" /> + <item name="key_command_user_send_message" type="id" /> + <item name="key_command_status_add_to_reply" type="id" /> + <item name="key_command_status_open_chain" type="id" /> + <item name="key_command_status_add_to_ignore" type="id" /> + <item name="key_command_status_search_on_google" type="id" /> + <item name="key_command_status_copy" type="id" /> + <item name="key_command_status_congratulate" type="id" /> + <item name="key_command_status_review" type="id" /> + <item name="key_command_message_share" type="id" /> + <item name="key_command_message_search_on_google" type="id" /> + <item name="key_command_message_tofubuster" type="id" /> </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 201e623c..807f9f74 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net @@ -24,20 +23,20 @@ --> <resources> - <item name="actionbar_search" type="id"/> - <item name="actionbar_settings" type="id"/> - <item name="actionbar_setting" type="id"/> - <item name="actionbar_edit_templates" type="id"/> - <item name="actionbar_edit_extraction" type="id"/> - <item name="actionbar_edit_commands" type="id"/> - <item name="actionbar_services" type="id"/> - <item name="actionbar_report" type="id"/> - <item name="actionbar_favstar" type="id"/> - <item name="actionbar_aclog" type="id"/> - <item name="actionbar_twilog" type="id"/> - <item name="fragment_setting" type="id"/> - <item name="menu_edit_list_add" type="id"/> - <item name="menu_edit_command_all_on" type="id"/> - <item name="actionbar_post" type="id"/> - <item name="actionbar_edit_tabs" type="id"/> + <item name="actionbar_search" type="id" /> + <item name="actionbar_settings" type="id" /> + <item name="actionbar_setting" type="id" /> + <item name="actionbar_edit_templates" type="id" /> + <item name="actionbar_edit_extraction" type="id" /> + <item name="actionbar_edit_commands" type="id" /> + <item name="actionbar_services" type="id" /> + <item name="actionbar_report" type="id" /> + <item name="actionbar_favstar" type="id" /> + <item name="actionbar_aclog" type="id" /> + <item name="actionbar_twilog" type="id" /> + <item name="fragment_setting" type="id" /> + <item name="menu_edit_list_add" type="id" /> + <item name="menu_edit_command_all_on" type="id" /> + <item name="actionbar_post" type="id" /> + <item name="actionbar_edit_tabs" type="id" /> </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index b3a3a3be..7449d5ed 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/values/license.xml b/app/src/main/res/values/license.xml index 9c51a370..db854ca5 100644 --- a/app/src/main/res/values/license.xml +++ b/app/src/main/res/values/license.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0afb8164..bc364689 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 11afb285..ea7fab11 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- ~ The MIT License (MIT) ~ ~ Copyright (c) 2012-2014 lacolaco.net diff --git a/app/src/main/res/xml/setting.xml b/app/src/main/res/xml/setting.xml index 30cd6d68..ed8658f0 100644 --- a/app/src/main/res/xml/setting.xml +++ b/app/src/main/res/xml/setting.xml @@ -27,79 +27,79 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory - android:title="@string/setting_category_display_title" - android:summary="@string/setting_category_display_summary"> + android:summary="@string/setting_category_display_summary" + android:title="@string/setting_category_display_title"> <EditTextPreference - android:title="@string/setting_text_size_title" - android:key="@string/key_setting_text_size" android:defaultValue="10" - android:maxLength="2" - android:dialogTitle="@string/setting_text_size_dialog_title" android:dialogMessage="@string/setting_text_size_dialog_message" - android:numeric="decimal"/> + android:dialogTitle="@string/setting_text_size_dialog_title" + android:key="@string/key_setting_text_size" + android:maxLength="2" + android:numeric="decimal" + android:title="@string/setting_text_size_title" /> <ListPreference - android:title="@string/setting_theme_title" - android:key="@string/key_setting_theme" + android:defaultValue="0" android:dialogTitle="@string/setting_theme_dialog_title" android:entries="@array/setting_theme_names" android:entryValues="@array/setting_theme_ids" - android:defaultValue="0"/> + android:key="@string/key_setting_theme" + android:title="@string/setting_theme_title" /> <ListPreference - android:title="@string/setting_namestyle_title" - android:key="@string/key_setting_namestyle" + android:defaultValue="0" android:dialogTitle="@string/setting_namestyle_dialog_title" android:entries="@array/setting_namestyle_names" android:entryValues="@array/setting_namestyle_ids" - android:defaultValue="0"/> + android:key="@string/key_setting_namestyle" + android:title="@string/setting_namestyle_title" /> <SwitchPreference - android:title="@string/setting_read_morse" + android:defaultValue="true" android:key="@string/key_setting_read_morse" - android:defaultValue="true"/> + android:title="@string/setting_read_morse" /> <SwitchPreference - android:title="@string/setting_extend_status_url" + android:defaultValue="false" android:key="@string/key_setting_extend_status_url" android:summary="@string/setting_extend_status_url_summary" - android:defaultValue="false"/> + android:title="@string/setting_extend_status_url" /> </PreferenceCategory> <PreferenceCategory android:title="@string/setting_category_system_title"> <SwitchPreference - android:title="@string/setting_safe_mode_title" - android:summaryOn="@string/setting_safe_mode_summary_on" - android:summaryOff="@string/setting_safe_mode_summary_off" + android:defaultValue="true" android:key="@string/key_setting_show_confirm_dialog" - android:defaultValue="true"/> + android:summaryOff="@string/setting_safe_mode_summary_off" + android:summaryOn="@string/setting_safe_mode_summary_on" + android:title="@string/setting_safe_mode_title" /> <SwitchPreference - android:title="@string/setting_resize_post_image" - android:summary="@string/setting_resize_post_image_summary" + android:defaultValue="true" android:key="@string/key_setting_resize_post_image" - android:defaultValue="true"/> + android:summary="@string/setting_resize_post_image_summary" + android:title="@string/setting_resize_post_image" /> <SwitchPreference - android:title="@string/setting_notify_on_unfavorited_title" - android:summaryOn="@string/setting_notify_on_unfavorited_summary_on" - android:summaryOff="@string/setting_notify_on_unfavorited_summary_off" + android:defaultValue="false" android:key="@string/key_setting_notify_on_unfavorited" - android:defaultValue="false"/> + android:summaryOff="@string/setting_notify_on_unfavorited_summary_off" + android:summaryOn="@string/setting_notify_on_unfavorited_summary_on" + android:title="@string/setting_notify_on_unfavorited_title" /> <EditTextPreference - android:title="@string/setting_timelines_title" - android:summary="@string/setting_timelines_summary_format" - android:key="@string/key_setting_timelines" - android:dialogTitle="@string/setting_timelines_dialog_title" - android:dialogMessage="@string/setting_timelines_dialog_message" android:defaultValue="20" - android:maxLength="3"/> + android:dialogMessage="@string/setting_timelines_dialog_message" + android:dialogTitle="@string/setting_timelines_dialog_title" + android:key="@string/key_setting_timelines" + android:maxLength="3" + android:summary="@string/setting_timelines_summary_format" + android:title="@string/setting_timelines_title" /> </PreferenceCategory> <PreferenceCategory android:title="@string/setting_category_about_title"> <Preference - android:title="@string/setting_application_information_title" - android:key="@string/key_setting_application_information"/> + android:key="@string/key_setting_application_information" + android:title="@string/setting_application_information_title" /> <Preference - android:title="@string/setting_licenses_title" - android:key="@string/key_setting_licenses"/> + android:key="@string/key_setting_licenses" + android:title="@string/setting_licenses_title" /> </PreferenceCategory> <PreferenceCategory android:title="@string/setting_category_account_title"> <Preference - android:title="@string/setting_delete_authentication_title" + android:key="@string/key_setting_clear_account" android:summary="@string/setting_delete_authentication_summary" - android:key="@string/key_setting_clear_account"/> + android:title="@string/setting_delete_authentication_title" /> </PreferenceCategory> </PreferenceScreen>
\ No newline at end of file |