Merge pull request 'Remove reddit related stuff' (#51) from reddit_removal into master

Reviewed-on: https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/pulls/51
This commit is contained in:
Bazsalanszky 2023-08-04 13:06:20 +00:00
commit acb651cf92
16 changed files with 82 additions and 171 deletions

View File

@ -1400,10 +1400,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
goToUser(); goToUser();
break; break;
} }
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
randomThing();
break;
}
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: { case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts(); sectionsPagerAdapter.hideReadPosts();

View File

@ -558,10 +558,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
goToUser(); goToUser();
break; break;
} }
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
random();
break;
}
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: { case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts(); sectionsPagerAdapter.hideReadPosts();

View File

@ -233,7 +233,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
}); });
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter); viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(3); viewPager.setOffscreenPageLimit(1);
if (viewPager.getCurrentItem() != 2) { if (viewPager.getCurrentItem() != 2) {
fab.hide(); fab.hide();
} }
@ -358,7 +358,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
} }
if (!(!forceLoad && mInsertMultiredditSuccess)) { if (!(!forceLoad && mInsertMultiredditSuccess)) {
loadMultiReddits(); //loadMultiReddits();
} }
} }
@ -412,7 +412,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
public void success() { public void success() {
Toast.makeText(SubscribedThingListingActivity.this, Toast.makeText(SubscribedThingListingActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
loadMultiReddits(); //loadMultiReddits();
} }
@Override @Override
@ -439,7 +439,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
@Subscribe @Subscribe
public void onRefreshMultiRedditsEvent(RefreshMultiRedditsEvent event) { public void onRefreshMultiRedditsEvent(RefreshMultiRedditsEvent event) {
loadMultiReddits(); //loadMultiReddits();
} }
@Override @Override
@ -477,6 +477,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
switch (position) { switch (position) {
default:
case 0: { case 0: {
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment(); SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -487,28 +488,12 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
case 1: {
FollowedUsersListingFragment fragment = new FollowedUsersListingFragment();
Bundle bundle = new Bundle();
bundle.putString(FollowedUsersListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountName);
bundle.putString(FollowedUsersListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
fragment.setArguments(bundle);
return fragment;
}
default: {
MultiRedditListingFragment fragment = new MultiRedditListingFragment();
Bundle bundle = new Bundle();
bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountName);
fragment.setArguments(bundle);
return fragment;
}
} }
} }
@Override @Override
public int getCount() { public int getCount() {
return 3; return 1;
} }
@Override @Override

View File

@ -946,10 +946,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
goToUser(); goToUser();
break; break;
} }
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
random();
break;
}
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: { case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
if (mFragment instanceof PostFragment) { if (mFragment instanceof PostFragment) {
((PostFragment) mFragment).hideReadPosts(); ((PostFragment) mFragment).hideReadPosts();

View File

@ -554,12 +554,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
creationTimeTextView.setText(subredditData.getCreatedUTC()); creationTimeTextView.setText(subredditData.getCreatedUTC());
description = subredditData.getDescription(); description = subredditData.getDescription();
if (hideSubredditDescription || description.equals("")) {
descriptionTextView.setVisibility(View.GONE); descriptionTextView.setVisibility(View.GONE);
} else {
descriptionTextView.setVisibility(View.VISIBLE);
markwon.setMarkdown(descriptionTextView, description);
}
if (subredditData.isNSFW()) { if (subredditData.isNSFW()) {
if (nsfwWarningBuilder == null if (nsfwWarningBuilder == null
@ -1402,10 +1399,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
goToUser(); goToUser();
break; break;
} }
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
random();
break;
}
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: { case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts(); sectionsPagerAdapter.hideReadPosts();

View File

@ -1341,10 +1341,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
goToUser(); goToUser();
break; break;
} }
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
random();
break;
}
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: { case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts(); sectionsPagerAdapter.hideReadPosts();

View File

@ -215,7 +215,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getComment().getAuthor()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getComment().getAuthor());
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getComment().getCommunityQualifiedName()); intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getComment().getAuthorQualifiedName());
mActivity.startActivity(intent); mActivity.startActivity(intent);
}); });
} }

View File

