From 0dbb6a745f519986e7033cd8a60dd0c055a559a4 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 8 Jun 2020 21:11:01 +0800 Subject: Move all bottom sheet fragments to package BottomSheetFragment. Add a UrlMenuBottomSheetFragment for future use. --- .../Activity/AccountPostsActivity.java | 2 +- .../Activity/CommentActivity.java | 2 +- .../Activity/CustomThemeListingActivity.java | 4 +- .../Activity/FilteredThingActivity.java | 10 +- .../infinityforreddit/Activity/MainActivity.java | 8 +- .../Activity/PostImageActivity.java | 2 +- .../Activity/PostLinkActivity.java | 2 +- .../Activity/PostTextActivity.java | 2 +- .../Activity/PostVideoActivity.java | 2 +- .../Activity/SearchResultActivity.java | 8 +- .../Activity/ViewMultiRedditDetailActivity.java | 6 +- .../Activity/ViewPostDetailActivity.java | 4 +- .../Activity/ViewSubredditDetailActivity.java | 8 +- .../Activity/ViewUserDetailActivity.java | 6 +- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 8 +- .../CommentsListingRecyclerViewAdapter.java | 2 +- .../CustomThemeListingRecyclerViewAdapter.java | 2 +- .../MultiRedditListingRecyclerViewAdapter.java | 2 +- .../Adapter/PostRecyclerViewAdapter.java | 2 +- .../infinityforreddit/AppComponent.java | 2 +- .../CommentMoreBottomSheetFragment.java | 142 +++++++++++++++++++++ .../CopyTextBottomSheetFragment.java | 115 +++++++++++++++++ .../CreateThemeBottomSheetFragment.java | 90 +++++++++++++ .../CustomThemeOptionsBottomSheetFragment.java | 91 +++++++++++++ .../FlairBottomSheetFragment.java | 125 ++++++++++++++++++ .../MultiRedditOptionsBottomSheetFragment.java | 70 ++++++++++ .../PostCommentSortTypeBottomSheetFragment.java | 119 +++++++++++++++++ .../PostLayoutBottomSheetFragment.java | 65 ++++++++++ .../PostTypeBottomSheetFragment.java | 90 +++++++++++++ .../SearchPostSortTypeBottomSheetFragment.java | 90 +++++++++++++ ...serAndSubredditSortTypeBottomSheetFragment.java | 76 +++++++++++ .../ShareLinkBottomSheetFragment.java | 142 +++++++++++++++++++++ .../SortTimeBottomSheetFragment.java | 112 ++++++++++++++++ .../SortTypeBottomSheetFragment.java | 114 +++++++++++++++++ .../UrlMenuBottomSheetFragment.java | 87 +++++++++++++ .../UserThingSortTypeBottomSheetFragment.java | 86 +++++++++++++ .../Fragment/CommentMoreBottomSheetFragment.java | 142 --------------------- .../Fragment/CopyTextBottomSheetFragment.java | 115 ----------------- .../Fragment/CreateThemeBottomSheetFragment.java | 90 ------------- .../CustomThemeOptionsBottomSheetFragment.java | 91 ------------- .../Fragment/FlairBottomSheetFragment.java | 125 ------------------ .../MultiRedditOptionsBottomSheetFragment.java | 70 ---------- .../PostCommentSortTypeBottomSheetFragment.java | 119 ----------------- .../Fragment/PostLayoutBottomSheetFragment.java | 65 ---------- .../Fragment/PostTypeBottomSheetFragment.java | 90 ------------- .../SearchPostSortTypeBottomSheetFragment.java | 90 ------------- ...serAndSubredditSortTypeBottomSheetFragment.java | 76 ----------- .../Fragment/ShareLinkBottomSheetFragment.java | 142 --------------------- .../Fragment/SortTimeBottomSheetFragment.java | 112 ---------------- .../Fragment/SortTypeBottomSheetFragment.java | 114 ----------------- .../UserThingSortTypeBottomSheetFragment.java | 86 ------------- .../main/res/drawable-night/ic_open_link_24dp.xml | 9 ++ app/src/main/res/drawable/ic_open_link_24dp.xml | 9 ++ .../res/layout/fragment_copy_text_bottom_sheet.xml | 2 +- ...ragment_post_comment_sort_type_bottom_sheet.xml | 2 +- .../layout/fragment_post_layot_bottom_sheet.xml | 2 +- .../res/layout/fragment_sort_time_bottom_sheet.xml | 2 +- .../res/layout/fragment_url_menu_bottom_sheet.xml | 68 ++++++++++ app/src/main/res/values/strings.xml | 2 + 59 files changed, 1748 insertions(+), 1573 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CopyTextBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CreateThemeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CustomThemeOptionsBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FlairBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostCommentSortTypeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostLayoutBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostTypeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchPostSortTypeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/ShareLinkBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTimeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UrlMenuBottomSheetFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UserThingSortTypeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditOptionsBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostCommentSortTypeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostTypeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchPostSortTypeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTimeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTypeBottomSheetFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserThingSortTypeBottomSheetFragment.java create mode 100644 app/src/main/res/drawable-night/ic_open_link_24dp.xml create mode 100644 app/src/main/res/drawable/ic_open_link_24dp.xml create mode 100644 app/src/main/res/layout/fragment_url_menu_bottom_sheet.xml (limited to 'app') 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 81cb85c7..1e6ef259 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java @@ -31,7 +31,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Post.PostDataSource; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java index b1ea2f30..d9c07e88 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java @@ -51,7 +51,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask import ml.docilealligator.infinityforreddit.CommentData; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; -import ml.docilealligator.infinityforreddit.Fragment.CopyTextBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java index 0a8acf90..42ee73c0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java @@ -42,8 +42,8 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; -import ml.docilealligator.infinityforreddit.Fragment.CreateThemeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.CustomThemeOptionsBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CreateThemeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CustomThemeOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; 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 01c74de3..c850f2d3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -30,11 +30,11 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SearchPostSortTypeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SearchPostSortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Post.Post; 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 08596718..14c12d2e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -73,10 +73,10 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostTypeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; import ml.docilealligator.infinityforreddit.Post.PostDataSource; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java index 12d06132..0bfbc20e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java @@ -51,7 +51,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.SubmitImagePostEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Flair; -import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; 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 f59e807b..5edb7c8f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java @@ -41,7 +41,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Flair; -import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; 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 a448759f..29b0256f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java @@ -41,7 +41,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Flair; -import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java index dc590b4e..386032a7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java @@ -53,7 +53,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Flair; -import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; 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 3bda986c..764c065c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java @@ -36,10 +36,10 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SearchPostSortTypeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SearchUserAndSubredditSortTypeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SearchPostSortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SearchUserAndSubredditSortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment; import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java index da94b78e..a87a200a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java @@ -31,9 +31,9 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.RefreshMultiRedditsEvent; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.MultiReddit.DeleteMultiReddit; 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 247bd12e..51a5beaa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -72,8 +72,8 @@ import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.FetchComment; import ml.docilealligator.infinityforreddit.Flair; -import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostCommentSortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostCommentSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.ParseComment; import ml.docilealligator.infinityforreddit.Post.FetchPost; 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 19b34354..0ec10e46 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -62,11 +62,11 @@ import ml.docilealligator.infinityforreddit.Event.GoBackToMainPageEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.SidebarFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Post.PostDataSource; 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 36f3c203..a72c7389 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -61,9 +61,9 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.FetchUserData; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Post.PostDataSource; 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 005da2f0..c4d65766 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -89,21 +89,21 @@ import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity; import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomSheetFragment; import ml.docilealligator.infinityforreddit.CommentData; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager; import ml.docilealligator.infinityforreddit.FetchComment; -import ml.docilealligator.infinityforreddit.Fragment.CommentMoreBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.CopyTextBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Fragment.ShareLinkBottomSheetFragment; import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SaveThing; -import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter; import ml.docilealligator.infinityforreddit.Utils.APIUtils; +import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.VoteThing; 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 3c32b201..0c29ae47 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java @@ -39,7 +39,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.CommentData; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.Fragment.CommentMoreBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SaveThing; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java index b3cbb38c..c4ea3963 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java @@ -21,7 +21,7 @@ import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.Activity.CustomThemeListingActivity; import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; -import ml.docilealligator.infinityforreddit.Fragment.CustomThemeOptionsBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.CustomThemeOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.R; public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java index 7ededb6d..4be79e91 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java @@ -25,7 +25,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import me.zhanghai.android.fastscroll.PopupTextProvider; import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.Fragment.MultiRedditOptionsBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.MultiRedditOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.MultiReddit.FavoriteMultiReddit; import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; import ml.docilealligator.infinityforreddit.R; 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 07009344..7aaaa391 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -75,7 +75,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity; -import ml.docilealligator.infinityforreddit.Fragment.ShareLinkBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomSheetFragment; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Post.PostDataSource; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index f36c1932..651b09b7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -43,7 +43,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; -import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.Fragment.FollowedUsersListingFragment; import ml.docilealligator.infinityforreddit.Fragment.MultiRedditListingFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java new file mode 100644 index 00000000..364096e6 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CommentMoreBottomSheetFragment.java @@ -0,0 +1,142 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Activity.EditCommentActivity; +import ml.docilealligator.infinityforreddit.Activity.ReportActivity; +import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity; +import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity; +import ml.docilealligator.infinityforreddit.CommentData; +import ml.docilealligator.infinityforreddit.R; + + +/** + * A simple {@link Fragment} subclass. + */ +public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_COMMENT = "ECF"; + public static final String EXTRA_ACCESS_TOKEN = "EAT"; + public static final String EXTRA_POSITION = "EP"; + @BindView(R.id.edit_text_view_comment_more_bottom_sheet_fragment) + TextView editTextView; + @BindView(R.id.delete_text_view_comment_more_bottom_sheet_fragment) + TextView deleteTextView; + @BindView(R.id.save_text_view_comment_more_bottom_sheet_fragment) + TextView shareTextView; + @BindView(R.id.copy_text_view_comment_more_bottom_sheet_fragment) + TextView copyTextView; + @BindView(R.id.report_view_comment_more_bottom_sheet_fragment) + TextView reportTextView; + private AppCompatActivity activity; + public CommentMoreBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_comment_more_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + Bundle bundle = getArguments(); + CommentData commentData = bundle.getParcelable(EXTRA_COMMENT); + if (commentData == null) { + dismiss(); + return rootView; + } + String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN); + + if (accessToken != null && !accessToken.equals("")) { + editTextView.setVisibility(View.VISIBLE); + deleteTextView.setVisibility(View.VISIBLE); + + editTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, EditCommentActivity.class); + intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken); + intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, commentData.getFullName()); + intent.putExtra(EditCommentActivity.EXTRA_CONTENT, commentData.getCommentMarkdown()); + intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION)); + if (activity instanceof ViewPostDetailActivity) { + activity.startActivityForResult(intent, ViewPostDetailActivity.EDIT_COMMENT_REQUEST_CODE); + } else { + startActivity(intent); + } + + dismiss(); + }); + + deleteTextView.setOnClickListener(view -> { + dismiss(); + if (activity instanceof ViewPostDetailActivity) { + ((ViewPostDetailActivity) activity).deleteComment(commentData.getFullName(), bundle.getInt(EXTRA_POSITION)); + } else if (activity instanceof ViewUserDetailActivity) { + ((ViewUserDetailActivity) activity).deleteComment(commentData.getFullName()); + } + }); + } + + shareTextView.setOnClickListener(view -> { + dismiss(); + try { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, commentData.getPermalink()); + activity.startActivity(Intent.createChooser(intent, getString(R.string.share))); + } catch (ActivityNotFoundException e) { + Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show(); + } + }); + + copyTextView.setOnClickListener(view -> { + dismiss(); + CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment(); + Bundle copyBundle = new Bundle(); + copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, commentData.getCommentMarkdown()); + copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, commentData.getCommentRawText()); + copyTextBottomSheetFragment.setArguments(copyBundle); + copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag()); + }); + + reportTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, ReportActivity.class); + intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, commentData.getSubredditName()); + intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, commentData.getFullName()); + activity.startActivity(intent); + + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (AppCompatActivity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CopyTextBottomSheetFragment.java new file mode 100644 index 00000000..83cb6569 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CopyTextBottomSheetFragment.java @@ -0,0 +1,115 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class CopyTextBottomSheetFragment extends RoundedBottomSheetDialogFragment { + public static final String EXTRA_RAW_TEXT = "ERT"; + public static final String EXTRA_MARKDOWN = "EM"; + + @BindView(R.id.copy_raw_text_text_view_copy_text_bottom_sheet_fragment) + TextView copyRawTextTextView; + @BindView(R.id.copy_markdown_text_view_copy_text_bottom_sheet_fragment) + TextView copyMarkdownTextView; + @BindView(R.id.copy_all_raw_text_text_view_copy_text_bottom_sheet_fragment) + TextView copyAllRawTextTextView; + @BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment) + TextView copyAllMarkdownTextView; + + private Activity activity; + + public CopyTextBottomSheetFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View rootView = inflater.inflate(R.layout.fragment_copy_text_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + String rawText = getArguments().getString(EXTRA_RAW_TEXT); + String markdownText = getArguments().getString(EXTRA_MARKDOWN); + + copyRawTextTextView.setOnClickListener(view -> { + showCopyDialog(rawText); + dismiss(); + }); + + copyAllRawTextTextView.setOnClickListener(view -> { + copyText(rawText); + dismiss(); + }); + + if (markdownText != null) { + copyMarkdownTextView.setOnClickListener(view -> { + showCopyDialog(markdownText); + dismiss(); + }); + + copyAllMarkdownTextView.setOnClickListener(view -> { + copyText(markdownText); + dismiss(); + }); + } else { + copyMarkdownTextView.setVisibility(View.GONE); + copyAllMarkdownTextView.setVisibility(View.GONE); + } + + return rootView; + } + + private void showCopyDialog(String text) { + LayoutInflater inflater = activity.getLayoutInflater(); + View layout = inflater.inflate(R.layout.copy_text_material_dialog, null); + TextView textView = layout.findViewById(R.id.text_view_copy_text_material_dialog); + textView.setText(text); + new MaterialAlertDialogBuilder(activity, R.style.CopyTextMaterialAlertDialogTheme) + .setTitle(R.string.copy_text) + .setView(layout) + .setPositiveButton(R.string.copy_all, (dialogInterface, i) -> copyText(text)) + .setNegativeButton(R.string.cancel, null) + .show(); + } + + private void copyText(String text) { + ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); + if (clipboard != null) { + ClipData clip = ClipData.newPlainText("simple text", text); + clipboard.setPrimaryClip(clip); + Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CreateThemeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CreateThemeBottomSheetFragment.java new file mode 100644 index 00000000..111916d3 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CreateThemeBottomSheetFragment.java @@ -0,0 +1,90 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; +import ml.docilealligator.infinityforreddit.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class CreateThemeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + @BindView(R.id.import_theme_text_view_create_theme_bottom_sheet_fragment) + TextView importTextView; + @BindView(R.id.light_theme_text_view_create_theme_bottom_sheet_fragment) + TextView lightThemeTextView; + @BindView(R.id.dark_theme_text_view_create_theme_bottom_sheet_fragment) + TextView darkThemeTextView; + @BindView(R.id.amoled_theme_text_view_create_theme_bottom_sheet_fragment) + TextView amoledThemeTextView; + private Activity activity; + + public interface SelectBaseThemeBottomSheetFragmentListener { + void importTheme(); + } + + public CreateThemeBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_create_theme_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + importTextView.setOnClickListener(view -> { + ((SelectBaseThemeBottomSheetFragmentListener) activity).importTheme(); + dismiss(); + }); + + lightThemeTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); + intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo)); + startActivity(intent); + dismiss(); + }); + + darkThemeTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); + intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo_dark)); + startActivity(intent); + dismiss(); + }); + + amoledThemeTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); + intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo_amoled)); + startActivity(intent); + dismiss(); + }); + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CustomThemeOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CustomThemeOptionsBottomSheetFragment.java new file mode 100644 index 00000000..b9a17fef --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/CustomThemeOptionsBottomSheetFragment.java @@ -0,0 +1,91 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; +import ml.docilealligator.infinityforreddit.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class CustomThemeOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_THEME_NAME = "ETN"; + @BindView(R.id.theme_name_text_view_custom_theme_options_bottom_sheet_fragment) + TextView themeNameTextView; + @BindView(R.id.edit_theme_text_view_custom_theme_options_bottom_sheet_fragment) + TextView editThemeTextView; + @BindView(R.id.share_theme_text_view_custom_theme_options_bottom_sheet_fragment) + TextView shareThemeTextView; + @BindView(R.id.change_theme_name_text_view_custom_theme_options_bottom_sheet_fragment) + TextView changeThemeNameTextView; + @BindView(R.id.delete_theme_text_view_custom_theme_options_bottom_sheet_fragment) + TextView deleteTextView; + private String themeName; + private Activity activity; + + public CustomThemeOptionsBottomSheetFragment() { + // Required empty public constructor + } + + public interface CustomThemeOptionsBottomSheetFragmentListener { + void changeName(String oldThemeName); + void shareTheme(String themeName); + void delete(String themeName); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_custom_theme_options_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + themeName = getArguments().getString(EXTRA_THEME_NAME); + themeNameTextView.setText(themeName); + + editThemeTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, themeName); + startActivity(intent); + dismiss(); + }); + + shareThemeTextView.setOnClickListener(view -> { + ((CustomThemeOptionsBottomSheetFragmentListener) activity).shareTheme(themeName); + dismiss(); + }); + + changeThemeNameTextView.setOnClickListener(view -> { + ((CustomThemeOptionsBottomSheetFragmentListener) activity).changeName(themeName); + dismiss(); + }); + + deleteTextView.setOnClickListener(view -> { + ((CustomThemeOptionsBottomSheetFragmentListener) activity).delete(themeName); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (AppCompatActivity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FlairBottomSheetFragment.java new file mode 100644 index 00000000..1856eb68 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FlairBottomSheetFragment.java @@ -0,0 +1,125 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.bottomsheet.BottomSheetDialogFragment; + +import java.util.ArrayList; + +import javax.inject.Inject; +import javax.inject.Named; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Adapter.FlairBottomSheetRecyclerViewAdapter; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.FetchFlairs; +import ml.docilealligator.infinityforreddit.Flair; +import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.R; +import retrofit2.Retrofit; + + +/** + * A simple {@link Fragment} subclass. + */ +public class FlairBottomSheetFragment extends BottomSheetDialogFragment { + + public static final String EXTRA_ACCESS_TOKEN = "EAT"; + public static final String EXTRA_SUBREDDIT_NAME = "ESN"; + @BindView(R.id.progress_bar_flair_bottom_sheet_fragment) + ProgressBar progressBar; + @BindView(R.id.error_text_view_flair_bottom_sheet_fragment) + TextView errorTextView; + @BindView(R.id.recycler_view_bottom_sheet_fragment) + RecyclerView recyclerView; + @Inject + @Named("oauth") + Retrofit mOauthRetrofit; + @Inject + @Named("no_oauth") + Retrofit mRetrofit; + @Inject + CustomThemeWrapper mCustomThemeWrapper; + private String mAccessToken; + private String mSubredditName; + private Activity mActivity; + private FlairBottomSheetRecyclerViewAdapter mAdapter; + + public FlairBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_flair_bottom_sheet, container, false); + + ButterKnife.bind(this, rootView); + + ((Infinity) mActivity.getApplication()).getAppComponent().inject(this); + + mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, mCustomThemeWrapper, flair -> { + ((FlairSelectionCallback) mActivity).flairSelected(flair); + dismiss(); + }); + + recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + recyclerView.setAdapter(mAdapter); + + mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); + mSubredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); + + fetchFlairs(); + + return rootView; + } + + private void fetchFlairs() { + FetchFlairs.fetchFlairsInSubreddit(mOauthRetrofit, mAccessToken, + mSubredditName, new FetchFlairs.FetchFlairsInSubredditListener() { + @Override + public void fetchSuccessful(ArrayList flairs) { + progressBar.setVisibility(View.GONE); + if (flairs == null || flairs.size() == 0) { + errorTextView.setVisibility(View.VISIBLE); + errorTextView.setText(R.string.no_flair); + } else { + errorTextView.setVisibility(View.GONE); + mAdapter.changeDataset(flairs); + } + } + + @Override + public void fetchFailed() { + progressBar.setVisibility(View.GONE); + errorTextView.setVisibility(View.VISIBLE); + errorTextView.setText(R.string.error_loading_flairs); + errorTextView.setOnClickListener(view -> fetchFlairs()); + } + }); + } + + public interface FlairSelectionCallback { + void flairSelected(Flair flair); + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + mActivity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java new file mode 100644 index 00000000..60b065ba --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java @@ -0,0 +1,70 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Activity.EditMultiRedditActivity; +import ml.docilealligator.infinityforreddit.Activity.MultiRedditListingActivity; +import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; +import ml.docilealligator.infinityforreddit.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class MultiRedditOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_MULTI_REDDIT = "EMR"; + + @BindView(R.id.edit_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment) + TextView editMultiRedditTextView; + @BindView(R.id.delete_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment) + TextView deleteMultiRedditTextView; + private MultiRedditListingActivity multiRedditListingActivity; + + public MultiRedditOptionsBottomSheetFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_multi_reddit_options_bottom_sheet, container, false); + + ButterKnife.bind(this, rootView); + + MultiReddit multiReddit = getArguments().getParcelable(EXTRA_MULTI_REDDIT); + + editMultiRedditTextView.setOnClickListener(view -> { + Intent editIntent = new Intent(multiRedditListingActivity, EditMultiRedditActivity.class); + editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_REDDIT, multiReddit); + startActivity(editIntent); + dismiss(); + }); + + deleteMultiRedditTextView.setOnClickListener(view -> { + multiRedditListingActivity.deleteMultiReddit(multiReddit); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + multiRedditListingActivity = (MultiRedditListingActivity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostCommentSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostCommentSortTypeBottomSheetFragment.java new file mode 100644 index 00000000..da747efd --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostCommentSortTypeBottomSheetFragment.java @@ -0,0 +1,119 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; + +/** + * A simple {@link Fragment} subclass. + */ +public class PostCommentSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + @BindView(R.id.best_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView bestTypeTextView; + @BindView(R.id.confidence_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView confidenceTypeTextView; + @BindView(R.id.top_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView topTypeTextView; + @BindView(R.id.new_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView newTypeTextView; + @BindView(R.id.controversial_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView controversialTypeTextView; + @BindView(R.id.old_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView oldTypeTextView; + @BindView(R.id.random_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView randomTypeTextView; + @BindView(R.id.qa_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView qaTypeTextView; + @BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment) + TextView liveTypeTextView; + private Activity activity; + public PostCommentSortTypeBottomSheetFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View rootView = inflater.inflate(R.layout.fragment_post_comment_sort_type_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + bestTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.BEST)); + dismiss(); + }); + + confidenceTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.CONFIDENCE)); + dismiss(); + }); + + topTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.TOP)); + dismiss(); + }); + + newTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); + dismiss(); + }); + + controversialTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.CONTROVERSIAL)); + dismiss(); + }); + + oldTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD)); + dismiss(); + }); + + randomTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM)); + dismiss(); + }); + + qaTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.QA)); + dismiss(); + }); + + liveTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.LIVE)); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostLayoutBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostLayoutBottomSheetFragment.java new file mode 100644 index 00000000..c0873a14 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostLayoutBottomSheetFragment.java @@ -0,0 +1,65 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; + +/** + * A simple {@link Fragment} subclass. + */ +public class PostLayoutBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + @BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment) + TextView cardLayoutTextView; + @BindView(R.id.compact_layout_text_view_post_layout_bottom_sheet_fragment) + TextView compactLayoutTextView; + private Activity activity; + public PostLayoutBottomSheetFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View rootView = inflater.inflate(R.layout.fragment_post_layot_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + cardLayoutTextView.setOnClickListener(view -> { + ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD); + dismiss(); + }); + compactLayoutTextView.setOnClickListener(view -> { + ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_COMPACT); + dismiss(); + }); + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.activity = (Activity) context; + } + + public interface PostLayoutSelectionCallback { + void postLayoutSelected(int postLayout); + } + +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostTypeBottomSheetFragment.java new file mode 100644 index 00000000..1f40fc22 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/PostTypeBottomSheetFragment.java @@ -0,0 +1,90 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; + + +/** + * A simple {@link Fragment} subclass. + */ +public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final int TYPE_TEXT = 0; + public static final int TYPE_LINK = 1; + public static final int TYPE_IMAGE = 2; + public static final int TYPE_VIDEO = 3; + @BindView(R.id.text_type_linear_layout_post_type_bottom_sheet_fragment) + TextView textTypeTextView; + @BindView(R.id.link_type_linear_layout_post_type_bottom_sheet_fragment) + TextView linkTypeTextView; + @BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment) + TextView imageTypeTextView; + @BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment) + TextView videoTypeTextView; + private Activity activity; + public PostTypeBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_post_type_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + textTypeTextView.setOnClickListener(view -> { + ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_TEXT); + dismiss(); + }); + + linkTypeTextView.setOnClickListener(view -> { + ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_LINK); + dismiss(); + }); + + imageTypeTextView.setOnClickListener(view -> { + ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_IMAGE); + dismiss(); + }); + + videoTypeTextView.setOnClickListener(view -> { + ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.activity = (Activity) context; + } + + public interface PostTypeSelectionCallback { + void postTypeSelected(int postType); + } + +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchPostSortTypeBottomSheetFragment.java new file mode 100644 index 00000000..12f97c9e --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchPostSortTypeBottomSheetFragment.java @@ -0,0 +1,90 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; + + +/** + * A simple {@link Fragment} subclass. + */ +public class SearchPostSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + @BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment) + TextView relevanceTypeTextView; + @BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment) + TextView hotTypeTextView; + @BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment) + TextView topTypeTextView; + @BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment) + TextView newTypeTextView; + @BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) + TextView commentsTypeTextView; + private Activity activity; + public SearchPostSortTypeBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + relevanceTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name()); + dismiss(); + }); + + hotTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name()); + dismiss(); + }); + + topTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); + dismiss(); + }); + + newTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); + dismiss(); + }); + + commentsTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.COMMENTS.name()); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java new file mode 100644 index 00000000..0fad6d7b --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java @@ -0,0 +1,76 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; + + +/** + * A simple {@link Fragment} subclass. + */ +public class SearchUserAndSubredditSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_FRAGMENT_POSITION = "EFP"; + @BindView(R.id.relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) + TextView relevanceTypeTextView; + @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) + TextView activityTypeTextView; + private Activity activity; + public SearchUserAndSubredditSortTypeBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + int position = getArguments() != null ? getArguments().getInt(EXTRA_FRAGMENT_POSITION) : -1; + if(position < 0) { + dismiss(); + return rootView; + } + + relevanceTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(new SortType(SortType.Type.RELEVANCE), position); + dismiss(); + }); + + activityTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(new SortType(SortType.Type.ACTIVITY), position); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/ShareLinkBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/ShareLinkBottomSheetFragment.java new file mode 100644 index 00000000..1214dbc8 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/ShareLinkBottomSheetFragment.java @@ -0,0 +1,142 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Post.Post; +import ml.docilealligator.infinityforreddit.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class ShareLinkBottomSheetFragment extends RoundedBottomSheetDialogFragment { + public static final String EXTRA_POST_LINK = "EPL"; + public static final String EXTRA_MEDIA_LINK = "EML"; + public static final String EXTRA_MEDIA_TYPE = "EMT"; + + @BindView(R.id.share_post_link_text_view_share_link_bottom_sheet_fragment) + TextView sharePostLinkTextView; + @BindView(R.id.share_media_link_text_view_share_link_bottom_sheet_fragment) + TextView shareMediaLinkTextView; + @BindView(R.id.copy_post_link_text_view_share_link_bottom_sheet_fragment) + TextView copyPostLinkTextView; + @BindView(R.id.copy_media_link_text_view_share_link_bottom_sheet_fragment) + TextView copyMediaLinkTextView; + + private Activity activity; + + public ShareLinkBottomSheetFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View rootView = inflater.inflate(R.layout.fragment_share_link_bottom_sheet, container, false); + + ButterKnife.bind(this, rootView); + + String postLink = getArguments().getString(EXTRA_POST_LINK); + String mediaLink = getArguments().containsKey(EXTRA_MEDIA_LINK) ? getArguments().getString(EXTRA_MEDIA_LINK) : null; + + if (mediaLink != null) { + shareMediaLinkTextView.setVisibility(View.VISIBLE); + copyMediaLinkTextView.setVisibility(View.VISIBLE); + + int mediaType = getArguments().getInt(EXTRA_MEDIA_TYPE); + switch (mediaType) { + case Post.IMAGE_TYPE: + shareMediaLinkTextView.setText(R.string.share_image_link); + copyMediaLinkTextView.setText(R.string.copy_image_link); + shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( + activity.getDrawable(R.drawable.ic_image_24dp), null, null, null); + break; + case Post.GIF_TYPE: + shareMediaLinkTextView.setText(R.string.share_gif_link); + copyMediaLinkTextView.setText(R.string.copy_gif_link); + shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( + activity.getDrawable(R.drawable.ic_image_24dp), null, null, null); + break; + case Post.VIDEO_TYPE: + shareMediaLinkTextView.setText(R.string.share_video_link); + copyMediaLinkTextView.setText(R.string.copy_video_link); + shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( + activity.getDrawable(R.drawable.ic_outline_video_24dp), null, null, null); + break; + case Post.LINK_TYPE: + case Post.NO_PREVIEW_LINK_TYPE: + shareMediaLinkTextView.setText(R.string.share_link); + copyMediaLinkTextView.setText(R.string.copy_link); + break; + } + + shareMediaLinkTextView.setOnClickListener(view -> { + shareLink(mediaLink); + dismiss(); + }); + copyMediaLinkTextView.setOnClickListener(view -> { + copyLink(mediaLink); + dismiss(); + }); + } + + sharePostLinkTextView.setOnClickListener(view -> { + shareLink(postLink); + dismiss(); + }); + copyPostLinkTextView.setOnClickListener(view -> { + copyLink(postLink); + dismiss(); + }); + return rootView; + } + + private void shareLink(String link) { + try { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, link); + activity.startActivity(Intent.createChooser(intent, getString(R.string.share))); + } catch (ActivityNotFoundException e) { + Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show(); + } + } + + private void copyLink(String link) { + ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); + if (clipboard != null) { + ClipData clip = ClipData.newPlainText("simple text", link); + clipboard.setPrimaryClip(clip); + Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (AppCompatActivity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTimeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTimeBottomSheetFragment.java new file mode 100644 index 00000000..f2f1da4d --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTimeBottomSheetFragment.java @@ -0,0 +1,112 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; + +/** + * A simple {@link Fragment} subclass. + */ +public class SortTimeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_SORT_TYPE = "EST"; + + @BindView(R.id.hour_text_view_sort_time_bottom_sheet_fragment) + TextView hourTextView; + @BindView(R.id.day_text_view_sort_time_bottom_sheet_fragment) + TextView dayTextView; + @BindView(R.id.week_text_view_sort_time_bottom_sheet_fragment) + TextView weekTextView; + @BindView(R.id.month_text_view_sort_time_bottom_sheet_fragment) + TextView monthTextView; + @BindView(R.id.year_text_view_sort_time_bottom_sheet_fragment) + TextView yearTextView; + @BindView(R.id.all_time_text_view_sort_time_bottom_sheet_fragment) + TextView allTimeTextView; + private Activity activity; + public SortTimeBottomSheetFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_sort_time_bottom_sheet, container, false); + + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + String sortType = getArguments() != null ? getArguments().getString(EXTRA_SORT_TYPE) : null; + if(sortType == null) { + dismiss(); + return rootView; + } + + hourTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity) + .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.HOUR)); + dismiss(); + }); + + dayTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity) + .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.DAY)); + dismiss(); + }); + + weekTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity) + .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.WEEK)); + dismiss(); + }); + + monthTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity) + .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.MONTH)); + dismiss(); + }); + + yearTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity) + .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.YEAR)); + dismiss(); + }); + + allTimeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity) + .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.ALL)); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java new file mode 100644 index 00000000..ee5ba39f --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java @@ -0,0 +1,114 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; + + +/** + * A simple {@link Fragment} subclass. + */ +public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_NO_BEST_TYPE = "ENBT"; + public static final String EXTRA_NO_RANDOM_TYPE = "ENRT"; + @BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment) + TextView bestTypeTextView; + @BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment) + TextView hotTypeTextView; + @BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment) + TextView newTypeTextView; + @BindView(R.id.random_type_text_view_sort_type_bottom_sheet_fragment) + TextView randomTypeTextView; + @BindView(R.id.rising_type_text_view_sort_type_bottom_sheet_fragment) + TextView risingTypeTextView; + @BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment) + TextView topTypeTextView; + @BindView(R.id.controversial_type_text_view_sort_type_bottom_sheet_fragment) + TextView controversialTypeTextView; + private Activity activity; + public SortTypeBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_sort_type_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + if (getArguments() == null || getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) { + bestTypeTextView.setVisibility(View.GONE); + } else { + bestTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.BEST)); + dismiss(); + }); + } + + hotTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); + dismiss(); + }); + + newTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); + dismiss(); + }); + + if (getArguments() == null || (getArguments().containsKey(EXTRA_NO_RANDOM_TYPE) && getArguments().getBoolean(EXTRA_NO_RANDOM_TYPE))) { + randomTypeTextView.setVisibility(View.GONE); + } else { + randomTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM)); + dismiss(); + }); + } + + risingTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING)); + dismiss(); + }); + + topTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); + dismiss(); + }); + + controversialTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name()); + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UrlMenuBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UrlMenuBottomSheetFragment.java new file mode 100644 index 00000000..f2812232 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UrlMenuBottomSheetFragment.java @@ -0,0 +1,87 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + +import android.app.Activity; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; +import ml.docilealligator.infinityforreddit.R; + +public class UrlMenuBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_URL = "EU"; + @BindView(R.id.open_link_text_view_url_menu_bottom_sheet_fragment) + TextView openLinkTextView; + @BindView(R.id.copy_link_text_view_url_menu_bottom_sheet_fragment) + TextView copyLinkTextView; + @BindView(R.id.share_link_text_view_url_menu_bottom_sheet_fragment) + TextView shareLinkTextView; + private Activity activity; + + public UrlMenuBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_url_menu_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + String url = getArguments().getString(EXTRA_URL); + + openLinkTextView.setOnClickListener(view -> { + Intent intent = new Intent(activity, LinkResolverActivity.class); + intent.setData(Uri.parse(url)); + activity.startActivity(intent); + dismiss(); + }); + + copyLinkTextView.setOnClickListener(view -> { + ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); + if (clipboard != null) { + ClipData clip = ClipData.newPlainText("simple text", url); + clipboard.setPrimaryClip(clip); + Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show(); + } + dismiss(); + }); + + shareLinkTextView.setOnClickListener(view -> { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, url); + if (intent.resolveActivity(activity.getPackageManager()) != null) { + startActivity(intent); + } else { + Toast.makeText(activity, R.string.no_app, Toast.LENGTH_SHORT).show(); + } + dismiss(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +} \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UserThingSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UserThingSortTypeBottomSheetFragment.java new file mode 100644 index 00000000..2d6b7cae --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/UserThingSortTypeBottomSheetFragment.java @@ -0,0 +1,86 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + + +import android.app.Activity; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; + + +/** + * A simple {@link Fragment} subclass. + */ +public class UserThingSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + @BindView(R.id.new_type_text_view_user_thing_sort_type_bottom_sheet_fragment) + TextView newTypeTextView; + @BindView(R.id.hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment) + TextView hotTypeTextView; + @BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment) + TextView topTypeTextView; + @BindView(R.id.controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment) + TextView controversialTypeTextView; + public UserThingSortTypeBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_user_thing_sort_type_bottom_sheet, container, false); + + ButterKnife.bind(this, rootView); + + Activity activity = getActivity(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + + newTypeTextView.setOnClickListener(view -> { + if (activity != null) { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); + } + dismiss(); + }); + + hotTypeTextView.setOnClickListener(view -> { + if (activity != null) { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); + } + dismiss(); + }); + + topTypeTextView.setOnClickListener(view -> { + if (activity != null) { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); + } + dismiss(); + }); + + controversialTypeTextView.setOnClickListener(view -> { + if (activity != null) { + ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name()); + } + dismiss(); + }); + + return rootView; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java deleted file mode 100644 index fd97f1d4..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java +++ /dev/null @@ -1,142 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.Intent; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.Activity.EditCommentActivity; -import ml.docilealligator.infinityforreddit.Activity.ReportActivity; -import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity; -import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity; -import ml.docilealligator.infinityforreddit.CommentData; -import ml.docilealligator.infinityforreddit.R; - - -/** - * A simple {@link Fragment} subclass. - */ -public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final String EXTRA_COMMENT = "ECF"; - public static final String EXTRA_ACCESS_TOKEN = "EAT"; - public static final String EXTRA_POSITION = "EP"; - @BindView(R.id.edit_text_view_comment_more_bottom_sheet_fragment) - TextView editTextView; - @BindView(R.id.delete_text_view_comment_more_bottom_sheet_fragment) - TextView deleteTextView; - @BindView(R.id.save_text_view_comment_more_bottom_sheet_fragment) - TextView shareTextView; - @BindView(R.id.copy_text_view_comment_more_bottom_sheet_fragment) - TextView copyTextView; - @BindView(R.id.report_view_comment_more_bottom_sheet_fragment) - TextView reportTextView; - private AppCompatActivity activity; - public CommentMoreBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_comment_more_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - Bundle bundle = getArguments(); - CommentData commentData = bundle.getParcelable(EXTRA_COMMENT); - if (commentData == null) { - dismiss(); - return rootView; - } - String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN); - - if (accessToken != null && !accessToken.equals("")) { - editTextView.setVisibility(View.VISIBLE); - deleteTextView.setVisibility(View.VISIBLE); - - editTextView.setOnClickListener(view -> { - Intent intent = new Intent(activity, EditCommentActivity.class); - intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken); - intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, commentData.getFullName()); - intent.putExtra(EditCommentActivity.EXTRA_CONTENT, commentData.getCommentMarkdown()); - intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION)); - if (activity instanceof ViewPostDetailActivity) { - activity.startActivityForResult(intent, ViewPostDetailActivity.EDIT_COMMENT_REQUEST_CODE); - } else { - startActivity(intent); - } - - dismiss(); - }); - - deleteTextView.setOnClickListener(view -> { - dismiss(); - if (activity instanceof ViewPostDetailActivity) { - ((ViewPostDetailActivity) activity).deleteComment(commentData.getFullName(), bundle.getInt(EXTRA_POSITION)); - } else if (activity instanceof ViewUserDetailActivity) { - ((ViewUserDetailActivity) activity).deleteComment(commentData.getFullName()); - } - }); - } - - shareTextView.setOnClickListener(view -> { - dismiss(); - try { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, commentData.getPermalink()); - activity.startActivity(Intent.createChooser(intent, getString(R.string.share))); - } catch (ActivityNotFoundException e) { - Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show(); - } - }); - - copyTextView.setOnClickListener(view -> { - dismiss(); - CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment(); - Bundle copyBundle = new Bundle(); - copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, commentData.getCommentMarkdown()); - copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, commentData.getCommentRawText()); - copyTextBottomSheetFragment.setArguments(copyBundle); - copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag()); - }); - - reportTextView.setOnClickListener(view -> { - Intent intent = new Intent(activity, ReportActivity.class); - intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, commentData.getSubredditName()); - intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, commentData.getFullName()); - activity.startActivity(intent); - - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (AppCompatActivity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java deleted file mode 100644 index b0b6469d..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CopyTextBottomSheetFragment.java +++ /dev/null @@ -1,115 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.ClipData; -import android.content.ClipboardManager; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class CopyTextBottomSheetFragment extends RoundedBottomSheetDialogFragment { - public static final String EXTRA_RAW_TEXT = "ERT"; - public static final String EXTRA_MARKDOWN = "EM"; - - @BindView(R.id.copy_raw_text_text_view_copy_text_bottom_sheet_fragment) - TextView copyRawTextTextView; - @BindView(R.id.copy_markdown_text_view_copy_text_bottom_sheet_fragment) - TextView copyMarkdownTextView; - @BindView(R.id.copy_all_raw_text_text_view_copy_text_bottom_sheet_fragment) - TextView copyAllRawTextTextView; - @BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment) - TextView copyAllMarkdownTextView; - - private Activity activity; - - public CopyTextBottomSheetFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_copy_text_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - String rawText = getArguments().getString(EXTRA_RAW_TEXT); - String markdownText = getArguments().getString(EXTRA_MARKDOWN); - - copyRawTextTextView.setOnClickListener(view -> { - showCopyDialog(rawText); - dismiss(); - }); - - copyAllRawTextTextView.setOnClickListener(view -> { - copyText(rawText); - dismiss(); - }); - - if (markdownText != null) { - copyMarkdownTextView.setOnClickListener(view -> { - showCopyDialog(markdownText); - dismiss(); - }); - - copyAllMarkdownTextView.setOnClickListener(view -> { - copyText(markdownText); - dismiss(); - }); - } else { - copyMarkdownTextView.setVisibility(View.GONE); - copyAllMarkdownTextView.setVisibility(View.GONE); - } - - return rootView; - } - - private void showCopyDialog(String text) { - LayoutInflater inflater = activity.getLayoutInflater(); - View layout = inflater.inflate(R.layout.copy_text_material_dialog, null); - TextView textView = layout.findViewById(R.id.text_view_copy_text_material_dialog); - textView.setText(text); - new MaterialAlertDialogBuilder(activity, R.style.CopyTextMaterialAlertDialogTheme) - .setTitle(R.string.copy_text) - .setView(layout) - .setPositiveButton(R.string.copy_all, (dialogInterface, i) -> copyText(text)) - .setNegativeButton(R.string.cancel, null) - .show(); - } - - private void copyText(String text) { - ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); - if (clipboard != null) { - ClipData clip = ClipData.newPlainText("simple text", text); - clipboard.setPrimaryClip(clip); - Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java deleted file mode 100644 index d92286ae..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CreateThemeBottomSheetFragment.java +++ /dev/null @@ -1,90 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; -import ml.docilealligator.infinityforreddit.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class CreateThemeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - @BindView(R.id.import_theme_text_view_create_theme_bottom_sheet_fragment) - TextView importTextView; - @BindView(R.id.light_theme_text_view_create_theme_bottom_sheet_fragment) - TextView lightThemeTextView; - @BindView(R.id.dark_theme_text_view_create_theme_bottom_sheet_fragment) - TextView darkThemeTextView; - @BindView(R.id.amoled_theme_text_view_create_theme_bottom_sheet_fragment) - TextView amoledThemeTextView; - private Activity activity; - - public interface SelectBaseThemeBottomSheetFragmentListener { - void importTheme(); - } - - public CreateThemeBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_create_theme_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - importTextView.setOnClickListener(view -> { - ((SelectBaseThemeBottomSheetFragmentListener) activity).importTheme(); - dismiss(); - }); - - lightThemeTextView.setOnClickListener(view -> { - Intent intent = new Intent(activity, CustomizeThemeActivity.class); - intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); - intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); - intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo)); - startActivity(intent); - dismiss(); - }); - - darkThemeTextView.setOnClickListener(view -> { - Intent intent = new Intent(activity, CustomizeThemeActivity.class); - intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); - intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); - intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo_dark)); - startActivity(intent); - dismiss(); - }); - - amoledThemeTextView.setOnClickListener(view -> { - Intent intent = new Intent(activity, CustomizeThemeActivity.class); - intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); - intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); - intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo_amoled)); - startActivity(intent); - dismiss(); - }); - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java deleted file mode 100644 index 5529a599..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java +++ /dev/null @@ -1,91 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; -import ml.docilealligator.infinityforreddit.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class CustomThemeOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final String EXTRA_THEME_NAME = "ETN"; - @BindView(R.id.theme_name_text_view_custom_theme_options_bottom_sheet_fragment) - TextView themeNameTextView; - @BindView(R.id.edit_theme_text_view_custom_theme_options_bottom_sheet_fragment) - TextView editThemeTextView; - @BindView(R.id.share_theme_text_view_custom_theme_options_bottom_sheet_fragment) - TextView shareThemeTextView; - @BindView(R.id.change_theme_name_text_view_custom_theme_options_bottom_sheet_fragment) - TextView changeThemeNameTextView; - @BindView(R.id.delete_theme_text_view_custom_theme_options_bottom_sheet_fragment) - TextView deleteTextView; - private String themeName; - private Activity activity; - - public CustomThemeOptionsBottomSheetFragment() { - // Required empty public constructor - } - - public interface CustomThemeOptionsBottomSheetFragmentListener { - void changeName(String oldThemeName); - void shareTheme(String themeName); - void delete(String themeName); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_custom_theme_options_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - themeName = getArguments().getString(EXTRA_THEME_NAME); - themeNameTextView.setText(themeName); - - editThemeTextView.setOnClickListener(view -> { - Intent intent = new Intent(activity, CustomizeThemeActivity.class); - intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, themeName); - startActivity(intent); - dismiss(); - }); - - shareThemeTextView.setOnClickListener(view -> { - ((CustomThemeOptionsBottomSheetFragmentListener) activity).shareTheme(themeName); - dismiss(); - }); - - changeThemeNameTextView.setOnClickListener(view -> { - ((CustomThemeOptionsBottomSheetFragmentListener) activity).changeName(themeName); - dismiss(); - }); - - deleteTextView.setOnClickListener(view -> { - ((CustomThemeOptionsBottomSheetFragmentListener) activity).delete(themeName); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (AppCompatActivity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java deleted file mode 100644 index 78b3c665..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java +++ /dev/null @@ -1,125 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ProgressBar; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.google.android.material.bottomsheet.BottomSheetDialogFragment; - -import java.util.ArrayList; - -import javax.inject.Inject; -import javax.inject.Named; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.Adapter.FlairBottomSheetRecyclerViewAdapter; -import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.FetchFlairs; -import ml.docilealligator.infinityforreddit.Flair; -import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.R; -import retrofit2.Retrofit; - - -/** - * A simple {@link Fragment} subclass. - */ -public class FlairBottomSheetFragment extends BottomSheetDialogFragment { - - public static final String EXTRA_ACCESS_TOKEN = "EAT"; - public static final String EXTRA_SUBREDDIT_NAME = "ESN"; - @BindView(R.id.progress_bar_flair_bottom_sheet_fragment) - ProgressBar progressBar; - @BindView(R.id.error_text_view_flair_bottom_sheet_fragment) - TextView errorTextView; - @BindView(R.id.recycler_view_bottom_sheet_fragment) - RecyclerView recyclerView; - @Inject - @Named("oauth") - Retrofit mOauthRetrofit; - @Inject - @Named("no_oauth") - Retrofit mRetrofit; - @Inject - CustomThemeWrapper mCustomThemeWrapper; - private String mAccessToken; - private String mSubredditName; - private Activity mActivity; - private FlairBottomSheetRecyclerViewAdapter mAdapter; - - public FlairBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_flair_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); - - ((Infinity) mActivity.getApplication()).getAppComponent().inject(this); - - mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, mCustomThemeWrapper, flair -> { - ((FlairSelectionCallback) mActivity).flairSelected(flair); - dismiss(); - }); - - recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); - recyclerView.setAdapter(mAdapter); - - mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); - mSubredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); - - fetchFlairs(); - - return rootView; - } - - private void fetchFlairs() { - FetchFlairs.fetchFlairsInSubreddit(mOauthRetrofit, mAccessToken, - mSubredditName, new FetchFlairs.FetchFlairsInSubredditListener() { - @Override - public void fetchSuccessful(ArrayList flairs) { - progressBar.setVisibility(View.GONE); - if (flairs == null || flairs.size() == 0) { - errorTextView.setVisibility(View.VISIBLE); - errorTextView.setText(R.string.no_flair); - } else { - errorTextView.setVisibility(View.GONE); - mAdapter.changeDataset(flairs); - } - } - - @Override - public void fetchFailed() { - progressBar.setVisibility(View.GONE); - errorTextView.setVisibility(View.VISIBLE); - errorTextView.setText(R.string.error_loading_flairs); - errorTextView.setOnClickListener(view -> fetchFlairs()); - } - }); - } - - public interface FlairSelectionCallback { - void flairSelected(Flair flair); - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - mActivity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditOptionsBottomSheetFragment.java deleted file mode 100644 index 3ac1c407..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditOptionsBottomSheetFragment.java +++ /dev/null @@ -1,70 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.Activity.EditMultiRedditActivity; -import ml.docilealligator.infinityforreddit.Activity.MultiRedditListingActivity; -import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; -import ml.docilealligator.infinityforreddit.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class MultiRedditOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final String EXTRA_MULTI_REDDIT = "EMR"; - - @BindView(R.id.edit_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment) - TextView editMultiRedditTextView; - @BindView(R.id.delete_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment) - TextView deleteMultiRedditTextView; - private MultiRedditListingActivity multiRedditListingActivity; - - public MultiRedditOptionsBottomSheetFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_multi_reddit_options_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); - - MultiReddit multiReddit = getArguments().getParcelable(EXTRA_MULTI_REDDIT); - - editMultiRedditTextView.setOnClickListener(view -> { - Intent editIntent = new Intent(multiRedditListingActivity, EditMultiRedditActivity.class); - editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_REDDIT, multiReddit); - startActivity(editIntent); - dismiss(); - }); - - deleteMultiRedditTextView.setOnClickListener(view -> { - multiRedditListingActivity.deleteMultiReddit(multiReddit); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - multiRedditListingActivity = (MultiRedditListingActivity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostCommentSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostCommentSortTypeBottomSheetFragment.java deleted file mode 100644 index 2b78a220..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostCommentSortTypeBottomSheetFragment.java +++ /dev/null @@ -1,119 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; - -/** - * A simple {@link Fragment} subclass. - */ -public class PostCommentSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - @BindView(R.id.best_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView bestTypeTextView; - @BindView(R.id.confidence_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView confidenceTypeTextView; - @BindView(R.id.top_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.new_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.controversial_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView controversialTypeTextView; - @BindView(R.id.old_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView oldTypeTextView; - @BindView(R.id.random_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView randomTypeTextView; - @BindView(R.id.qa_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView qaTypeTextView; - @BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView liveTypeTextView; - private Activity activity; - public PostCommentSortTypeBottomSheetFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_post_comment_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - bestTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.BEST)); - dismiss(); - }); - - confidenceTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.CONFIDENCE)); - dismiss(); - }); - - topTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.TOP)); - dismiss(); - }); - - newTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); - dismiss(); - }); - - controversialTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.CONTROVERSIAL)); - dismiss(); - }); - - oldTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD)); - dismiss(); - }); - - randomTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM)); - dismiss(); - }); - - qaTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.QA)); - dismiss(); - }); - - liveTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.LIVE)); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java deleted file mode 100644 index 10ee1ca2..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostLayoutBottomSheetFragment.java +++ /dev/null @@ -1,65 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; - -/** - * A simple {@link Fragment} subclass. - */ -public class PostLayoutBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - @BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment) - TextView cardLayoutTextView; - @BindView(R.id.compact_layout_text_view_post_layout_bottom_sheet_fragment) - TextView compactLayoutTextView; - private Activity activity; - public PostLayoutBottomSheetFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_post_layot_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - cardLayoutTextView.setOnClickListener(view -> { - ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD); - dismiss(); - }); - compactLayoutTextView.setOnClickListener(view -> { - ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_COMPACT); - dismiss(); - }); - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } - - public interface PostLayoutSelectionCallback { - void postLayoutSelected(int postLayout); - } - -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostTypeBottomSheetFragment.java deleted file mode 100644 index abd528b7..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostTypeBottomSheetFragment.java +++ /dev/null @@ -1,90 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; - - -/** - * A simple {@link Fragment} subclass. - */ -public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final int TYPE_TEXT = 0; - public static final int TYPE_LINK = 1; - public static final int TYPE_IMAGE = 2; - public static final int TYPE_VIDEO = 3; - @BindView(R.id.text_type_linear_layout_post_type_bottom_sheet_fragment) - TextView textTypeTextView; - @BindView(R.id.link_type_linear_layout_post_type_bottom_sheet_fragment) - TextView linkTypeTextView; - @BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment) - TextView imageTypeTextView; - @BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment) - TextView videoTypeTextView; - private Activity activity; - public PostTypeBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_post_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - textTypeTextView.setOnClickListener(view -> { - ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_TEXT); - dismiss(); - }); - - linkTypeTextView.setOnClickListener(view -> { - ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_LINK); - dismiss(); - }); - - imageTypeTextView.setOnClickListener(view -> { - ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_IMAGE); - dismiss(); - }); - - videoTypeTextView.setOnClickListener(view -> { - ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } - - public interface PostTypeSelectionCallback { - void postTypeSelected(int postType); - } - -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchPostSortTypeBottomSheetFragment.java deleted file mode 100644 index 9973b1af..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchPostSortTypeBottomSheetFragment.java +++ /dev/null @@ -1,90 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; - - -/** - * A simple {@link Fragment} subclass. - */ -public class SearchPostSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - @BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView relevanceTypeTextView; - @BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; - @BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView commentsTypeTextView; - private Activity activity; - public SearchPostSortTypeBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - relevanceTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name()); - dismiss(); - }); - - hotTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name()); - dismiss(); - }); - - topTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); - dismiss(); - }); - - newTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); - dismiss(); - }); - - commentsTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.COMMENTS.name()); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java deleted file mode 100644 index bd40b263..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SearchUserAndSubredditSortTypeBottomSheetFragment.java +++ /dev/null @@ -1,76 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; - - -/** - * A simple {@link Fragment} subclass. - */ -public class SearchUserAndSubredditSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final String EXTRA_FRAGMENT_POSITION = "EFP"; - @BindView(R.id.relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) - TextView relevanceTypeTextView; - @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) - TextView activityTypeTextView; - private Activity activity; - public SearchUserAndSubredditSortTypeBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - int position = getArguments() != null ? getArguments().getInt(EXTRA_FRAGMENT_POSITION) : -1; - if(position < 0) { - dismiss(); - return rootView; - } - - relevanceTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(new SortType(SortType.Type.RELEVANCE), position); - dismiss(); - }); - - activityTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(new SortType(SortType.Type.ACTIVITY), position); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java deleted file mode 100644 index 4a2ed929..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java +++ /dev/null @@ -1,142 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.ActivityNotFoundException; -import android.content.ClipData; -import android.content.ClipboardManager; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.Post.Post; -import ml.docilealligator.infinityforreddit.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class ShareLinkBottomSheetFragment extends RoundedBottomSheetDialogFragment { - public static final String EXTRA_POST_LINK = "EPL"; - public static final String EXTRA_MEDIA_LINK = "EML"; - public static final String EXTRA_MEDIA_TYPE = "EMT"; - - @BindView(R.id.share_post_link_text_view_share_link_bottom_sheet_fragment) - TextView sharePostLinkTextView; - @BindView(R.id.share_media_link_text_view_share_link_bottom_sheet_fragment) - TextView shareMediaLinkTextView; - @BindView(R.id.copy_post_link_text_view_share_link_bottom_sheet_fragment) - TextView copyPostLinkTextView; - @BindView(R.id.copy_media_link_text_view_share_link_bottom_sheet_fragment) - TextView copyMediaLinkTextView; - - private Activity activity; - - public ShareLinkBottomSheetFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_share_link_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); - - String postLink = getArguments().getString(EXTRA_POST_LINK); - String mediaLink = getArguments().containsKey(EXTRA_MEDIA_LINK) ? getArguments().getString(EXTRA_MEDIA_LINK) : null; - - if (mediaLink != null) { - shareMediaLinkTextView.setVisibility(View.VISIBLE); - copyMediaLinkTextView.setVisibility(View.VISIBLE); - - int mediaType = getArguments().getInt(EXTRA_MEDIA_TYPE); - switch (mediaType) { - case Post.IMAGE_TYPE: - shareMediaLinkTextView.setText(R.string.share_image_link); - copyMediaLinkTextView.setText(R.string.copy_image_link); - shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( - activity.getDrawable(R.drawable.ic_image_24dp), null, null, null); - break; - case Post.GIF_TYPE: - shareMediaLinkTextView.setText(R.string.share_gif_link); - copyMediaLinkTextView.setText(R.string.copy_gif_link); - shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( - activity.getDrawable(R.drawable.ic_image_24dp), null, null, null); - break; - case Post.VIDEO_TYPE: - shareMediaLinkTextView.setText(R.string.share_video_link); - copyMediaLinkTextView.setText(R.string.copy_video_link); - shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( - activity.getDrawable(R.drawable.ic_outline_video_24dp), null, null, null); - break; - case Post.LINK_TYPE: - case Post.NO_PREVIEW_LINK_TYPE: - shareMediaLinkTextView.setText(R.string.share_link); - copyMediaLinkTextView.setText(R.string.copy_link); - break; - } - - shareMediaLinkTextView.setOnClickListener(view -> { - shareLink(mediaLink); - dismiss(); - }); - copyMediaLinkTextView.setOnClickListener(view -> { - copyLink(mediaLink); - dismiss(); - }); - } - - sharePostLinkTextView.setOnClickListener(view -> { - shareLink(postLink); - dismiss(); - }); - copyPostLinkTextView.setOnClickListener(view -> { - copyLink(postLink); - dismiss(); - }); - return rootView; - } - - private void shareLink(String link) { - try { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, link); - activity.startActivity(Intent.createChooser(intent, getString(R.string.share))); - } catch (ActivityNotFoundException e) { - Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show(); - } - } - - private void copyLink(String link) { - ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); - if (clipboard != null) { - ClipData clip = ClipData.newPlainText("simple text", link); - clipboard.setPrimaryClip(clip); - Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (AppCompatActivity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTimeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTimeBottomSheetFragment.java deleted file mode 100644 index 10cfdde7..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTimeBottomSheetFragment.java +++ /dev/null @@ -1,112 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; - -/** - * A simple {@link Fragment} subclass. - */ -public class SortTimeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final String EXTRA_SORT_TYPE = "EST"; - - @BindView(R.id.hour_text_view_sort_time_bottom_sheet_fragment) - TextView hourTextView; - @BindView(R.id.day_text_view_sort_time_bottom_sheet_fragment) - TextView dayTextView; - @BindView(R.id.week_text_view_sort_time_bottom_sheet_fragment) - TextView weekTextView; - @BindView(R.id.month_text_view_sort_time_bottom_sheet_fragment) - TextView monthTextView; - @BindView(R.id.year_text_view_sort_time_bottom_sheet_fragment) - TextView yearTextView; - @BindView(R.id.all_time_text_view_sort_time_bottom_sheet_fragment) - TextView allTimeTextView; - private Activity activity; - public SortTimeBottomSheetFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_sort_time_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - String sortType = getArguments() != null ? getArguments().getString(EXTRA_SORT_TYPE) : null; - if(sortType == null) { - dismiss(); - return rootView; - } - - hourTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity) - .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.HOUR)); - dismiss(); - }); - - dayTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity) - .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.DAY)); - dismiss(); - }); - - weekTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity) - .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.WEEK)); - dismiss(); - }); - - monthTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity) - .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.MONTH)); - dismiss(); - }); - - yearTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity) - .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.YEAR)); - dismiss(); - }); - - allTimeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity) - .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.ALL)); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTypeBottomSheetFragment.java deleted file mode 100644 index ba03d93c..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SortTypeBottomSheetFragment.java +++ /dev/null @@ -1,114 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; - - -/** - * A simple {@link Fragment} subclass. - */ -public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - public static final String EXTRA_NO_BEST_TYPE = "ENBT"; - public static final String EXTRA_NO_RANDOM_TYPE = "ENRT"; - @BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment) - TextView bestTypeTextView; - @BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; - @BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.random_type_text_view_sort_type_bottom_sheet_fragment) - TextView randomTypeTextView; - @BindView(R.id.rising_type_text_view_sort_type_bottom_sheet_fragment) - TextView risingTypeTextView; - @BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.controversial_type_text_view_sort_type_bottom_sheet_fragment) - TextView controversialTypeTextView; - private Activity activity; - public SortTypeBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - if (getArguments() == null || getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) { - bestTypeTextView.setVisibility(View.GONE); - } else { - bestTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.BEST)); - dismiss(); - }); - } - - hotTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); - dismiss(); - }); - - newTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); - dismiss(); - }); - - if (getArguments() == null || (getArguments().containsKey(EXTRA_NO_RANDOM_TYPE) && getArguments().getBoolean(EXTRA_NO_RANDOM_TYPE))) { - randomTypeTextView.setVisibility(View.GONE); - } else { - randomTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM)); - dismiss(); - }); - } - - risingTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING)); - dismiss(); - }); - - topTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); - dismiss(); - }); - - controversialTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name()); - dismiss(); - }); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (Activity) context; - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserThingSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserThingSortTypeBottomSheetFragment.java deleted file mode 100644 index 59e099c4..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserThingSortTypeBottomSheetFragment.java +++ /dev/null @@ -1,86 +0,0 @@ -package ml.docilealligator.infinityforreddit.Fragment; - - -import android.app.Activity; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; - - -/** - * A simple {@link Fragment} subclass. - */ -public class UserThingSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment { - - @BindView(R.id.new_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; - @BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView controversialTypeTextView; - public UserThingSortTypeBottomSheetFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_user_thing_sort_type_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); - - Activity activity = getActivity(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - - newTypeTextView.setOnClickListener(view -> { - if (activity != null) { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); - } - dismiss(); - }); - - hotTypeTextView.setOnClickListener(view -> { - if (activity != null) { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); - } - dismiss(); - }); - - topTypeTextView.setOnClickListener(view -> { - if (activity != null) { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); - } - dismiss(); - }); - - controversialTypeTextView.setOnClickListener(view -> { - if (activity != null) { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name()); - } - dismiss(); - }); - - return rootView; - } -} diff --git a/app/src/main/res/drawable-night/ic_open_link_24dp.xml b/app/src/main/res/drawable-night/ic_open_link_24dp.xml new file mode 100644 index 00000000..db3c9198 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_open_link_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_open_link_24dp.xml b/app/src/main/res/drawable/ic_open_link_24dp.xml new file mode 100644 index 00000000..48468b54 --- /dev/null +++ b/app/src/main/res/drawable/ic_open_link_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_copy_text_bottom_sheet.xml b/app/src/main/res/layout/fragment_copy_text_bottom_sheet.xml index 3d82d549..1e1e5394 100644 --- a/app/src/main/res/layout/fragment_copy_text_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_copy_text_bottom_sheet.xml @@ -5,7 +5,7 @@ android:layout_height="wrap_content" android:paddingBottom="8dp" android:overScrollMode="never" - tools:context=".Fragment.SortTimeBottomSheetFragment"> + tools:context=".BottomSheetFragment.CopyTextBottomSheetFragment"> + tools:context=".BottomSheetFragment.PostCommentSortTypeBottomSheetFragment"> + tools:context=".BottomSheetFragment.PostLayoutBottomSheetFragment"> + tools:context=".BottomSheetFragment.SortTimeBottomSheetFragment"> + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f313913..bdd8df76 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -754,5 +754,7 @@ Download failed: cannot save audio to cache directory Download failed: cannot mux video and audio Download failed: cannot save the video to public directory + + Hello blank fragment -- cgit v1.2.3