mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 20:37:12 +01:00
Add go to subreddit, go to user, and random to FAB options.
This commit is contained in:
parent
2b6f04a283
commit
b8783c2488
@ -576,6 +576,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SEARCH:
|
||||
fab.setImageResource(R.drawable.ic_search_black_24dp);
|
||||
break;
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT:
|
||||
fab.setImageResource(R.drawable.ic_subreddit_24dp);
|
||||
break;
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_USER:
|
||||
fab.setImageResource(R.drawable.ic_user_24dp);
|
||||
break;
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_RANDOM:
|
||||
fab.setImageResource(R.drawable.ic_random_24dp);
|
||||
break;
|
||||
default:
|
||||
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
|
||||
break;
|
||||
@ -601,6 +610,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT:
|
||||
goToSubreddit();
|
||||
break;
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_USER:
|
||||
goToUser();
|
||||
break;
|
||||
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_RANDOM:
|
||||
randomThing();
|
||||
break;
|
||||
default:
|
||||
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
|
||||
break;
|
||||
@ -1166,72 +1184,84 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
startActivity(intent);
|
||||
break;
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
goToSubreddit();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_USER: {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
|
||||
randomBottomSheetFragment.setArguments(bundle);
|
||||
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
||||
randomThing();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void goToSubreddit() {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void goToUser() {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void randomThing() {
|
||||
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
|
||||
randomBottomSheetFragment.setArguments(bundle);
|
||||
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomOptionSelected(int option) {
|
||||
Intent intent = new Intent(this, FetchRandomSubredditOrPostActivity.class);
|
||||
|
@ -681,6 +681,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH:
|
||||
fab.setImageResource(R.drawable.ic_search_black_24dp);
|
||||
break;
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT:
|
||||
fab.setImageResource(R.drawable.ic_subreddit_24dp);
|
||||
break;
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER:
|
||||
fab.setImageResource(R.drawable.ic_user_24dp);
|
||||
break;
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM:
|
||||
fab.setImageResource(R.drawable.ic_random_24dp);
|
||||
break;
|
||||
default:
|
||||
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
|
||||
break;
|
||||
@ -707,6 +716,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT:
|
||||
goToSubreddit();
|
||||
break;
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER:
|
||||
goToUser();
|
||||
break;
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM:
|
||||
random();
|
||||
break;
|
||||
default:
|
||||
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
|
||||
break;
|
||||
@ -1071,72 +1089,84 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
startActivity(intent);
|
||||
break;
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
goToSubreddit();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_USER: {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
|
||||
randomBottomSheetFragment.setArguments(bundle);
|
||||
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
||||
random();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void goToSubreddit() {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(subredditIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void goToUser() {
|
||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
||||
thingEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.go_to_user)
|
||||
.setView(thingEditText)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
||||
startActivity(userIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void random() {
|
||||
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
|
||||
randomBottomSheetFragment.setArguments(bundle);
|
||||
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomOptionSelected(int option) {
|
||||
Intent intent = new Intent(this, FetchRandomSubredditOrPostActivity.class);
|
||||
|
@ -179,6 +179,9 @@ public class SharedPreferencesUtils {
|
||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE = 2;
|
||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT = 3;
|
||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SEARCH = 4;
|
||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT = 5;
|
||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_USER = 6;
|
||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_RANDOM = 7;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME = 0;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 1;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX = 2;
|
||||
@ -189,6 +192,9 @@ public class SharedPreferencesUtils {
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE = 2;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT = 3;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH = 4;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT = 5;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER = 6;
|
||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM = 7;
|
||||
|
||||
public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler";
|
||||
public static final String NSFW_BASE = "_nsfw";
|
||||
|
@ -257,6 +257,9 @@
|
||||
<item>Change sort type</item>
|
||||
<item>Change post layout</item>
|
||||
<item>Search</item>
|
||||
<item>Go to Subreddit</item>
|
||||
<item>Go to User</item>
|
||||
<item>Random</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_swipe_action_threshold">
|
||||
|
Loading…
Reference in New Issue
Block a user