@ -24,8 +24,8 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1; private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
private static final int VIEW_TYPE_MENU_ITEM = 2; private static final int VIEW_TYPE_MENU_ITEM = 2;
private static final int ACCOUNT_SECTION_ITEMS = 5; private static final int ACCOUNT_SECTION_ITEMS = 4;
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 3; private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 2;
private BaseActivity baseActivity; private BaseActivity baseActivity;
private int inboxCount; private int inboxCount;
@ -101,10 +101,6 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp; drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
break; break;
case 3: case 3:
stringId = R.string.multi_reddit;
drawableId = R.drawable.ic_multi_reddit_24dp;
break;
case 4:
setOnClickListener = false; setOnClickListener = false;
if (inboxCount > 0) { if (inboxCount > 0) {
((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount)); ((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount));
@ -118,23 +114,21 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}); });
break; break;
default: default:
stringId = R.string.history; stringId = R.string.account_saved_thing_activity_label;
drawableId = R.drawable.ic_history_24dp; drawableId = R.drawable.ic_outline_bookmarks_24dp;
break;
} }
} else { } else {
switch (position) { switch (position) {
case 1: case 1:
stringId = R.string.subscriptions; stringId = R.string.subscriptions;
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp; drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
break; break;
case 2:
stringId = R.string.multi_reddit;
drawableId = R.drawable.ic_multi_reddit_24dp;
break;
default: default:
stringId = R.string.history; stringId = R.string.anonymous_account_instance;
drawableId = R.drawable.ic_history_24dp; drawableId = R.drawable.ic_account_circle_24dp;
break;
} }
} }

View File

@ -17,8 +17,6 @@ import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
public class NavigationDrawerRecyclerViewMergedAdapter { public class NavigationDrawerRecyclerViewMergedAdapter {
private HeaderSectionRecyclerViewAdapter headerSectionRecyclerViewAdapter; private HeaderSectionRecyclerViewAdapter headerSectionRecyclerViewAdapter;
private AccountSectionRecyclerViewAdapter accountSectionRecyclerViewAdapter; private AccountSectionRecyclerViewAdapter accountSectionRecyclerViewAdapter;
private RedditSectionRecyclerViewAdapter redditSectionRecyclerViewAdapter;
private PostSectionRecyclerViewAdapter postSectionRecyclerViewAdapter;
private PreferenceSectionRecyclerViewAdapter preferenceSectionRecyclerViewAdapter; private PreferenceSectionRecyclerViewAdapter preferenceSectionRecyclerViewAdapter;
private FavoriteSubscribedSubredditsSectionRecyclerViewAdapter favoriteSubscribedSubredditsSectionRecyclerViewAdapter; private FavoriteSubscribedSubredditsSectionRecyclerViewAdapter favoriteSubscribedSubredditsSectionRecyclerViewAdapter;
private SubscribedSubredditsRecyclerViewAdapter subscribedSubredditsRecyclerViewAdapter; private SubscribedSubredditsRecyclerViewAdapter subscribedSubredditsRecyclerViewAdapter;
@ -49,10 +47,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
}); });
accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper, accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
navigationDrawerSharedPreferences, accountName != null, itemClickListener); navigationDrawerSharedPreferences, accountName != null, itemClickListener);
redditSectionRecyclerViewAdapter = new RedditSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
navigationDrawerSharedPreferences, itemClickListener, accountName != null);
postSectionRecyclerViewAdapter = new PostSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper, preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener); accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener);
favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter( favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter(
@ -65,8 +59,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
mainPageConcatAdapter = new ConcatAdapter( mainPageConcatAdapter = new ConcatAdapter(
headerSectionRecyclerViewAdapter, headerSectionRecyclerViewAdapter,
accountSectionRecyclerViewAdapter, accountSectionRecyclerViewAdapter,
redditSectionRecyclerViewAdapter,
postSectionRecyclerViewAdapter,
preferenceSectionRecyclerViewAdapter, preferenceSectionRecyclerViewAdapter,
favoriteSubscribedSubredditsSectionRecyclerViewAdapter, favoriteSubscribedSubredditsSectionRecyclerViewAdapter,
subscribedSubredditsRecyclerViewAdapter); subscribedSubredditsRecyclerViewAdapter);
@ -78,8 +70,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
private void openAccountSection() { private void openAccountSection() {
mainPageConcatAdapter.removeAdapter(accountSectionRecyclerViewAdapter); mainPageConcatAdapter.removeAdapter(accountSectionRecyclerViewAdapter);
mainPageConcatAdapter.removeAdapter(redditSectionRecyclerViewAdapter);
mainPageConcatAdapter.removeAdapter(postSectionRecyclerViewAdapter);
mainPageConcatAdapter.removeAdapter(preferenceSectionRecyclerViewAdapter); mainPageConcatAdapter.removeAdapter(preferenceSectionRecyclerViewAdapter);
mainPageConcatAdapter.removeAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter); mainPageConcatAdapter.removeAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
mainPageConcatAdapter.removeAdapter(subscribedSubredditsRecyclerViewAdapter); mainPageConcatAdapter.removeAdapter(subscribedSubredditsRecyclerViewAdapter);
@ -91,8 +81,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
mainPageConcatAdapter.removeAdapter(accountManagementSectionRecyclerViewAdapter); mainPageConcatAdapter.removeAdapter(accountManagementSectionRecyclerViewAdapter);
mainPageConcatAdapter.addAdapter(accountSectionRecyclerViewAdapter); mainPageConcatAdapter.addAdapter(accountSectionRecyclerViewAdapter);
mainPageConcatAdapter.addAdapter(redditSectionRecyclerViewAdapter);
mainPageConcatAdapter.addAdapter(postSectionRecyclerViewAdapter);
mainPageConcatAdapter.addAdapter(preferenceSectionRecyclerViewAdapter); mainPageConcatAdapter.addAdapter(preferenceSectionRecyclerViewAdapter);
mainPageConcatAdapter.addAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter); mainPageConcatAdapter.addAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
mainPageConcatAdapter.addAdapter(subscribedSubredditsRecyclerViewAdapter); mainPageConcatAdapter.addAdapter(subscribedSubredditsRecyclerViewAdapter);

View File

@ -24,7 +24,6 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
public static final int FAB_OPTION_SEARCH = 4; public static final int FAB_OPTION_SEARCH = 4;
public static final int FAB_OPTION_GO_TO_SUBREDDIT = 5; public static final int FAB_OPTION_GO_TO_SUBREDDIT = 5;
public static final int FAB_OPTION_GO_TO_USER = 6; public static final int FAB_OPTION_GO_TO_USER = 6;
public static final int FAB_RANDOM = 7;
public static final int FAB_HIDE_READ_POSTS = 8; public static final int FAB_HIDE_READ_POSTS = 8;
public static final int FAB_FILTER_POSTS = 9; public static final int FAB_FILTER_POSTS = 9;
public static final int FAB_GO_TO_TOP = 10; public static final int FAB_GO_TO_TOP = 10;
@ -86,10 +85,6 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
dismiss(); dismiss();
}); });
binding.randomTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_RANDOM);
dismiss();
});
binding.filterPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> { binding.filterPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_FILTER_POSTS); activity.fabOptionSelected(FAB_FILTER_POSTS);

