aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.idea/caches/build_file_checksums.serbin533 -> 533 bytes
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/UserThingSortTypeBottomSheetFragment.java88
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java50
-rw-r--r--app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml63
-rw-r--r--app/src/main/res/menu/view_user_detail_activity.xml12
-rw-r--r--app/src/main/res/values/strings.xml3
10 files changed, 215 insertions, 36 deletions
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index dae89535..1090b71e 100644
--- a/.idea/caches/build_file_checksums.ser
+++ b/.idea/caches/build_file_checksums.ser
Binary files differ
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java
index e0f2bcf2..6de62689 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java
@@ -24,13 +24,14 @@ import butterknife.BindView;
import butterknife.ButterKnife;
public class FilteredPostsActivity extends AppCompatActivity implements SortTypeBottomSheetFragment.SortTypeSelectionCallback,
- SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback {
+ SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback, UserThingSortTypeBottomSheetFragment.UserPostsSortTypeSelectionCallback {
static final String EXTRA_NAME = "ESN";
static final String EXTRA_QUERY = "EQ";
static final String EXTRA_FILTER = "EF";
static final String EXTRA_POST_TYPE = "EPT";
static final String EXTRA_SORT_TYPE = "EST";
+ static final String EXTRA_USER_WHERE = "EUW";
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS";
@@ -49,6 +50,7 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
private SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment;
private SortTypeBottomSheetFragment popularAndAllSortTypeBottomSheetFragment;
private SortTypeBottomSheetFragment subredditSortTypeBottomSheetFragment;
+ private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
private SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment;
@Inject
@@ -176,6 +178,8 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
case PostDataSource.TYPE_USER:
String usernamePrefixed = "u/" + name;
getSupportActionBar().setTitle(usernamePrefixed);
+
+ userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
break;
}
@@ -205,6 +209,9 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
bundle.putString(PostFragment.EXTRA_SORT_TYPE, sortType);
bundle.putInt(PostFragment.EXTRA_FILTER, filter);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ if(postType == PostDataSource.TYPE_USER) {
+ bundle.putString(PostFragment.EXTRA_USER_WHERE, getIntent().getExtras().getString(EXTRA_USER_WHERE));
+ }
if(postType == PostDataSource.TYPE_SEARCH) {
bundle.putString(PostFragment.EXTRA_QUERY, getIntent().getExtras().getString(EXTRA_QUERY));
}
@@ -216,9 +223,6 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.filtered_posts_activity, menu);
- if(postType == PostDataSource.TYPE_USER) {
- menu.findItem(R.id.action_sort_filtered_posts_activity).setVisible(false);
- }
return true;
}
@@ -242,6 +246,9 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
} else {
subredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), subredditSortTypeBottomSheetFragment.getTag());
}
+ break;
+ case PostDataSource.TYPE_USER:
+ userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
}
return true;
case R.id.action_refresh_filtered_posts_activity:
@@ -270,4 +277,9 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
public void sortTypeSelected(String sortType) {
((PostFragment)mFragment).changeSortType(sortType);
}
+
+ @Override
+ public void userThingSortTypeSelected(String sortType) {
+ ((PostFragment)mFragment).changeSortType(sortType);
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java
index 625930e8..8e91314a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java
@@ -98,10 +98,6 @@ class PostDataSourceFactory extends DataSource.Factory {
return postDataSource;
}
- void changeAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-
void changeSortType(String sortType) {
this.sortType = sortType;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
index e9fb7bb2..7382fbaf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
@@ -272,6 +272,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username);
intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
intent.putExtra(FilteredPostsActivity.EXTRA_SORT_TYPE, sortType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where);
intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter);
startActivity(intent);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java
index f423fbec..70209249 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java
@@ -100,6 +100,10 @@ public class PostViewModel extends ViewModel {
accessTokenLiveData = new MutableLiveData<>();
accessTokenLiveData.postValue(accessToken);
+ sortTypeLiveData = new MutableLiveData<>();
+ sortTypeLiveData.postValue(sortType);
+
+ accessTokenAndSortTypeLiveData = new AccessTokenAndSortTypeLiveData(accessTokenLiveData, sortTypeLiveData);
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
@@ -107,10 +111,8 @@ public class PostViewModel extends ViewModel {
.setPageSize(25)
.build();
- posts = (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
-
- posts = Transformations.switchMap(accessTokenLiveData, newAccessToken -> {
- postDataSourceFactory.changeAccessToken(accessTokenLiveData.getValue());
+ posts = Transformations.switchMap(accessTokenAndSortTypeLiveData, sort -> {
+ postDataSourceFactory.changeAccessTokenAndSortType(accessTokenLiveData.getValue(), sortTypeLiveData.getValue());
return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
});
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserThingSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserThingSortTypeBottomSheetFragment.java
new file mode 100644
index 00000000..83fb1464
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserThingSortTypeBottomSheetFragment.java
@@ -0,0 +1,88 @@
+package ml.docilealligator.infinityforreddit;
+
+
+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;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class UserThingSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ interface UserPostsSortTypeSelectionCallback {
+ void userThingSortTypeSelected(String sortType);
+ }
+
+ static final String EXTRA_NO_BEST_TYPE = "ENBT";
+
+ @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) {
+ ((UserPostsSortTypeSelectionCallback) activity).userThingSortTypeSelected(PostDataSource.SORT_TYPE_NEW);
+ }
+ dismiss();
+ });
+
+ hotTypeTextView.setOnClickListener(view -> {
+ if(activity != null) {
+ ((UserPostsSortTypeSelectionCallback) activity).userThingSortTypeSelected(PostDataSource.SORT_TYPE_HOT);
+ }
+ dismiss();
+ });
+
+ topTypeTextView.setOnClickListener(view -> {
+ if(activity != null) {
+ ((UserPostsSortTypeSelectionCallback) activity).userThingSortTypeSelected(PostDataSource.SORT_TYPE_TOP);
+ }
+ dismiss();
+ });
+
+ controversialTypeTextView.setOnClickListener(view -> {
+ if(activity != null) {
+ ((UserPostsSortTypeSelectionCallback) activity).userThingSortTypeSelected(PostDataSource.SORT_TYPE_CONTROVERSIAL);
+ }
+ dismiss();
+ });
+
+ return rootView;
+ }
+
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
index cd57a70a..f510ce27 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
@@ -48,7 +48,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
-public class ViewUserDetailActivity extends AppCompatActivity {
+public class ViewUserDetailActivity extends AppCompatActivity implements UserThingSortTypeBottomSheetFragment.UserPostsSortTypeSelectionCallback {
public static final String EXTRA_USER_NAME_KEY = "EUNK";
@@ -58,26 +58,16 @@ public class ViewUserDetailActivity extends AppCompatActivity {
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
- @BindView(R.id.coordinator_layout_view_user_detail_activity)
- CoordinatorLayout coordinatorLayout;
- @BindView(R.id.view_pager_view_user_detail_activity)
- ViewPager viewPager;
- @BindView(R.id.appbar_layout_view_user_detail)
- AppBarLayout appBarLayout;
- @BindView(R.id.tab_layout_view_user_detail_activity)
- TabLayout tabLayout;
- @BindView(R.id.collapsing_toolbar_layout_view_user_detail_activity)
- CollapsingToolbarLayout collapsingToolbarLayout;
- @BindView(R.id.banner_image_view_view_user_detail_activity)
- GifImageView bannerImageView;
- @BindView(R.id.icon_gif_image_view_view_user_detail_activity)
- GifImageView iconGifImageView;
- @BindView(R.id.user_name_text_view_view_user_detail_activity)
- TextView userNameTextView;
- @BindView(R.id.subscribe_user_chip_view_user_detail_activity)
- Chip subscribeUserChip;
- @BindView(R.id.karma_text_view_view_user_detail_activity)
- TextView karmaTextView;
+ @BindView(R.id.coordinator_layout_view_user_detail_activity) CoordinatorLayout coordinatorLayout;
+ @BindView(R.id.view_pager_view_user_detail_activity) ViewPager viewPager;
+ @BindView(R.id.appbar_layout_view_user_detail) AppBarLayout appBarLayout;
+ @BindView(R.id.tab_layout_view_user_detail_activity) TabLayout tabLayout;
+ @BindView(R.id.collapsing_toolbar_layout_view_user_detail_activity) CollapsingToolbarLayout collapsingToolbarLayout;
+ @BindView(R.id.banner_image_view_view_user_detail_activity) GifImageView bannerImageView;
+ @BindView(R.id.icon_gif_image_view_view_user_detail_activity) GifImageView iconGifImageView;
+ @BindView(R.id.user_name_text_view_view_user_detail_activity) TextView userNameTextView;
+ @BindView(R.id.subscribe_user_chip_view_user_detail_activity) Chip subscribeUserChip;
+ @BindView(R.id.karma_text_view_view_user_detail_activity) TextView karmaTextView;
private SectionsPagerAdapter sectionsPagerAdapter;
@@ -87,6 +77,8 @@ public class ViewUserDetailActivity extends AppCompatActivity {
private Menu mMenu;
private AppBarLayout.LayoutParams params;
+ private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
+
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -347,6 +339,8 @@ public class ViewUserDetailActivity extends AppCompatActivity {
karmaTextView.setText(karma);
}
});
+
+ userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
}
private void getCurrentAccountAndInitializeViewPager() {
@@ -431,6 +425,9 @@ public class ViewUserDetailActivity extends AppCompatActivity {
case android.R.id.home:
finish();
return true;
+ case R.id.action_sort_view_user_detail_activity:
+ userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
+ return true;
case R.id.action_search_view_user_detail_activity:
Intent intent = new Intent(this, SearchActivity.class);
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, username);
@@ -486,6 +483,11 @@ public class ViewUserDetailActivity extends AppCompatActivity {
}
}
+ @Override
+ public void userThingSortTypeSelected(String sortType) {
+ sectionsPagerAdapter.changeSortType(sortType);
+ }
+
private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
interface InsertUserDataAsyncTaskListener {
@@ -590,5 +592,11 @@ public class ViewUserDetailActivity extends AppCompatActivity {
commentsListingFragment.refresh();
}
}
+
+ public void changeSortType(String sortType) {
+ if(postFragment != null) {
+ postFragment.changeSortType(sortType);
+ }
+ }
}
}
diff --git a/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml
new file mode 100644
index 00000000..aa928f7c
--- /dev/null
+++ b/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="8dp">
+
+ <TextView
+ android:id="@+id/new_type_text_view_user_thing_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_new"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_hot"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/top_type_text_view_user_thing_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_top"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_controversial"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_user_detail_activity.xml b/app/src/main/res/menu/view_user_detail_activity.xml
index b47f91d3..44af8d7a 100644
--- a/app/src/main/res/menu/view_user_detail_activity.xml
+++ b/app/src/main/res/menu/view_user_detail_activity.xml
@@ -3,21 +3,27 @@
xmlns:tools="http://schemas.android.com/tools"
tools:application="ml.docilealligator.infinityforreddit.ViewUserDetailActivity">
<item
- android:id="@+id/action_search_view_user_detail_activity"
+ android:id="@+id/action_sort_view_user_detail_activity"
android:orderInCategory="1"
android:title="@string/action_search"
+ android:icon="@drawable/ic_outline_sort_24px"
+ app:showAsAction="ifRoom" />
+ <item
+ android:id="@+id/action_search_view_user_detail_activity"
+ android:orderInCategory="2"
+ android:title="@string/action_search"
android:icon="@drawable/ic_search_white_24dp"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_refresh_view_user_detail_activity"
- android:orderInCategory="2"
+ android:orderInCategory="3"
android:title="@string/action_refresh"
android:icon="@drawable/ic_refresh_white_24dp"
app:showAsAction="never" />
<item
android:id="@+id/action_lazy_mode_view_user_detail_activity"
- android:orderInCategory="3"
+ android:orderInCategory="4"
android:title="@string/action_start_lazy_mode"
app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 742706ea..9f8b938e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -216,4 +216,7 @@
<string name="edit_flair">Edit Flair</string>
<string name="only_allow_64_chars">Only allow less than 64 characters</string>
+
+ <!-- TODO: Remove or change this placeholder text -->
+ <string name="hello_blank_fragment">Hello blank fragment</string>
</resources>