From 3233ca6471af3f966b3f6dee5497421442893ff7 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 14 Nov 2019 17:04:40 +0800 Subject: Move util classes to Utils package. --- .../AccessTokenAuthenticator.java | 1 + .../Activity/AccountPostsActivity.java | 2 +- .../Activity/AccountSavedThingActivity.java | 2 +- .../infinityforreddit/Activity/BaseActivity.java | 2 +- .../Activity/EditCommentActivity.java | 2 +- .../Activity/EditPostActivity.java | 2 +- .../Activity/FilteredThingActivity.java | 2 +- .../Activity/LinkResolverActivity.java | 2 +- .../infinityforreddit/Activity/LoginActivity.java | 2 +- .../infinityforreddit/Activity/MainActivity.java | 2 +- .../Activity/PostLinkActivity.java | 2 +- .../Activity/PostTextActivity.java | 2 +- .../infinityforreddit/Activity/RulesActivity.java | 6 +- .../Activity/SearchResultActivity.java | 2 +- .../Activity/SearchSubredditsResultActivity.java | 2 +- .../Activity/SubredditSelectionActivity.java | 2 +- .../Activity/SubscribedThingListingActivity.java | 2 +- .../Activity/ViewGIFActivity.java | 2 +- .../Activity/ViewImageActivity.java | 2 +- .../Activity/ViewMessageActivity.java | 2 +- .../Activity/ViewPostDetailActivity.java | 4 +- .../Activity/ViewSubredditDetailActivity.java | 2 +- .../Activity/ViewUserDetailActivity.java | 2 +- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 2 +- .../CommentsListingRecyclerViewAdapter.java | 2 +- .../Adapter/PostRecyclerViewAdapter.java | 4 +- .../infinityforreddit/AppModule.java | 1 + .../infinityforreddit/CommentData.java | 2 + .../infinityforreddit/CommentDataSource.java | 2 + .../infinityforreddit/DeleteThing.java | 1 + .../infinityforreddit/FavoriteThing.java | 1 + .../infinityforreddit/FetchComment.java | 1 + .../infinityforreddit/FetchFlairs.java | 2 + .../infinityforreddit/FetchMessages.java | 3 + .../infinityforreddit/FetchMyInfo.java | 1 + .../infinityforreddit/FetchPost.java | 1 + .../infinityforreddit/FetchSubscribedThing.java | 1 + .../Fragment/CommentsListingFragment.java | 2 +- .../infinityforreddit/Fragment/PostFragment.java | 2 +- .../Fragment/PostLayoutBottomSheetFragment.java | 2 +- .../Fragment/SubredditListingFragment.java | 2 +- .../Fragment/UserListingFragment.java | 2 +- .../infinityforreddit/HidePost.java | 1 + .../infinityforreddit/JSONUtils.java | 92 ------------------- .../infinityforreddit/ParseAndSaveAccountInfo.java | 2 + .../infinityforreddit/ParseComment.java | 3 + .../infinityforreddit/ParsePost.java | 2 + .../infinityforreddit/ParseSubredditData.java | 1 + .../infinityforreddit/ParseSubscribedThing.java | 1 + .../infinityforreddit/ParseUserData.java | 1 + .../ml/docilealligator/infinityforreddit/Post.java | 2 + .../infinityforreddit/PostDataSource.java | 1 + .../infinityforreddit/PullNotificationWorker.java | 2 + .../infinityforreddit/ReadMessage.java | 1 + .../infinityforreddit/RedditUtils.java | 102 --------------------- .../infinityforreddit/SaveThing.java | 1 + .../infinityforreddit/SendComment.java | 1 + .../Settings/AboutPreferenceFragment.java | 2 +- .../Settings/CreditsPreferenceFragment.java | 2 +- .../Settings/FontSizePreferenceFragment.java | 2 +- .../Settings/MainPreferenceFragment.java | 2 +- .../Settings/NotificationPreferenceFragment.java | 2 +- .../infinityforreddit/SharedPreferencesUtils.java | 60 ------------ .../infinityforreddit/SubmitPost.java | 2 + .../infinityforreddit/SubredditSubscription.java | 1 + .../infinityforreddit/UserFollowing.java | 1 + .../docilealligator/infinityforreddit/Utils.java | 22 ----- .../infinityforreddit/Utils/JSONUtils.java | 92 +++++++++++++++++++ .../infinityforreddit/Utils/RedditUtils.java | 102 +++++++++++++++++++++ .../Utils/SharedPreferencesUtils.java | 60 ++++++++++++ .../infinityforreddit/Utils/Utils.java | 22 +++++ .../infinityforreddit/VoteThing.java | 1 + 72 files changed, 356 insertions(+), 315 deletions(-) delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Utils.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java index dfccfecd..8440fec7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Map; import ml.docilealligator.infinityforreddit.Account.Account; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import okhttp3.Authenticator; import okhttp3.Headers; import okhttp3.Request; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java index a2a48e35..8eaef666 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java @@ -37,7 +37,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java index 87e8131e..f55086de 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java @@ -42,7 +42,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; public class AccountSavedThingActivity extends BaseActivity { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java index f887e7f1..c7a2abf2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -15,7 +15,7 @@ import androidx.appcompat.app.AppCompatDelegate; import ml.docilealligator.infinityforreddit.ContentFontStyle; import ml.docilealligator.infinityforreddit.FontStyle; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.TitleFontStyle; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java index a1aa24dd..30857891 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java @@ -31,7 +31,7 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditAPI; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java index 535124c0..d8c2fae2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java @@ -32,7 +32,7 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditAPI; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java index 68ec15d0..3c8160f9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -41,7 +41,7 @@ import ml.docilealligator.infinityforreddit.Post; import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index a6e130b8..c7c57387 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -21,7 +21,7 @@ import javax.inject.Inject; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java index e081d5c6..e5aa3668 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java @@ -33,7 +33,7 @@ import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 68edf1d1..0508b82c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -85,7 +85,7 @@ import ml.docilealligator.infinityforreddit.PullNotificationWorker; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java index 6abce5fb..28bdc2ff 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java @@ -40,7 +40,7 @@ import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java index 216d2c3b..4a758517 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java @@ -40,7 +40,7 @@ import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java index 32ff2a6f..01f60356 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java @@ -38,12 +38,12 @@ import ml.docilealligator.infinityforreddit.Adapter.RulesRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.Rule; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; -import ml.docilealligator.infinityforreddit.Utils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java index 458506de..beafad93 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java @@ -46,7 +46,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java index 0b4cc900..5d3c0bf1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java @@ -33,7 +33,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; public class SearchSubredditsResultActivity extends BaseActivity { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java index ffd882d6..e6bbd51c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java @@ -40,7 +40,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListing import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java index 71c1684c..1f0c1e20 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java @@ -41,7 +41,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListing import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java index be842ae0..49b00060 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java @@ -51,7 +51,7 @@ import ml.docilealligator.infinityforreddit.ContentFontStyle; import ml.docilealligator.infinityforreddit.FontStyle; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.TitleFontStyle; import pl.droidsonroids.gif.GifImageView; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java index 652db78e..d7c5303e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java @@ -54,7 +54,7 @@ import ml.docilealligator.infinityforreddit.ContentFontStyle; import ml.docilealligator.infinityforreddit.FontStyle; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.TitleFontStyle; public class ViewImageActivity extends AppCompatActivity { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java index 1de46790..58b8b03e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java @@ -48,7 +48,7 @@ import ml.docilealligator.infinityforreddit.MessageViewModel; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; public class ViewMessageActivity extends BaseActivity { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 6264b0a1..42824df6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -71,9 +71,9 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditAPI; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.SaveThing; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import retrofit2.Call; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index c0628bb4..4c50c45c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -58,7 +58,7 @@ import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index 133e6875..b4617196 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -64,7 +64,7 @@ import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 2074999e..3a21d872 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -73,7 +73,7 @@ import ml.docilealligator.infinityforreddit.Post; import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.VoteThing; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java index 3002ee10..1f629072 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java @@ -44,7 +44,7 @@ import ml.docilealligator.infinityforreddit.CommentData; import ml.docilealligator.infinityforreddit.Fragment.ModifyCommentBottomSheetFragment; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.VoteThing; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index 2c1c31ef..8c7c443d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -63,9 +63,9 @@ import ml.docilealligator.infinityforreddit.Post; import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.SaveThing; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.VoteThing; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java index a0730b73..a3792492 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java @@ -10,6 +10,7 @@ import javax.inject.Singleton; import dagger.Module; import dagger.Provides; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.converter.scalars.ScalarsConverterFactory; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java index a08fa920..9d169147 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java @@ -5,6 +5,8 @@ import android.os.Parcelable; import java.util.ArrayList; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; + public class CommentData implements Parcelable { public static final int VOTE_TYPE_NO_VOTE = 0; public static final int VOTE_TYPE_UPVOTE = 1; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java index 163a8e56..fac8ddd4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java @@ -14,6 +14,8 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/DeleteThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/DeleteThing.java index a23802a3..7ca89ff9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/DeleteThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/DeleteThing.java @@ -5,6 +5,7 @@ import androidx.annotation.NonNull; import java.util.HashMap; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java index e2756098..4183b276 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java @@ -8,6 +8,7 @@ import java.util.Map; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java index 68255c21..f40f2e1d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java @@ -6,6 +6,7 @@ import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchFlairs.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchFlairs.java index 1728163a..28acfeb7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchFlairs.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchFlairs.java @@ -9,6 +9,8 @@ import org.json.JSONException; import java.util.ArrayList; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java index 3cd9b9c9..59b13040 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java @@ -14,6 +14,9 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java index c7b78475..a8430b01 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit; import androidx.annotation.NonNull; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java index d9bda5ab..07523722 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java @@ -4,6 +4,7 @@ import androidx.annotation.NonNull; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java index 79af6f63..de1e1cfe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java index be16db1d..b4ada7d5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java @@ -39,7 +39,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 24b116fd..214f77cb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -62,7 +62,7 @@ import ml.docilealligator.infinityforreddit.PostDataSource; import ml.docilealligator.infinityforreddit.PostViewModel; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java index f4bcce9c..10ee1ca2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java @@ -17,7 +17,7 @@ import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; /** * A simple {@link Fragment} subclass. diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java index 572bbf61..3a5955f1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java @@ -38,7 +38,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SubredditListingViewModel; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java index af14afc8..697ae757 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java @@ -33,7 +33,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.UserListingViewModel; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java index 25626d2c..39f6a2fb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java @@ -5,6 +5,7 @@ import androidx.annotation.NonNull; import java.util.HashMap; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java deleted file mode 100644 index a4edb575..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -/** - * Created by alex on 2/25/18. - */ - -public class JSONUtils { - public static final String KIND_KEY = "kind"; - public static final String DATA_KEY = "data"; - public static final String AFTER_KEY = "after"; - public static final String CHILDREN_KEY = "children"; - public static final String COUNT_KEY = "count"; - public static final String TITLE_KEY = "title"; - public static final String NAME_KEY = "name"; - public static final String SUBREDDIT_NAME_PREFIX_KEY = "subreddit_name_prefixed"; - public static final String SELFTEXT_KEY = "selftext"; - public static final String SELFTEXT_HTML_KEY = "selftext_html"; - public static final String AUTHOR_KEY = "author"; - public static final String AUTHOR_FLAIR_TEXT_KEY = "author_flair_text"; - public static final String LINK_AUTHOR_KEY = "link_author"; - public static final String LINK_FLAIR_TEXT_KEY = "link_flair_text"; - public static final String SCORE_KEY = "score"; - public static final String LIKES_KEY = "likes"; - public static final String NSFW_KEY = "over_18"; - public static final String GILDED_KEY = "gilded"; - public static final String PERMALINK_KEY = "permalink"; - public static final String CREATED_UTC_KEY = "created_utc"; - public static final String PREVIEW_KEY = "preview"; - public static final String IMAGES_KEY = "images"; - public static final String WIDTH_KEY = "width"; - public static final String HEIGHT_KEY = "height"; - public static final String VARIANTS_KEY = "variants"; - public static final String GIF_KEY = "gif"; - public static final String MP4_KEY = "mp4"; - public static final String SOURCE_KEY = "source"; - public static final String URL_KEY = "url"; - public static final String MEDIA_KEY = "media"; - public static final String REDDIT_VIDEO_KEY = "reddit_video"; - public static final String HLS_URL_KEY = "hls_url"; - public static final String IS_VIDEO_KEY = "is_video"; - public static final String CROSSPOST_PARENT_LIST = "crosspost_parent_list"; - public static final String REDDIT_VIDEO_PREVIEW_KEY = "reddit_video_preview"; - public static final String STICKIED_KEY = "stickied"; - public static final String BODY_KEY = "body"; - public static final String COLLAPSED_KEY = "collapsed"; - public static final String IS_SUBMITTER_KEY = "is_submitter"; - public static final String REPLIES_KEY = "replies"; - public static final String DEPTH_KEY = "depth"; - public static final String ID_KEY = "id"; - public static final String SCORE_HIDDEN_KEY = "score_hidden"; - public static final String SUBREDDIT_KEY = "subreddit"; - public static final String BANNER_IMG_KEY = "banner_img"; - public static final String BANNER_BACKGROUND_IMAGE_KEY = "banner_background_image"; - public static final String ICON_IMG_KEY = "icon_img"; - public static final String COMMUNITY_ICON_KEY = "community_icon"; - public static final String LINK_KARMA_KEY = "link_karma"; - public static final String COMMENT_KARMA_KEY = "comment_karma"; - public static final String DISPLAY_NAME = "display_name"; - public static final String SUBREDDIT_TYPE_KEY = "subreddit_type"; - public static final String SUBREDDIT_TYPE_VALUE_USER = "user"; - public static final String SUBSCRIBERS_KEY = "subscribers"; - public static final String PUBLIC_DESCRIPTION_KEY = "public_description"; - public static final String ACTIVE_USER_COUNT_KEY = "active_user_count"; - public static final String IS_GOLD_KEY = "is_gold"; - public static final String IS_FRIEND_KEY = "is_friend"; - public static final String JSON_KEY = "json"; - public static final String PARENT_ID_KEY = "parent_id"; - public static final String LINK_ID_KEY = "link_id"; - public static final String LINK_TITLE_KEY = "link_title"; - public static final String ERRORS_KEY = "errors"; - public static final String ARGS_KEY = "args"; - public static final String FIELDS_KEY = "fields"; - public static final String VALUE_KEY = "value"; - public static final String TEXT_KEY = "text"; - public static final String SPOILER_KEY = "spoiler"; - public static final String RULES_KEY = "rules"; - public static final String SHORT_NAME_KEY = "short_name"; - public static final String DESCRIPTION_KEY = "description"; - public static final String ARCHIVED_KEY = "archived"; - public static final String LOCKEC_KEY = "locked"; - public static final String SAVED_KEY = "saved"; - public static final String TEXT_EDITABLE_KEY = "text_editable"; - public static final String SUBJECT_KEY = "subject"; - public static final String CONTEXT_KEY = "context"; - public static final String DISTINGUISHED_KEY = "distinguished"; - public static final String WAS_COMMENT_KEY = "was_comment"; - public static final String NEW_KEY = "new"; - public static final String NUM_COMMENTS_KEY = "num_comments"; - public static final String HIDDEN_KEY = "hidden"; - public static final String USER_HAS_FAVORITED_KEY = "user_has_favorited"; - public static final String RESOLUTIONS_KEY = "resolutions"; -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java index d991f4a6..387b75f4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java @@ -6,6 +6,8 @@ import android.text.Html; import org.json.JSONException; import org.json.JSONObject; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; + public class ParseAndSaveAccountInfo { public static void parseAndSaveAccountInfo(String response, RedditDataRoomDatabase redditDataRoomDatabase, ParseAndSaveAccountInfoListener parseAndSaveAccountInfoListener) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index 815ef8e3..739b0b84 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -14,6 +14,9 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; + import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_DOWNVOTE; import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_NO_VOTE; import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_UPVOTE; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index 66133766..cc5f8f2a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -13,6 +13,8 @@ import java.util.Calendar; import java.util.Locale; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; /** * Created by alex on 3/21/18. diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java index 915547d1..8a99fd22 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java @@ -9,6 +9,7 @@ import org.json.JSONObject; import java.util.ArrayList; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; class ParseSubredditData { static void parseSubredditData(String response, ParseSubredditDataListener parseSubredditDataListener) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java index 116d2ba2..586df44b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; class ParseSubscribedThing { static void parseSubscribedSubreddits(String response, String accountName, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java index e0fa6651..73932c34 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java @@ -9,6 +9,7 @@ import org.json.JSONObject; import java.util.ArrayList; import ml.docilealligator.infinityforreddit.User.UserData; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; public class ParseUserData { static void parseUserData(String response, ParseUserDataListener parseUserDataListener) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java index fba35a7e..e2135910 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java @@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit; import android.os.Parcel; import android.os.Parcelable; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; + /** * Created by alex on 3/1/18. */ diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java index f49d167b..d35d5667 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java @@ -7,6 +7,7 @@ import androidx.paging.PageKeyedDataSource; import java.util.ArrayList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java index f3eaca39..716c4f0b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java @@ -28,6 +28,8 @@ import javax.inject.Named; import ml.docilealligator.infinityforreddit.Account.Account; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Call; import retrofit2.Response; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java index 5d02d719..03479021 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java @@ -5,6 +5,7 @@ import androidx.annotation.NonNull; import java.util.HashMap; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java deleted file mode 100644 index cc282ca3..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java +++ /dev/null @@ -1,102 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -import android.util.Base64; - -import java.util.HashMap; -import java.util.Map; - -import okhttp3.MediaType; -import okhttp3.RequestBody; - -/** - * Created by alex on 2/23/18. - */ - -public class RedditUtils { - public static final String OAUTH_URL = "https://www.reddit.com/api/v1/authorize.compact"; - public static final String OAUTH_API_BASE_URI = "https://oauth.reddit.com"; - public static final String API_BASE_URI = "https://www.reddit.com"; - public static final String API_UPLOAD_MEDIA_URI = "https://reddit-uploaded-media.s3-accelerate.amazonaws.com"; - public static final String API_UPLOAD_VIDEO_URI = "https://reddit-uploaded-video.s3-accelerate.amazonaws.com"; - - public static final String CLIENT_ID_KEY = "client_id"; - public static final String CLIENT_ID = ""; - public static final String RESPONSE_TYPE_KEY = "response_type"; - public static final String RESPONSE_TYPE = "code"; - public static final String STATE_KEY = "state"; - public static final String STATE = ""; - public static final String REDIRECT_URI_KEY = "redirect_uri"; - public static final String REDIRECT_URI = ""; - public static final String DURATION_KEY = "duration"; - public static final String DURATION = "permanent"; - public static final String SCOPE_KEY = "scope"; - public static final String SCOPE = "identity edit flair history modconfig modflair modlog modposts modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread"; - public static final String ACCESS_TOKEN_KEY = "access_token"; - - public static final String AUTHORIZATION_KEY = "Authorization"; - public static final String AUTHORIZATION_BASE = "bearer "; - public static final String USER_AGENT_KEY = "User-Agent"; - public static final String USER_AGENT = ""; - - public static final String GRANT_TYPE_KEY = "grant_type"; - public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; - public static final String REFRESH_TOKEN_KEY = "refresh_token"; - - public static final String DIR_KEY = "dir"; - public static final String ID_KEY = "id"; - public static final String RANK_KEY = "rank"; - public static final String DIR_UPVOTE = "1"; - public static final String DIR_UNVOTE = "0"; - public static final String DIR_DOWNVOTE = "-1"; - public static final String RANK = "10"; - - public static final String ACTION_KEY = "action"; - public static final String SR_NAME_KEY = "sr_name"; - - public static final String API_TYPE_KEY = "api_type"; - public static final String API_TYPE_JSON = "json"; - public static final String RETURN_RTJSON_KEY = "return_rtjson"; - public static final String TEXT_KEY = "text"; - public static final String URL_KEY = "url"; - public static final String VIDEO_POSTER_URL_KEY = "video_poster_url"; - public static final String THING_ID_KEY = "thing_id"; - - public static final String SR_KEY = "sr"; - public static final String TITLE_KEY = "title"; - public static final String FLAIR_TEXT_KEY = "flair_text"; - public static final String SPOILER_KEY = "spoiler"; - public static final String NSFW_KEY = "nsfw"; - public static final String KIND_KEY = "kind"; - public static final String KIND_SELF = "self"; - public static final String KIND_LINK = "link"; - public static final String KIND_IMAGE = "image"; - public static final String KIND_VIDEO = "video"; - public static final String KIND_VIDEOGIF = "videogif"; - - public static final String FILEPATH_KEY = "filepath"; - public static final String MIMETYPE_KEY = "mimetype"; - - public static final String LINK_KEY = "link"; - public static final String FLAIR_TEMPLATE_ID_KEY = "flair_template_id"; - - public static final String MAKE_FAVORITE_KEY = "make_favorite"; - - public static Map getHttpBasicAuthHeader() { - Map params = new HashMap<>(); - String credentials = String.format("%s:%s", RedditUtils.CLIENT_ID, ""); - String auth = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); - params.put(RedditUtils.AUTHORIZATION_KEY, auth); - return params; - } - - public static Map getOAuthHeader(String accessToken) { - Map params = new HashMap<>(); - params.put(RedditUtils.AUTHORIZATION_KEY, RedditUtils.AUTHORIZATION_BASE + accessToken); - params.put(RedditUtils.USER_AGENT_KEY, RedditUtils.USER_AGENT); - return params; - } - - public static RequestBody getRequestBody(String s) { - return RequestBody.create(MediaType.parse("text/plain"), s); - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SaveThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SaveThing.java index c83f80ae..55babf4e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SaveThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SaveThing.java @@ -5,6 +5,7 @@ import androidx.annotation.NonNull; import java.util.HashMap; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java index e8c035d3..d2d34471 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java index e02da668..65b8237f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java @@ -12,7 +12,7 @@ import androidx.preference.PreferenceFragmentCompat; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; /** * A simple {@link PreferenceFragmentCompat} subclass. diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java index 3712d9ce..7fc725bb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java @@ -11,7 +11,7 @@ import androidx.preference.PreferenceFragmentCompat; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; /** * A simple {@link PreferenceFragmentCompat} subclass. diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FontSizePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FontSizePreferenceFragment.java index 17f5cf05..53abe8ab 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FontSizePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FontSizePreferenceFragment.java @@ -10,7 +10,7 @@ import org.greenrobot.eventbus.EventBus; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; public class FontSizePreferenceFragment extends PreferenceFragmentCompat { @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java index c6f936f4..99d06569 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java @@ -24,7 +24,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NotificationPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NotificationPreferenceFragment.java index 927d3b2a..86169571 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NotificationPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NotificationPreferenceFragment.java @@ -22,7 +22,7 @@ import javax.inject.Inject; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.PullNotificationWorker; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; /** * A simple {@link Fragment} subclass. diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java deleted file mode 100644 index 510cb357..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java +++ /dev/null @@ -1,60 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -/** - * Created by alex on 2/23/18. - */ - -public class SharedPreferencesUtils { - public static final String ENABLE_NOTIFICATION_KEY = "enable_notification"; - public static final String NOTIFICATION_INTERVAL_KEY = "notificaiton_interval"; - public static final String LAZY_MODE_INTERVAL_KEY = "lazy_mode_interval"; - public static final String NSFW_KEY = "nsfw"; - public static final String BLUR_NSFW_KEY = "blur_nsfw"; - public static final String BLUR_SPOILER_KEY = "blur_spoiler"; - public static final String THEME_KEY = "theme"; - public static final String ICON_FOREGROUND_KEY = "icon_foreground"; - public static final String ICON_BACKGROUND_KEY = "icon_background"; - public static final String ERROR_IMAGE_KEY = "error_image"; - public static final String GILDED_ICON_KEY = "gilded_icon"; - public static final String CROSSPOST_ICON_KEY = "crosspost_icon"; - public static final String THUMBTACK_ICON_KEY = "thumbtack_icon"; - public static final String MATERIAL_ICONS_KEY = "material_icons"; - public static final String OPEN_SOURCE_KEY = "open_source"; - public static final String RATE_KEY = "rate"; - public static final String EMAIL_KEY = "email"; - public static final String REDDIT_ACCOUNT_KEY = "reddit_account"; - public static final String SUBREDDIT_KEY = "subreddit"; - public static final String FONT_SIZE_KEY = "font_size"; - public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; - public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; - public static final String AMOLED_DARK_KEY = "amoled_dark"; - public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface"; - public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right"; - public static final String SORT_TYPE_BEST_POST = "sort_type_best_post"; - public static final String SORT_TIME_BEST_POST = "sort_time_best_post"; - public static final String SORT_TYPE_ALL_POST = "sort_type_all_post"; - public static final String SORT_TIME_ALL_POST = "sort_time_all_post"; - public static final String SORT_TYPE_POPULAR_POST = "sort_type_popular_post"; - public static final String SORT_TIME_POPULAR_POST = "sort_time_popular_post"; - public static final String SORT_TYPE_SEARCH_POST = "sort_type_search_post"; - public static final String SORT_TIME_SEARCH_POST = "sort_time_search_post"; - public static final String SORT_TYPE_SUBREDDIT_POST = "sort_type_subreddit_post"; - public static final String SORT_TIME_SUBREDDIT_POST = "sort_time_subreddit_post"; - public static final String SORT_TYPE_USER_POST = "sort_type_user_post"; - public static final String SORT_TIME_USER_POST = "sort_time_user_post"; - public static final String SORT_TYPE_USER_COMMENT = "sort_type_user_comment"; - public static final String SORT_TIME_USER_COMMENT = "sort_time_user_comment"; - public static final String SORT_TYPE_SEARCH_SUBREDDIT = "sort_type_search_subreddit"; - public static final String SORT_TYPE_SEARCH_USER = "sort_type_search_user"; - public static final String SORT_TYPE_POST_COMMENT = "sort_type_post_comment"; - public static final String POST_LAYOUT_FRONT_PAGE_POST = "post_layout_best_post"; - public static final String POST_LAYOUT_POPULAR_POST = "post_layout_popular_post"; - public static final String POST_LAYOUT_ALL_POST = "post_layout_all_post"; - public static final String POST_LAYOUT_SUBREDDIT_POST_BASE = "post_layout_subreddit_post_"; - public static final String POST_LAYOUT_USER_POST_BASE = "post_layout_user_post_"; - public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post"; - public static final int POST_LAYOUT_CARD = 0; - public static final int POST_LAYOUT_COMPACT = 1; - public static final String PULL_NOTIFICATION_TIME = "pull_notification_time"; - public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time"; -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java index f5192823..ace57b38 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java @@ -20,6 +20,8 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.RequestBody; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditSubscription.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditSubscription.java index 15d9ee3b..f79ae19b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditSubscription.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditSubscription.java @@ -9,6 +9,7 @@ import java.util.Map; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java index b48bfde9..bb85667a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java @@ -10,6 +10,7 @@ import java.util.Map; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.User.UserData; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils.java deleted file mode 100644 index cebff4ea..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils.java +++ /dev/null @@ -1,22 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -public class Utils { - public static String addSubredditAndUserLink(String markdown) { - return markdown.replaceAll("((?<=[\\s])|^)/{0,1}[rRuU]/\\w+/{0,1}", "[$0]($0)"); - } - - public static CharSequence trimTrailingWhitespace(CharSequence source) { - - if(source == null) - return ""; - - int i = source.length(); - - // loop back to the first non-whitespace character - do { - i--; - } while (i >= 0 && Character.isWhitespace(source.charAt(i))); - - return source.subSequence(0, i+1); - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java new file mode 100644 index 00000000..0ac098ce --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java @@ -0,0 +1,92 @@ +package ml.docilealligator.infinityforreddit.Utils; + +/** + * Created by alex on 2/25/18. + */ + +public class JSONUtils { + public static final String KIND_KEY = "kind"; + public static final String DATA_KEY = "data"; + public static final String AFTER_KEY = "after"; + public static final String CHILDREN_KEY = "children"; + public static final String COUNT_KEY = "count"; + public static final String TITLE_KEY = "title"; + public static final String NAME_KEY = "name"; + public static final String SUBREDDIT_NAME_PREFIX_KEY = "subreddit_name_prefixed"; + public static final String SELFTEXT_KEY = "selftext"; + public static final String SELFTEXT_HTML_KEY = "selftext_html"; + public static final String AUTHOR_KEY = "author"; + public static final String AUTHOR_FLAIR_TEXT_KEY = "author_flair_text"; + public static final String LINK_AUTHOR_KEY = "link_author"; + public static final String LINK_FLAIR_TEXT_KEY = "link_flair_text"; + public static final String SCORE_KEY = "score"; + public static final String LIKES_KEY = "likes"; + public static final String NSFW_KEY = "over_18"; + public static final String GILDED_KEY = "gilded"; + public static final String PERMALINK_KEY = "permalink"; + public static final String CREATED_UTC_KEY = "created_utc"; + public static final String PREVIEW_KEY = "preview"; + public static final String IMAGES_KEY = "images"; + public static final String WIDTH_KEY = "width"; + public static final String HEIGHT_KEY = "height"; + public static final String VARIANTS_KEY = "variants"; + public static final String GIF_KEY = "gif"; + public static final String MP4_KEY = "mp4"; + public static final String SOURCE_KEY = "source"; + public static final String URL_KEY = "url"; + public static final String MEDIA_KEY = "media"; + public static final String REDDIT_VIDEO_KEY = "reddit_video"; + public static final String HLS_URL_KEY = "hls_url"; + public static final String IS_VIDEO_KEY = "is_video"; + public static final String CROSSPOST_PARENT_LIST = "crosspost_parent_list"; + public static final String REDDIT_VIDEO_PREVIEW_KEY = "reddit_video_preview"; + public static final String STICKIED_KEY = "stickied"; + public static final String BODY_KEY = "body"; + public static final String COLLAPSED_KEY = "collapsed"; + public static final String IS_SUBMITTER_KEY = "is_submitter"; + public static final String REPLIES_KEY = "replies"; + public static final String DEPTH_KEY = "depth"; + public static final String ID_KEY = "id"; + public static final String SCORE_HIDDEN_KEY = "score_hidden"; + public static final String SUBREDDIT_KEY = "subreddit"; + public static final String BANNER_IMG_KEY = "banner_img"; + public static final String BANNER_BACKGROUND_IMAGE_KEY = "banner_background_image"; + public static final String ICON_IMG_KEY = "icon_img"; + public static final String COMMUNITY_ICON_KEY = "community_icon"; + public static final String LINK_KARMA_KEY = "link_karma"; + public static final String COMMENT_KARMA_KEY = "comment_karma"; + public static final String DISPLAY_NAME = "display_name"; + public static final String SUBREDDIT_TYPE_KEY = "subreddit_type"; + public static final String SUBREDDIT_TYPE_VALUE_USER = "user"; + public static final String SUBSCRIBERS_KEY = "subscribers"; + public static final String PUBLIC_DESCRIPTION_KEY = "public_description"; + public static final String ACTIVE_USER_COUNT_KEY = "active_user_count"; + public static final String IS_GOLD_KEY = "is_gold"; + public static final String IS_FRIEND_KEY = "is_friend"; + public static final String JSON_KEY = "json"; + public static final String PARENT_ID_KEY = "parent_id"; + public static final String LINK_ID_KEY = "link_id"; + public static final String LINK_TITLE_KEY = "link_title"; + public static final String ERRORS_KEY = "errors"; + public static final String ARGS_KEY = "args"; + public static final String FIELDS_KEY = "fields"; + public static final String VALUE_KEY = "value"; + public static final String TEXT_KEY = "text"; + public static final String SPOILER_KEY = "spoiler"; + public static final String RULES_KEY = "rules"; + public static final String SHORT_NAME_KEY = "short_name"; + public static final String DESCRIPTION_KEY = "description"; + public static final String ARCHIVED_KEY = "archived"; + public static final String LOCKEC_KEY = "locked"; + public static final String SAVED_KEY = "saved"; + public static final String TEXT_EDITABLE_KEY = "text_editable"; + public static final String SUBJECT_KEY = "subject"; + public static final String CONTEXT_KEY = "context"; + public static final String DISTINGUISHED_KEY = "distinguished"; + public static final String WAS_COMMENT_KEY = "was_comment"; + public static final String NEW_KEY = "new"; + public static final String NUM_COMMENTS_KEY = "num_comments"; + public static final String HIDDEN_KEY = "hidden"; + public static final String USER_HAS_FAVORITED_KEY = "user_has_favorited"; + public static final String RESOLUTIONS_KEY = "resolutions"; +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java new file mode 100644 index 00000000..000178e4 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java @@ -0,0 +1,102 @@ +package ml.docilealligator.infinityforreddit.Utils; + +import android.util.Base64; + +import java.util.HashMap; +import java.util.Map; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +/** + * Created by alex on 2/23/18. + */ + +public class RedditUtils { + public static final String OAUTH_URL = "https://www.reddit.com/api/v1/authorize.compact"; + public static final String OAUTH_API_BASE_URI = "https://oauth.reddit.com"; + public static final String API_BASE_URI = "https://www.reddit.com"; + public static final String API_UPLOAD_MEDIA_URI = "https://reddit-uploaded-media.s3-accelerate.amazonaws.com"; + public static final String API_UPLOAD_VIDEO_URI = "https://reddit-uploaded-video.s3-accelerate.amazonaws.com"; + + public static final String CLIENT_ID_KEY = "client_id"; + public static final String CLIENT_ID = ""; + public static final String RESPONSE_TYPE_KEY = "response_type"; + public static final String RESPONSE_TYPE = "code"; + public static final String STATE_KEY = "state"; + public static final String STATE = ""; + public static final String REDIRECT_URI_KEY = "redirect_uri"; + public static final String REDIRECT_URI = ""; + public static final String DURATION_KEY = "duration"; + public static final String DURATION = "permanent"; + public static final String SCOPE_KEY = "scope"; + public static final String SCOPE = "identity edit flair history modconfig modflair modlog modposts modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread"; + public static final String ACCESS_TOKEN_KEY = "access_token"; + + public static final String AUTHORIZATION_KEY = "Authorization"; + public static final String AUTHORIZATION_BASE = "bearer "; + public static final String USER_AGENT_KEY = "User-Agent"; + public static final String USER_AGENT = ""; + + public static final String GRANT_TYPE_KEY = "grant_type"; + public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; + public static final String REFRESH_TOKEN_KEY = "refresh_token"; + + public static final String DIR_KEY = "dir"; + public static final String ID_KEY = "id"; + public static final String RANK_KEY = "rank"; + public static final String DIR_UPVOTE = "1"; + public static final String DIR_UNVOTE = "0"; + public static final String DIR_DOWNVOTE = "-1"; + public static final String RANK = "10"; + + public static final String ACTION_KEY = "action"; + public static final String SR_NAME_KEY = "sr_name"; + + public static final String API_TYPE_KEY = "api_type"; + public static final String API_TYPE_JSON = "json"; + public static final String RETURN_RTJSON_KEY = "return_rtjson"; + public static final String TEXT_KEY = "text"; + public static final String URL_KEY = "url"; + public static final String VIDEO_POSTER_URL_KEY = "video_poster_url"; + public static final String THING_ID_KEY = "thing_id"; + + public static final String SR_KEY = "sr"; + public static final String TITLE_KEY = "title"; + public static final String FLAIR_TEXT_KEY = "flair_text"; + public static final String SPOILER_KEY = "spoiler"; + public static final String NSFW_KEY = "nsfw"; + public static final String KIND_KEY = "kind"; + public static final String KIND_SELF = "self"; + public static final String KIND_LINK = "link"; + public static final String KIND_IMAGE = "image"; + public static final String KIND_VIDEO = "video"; + public static final String KIND_VIDEOGIF = "videogif"; + + public static final String FILEPATH_KEY = "filepath"; + public static final String MIMETYPE_KEY = "mimetype"; + + public static final String LINK_KEY = "link"; + public static final String FLAIR_TEMPLATE_ID_KEY = "flair_template_id"; + + public static final String MAKE_FAVORITE_KEY = "make_favorite"; + + public static Map getHttpBasicAuthHeader() { + Map params = new HashMap<>(); + String credentials = String.format("%s:%s", RedditUtils.CLIENT_ID, ""); + String auth = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); + params.put(RedditUtils.AUTHORIZATION_KEY, auth); + return params; + } + + public static Map getOAuthHeader(String accessToken) { + Map params = new HashMap<>(); + params.put(RedditUtils.AUTHORIZATION_KEY, RedditUtils.AUTHORIZATION_BASE + accessToken); + params.put(RedditUtils.USER_AGENT_KEY, RedditUtils.USER_AGENT); + return params; + } + + public static RequestBody getRequestBody(String s) { + return RequestBody.create(MediaType.parse("text/plain"), s); + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java new file mode 100644 index 00000000..4379beaf --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -0,0 +1,60 @@ +package ml.docilealligator.infinityforreddit.Utils; + +/** + * Created by alex on 2/23/18. + */ + +public class SharedPreferencesUtils { + public static final String ENABLE_NOTIFICATION_KEY = "enable_notification"; + public static final String NOTIFICATION_INTERVAL_KEY = "notificaiton_interval"; + public static final String LAZY_MODE_INTERVAL_KEY = "lazy_mode_interval"; + public static final String NSFW_KEY = "nsfw"; + public static final String BLUR_NSFW_KEY = "blur_nsfw"; + public static final String BLUR_SPOILER_KEY = "blur_spoiler"; + public static final String THEME_KEY = "theme"; + public static final String ICON_FOREGROUND_KEY = "icon_foreground"; + public static final String ICON_BACKGROUND_KEY = "icon_background"; + public static final String ERROR_IMAGE_KEY = "error_image"; + public static final String GILDED_ICON_KEY = "gilded_icon"; + public static final String CROSSPOST_ICON_KEY = "crosspost_icon"; + public static final String THUMBTACK_ICON_KEY = "thumbtack_icon"; + public static final String MATERIAL_ICONS_KEY = "material_icons"; + public static final String OPEN_SOURCE_KEY = "open_source"; + public static final String RATE_KEY = "rate"; + public static final String EMAIL_KEY = "email"; + public static final String REDDIT_ACCOUNT_KEY = "reddit_account"; + public static final String SUBREDDIT_KEY = "subreddit"; + public static final String FONT_SIZE_KEY = "font_size"; + public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; + public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; + public static final String AMOLED_DARK_KEY = "amoled_dark"; + public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface"; + public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right"; + public static final String SORT_TYPE_BEST_POST = "sort_type_best_post"; + public static final String SORT_TIME_BEST_POST = "sort_time_best_post"; + public static final String SORT_TYPE_ALL_POST = "sort_type_all_post"; + public static final String SORT_TIME_ALL_POST = "sort_time_all_post"; + public static final String SORT_TYPE_POPULAR_POST = "sort_type_popular_post"; + public static final String SORT_TIME_POPULAR_POST = "sort_time_popular_post"; + public static final String SORT_TYPE_SEARCH_POST = "sort_type_search_post"; + public static final String SORT_TIME_SEARCH_POST = "sort_time_search_post"; + public static final String SORT_TYPE_SUBREDDIT_POST = "sort_type_subreddit_post"; + public static final String SORT_TIME_SUBREDDIT_POST = "sort_time_subreddit_post"; + public static final String SORT_TYPE_USER_POST = "sort_type_user_post"; + public static final String SORT_TIME_USER_POST = "sort_time_user_post"; + public static final String SORT_TYPE_USER_COMMENT = "sort_type_user_comment"; + public static final String SORT_TIME_USER_COMMENT = "sort_time_user_comment"; + public static final String SORT_TYPE_SEARCH_SUBREDDIT = "sort_type_search_subreddit"; + public static final String SORT_TYPE_SEARCH_USER = "sort_type_search_user"; + public static final String SORT_TYPE_POST_COMMENT = "sort_type_post_comment"; + public static final String POST_LAYOUT_FRONT_PAGE_POST = "post_layout_best_post"; + public static final String POST_LAYOUT_POPULAR_POST = "post_layout_popular_post"; + public static final String POST_LAYOUT_ALL_POST = "post_layout_all_post"; + public static final String POST_LAYOUT_SUBREDDIT_POST_BASE = "post_layout_subreddit_post_"; + public static final String POST_LAYOUT_USER_POST_BASE = "post_layout_user_post_"; + public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post"; + public static final int POST_LAYOUT_CARD = 0; + public static final int POST_LAYOUT_COMPACT = 1; + public static final String PULL_NOTIFICATION_TIME = "pull_notification_time"; + public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time"; +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java new file mode 100644 index 00000000..c5c299be --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java @@ -0,0 +1,22 @@ +package ml.docilealligator.infinityforreddit.Utils; + +public class Utils { + public static String addSubredditAndUserLink(String markdown) { + return markdown.replaceAll("((?<=[\\s])|^)/{0,1}[rRuU]/\\w+/{0,1}", "[$0]($0)"); + } + + public static CharSequence trimTrailingWhitespace(CharSequence source) { + + if(source == null) + return ""; + + int i = source.length(); + + // loop back to the first non-whitespace character + do { + i--; + } while (i >= 0 && Character.isWhitespace(source.charAt(i))); + + return source.subSequence(0, i+1); + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/VoteThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/VoteThing.java index 854a152d..5bbbeedf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/VoteThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/VoteThing.java @@ -5,6 +5,7 @@ import androidx.annotation.NonNull; import java.util.HashMap; import java.util.Map; +import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; -- cgit v1.2.3