Fix a minor string issue.

This commit is contained in:
Alex Ning 2021-01-05 23:22:52 +08:00
parent 68b1c6a7f4
commit 29b6c66ae2
2 changed files with 66 additions and 84 deletions

View File

@ -676,89 +676,71 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override @Override
public void onMenuClick(int stringId) { public void onMenuClick(int stringId) {
Intent intent = null; Intent intent = null;
switch (stringId) { if (stringId == R.string.profile) {
case R.string.profile: intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName); } else if (stringId == R.string.subscriptions) {
break; intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
case R.string.subscriptions: } else if (stringId == R.string.multi_reddit) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
break; intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
case R.string.multi_reddit: } else if (stringId == R.string.inbox) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); intent = new Intent(MainActivity.this, InboxActivity.class);
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true); } else if (stringId == R.string.upvoted) {
break; intent = new Intent(MainActivity.this, AccountPostsActivity.class);
case R.string.inbox: intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_UPVOTED);
intent = new Intent(MainActivity.this, InboxActivity.class); } else if (stringId == R.string.downvoted) {
break; intent = new Intent(MainActivity.this, AccountPostsActivity.class);
case R.string.upvoted: intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_DOWNVOTED);
intent = new Intent(MainActivity.this, AccountPostsActivity.class); } else if (stringId == R.string.hidden) {
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_UPVOTED); intent = new Intent(MainActivity.this, AccountPostsActivity.class);
break; intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_HIDDEN);
case R.string.downvoted: } else if (stringId == R.string.account_saved_thing_activity_label) {
intent = new Intent(MainActivity.this, AccountPostsActivity.class); intent = new Intent(MainActivity.this, AccountSavedThingActivity.class);
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_DOWNVOTED); } else if (stringId == R.string.gilded) {
break; intent = new Intent(MainActivity.this, AccountPostsActivity.class);
case R.string.hidden: intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_GILDED);
intent = new Intent(MainActivity.this, AccountPostsActivity.class); } else if (stringId == R.string.light_theme) {
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_HIDDEN); mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "0").apply();
break; AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
case R.string.saved: mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT);
intent = new Intent(MainActivity.this, AccountSavedThingActivity.class); } else if (stringId == R.string.dark_theme) {
break; mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "1").apply();
case R.string.gilded: AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
intent = new Intent(MainActivity.this, AccountPostsActivity.class); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_GILDED); mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED);
break; } else {
case R.string.light_theme: mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK);
mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "0").apply(); }
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO); } else if (stringId == R.string.enable_nsfw) {
mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT); if (sectionsPagerAdapter != null) {
break; mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
case R.string.dark_theme: sectionsPagerAdapter.changeNSFW(true);
mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "1").apply(); }
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES); } else if (stringId == R.string.disable_nsfw) {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) { if (sectionsPagerAdapter != null) {
mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED); mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
} else { sectionsPagerAdapter.changeNSFW(false);
mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); }
} } else if (stringId == R.string.settings) {
break; intent = new Intent(MainActivity.this, SettingsActivity.class);
case R.string.enable_nsfw: } else if (stringId == R.string.add_account) {
if (sectionsPagerAdapter != null) { Intent addAccountIntent = new Intent(MainActivity.this, LoginActivity.class);
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply(); startActivityForResult(addAccountIntent, LOGIN_ACTIVITY_REQUEST_CODE);
sectionsPagerAdapter.changeNSFW(true); } else if (stringId == R.string.anonymous_account) {
} new SwitchToAnonymousAccountAsyncTask(mRedditDataRoomDatabase, false,
break; () -> {
case R.string.disable_nsfw: Intent anonymousIntent = new Intent(MainActivity.this, MainActivity.class);
if (sectionsPagerAdapter != null) { startActivity(anonymousIntent);
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply(); finish();
sectionsPagerAdapter.changeNSFW(false); }).execute();
} } else if (stringId == R.string.log_out) {
break; new SwitchToAnonymousAccountAsyncTask(mRedditDataRoomDatabase, true,
case R.string.settings: () -> {
intent = new Intent(MainActivity.this, SettingsActivity.class); Intent logOutIntent = new Intent(MainActivity.this, MainActivity.class);
break; startActivity(logOutIntent);
case R.string.add_account: finish();
Intent addAccountIntent = new Intent(MainActivity.this, LoginActivity.class); }).execute();
startActivityForResult(addAccountIntent, LOGIN_ACTIVITY_REQUEST_CODE);
break;
case R.string.anonymous_account:
new SwitchToAnonymousAccountAsyncTask(mRedditDataRoomDatabase, false,
() -> {
Intent anonymousIntent = new Intent(MainActivity.this, MainActivity.class);
startActivity(anonymousIntent);
finish();
}).execute();
break;
case R.string.log_out:
new SwitchToAnonymousAccountAsyncTask(mRedditDataRoomDatabase, true,
() -> {
Intent logOutIntent = new Intent(MainActivity.this, MainActivity.class);
startActivity(logOutIntent);
finish();
}).execute();
} }
if (intent != null) { if (intent != null) {
startActivity(intent); startActivity(intent);

View File

@ -293,7 +293,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
drawableId = R.drawable.ic_outline_lock_24dp; drawableId = R.drawable.ic_outline_lock_24dp;
break; break;
case 10: case 10:
stringId = R.string.saved; stringId = R.string.account_saved_thing_activity_label;
drawableId = R.drawable.ic_outline_bookmarks_24dp; drawableId = R.drawable.ic_outline_bookmarks_24dp;
break; break;
case 11: case 11: