aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java140
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java140
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java6
-rw-r--r--app/src/main/res/values/arrays.xml3
4 files changed, 179 insertions, 110 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index c96e5544..90302bea 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -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);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index 7db3a9cc..f53bd244 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -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);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
index 78c1567f..cb659c23 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -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";
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 51f5f3ee..c26ce4f4 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -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">