mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-07 15:14:47 +01:00
Compare commits
5 Commits
726eac70a9
...
56c5043249
Author | SHA1 | Date | |
---|---|---|---|
|
56c5043249 | ||
|
8c8c6c6195 | ||
|
c4eace9330 | ||
|
3f0862c5e5 | ||
|
4f3e09c84b |
@ -49,7 +49,7 @@ public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
|
|||||||
if (anonymousSubscribedSubreddits != null && !anonymousSubscribedSubreddits.isEmpty()) {
|
if (anonymousSubscribedSubreddits != null && !anonymousSubscribedSubreddits.isEmpty()) {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (SubscribedSubredditData s : anonymousSubscribedSubreddits) {
|
for (SubscribedSubredditData s : anonymousSubscribedSubreddits) {
|
||||||
stringBuilder.append(s.getName()).append("+");
|
stringBuilder.append(s.getQualified_name()).append(",");
|
||||||
}
|
}
|
||||||
if (stringBuilder.length() > 0) {
|
if (stringBuilder.length() > 0) {
|
||||||
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||||
|
@ -12,7 +12,6 @@ import android.view.View;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -25,6 +24,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
|||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -40,6 +40,7 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
|||||||
import eu.toldi.infinityforlemmy.multireddit.EditMultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.EditMultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.FetchMultiRedditInfo;
|
import eu.toldi.infinityforlemmy.multireddit.FetchMultiRedditInfo;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -69,12 +70,6 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
EditText descriptionEditText;
|
EditText descriptionEditText;
|
||||||
@BindView(R.id.divider_2_edit_multi_reddit_activity)
|
@BindView(R.id.divider_2_edit_multi_reddit_activity)
|
||||||
View divider2;
|
View divider2;
|
||||||
@BindView(R.id.visibility_wrapper_linear_layout_edit_multi_reddit_activity)
|
|
||||||
LinearLayout visibilityLinearLayout;
|
|
||||||
@BindView(R.id.visibility_text_view_edit_multi_reddit_activity)
|
|
||||||
TextView visibilityTextView;
|
|
||||||
@BindView(R.id.visibility_switch_edit_multi_reddit_activity)
|
|
||||||
Switch visibilitySwitch;
|
|
||||||
@BindView(R.id.select_subreddit_text_view_edit_multi_reddit_activity)
|
@BindView(R.id.select_subreddit_text_view_edit_multi_reddit_activity)
|
||||||
TextView selectSubredditTextView;
|
TextView selectSubredditTextView;
|
||||||
@Inject
|
@Inject
|
||||||
@ -125,7 +120,6 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||||
|
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
visibilityLinearLayout.setVisibility(View.GONE);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||||
descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||||
@ -167,13 +161,21 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
linearLayout.setVisibility(View.VISIBLE);
|
linearLayout.setVisibility(View.VISIBLE);
|
||||||
nameEditText.setText(multiReddit.getDisplayName());
|
nameEditText.setText(multiReddit.getDisplayName());
|
||||||
descriptionEditText.setText(multiReddit.getDescription());
|
descriptionEditText.setText(multiReddit.getDescription());
|
||||||
visibilitySwitch.setChecked(!multiReddit.getVisibility().equals("public"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectSubredditTextView.setOnClickListener(view -> {
|
selectSubredditTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
|
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
|
||||||
if (multiReddit.getSubreddits() != null) {
|
if (multiReddit.getSubreddits() != null) {
|
||||||
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, multiReddit.getSubreddits());
|
if (multiReddit.getSubreddits().isEmpty() && !multiReddit.getPath().equals("")) {
|
||||||
|
String[] communities = multiReddit.getPath().split(",");
|
||||||
|
ArrayList<SubredditWithSelection> communitiesList = new ArrayList<>();
|
||||||
|
for (String community : communities) {
|
||||||
|
communitiesList.add(new SubredditWithSelection(community.substring(0, community.indexOf('@')), null, community));
|
||||||
|
}
|
||||||
|
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, communitiesList);
|
||||||
|
} else {
|
||||||
|
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, multiReddit.getSubreddits());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
||||||
});
|
});
|
||||||
@ -203,8 +205,18 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
multiReddit.setDisplayName(name);
|
multiReddit.setDisplayName(name);
|
||||||
multiReddit.setName(name);
|
multiReddit.setName(name);
|
||||||
multiReddit.setDescription(descriptionEditText.getText().toString());
|
multiReddit.setDescription(descriptionEditText.getText().toString());
|
||||||
|
StringBuilder pathStringBuilder = new StringBuilder();
|
||||||
|
String prefix = "";
|
||||||
|
for (SubredditWithSelection s : multiReddit.getSubreddits()) {
|
||||||
|
pathStringBuilder.append(prefix);
|
||||||
|
prefix = ",";
|
||||||
|
pathStringBuilder.append(s.getQualifiedName());
|
||||||
|
}
|
||||||
|
|
||||||
|
multiReddit.setPath(pathStringBuilder.toString());
|
||||||
|
|
||||||
EditMultiReddit.anonymousEditMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
EditMultiReddit.anonymousEditMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||||
multiReddit, new EditMultiReddit.EditMultiRedditListener() {
|
multiReddit, multipath, new EditMultiReddit.EditMultiRedditListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
finish();
|
finish();
|
||||||
@ -263,7 +275,6 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setBackgroundColor(dividerColor);
|
||||||
descriptionEditText.setTextColor(primaryTextColor);
|
descriptionEditText.setTextColor(primaryTextColor);
|
||||||
descriptionEditText.setHintTextColor(secondaryTextColor);
|
descriptionEditText.setHintTextColor(secondaryTextColor);
|
||||||
visibilityTextView.setTextColor(primaryTextColor);
|
|
||||||
selectSubredditTextView.setTextColor(primaryTextColor);
|
selectSubredditTextView.setTextColor(primaryTextColor);
|
||||||
|
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
|
@ -371,20 +371,17 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
} else if (itemId == R.id.action_sort_filtered_thing_activity) {
|
} else if (itemId == R.id.action_sort_filtered_thing_activity) {
|
||||||
switch (postType) {
|
switch (postType) {
|
||||||
case PostPagingSource.TYPE_FRONT_PAGE:
|
case PostPagingSource.TYPE_FRONT_PAGE:
|
||||||
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(false, mFragment.getSortType());
|
case PostPagingSource.TYPE_SUBREDDIT:
|
||||||
|
case PostPagingSource.TYPE_MULTI_REDDIT:
|
||||||
|
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
|
||||||
|
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
||||||
|
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(postType, mFragment.getSortType());
|
||||||
bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag());
|
bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag());
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_SEARCH:
|
case PostPagingSource.TYPE_SEARCH:
|
||||||
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
|
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
|
||||||
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
|
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_SUBREDDIT:
|
|
||||||
case PostPagingSource.TYPE_MULTI_REDDIT:
|
|
||||||
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
|
|
||||||
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
|
||||||
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, mFragment.getSortType());
|
|
||||||
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
|
||||||
break;
|
|
||||||
case PostPagingSource.TYPE_USER:
|
case PostPagingSource.TYPE_USER:
|
||||||
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
|
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
|
||||||
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
|
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
|
||||||
|
@ -1134,7 +1134,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
int currentPostType = sectionsPagerAdapter.getCurrentPostType();
|
int currentPostType = sectionsPagerAdapter.getCurrentPostType();
|
||||||
PostFragment postFragment = sectionsPagerAdapter.getCurrentFragment();
|
PostFragment postFragment = sectionsPagerAdapter.getCurrentFragment();
|
||||||
if (postFragment != null) {
|
if (postFragment != null) {
|
||||||
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType != PostPagingSource.TYPE_FRONT_PAGE, postFragment.getSortType());
|
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType, postFragment.getSortType());
|
||||||
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
|||||||
import eu.toldi.infinityforlemmy.Infinity;
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.adapters.SelectedSubredditsRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.SelectedSubredditsRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.SelectSubredditsOrUsersOptionsBottomSheetFragment;
|
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
@ -109,8 +108,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
|||||||
});
|
});
|
||||||
|
|
||||||
fab.setOnClickListener(view -> {
|
fab.setOnClickListener(view -> {
|
||||||
SelectSubredditsOrUsersOptionsBottomSheetFragment selectSubredditsOrUsersOptionsBottomSheetFragment = new SelectSubredditsOrUsersOptionsBottomSheetFragment();
|
selectSubreddits();
|
||||||
selectSubredditsOrUsersOptionsBottomSheetFragment.show(getSupportFragmentManager(), selectSubredditsOrUsersOptionsBottomSheetFragment.getTag());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
if (showMultiReddits) {
|
if (showMultiReddits) {
|
||||||
viewPager.setCurrentItem(2, false);
|
viewPager.setCurrentItem(1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSubscriptions(false);
|
loadSubscriptions(false);
|
||||||
|
@ -62,10 +62,8 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.customviews.NavigationWrapper;
|
import eu.toldi.infinityforlemmy.customviews.NavigationWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
import eu.toldi.infinityforlemmy.events.GoBackToMainPageEvent;
|
import eu.toldi.infinityforlemmy.events.GoBackToMainPageEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.RefreshMultiRedditsEvent;
|
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
|
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
@ -592,7 +590,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
|
|
||||||
private void showSortTypeBottomSheetFragment() {
|
private void showSortTypeBottomSheetFragment() {
|
||||||
if (mFragment instanceof PostFragment) {
|
if (mFragment instanceof PostFragment) {
|
||||||
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) mFragment).getSortType());
|
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_MULTICOMMUNITY, ((PostFragment) mFragment).getSortType());
|
||||||
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -678,7 +676,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@ -699,7 +697,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -764,6 +762,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
Intent editIntent = new Intent(this, EditMultiRedditActivity.class);
|
Intent editIntent = new Intent(this, EditMultiRedditActivity.class);
|
||||||
editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_PATH, multiPath);
|
editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_PATH, multiPath);
|
||||||
startActivity(editIntent);
|
startActivity(editIntent);
|
||||||
|
finish();
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_delete_view_multi_reddit_detail_activity) {
|
} else if (itemId == R.id.action_delete_view_multi_reddit_detail_activity) {
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
@ -771,30 +770,13 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
.setMessage(R.string.delete_multi_reddit_dialog_message)
|
.setMessage(R.string.delete_multi_reddit_dialog_message)
|
||||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||||
-> {
|
-> {
|
||||||
if (mAccessToken == null) {
|
|
||||||
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiPath,
|
|
||||||
() -> {
|
|
||||||
Toast.makeText(this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
|
||||||
finish();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
|
||||||
mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
Toast.makeText(ViewMultiRedditDetailActivity.this,
|
|
||||||
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
|
||||||
EventBus.getDefault().post(new RefreshMultiRedditsEvent());
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiPath,
|
||||||
public void failed() {
|
() -> {
|
||||||
Toast.makeText(ViewMultiRedditDetailActivity.this,
|
Toast.makeText(this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
||||||
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
|
finish();
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show();
|
.show();
|
||||||
|
@ -1206,7 +1206,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
private void displaySortTypeBottomSheetFragment() {
|
private void displaySortTypeBottomSheetFragment() {
|
||||||
Fragment fragment = fragmentManager.findFragmentByTag("f0");
|
Fragment fragment = fragmentManager.findFragmentByTag("f0");
|
||||||
if (fragment instanceof PostFragment) {
|
if (fragment instanceof PostFragment) {
|
||||||
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) fragment).getSortType());
|
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_COMMUNITY, ((PostFragment) fragment).getSortType());
|
||||||
sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag());
|
sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof SubredditViewHolder) {
|
if (holder instanceof SubredditViewHolder) {
|
||||||
((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition()).getName());
|
((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition()).getQualifiedName());
|
||||||
((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> {
|
((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> {
|
||||||
subreddits.remove(holder.getBindingAdapterPosition());
|
subreddits.remove(holder.getBindingAdapterPosition());
|
||||||
notifyItemRemoved(holder.getBindingAdapterPosition());
|
notifyItemRemoved(holder.getBindingAdapterPosition());
|
||||||
@ -58,7 +58,11 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
|
|
||||||
public void addSubreddits(ArrayList<SubredditWithSelection> newSubreddits) {
|
public void addSubreddits(ArrayList<SubredditWithSelection> newSubreddits) {
|
||||||
int oldSize = subreddits.size();
|
int oldSize = subreddits.size();
|
||||||
subreddits.addAll(newSubreddits);
|
for (SubredditWithSelection subreddit : newSubreddits) {
|
||||||
|
if (!subreddits.contains(subreddit)) {
|
||||||
|
subreddits.add(subreddit);
|
||||||
|
}
|
||||||
|
}
|
||||||
notifyItemRangeInserted(oldSize, newSubreddits.size());
|
notifyItemRangeInserted(oldSize, newSubreddits.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
|
|||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof SubscribedSubredditViewHolder) {
|
if (holder instanceof SubscribedSubredditViewHolder) {
|
||||||
((SubscribedSubredditViewHolder) holder).nameTextView.setText(subscribedSubreddits.get(position).getName());
|
((SubscribedSubredditViewHolder) holder).nameTextView.setText(subscribedSubreddits.get(position).getName());
|
||||||
|
((SubscribedSubredditViewHolder) holder).instanceTextView.setText(subscribedSubreddits.get(position).getQualifiedName().substring(subscribedSubreddits.get(position).getQualifiedName().indexOf("@")));
|
||||||
glide.load(subscribedSubreddits.get(position).getIconUrl())
|
glide.load(subscribedSubreddits.get(position).getIconUrl())
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -107,6 +108,9 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
|
|||||||
GifImageView iconImageView;
|
GifImageView iconImageView;
|
||||||
@BindView(R.id.name_text_view_item_subscribed_subreddit_multiselection)
|
@BindView(R.id.name_text_view_item_subscribed_subreddit_multiselection)
|
||||||
TextView nameTextView;
|
TextView nameTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.instance_text_view_item_subscribed_subreddit_multiselection)
|
||||||
|
TextView instanceTextView;
|
||||||
@BindView(R.id.checkbox_item_subscribed_subreddit_multiselection)
|
@BindView(R.id.checkbox_item_subscribed_subreddit_multiselection)
|
||||||
CheckBox checkBox;
|
CheckBox checkBox;
|
||||||
|
|
||||||
@ -115,10 +119,12 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
|
|||||||
this.itemView = itemView;
|
this.itemView = itemView;
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
nameTextView.setTextColor(primaryTextColor);
|
nameTextView.setTextColor(primaryTextColor);
|
||||||
|
instanceTextView.setTextColor(primaryTextColor);
|
||||||
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
|
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
nameTextView.setTypeface(activity.typeface);
|
nameTextView.setTypeface(activity.typeface);
|
||||||
|
instanceTextView.setTypeface(activity.typeface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 = 4;
|
private static final int ACCOUNT_SECTION_ITEMS = 5;
|
||||||
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 1;
|
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 2;
|
||||||
|
|
||||||
private BaseActivity baseActivity;
|
private BaseActivity baseActivity;
|
||||||
private int inboxCount;
|
private int inboxCount;
|
||||||
@ -113,6 +113,10 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
baseActivity.startActivity(intent);
|
baseActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
stringId = R.string.multi_reddit;
|
||||||
|
drawableId = R.drawable.ic_multi_reddit_24dp;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
stringId = R.string.account_saved_thing_activity_label;
|
stringId = R.string.account_saved_thing_activity_label;
|
||||||
drawableId = R.drawable.ic_outline_bookmarks_24dp;
|
drawableId = R.drawable.ic_outline_bookmarks_24dp;
|
||||||
@ -125,6 +129,10 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
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.anonymous_account_instance;
|
stringId = R.string.anonymous_account_instance;
|
||||||
drawableId = R.drawable.ic_account_circle_24dp;
|
drawableId = R.drawable.ic_account_circle_24dp;
|
||||||
|
@ -29,11 +29,20 @@ import eu.toldi.infinityforlemmy.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
|
|
||||||
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
|
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
|
||||||
|
|
||||||
|
public static final String EXTRA_PAGE_TYPE = "EPT";
|
||||||
|
|
||||||
|
public static final int PAGE_TYPE_FRONT_PAGE = 0;
|
||||||
|
public static final int PAGE_TYPE_COMMUNITY = 1;
|
||||||
|
public static final int PAGE_TYPE_USER = 2;
|
||||||
|
public static final int PAGE_TYPE_SEARCH = 3;
|
||||||
|
public static final int PAGE_TYPE_MULTICOMMUNITY = 4;
|
||||||
|
public static final int PAGE_TYPE_ANONYMOUS_FRONT_PAGE = 5;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
TextView bestTypeTextView;
|
TextView activeTypeTextView;
|
||||||
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
TextView hotTypeTextView;
|
TextView hotTypeTextView;
|
||||||
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
@ -49,10 +58,10 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, SortType currentSortType) {
|
public static SortTypeBottomSheetFragment getNewInstance(int pageType, SortType currentSortType) {
|
||||||
SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment();
|
SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putBoolean(EXTRA_NO_BEST_TYPE, isNoBestType);
|
bundle.putInt(EXTRA_PAGE_TYPE, pageType);
|
||||||
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
|
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
@ -69,18 +78,27 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) {
|
int pageType = getArguments().getInt(EXTRA_PAGE_TYPE, PAGE_TYPE_USER);
|
||||||
bestTypeTextView.setVisibility(View.GONE);
|
|
||||||
} else {
|
switch (pageType) {
|
||||||
bestTypeTextView.setOnClickListener(view -> {
|
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
|
case PAGE_TYPE_MULTICOMMUNITY:
|
||||||
dismiss();
|
case PAGE_TYPE_USER:
|
||||||
});
|
case PAGE_TYPE_ANONYMOUS_FRONT_PAGE:
|
||||||
|
activeTypeTextView.setVisibility(View.GONE);
|
||||||
|
hotTypeTextView.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case PAGE_TYPE_COMMUNITY:
|
||||||
|
case PAGE_TYPE_FRONT_PAGE:
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
|
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
|
||||||
if (currentSortType.equals(SortType.Type.ACTIVE.fullName)) {
|
if (currentSortType.equals(SortType.Type.ACTIVE.fullName)) {
|
||||||
bestTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(bestTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
activeTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(activeTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||||
} else if (currentSortType.equals(SortType.Type.HOT.fullName)) {
|
} else if (currentSortType.equals(SortType.Type.HOT.fullName)) {
|
||||||
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
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.NEW.fullName)) {
|
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
|
||||||
@ -91,6 +109,11 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeTypeTextView.setOnClickListener(view -> {
|
||||||
|
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
hotTypeTextView.setOnClickListener(view -> {
|
hotTypeTextView.setOnClickListener(view -> {
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT));
|
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT));
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -37,8 +37,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
|
|||||||
TextView hotTypeTextView;
|
TextView hotTypeTextView;
|
||||||
@BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
|
||||||
TextView topTypeTextView;
|
TextView topTypeTextView;
|
||||||
@BindView(R.id.controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
|
|
||||||
TextView controversialTypeTextView;
|
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
|
|
||||||
public UserThingSortTypeBottomSheetFragment() {
|
public UserThingSortTypeBottomSheetFragment() {
|
||||||
@ -95,12 +93,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
/* controversialTypeTextView.setOnClickListener(view -> {
|
|
||||||
if (activity != null) {
|
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name());
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
});*/
|
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
||||||
|
@ -438,7 +438,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
postType = getArguments().getInt(EXTRA_POST_TYPE);
|
postType = getArguments().getInt(EXTRA_POST_TYPE);
|
||||||
|
|
||||||
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true) && postType != PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE);
|
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
|
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
|
||||||
|
|
||||||
accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
@ -600,7 +600,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
|
|
||||||
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||||
SortType.Type.HOT.name());
|
SortType.Type.NEW.name());
|
||||||
if (sort.equals(SortType.Type.TOP.name())) {
|
if (sort.equals(SortType.Type.TOP.name())) {
|
||||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||||
SortType.Time.ALL.name());
|
SortType.Time.ALL.name());
|
||||||
@ -731,7 +731,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
nameOfUsage = PostFilterUsage.NO_USAGE;
|
nameOfUsage = PostFilterUsage.NO_USAGE;
|
||||||
subredditName = getArguments().getString(EXTRA_NAME);
|
subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
|
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.HOT.name());
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.NEW.name());
|
||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
if (sort.equals(SortType.Type.TOP.name())) {
|
if (sort.equals(SortType.Type.TOP.name())) {
|
||||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
|
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
|
||||||
|
@ -4,7 +4,6 @@ import android.os.Handler;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -73,12 +72,12 @@ public class CreateMultiReddit {
|
|||||||
}
|
}
|
||||||
redditDataRoomDatabase.multiRedditDao().insert(new MultiReddit(multipath, name, name, description,
|
redditDataRoomDatabase.multiRedditDao().insert(new MultiReddit(multipath, name, name, description,
|
||||||
null, null, "private", accountName, 0, System.currentTimeMillis(), true, false, false));
|
null, null, "private", accountName, 0, System.currentTimeMillis(), true, false, false));
|
||||||
List<AnonymousMultiredditSubreddit> anonymousMultiredditSubreddits = new ArrayList<>();
|
/*List<AnonymousMultiredditSubreddit> anonymousMultiredditSubreddits = new ArrayList<>();
|
||||||
for (SubredditWithSelection s : subreddits) {
|
for (SubredditWithSelection s : subreddits) {
|
||||||
anonymousMultiredditSubreddits.add(new AnonymousMultiredditSubreddit(multipath, s.getQualifiedName()));
|
anonymousMultiredditSubreddits.add(new AnonymousMultiredditSubreddit(multipath, s.getQualifiedName()));
|
||||||
}
|
}
|
||||||
redditDataRoomDatabase.anonymousMultiredditSubredditDao().insertAll(anonymousMultiredditSubreddits);
|
redditDataRoomDatabase.anonymousMultiredditSubredditDao().insertAll(anonymousMultiredditSubreddits);
|
||||||
|
*/
|
||||||
handler.post(createMultiRedditListener::success);
|
handler.post(createMultiRedditListener::success);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,14 @@ public class EditMultiReddit {
|
|||||||
|
|
||||||
public static void anonymousEditMultiReddit(Executor executor, Handler handler,
|
public static void anonymousEditMultiReddit(Executor executor, Handler handler,
|
||||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
MultiReddit multiReddit,
|
MultiReddit multiReddit, String oldPath,
|
||||||
EditMultiRedditListener editMultiRedditListener) {
|
EditMultiRedditListener editMultiRedditListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
ArrayList<AnonymousMultiredditSubreddit> anonymousMultiredditSubreddits = new ArrayList<>();
|
ArrayList<AnonymousMultiredditSubreddit> anonymousMultiredditSubreddits = new ArrayList<>();
|
||||||
ArrayList<SubredditWithSelection> subreddits = multiReddit.getSubreddits();
|
ArrayList<SubredditWithSelection> subreddits = multiReddit.getSubreddits();
|
||||||
|
redditDataRoomDatabase.multiRedditDao().anonymousDeleteMultiReddit(oldPath);
|
||||||
redditDataRoomDatabase.multiRedditDao().insert(multiReddit);
|
redditDataRoomDatabase.multiRedditDao().insert(multiReddit);
|
||||||
for (SubredditWithSelection s : subreddits) {
|
|
||||||
anonymousMultiredditSubreddits.add(new AnonymousMultiredditSubreddit(multiReddit.getPath(), s.getQualifiedName()));
|
|
||||||
}
|
|
||||||
redditDataRoomDatabase.anonymousMultiredditSubredditDao().insertAll(anonymousMultiredditSubreddits);
|
|
||||||
handler.post(editMultiRedditListener::success);
|
handler.post(editMultiRedditListener::success);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import androidx.paging.PagingDataTransforms;
|
|||||||
import androidx.paging.PagingLiveData;
|
import androidx.paging.PagingLiveData;
|
||||||
import androidx.paging.PagingSource;
|
import androidx.paging.PagingSource;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -249,8 +250,9 @@ public class PostViewModel extends ViewModel {
|
|||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_MULTI_REDDIT:
|
case PostPagingSource.TYPE_MULTI_REDDIT:
|
||||||
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
||||||
paging3PagingSource = new MulticommunityPagingSource(retrofit.getRetrofit().create(LemmyAPI.class), List.of(name.split(Pattern.quote(","))), accessToken,
|
String[] communities = (name != null) ? name.split(Pattern.quote(",")) : new String[0];
|
||||||
sortType, executor, postFilter, readPostList, postEnricher);
|
paging3PagingSource = new MulticommunityPagingSource(retrofit.getRetrofit().create(LemmyAPI.class), List.of(communities), accessToken,
|
||||||
|
sortType, executor, postFilter, (readPostList != null) ? readPostList : new ArrayList<>(), postEnricher);
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_SEARCH:
|
case PostPagingSource.TYPE_SEARCH:
|
||||||
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
|
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
|
||||||
@ -387,12 +389,12 @@ public class PostViewModel extends ViewModel {
|
|||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.sharedPreferences = sharedPreferences;
|
this.sharedPreferences = sharedPreferences;
|
||||||
// TODO is this used? because it is getting overwritten with opt
|
|
||||||
this.name = concatenatedSubredditNames;
|
this.name = concatenatedSubredditNames;
|
||||||
this.postType = postType;
|
this.postType = postType;
|
||||||
this.sortType = sortType;
|
this.sortType = sortType;
|
||||||
this.postFilter = postFilter;
|
this.postFilter = postFilter;
|
||||||
this.name = opt;
|
|
||||||
this.postEnricher = postEnricher;
|
this.postEnricher = postEnricher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class SubredditWithSelection implements Parcelable {
|
|||||||
if (!(obj instanceof SubredditWithSelection)) {
|
if (!(obj instanceof SubredditWithSelection)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return this.getName().compareToIgnoreCase(((SubredditWithSelection) obj).getName()) == 0;
|
return this.getQualifiedName().compareToIgnoreCase(((SubredditWithSelection) obj).getQualifiedName()) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import java.util.concurrent.Executor
|
|||||||
class MulticommunityPagingSource(
|
class MulticommunityPagingSource(
|
||||||
private val api: LemmyAPI,
|
private val api: LemmyAPI,
|
||||||
private val communities: List<String>,
|
private val communities: List<String>,
|
||||||
private val accessToken: String,
|
private val accessToken: String?,
|
||||||
private val sortType: SortType,
|
private val sortType: SortType,
|
||||||
private val executor: Executor,
|
private val executor: Executor,
|
||||||
private val postFilter: PostFilter,
|
private val postFilter: PostFilter,
|
||||||
@ -41,12 +41,14 @@ class MulticommunityPagingSource(
|
|||||||
val wasCached = mutableMapOf<String, Boolean>()
|
val wasCached = mutableMapOf<String, Boolean>()
|
||||||
// Loop through each community and fetch posts
|
// Loop through each community and fetch posts
|
||||||
for ((community, pageNumber) in currentPageMap) {
|
for ((community, pageNumber) in currentPageMap) {
|
||||||
|
if (community == "all") continue // Skip all
|
||||||
if (undisplayedPosts.containsKey(community) && undisplayedPosts[community]!!.size > 10) {
|
if (undisplayedPosts.containsKey(community) && undisplayedPosts[community]!!.size > 10) {
|
||||||
val posts: List<Post> = undisplayedPosts[community] ?: listOf()
|
val posts: List<Post> = undisplayedPosts[community] ?: listOf()
|
||||||
combinedPosts.addAll(posts)
|
combinedPosts.addAll(posts)
|
||||||
undisplayedPosts[community]!!.clear() // Clear used posts
|
undisplayedPosts[community]!!.clear() // Clear used posts
|
||||||
wasCached[community] = true
|
wasCached[community] = true
|
||||||
|
// Add a dummy future to the list
|
||||||
|
futuresList.add(Futures.immediateFuture(LoadResult.Page(posts, null, null)))
|
||||||
} else {
|
} else {
|
||||||
val future = fetchPostsFromCommunity(api, pageNumber, community)
|
val future = fetchPostsFromCommunity(api, pageNumber, community)
|
||||||
futuresList.add(future)
|
futuresList.add(future)
|
||||||
@ -71,6 +73,7 @@ class MulticommunityPagingSource(
|
|||||||
// Handle other cases like LoadResult.Error
|
// Handle other cases like LoadResult.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val sorted = when (sortType.type) {
|
val sorted = when (sortType.type) {
|
||||||
SortType.Type.NEW -> {
|
SortType.Type.NEW -> {
|
||||||
sortByNewest(combinedPosts)
|
sortByNewest(combinedPosts)
|
||||||
@ -97,10 +100,18 @@ class MulticommunityPagingSource(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentPageMap.containsKey("all")) {
|
||||||
|
nextPageMap["all"] = filteredPosts.size + currentPageMap["all"]!!
|
||||||
|
} else {
|
||||||
|
nextPageMap["all"] = filteredPosts.size
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LoadResult.Page(
|
LoadResult.Page(
|
||||||
data = filteredPosts,
|
data = filteredPosts,
|
||||||
prevKey = null, // Define prevKey logic if needed
|
prevKey = null, // Define prevKey logic if needed
|
||||||
nextKey = nextPageMap
|
nextKey = if (filteredPosts.isNotEmpty()) nextPageMap else null
|
||||||
)
|
)
|
||||||
}, executor)
|
}, executor)
|
||||||
val partialLoadResultFuture =
|
val partialLoadResultFuture =
|
||||||
|
@ -85,33 +85,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/visibility_wrapper_linear_layout_edit_multi_reddit_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:padding="16dp"
|
|
||||||
tools:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/visibility_text_view_edit_multi_reddit_activity"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/private_multi_reddit"
|
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/font_default" />
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/visibility_switch_edit_multi_reddit_activity"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:checked="true" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/select_subreddit_text_view_edit_multi_reddit_activity"
|
android:id="@+id/select_subreddit_text_view_edit_multi_reddit_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -63,23 +63,4 @@
|
|||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
app:drawableTint="?attr/primaryTextColor" />
|
app:drawableTint="?attr/primaryTextColor" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
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:background="?attr/selectableItemBackground"
|
|
||||||
android:clickable="true"
|
|
||||||
android:drawableStart="@drawable/ic_controversial_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_controversial"
|
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/font_default"
|
|
||||||
app:drawableTint="?attr/primaryTextColor" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -18,15 +18,36 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginEnd="32dp" />
|
android:layout_marginEnd="32dp" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/name_text_view_item_subscribed_subreddit_multiselection"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_gravity="center_vertical"
|
android:orientation="horizontal">
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:textSize="?attr/font_default"
|
<TextView
|
||||||
android:fontFamily="?attr/font_family" />
|
android:id="@+id/name_text_view_item_subscribed_subreddit_multiselection"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="start"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
|
android:textSize="?attr/font_default" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/instance_text_view_item_subscribed_subreddit_multiselection"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="start"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
|
android:textSize="?attr/font_default" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/checkbox_item_subscribed_subreddit_multiselection"
|
android:id="@+id/checkbox_item_subscribed_subreddit_multiselection"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user