Compare commits

..

No commits in common. "ecdd9da9c84ba1d3430016faedb1fa5d055f232a" and "28617cf9a820a41982f8974241b1ddf4c2181493" have entirely different histories.

10 changed files with 84 additions and 155 deletions

View File

@ -69,15 +69,15 @@ public class SortType {
}
public enum Time {
HOUR("hour", "Hour"),
SIX_HOURS("SixHour", "Six Hours"),
TWELVE_HOURS("TwelveHour", "Twelve Hours"),
HOUR("TopHour", "Top Hour"),
SIX_HOURS("TopSixHour", "Top Six Hours"),
TWELVE_HOURS("TopTwelveHour", "Top Twelve Hours"),
DAY("day", "Day"),
WEEK("week", "Week"),
MONTH("month", "Month"),
THREE_MONTHS("ThreeMonths", "Three Months"),
SIX_MONTHS("SixMonths", "Six Months"),
NINE_MONTHS("NineMonths", "Nine Months"),
THREE_MONTHS("TopThreeMonth", "Top Three Months"),
SIX_MONTHS("TopSixMonth", "Top Six Months"),
NINE_MONTHS("TopNineMonth", "Top Nine Months"),
YEAR("year", "Year"),
ALL("all", "All Time");
@ -88,14 +88,5 @@ 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;
}
}
}

View File

@ -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, mAccountQualifiedName);
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
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, mAccountQualifiedName);
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountName);
bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);

View File

@ -106,9 +106,6 @@ 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();

View File

@ -8,6 +8,7 @@ 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;
@ -179,7 +180,6 @@ 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() {
@ -189,23 +189,13 @@ public class LoginActivity extends BaseActivity {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
boolean canDownvote = siteInfo.isEnable_downvotes();
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name, display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance, canDownvote, mRedditDataRoomDatabase.accountDao(),
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,canDownvote, mRedditDataRoomDatabase.accountDao(),
() -> {
Intent resultIntent = new Intent();
setResult(Activity.RESULT_OK, resultIntent);
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

View File

@ -336,14 +336,11 @@ 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);
String instance = (mAccessToken == null) ? mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI) : mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
if (instance != null) {
if(instance != null) {
mRetrofit.setBaseURL(instance);
}
@ -1514,12 +1511,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
return true;
}
@ -1577,11 +1569,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@ -1602,11 +1590,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
return true;
}
@ -1619,11 +1603,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
-> {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@ -1518,11 +1518,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
return true;
}
@ -1580,11 +1576,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@ -1605,11 +1597,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
return true;
}
@ -1622,11 +1610,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
-> {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@ -1514,11 +1514,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
return true;
}
@ -1576,11 +1572,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@ -1601,11 +1593,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
String userName = thingEditText.getText().toString();
if (userName.startsWith("@")) {
userName = userName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, userName);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
return true;
}
@ -1618,11 +1606,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
-> {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
String userName = thingEditText.getText().toString();
if (userName.startsWith("@")) {
userName = userName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userName);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@ -158,7 +158,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
mFavoriteSubscribedSubredditData.size() + 3 : 1;
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 2 : 0;
mFavoriteSubscribedSubredditData.size() + 2 : 1;
}
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
@ -301,7 +301,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
}
if (itemClickListener != null) {
return (hasClearSelectionRow) ? mSubscribedSubredditData.size() + 1 : mSubscribedSubredditData.size();
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 1 : 0;
}
return mSubscribedSubredditData.size();

View File

@ -536,12 +536,17 @@ 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,
@ -605,12 +610,16 @@ 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,
@ -668,14 +677,17 @@ 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()));
String sortTime = null;
SortType.Type st = SortType.Type.fromValue(sort);
st = st == null ? SortType.Type.NEW : st;
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
String 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,
@ -732,11 +744,14 @@ 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());
String sortTime = null;
SortType.Type st = SortType.Type.fromValue(sort);
st = st == null ? SortType.Type.NEW : st;
if (sort.equals(SortType.Type.TOP.name())) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.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);
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
@ -791,11 +806,14 @@ 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());
String sortTime = null;
SortType.Type st = SortType.Type.fromValue(sort);
st = st == null ? SortType.Type.NEW : st;
if (sort.equals(SortType.Type.TOP.name())) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.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);
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout);
@ -848,11 +866,14 @@ 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());
String sortTime = null;
SortType.Type st = SortType.Type.fromValue(sort);
st = st == null ? SortType.Type.NEW : st;
if (sort.equals(SortType.Type.TOP.name())) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.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);
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
@ -1368,25 +1389,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().value).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().name()).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().value).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).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().value).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).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().value).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
}else {
@ -1396,14 +1417,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().value).apply();
sortType.getType().name()).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().value).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().name()).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", sortType.getTime().name()).apply();
}
@ -2242,24 +2263,6 @@ 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;

View File

@ -543,17 +543,17 @@
</string-array>
<string-array name="settings_default_sort_time_values">
<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>
<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>
</string-array>
<string-array name="settings_default_search_result_tab">