View File

@ -31,16 +31,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
@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) @BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment)
TextView topTypeTextView; TextView topTypeTextView;
@BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment) @BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment)
TextView newTypeTextView; TextView newTypeTextView;
@BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) @BindView(R.id.old_type_text_view_search_sort_type_bottom_sheet_fragment)
TextView commentsTypeTextView; TextView oldTypeTextView;
private BaseActivity activity; private BaseActivity activity;
public SearchPostSortTypeBottomSheetFragment() { public SearchPostSortTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
@ -61,14 +57,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.HOT.fullName)) { if (currentSortType.equals(SortType.Type.TOP.fullName)) {
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.TOP.fullName)) {
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) { } else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.OLD.fullName)) { } else if (currentSortType.equals(SortType.Type.OLD.fullName)) {
commentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(commentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); oldTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(oldTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
@ -76,15 +70,6 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); 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 -> { topTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name());
@ -92,12 +77,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
}); });
newTypeTextView.setOnClickListener(view -> { newTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW,null));
dismiss(); dismiss();
}); });
commentsTypeTextView.setOnClickListener(view -> { oldTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.MOST_COMMENTS.name()); ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD,null));
dismiss(); dismiss();
}); });

View File

@ -460,9 +460,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
nameOfUsage = PostFilterUsage.NO_USAGE; nameOfUsage = PostFilterUsage.NO_USAGE;
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.TOP_ALL.value); String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.TOP_ALL.value);
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name()); String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sort.equalsIgnoreCase(SortType.Type.TOP.value) ? SortType.Time.ALL.name() : null);
SortType.Type st = SortType.Type.fromValue(sort); SortType.Type st = SortType.Type.fromValue(sort);
sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st, SortType.Time.valueOf(sortTime)); sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st,sortTime != null ? SortType.Time.valueOf(sortTime) : null);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
@ -1385,6 +1385,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply(); mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
if (sortType.getTime() != null) { if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply(); mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
}else {
mSortTypeSharedPreferences.edit().remove(SharedPreferencesUtils.SORT_TIME_SEARCH_POST).apply();
} }
break; break;
case PostPagingSource.TYPE_MULTI_REDDIT: case PostPagingSource.TYPE_MULTI_REDDIT:

View File

