mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-06 22:54:47 +01:00
Compare commits
6 Commits
28617cf9a8
...
ecdd9da9c8
Author | SHA1 | Date | |
---|---|---|---|
|
ecdd9da9c8 | ||
|
1c17e6b7d2 | ||
|
9f60eca225 | ||
|
9deba8b10e | ||
|
05948d74f4 | ||
|
1007be50f8 |
@ -69,15 +69,15 @@ public class SortType {
|
||||
}
|
||||
|
||||
public enum Time {
|
||||
HOUR("TopHour", "Top Hour"),
|
||||
SIX_HOURS("TopSixHour", "Top Six Hours"),
|
||||
TWELVE_HOURS("TopTwelveHour", "Top Twelve Hours"),
|
||||
HOUR("hour", "Hour"),
|
||||
SIX_HOURS("SixHour", "Six Hours"),
|
||||
TWELVE_HOURS("TwelveHour", "Twelve Hours"),
|
||||
DAY("day", "Day"),
|
||||
WEEK("week", "Week"),
|
||||
MONTH("month", "Month"),
|
||||
THREE_MONTHS("TopThreeMonth", "Top Three Months"),
|
||||
SIX_MONTHS("TopSixMonth", "Top Six Months"),
|
||||
NINE_MONTHS("TopNineMonth", "Top Nine Months"),
|
||||
THREE_MONTHS("ThreeMonths", "Three Months"),
|
||||
SIX_MONTHS("SixMonths", "Six Months"),
|
||||
NINE_MONTHS("NineMonths", "Nine Months"),
|
||||
YEAR("year", "Year"),
|
||||
ALL("all", "All Time");
|
||||
|
||||
@ -88,5 +88,14 @@ public class SortType {
|
||||
this.value = value;
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public static Time fromValue(String value) {
|
||||
for (Time time : values()) {
|
||||
if (time.value.equalsIgnoreCase(value)) {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
PostFragment fragment = new PostFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
|
||||
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
|
||||
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountQualifiedName);
|
||||
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
|
||||
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
@ -293,7 +293,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
}
|
||||
CommentsListingFragment fragment = new CommentsListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountName);
|
||||
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountQualifiedName);
|
||||
bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);
|
||||
|
@ -106,6 +106,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
if (mAccessToken != null) {
|
||||
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
||||
mRetrofit.setBaseURL(instance);
|
||||
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
|
||||
mRetrofit.setAccessToken(mAccessToken);
|
||||
}
|
||||
}
|
||||
|
||||
Uri uri = getIntent().getData();
|
||||
|
@ -8,7 +8,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.InflateException;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Button;
|
||||
@ -180,6 +179,7 @@ public class LoginActivity extends BaseActivity {
|
||||
try {
|
||||
JSONObject responseJSON = new JSONObject(accountResponse);
|
||||
String accessToken = responseJSON.getString("jwt");
|
||||
mRetrofit.setAccessToken(null);
|
||||
|
||||
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
|
||||
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
||||
@ -196,6 +196,16 @@ public class LoginActivity extends BaseActivity {
|
||||
finish();
|
||||
});
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||
String[] version = siteInfo.getVersion().split("\\.");
|
||||
if (version.length > 0) {
|
||||
Log.d("SwitchAccount", "Lemmy Version: " + version[0] + "." + version[1]);
|
||||
int majorVersion = Integer.parseInt(version[0]);
|
||||
int minorVersion = Integer.parseInt(version[1]);
|
||||
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
|
||||
mRetrofit.setAccessToken(accessToken);
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -336,6 +336,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
|
||||
mRetrofit.setAccessToken(mAccessToken);
|
||||
}
|
||||
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
@ -1511,7 +1514,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
|
||||
String communityName = thingEditText.getText().toString();
|
||||
if (communityName.startsWith("!")) {
|
||||
communityName = communityName.substring(1);
|
||||
}
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||
|
||||
startActivity(subredditIntent);
|
||||
return true;
|
||||
}
|
||||
@ -1569,7 +1577,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
|
||||
String communityName = thingEditText.getText().toString();
|
||||
if (communityName.startsWith("!")) {
|
||||
communityName = communityName.substring(1);
|
||||
}
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
@ -1590,7 +1602,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
String qualifiedName = thingEditText.getText().toString();
|
||||
if (qualifiedName.startsWith("@")) {
|
||||
qualifiedName = qualifiedName.substring(1);
|
||||
}
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||
startActivity(userIntent);
|
||||
return true;
|
||||
}
|
||||
@ -1603,7 +1619,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
String qualifiedName = thingEditText.getText().toString();
|
||||
if (qualifiedName.startsWith("@")) {
|
||||
qualifiedName = qualifiedName.substring(1);
|
||||
}
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
|
@ -1518,7 +1518,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
String communityName = thingEditText.getText().toString();
|
||||
if (communityName.startsWith("!")) {
|
||||
communityName = communityName.substring(1);
|
||||
}
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||
startActivity(subredditIntent);
|
||||
return true;
|
||||
}
|
||||
@ -1576,7 +1580,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
String communityName = thingEditText.getText().toString();
|
||||
if (communityName.startsWith("!")) {
|
||||
communityName = communityName.substring(1);
|
||||
}
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
@ -1597,7 +1605,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
String qualifiedName = thingEditText.getText().toString();
|
||||
if (qualifiedName.startsWith("@")) {
|
||||
qualifiedName = qualifiedName.substring(1);
|
||||
}
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||
startActivity(userIntent);
|
||||
return true;
|
||||
}
|
||||
@ -1610,7 +1622,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
String qualifiedName = thingEditText.getText().toString();
|
||||
if (qualifiedName.startsWith("@")) {
|
||||
qualifiedName = qualifiedName.substring(1);
|
||||
}
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
|
@ -1514,7 +1514,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
String communityName = thingEditText.getText().toString();
|
||||
if (communityName.startsWith("!")) {
|
||||
communityName = communityName.substring(1);
|
||||
}
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||
startActivity(subredditIntent);
|
||||
return true;
|
||||
}
|
||||
@ -1572,7 +1576,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
String communityName = thingEditText.getText().toString();
|
||||
if (communityName.startsWith("!")) {
|
||||
communityName = communityName.substring(1);
|
||||
}
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
@ -1593,7 +1601,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
String userName = thingEditText.getText().toString();
|
||||
if (userName.startsWith("@")) {
|
||||
userName = userName.substring(1);
|
||||
}
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, userName);
|
||||
startActivity(userIntent);
|
||||
return true;
|
||||
}
|
||||
@ -1606,7 +1618,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
String userName = thingEditText.getText().toString();
|
||||
if (userName.startsWith("@")) {
|
||||
userName = userName.substring(1);
|
||||
}
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userName);
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
|
@ -158,7 +158,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
mFavoriteSubscribedSubredditData.size() + 3 : 1;
|
||||
} else {
|
||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||
mFavoriteSubscribedSubredditData.size() + 2 : 1;
|
||||
mFavoriteSubscribedSubredditData.size() + 2 : 0;
|
||||
}
|
||||
} else {
|
||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||
@ -301,7 +301,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
}
|
||||
|
||||
if (itemClickListener != null) {
|
||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 1 : 0;
|
||||
return (hasClearSelectionRow) ? mSubscribedSubredditData.size() + 1 : mSubscribedSubredditData.size();
|
||||
}
|
||||
|
||||
return mSubscribedSubredditData.size();
|
||||
|
@ -536,17 +536,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName,
|
||||
mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
|
||||
}
|
||||
|
||||
sortType = newSortType(sort, sortTime);
|
||||
|
||||
boolean displaySubredditName = subredditName != null && (subredditName.equals("local") || subredditName.equals("all"));
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
st = st == null ? SortType.Type.HOT : st;
|
||||
if (sortTime != null) {
|
||||
st = SortType.Type.fromValue(sortTime);
|
||||
st = st == null ? SortType.Type.TOP_ALL : st;
|
||||
sortType = new SortType(st);
|
||||
} else {
|
||||
sortType = new SortType(st);
|
||||
}
|
||||
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
|
||||
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
|
||||
@ -610,16 +605,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
SortType.Time.ALL.name());
|
||||
}
|
||||
|
||||
sortType = newSortType(sort, sortTime);
|
||||
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
defaultPostLayout);
|
||||
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
st = st == null ? SortType.Type.HOT : st;
|
||||
if (sortTime != null) {
|
||||
sortType = new SortType(st, SortType.Time.valueOf(sortTime));
|
||||
} else {
|
||||
sortType = new SortType(st);
|
||||
}
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
|
||||
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
|
||||
@ -677,17 +668,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username,
|
||||
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TYPE, SortType.Type.NEW.name()));
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
st = st == null ? SortType.Type.NEW : st;
|
||||
String sortTime = null;
|
||||
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
|
||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
|
||||
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
|
||||
st = SortType.Type.fromValue(sortTime);
|
||||
st = st == null ? SortType.Type.NEW : st;
|
||||
sortType = new SortType(st);
|
||||
} else {
|
||||
sortType = new SortType(st);
|
||||
}
|
||||
|
||||
sortType = newSortType(sort, sortTime);
|
||||
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
|
||||
@ -744,14 +732,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
subredditName = getArguments().getString(EXTRA_NAME);
|
||||
|
||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.HOT.name());
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
st = st == null ? SortType.Type.NEW : st;
|
||||
String sortTime = null;
|
||||
if (sort.equals(SortType.Type.TOP.name())) {
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
|
||||
sortType = new SortType(st, SortType.Time.valueOf(sortTime));
|
||||
} else {
|
||||
sortType = new SortType(st);
|
||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
|
||||
}
|
||||
sortType = newSortType(sort, sortTime);
|
||||
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||
|
||||
@ -806,14 +791,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
nameOfUsage = multiRedditPath;
|
||||
|
||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Type.HOT.name());
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
st = st == null ? SortType.Type.NEW : st;
|
||||
String sortTime = null;
|
||||
if (sort.equals(SortType.Type.TOP.name())) {
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name());
|
||||
sortType = new SortType(st, SortType.Time.valueOf(sortTime));
|
||||
} else {
|
||||
sortType = new SortType(st);
|
||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name());
|
||||
}
|
||||
sortType = newSortType(sort, sortTime);
|
||||
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout);
|
||||
|
||||
@ -866,14 +848,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
nameOfUsage = PostFilterUsage.NO_USAGE;
|
||||
subredditName = getArguments().getString(EXTRA_NAME);
|
||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.ACTIVE.name());
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
st = st == null ? SortType.Type.NEW : st;
|
||||
String sortTime = null;
|
||||
if (sort.equals(SortType.Type.TOP.name())) {
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
|
||||
sortType = new SortType(st, SortType.Time.valueOf(sortTime));
|
||||
} else {
|
||||
sortType = new SortType(st);
|
||||
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
|
||||
}
|
||||
sortType = newSortType(sort, sortTime);
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||
|
||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
|
||||
@ -1389,25 +1368,25 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
|
||||
switch (postType) {
|
||||
case PostPagingSource.TYPE_FRONT_PAGE:
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().name()).apply();
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().value).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_BEST_POST, sortType.getTime().name()).apply();
|
||||
}
|
||||
break;
|
||||
case PostPagingSource.TYPE_SUBREDDIT:
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().value).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
|
||||
}
|
||||
break;
|
||||
case PostPagingSource.TYPE_USER:
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).apply();
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().value).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, sortType.getTime().name()).apply();
|
||||
}
|
||||
break;
|
||||
case PostPagingSource.TYPE_SEARCH:
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().value).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
|
||||
}else {
|
||||
@ -1417,14 +1396,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
case PostPagingSource.TYPE_MULTI_REDDIT:
|
||||
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
sortType.getType().name()).apply();
|
||||
sortType.getType().value).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
sortType.getTime().name()).apply();
|
||||
}
|
||||
break;
|
||||
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().name()).apply();
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().value).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", sortType.getTime().name()).apply();
|
||||
}
|
||||
@ -2263,6 +2242,24 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SortType newSortType(String sortTypeText, String sortTimeText) {
|
||||
SortType.Type st = SortType.Type.fromValue(sortTypeText);
|
||||
st = st == null ? SortType.Type.NEW : st;
|
||||
SortType result;
|
||||
if (sortTypeText.startsWith("Top")) {
|
||||
sortTimeText = st.value.substring(3);
|
||||
result = new SortType(st, SortType.Time.fromValue(sortTimeText));
|
||||
} else if (sortTimeText != null) {
|
||||
SortType.Time sortTime = SortType.Time.fromValue(sortTimeText);
|
||||
SortType.Type sortType = SortType.Type.fromValue("Top" + sortTimeText);
|
||||
result = new SortType(sortType != null ? sortType : st, sortTime);
|
||||
} else {
|
||||
result = new SortType(st);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static abstract class LazyModeRunnable implements Runnable {
|
||||
private int currentPosition = -1;
|
||||
|
||||
|
@ -543,17 +543,17 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_default_sort_time_values">
|
||||
<item>TopHour</item>
|
||||
<item>TopSixHour</item>
|
||||
<item>TopTwelveHour</item>
|
||||
<item>TopDay</item>
|
||||
<item>TopWeek</item>
|
||||
<item>TopMonth</item>
|
||||
<item>TopThreeMonths</item>
|
||||
<item>TopSixMonths</item>
|
||||
<item>TopNineMonths</item>
|
||||
<item>TopYear</item>
|
||||
<item>TopAll</item>
|
||||
<item>hour</item>
|
||||
<item>SixHour</item>
|
||||
<item>TwelveHour</item>
|
||||
<item>day</item>
|
||||
<item>week</item>
|
||||
<item>month</item>
|
||||
<item>ThreeMonths</item>
|
||||
<item>SixMonths</item>
|
||||
<item>NineMonths</item>
|
||||
<item>year</item>
|
||||
<item>all</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_default_search_result_tab">
|
||||
|
Loading…
x
Reference in New Issue
Block a user