@ -8,7 +8,12 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import eu.toldi.infinityforlemmy.utils.JSONUtils; import eu.toldi.infinityforlemmy.utils.JSONUtils;
@ -47,7 +52,11 @@ public class ParseSubredditData {
} }
boolean removed = community.getBoolean("removed"); boolean removed = community.getBoolean("removed");
String published = community.getString("published"); String published_raw = community.getString("published");
String published = formatISOTime(published_raw);
if(published == null){
published = published_raw;
}
String updated = ""; String updated = "";
if (!community.isNull("updated")) { if (!community.isNull("updated")) {
updated = community.getString("updated"); updated = community.getString("updated");
@ -170,4 +179,25 @@ public class ParseSubredditData {
} }
} }
} }
public static String formatISOTime(String isoTime) {
// Truncate the time to millisecond precision
String truncatedTime = isoTime.substring(0, 23);
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
Date date = isoFormat.parse(truncatedTime);
// Set your desired output format here
SimpleDateFormat outputFormat = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss", Locale.US);
outputFormat.setTimeZone(TimeZone.getDefault()); // Set to device's default timezone
return outputFormat.format(date);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
} }

View File

@ -144,25 +144,6 @@
android:focusable="true" android:focusable="true"
android:background="?attr/selectableItemBackground" /> android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/random_text_view_fab_more_options_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/random"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:drawableStartCompat="@drawable/ic_random_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView <TextView
android:id="@+id/hide_read_posts_text_view_fab_more_options_bottom_sheet_fragment" android:id="@+id/hide_read_posts_text_view_fab_more_options_bottom_sheet_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -11,43 +11,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/relevance_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:drawableStart="@drawable/ic_best_24"
android:drawablePadding="48dp"
android:focusable="true"
android:fontFamily="?attr/font_family"
android:paddingStart="32dp"
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
android:text="@string/sort_relevance"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/hot_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:drawableStart="@drawable/ic_hot_24"
android:drawablePadding="48dp"
android:focusable="true"
android:fontFamily="?attr/font_family"
android:paddingStart="32dp"
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
android:text="@string/sort_hot"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/top_type_text_view_search_sort_type_bottom_sheet_fragment" android:id="@+id/top_type_text_view_search_sort_type_bottom_sheet_fragment"
@ -88,7 +51,7 @@
app:drawableTint="?attr/primaryTextColor" /> app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/comments_type_text_view_search_sort_type_bottom_sheet_fragment" android:id="@+id/old_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -101,7 +64,7 @@
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingEnd="32dp" android:paddingEnd="32dp"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:text="@string/sort_comments" android:text="@string/sort_old"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" /> app:drawableTint="?attr/primaryTextColor" />

View File

@ -501,47 +501,57 @@
<string-array name="settings_subreddit_default_sort_type"> <string-array name="settings_subreddit_default_sort_type">
<item>Hot</item> <item>Hot</item>
<item>New</item> <item>New</item>
<item>Rising</item> <item>Active</item>
<item>Top</item> <item>Top</item>
<item>Controversial</item> <item>Most Comments</item>
<item>New Comments</item>
</string-array> </string-array>
<string-array name="settings_subreddit_default_sort_type_values"> <string-array name="settings_subreddit_default_sort_type_values">
<item>HOT</item> <item>HOT</item>
<item>NEW</item> <item>NEW</item>
<item>RISING</item> <item>ACTIVE</item>
<item>TOP</item> <item>TOP</item>
<item>CONTROVERSIAL</item> <item>MOSTCOMMENTS</item>
<item>NEWCOMMENTS</item>
</string-array> </string-array>
<string-array name="settings_user_default_sort_type"> <string-array name="settings_user_default_sort_type">
<item>New</item> <item>New</item>
<item>Hot</item> <item>Old</item>
<item>Top</item> <item>Top</item>
<item>Controversial</item>
</string-array> </string-array>
<string-array name="settings_user_default_sort_type_values"> <string-array name="settings_user_default_sort_type_values">
<item>NEW</item> <item>NEW</item>
<item>HOT</item> <item>OLD</item>
<item>TOP</item> <item>TOP</item>
<item>CONTROVERSIAL</item>
</string-array> </string-array>
<string-array name="settings_default_sort_time"> <string-array name="settings_default_sort_time">
<item>Hour</item> <item>Hour</item>
<item>6 Hours</item>
<item>12 Hours</item>
<item>Day</item> <item>Day</item>
<item>Week</item> <item>Week</item>
<item>Month</item> <item>Month</item>
<item>3 Months</item>
<item>6 Months</item>
<item>9 Months</item>
<item>Year</item> <item>Year</item>
<item>All Time</item> <item>All Time</item>
</string-array> </string-array>
<string-array name="settings_default_sort_time_values"> <string-array name="settings_default_sort_time_values">
<item>HOUR</item> <item>HOUR</item>
<item>6HOURS</item>
<item>12HOURS</item>
<item>DAY</item> <item>DAY</item>
<item>WEEK</item> <item>WEEK</item>
<item>MONTH</item> <item>MONTH</item>
<item>3MONTHS</item>
<item>6MONTHS</item>
<item>9MONTHS</item>
<item>YEAR</item> <item>YEAR</item>
<item>ALL</item> <item>ALL</item>
</string-array> </string-array>