aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java52
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java6
-rw-r--r--app/src/main/res/values/strings.xml2
3 files changed, 37 insertions, 23 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
index 34351fc9..cd6c2c5c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -58,6 +58,7 @@ public class SearchActivity extends BaseActivity {
static final String EXTRA_RETURN_USER_NAME = "ERUN";
static final String EXTRA_RETURN_USER_ICON_URL = "ERUIU";
static final String EXTRA_IS_MULTI_SELECTION = "EIMS";
+ static final int SUICIDE_PREVENTION_ACTIVITY_REQUEST_CODE = 101;
private static final String SUBREDDIT_NAME_STATE = "SNS";
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
@@ -251,31 +252,36 @@ public class SearchActivity extends BaseActivity {
private void search(String query) {
if (query.equalsIgnoreCase("suicide") && mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_SUICIDE_PREVENTION_ACTIVITY, true)) {
Intent intent = new Intent(this, SuicidePreventionActivity.class);
- startActivity(intent);
+ intent.putExtra(SuicidePreventionActivity.EXTRA_QUERY, query);
+ startActivityForResult(intent, SUICIDE_PREVENTION_ACTIVITY_REQUEST_CODE);
} else {
- if (searchOnlySubreddits) {
- Intent intent = new Intent(SearchActivity.this, SearchSubredditsResultActivity.class);
- intent.putExtra(SearchSubredditsResultActivity.EXTRA_QUERY, query);
- intent.putExtra(SearchSubredditsResultActivity.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
- startActivityForResult(intent, SUBREDDIT_SEARCH_REQUEST_CODE);
- } else if (searchOnlyUsers) {
- Intent intent = new Intent(this, SearchUsersResultActivity.class);
- intent.putExtra(SearchUsersResultActivity.EXTRA_QUERY, query);
- intent.putExtra(SearchUsersResultActivity.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
- startActivityForResult(intent, USER_SEARCH_REQUEST_CODE);
- } else {
- Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
- intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);
- if (subredditName != null) {
- if (subredditIsUser) {
- intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
- } else {
- intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, subredditName);
- }
+ openSearchResult(query);
+ }
+ }
+
+ private void openSearchResult(String query) {
+ if (searchOnlySubreddits) {
+ Intent intent = new Intent(SearchActivity.this, SearchSubredditsResultActivity.class);
+ intent.putExtra(SearchSubredditsResultActivity.EXTRA_QUERY, query);
+ intent.putExtra(SearchSubredditsResultActivity.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
+ startActivityForResult(intent, SUBREDDIT_SEARCH_REQUEST_CODE);
+ } else if (searchOnlyUsers) {
+ Intent intent = new Intent(this, SearchUsersResultActivity.class);
+ intent.putExtra(SearchUsersResultActivity.EXTRA_QUERY, query);
+ intent.putExtra(SearchUsersResultActivity.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
+ startActivityForResult(intent, USER_SEARCH_REQUEST_CODE);
+ } else {
+ Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
+ intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);
+ if (subredditName != null) {
+ if (subredditIsUser) {
+ intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
+ } else {
+ intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, subredditName);
}
- startActivity(intent);
- finish();
}
+ startActivity(intent);
+ finish();
}
}
@@ -373,6 +379,8 @@ public class SearchActivity extends BaseActivity {
}
setResult(Activity.RESULT_OK, returnIntent);
finish();
+ } else if (requestCode == SUICIDE_PREVENTION_ACTIVITY_REQUEST_CODE) {
+ openSearchResult(data.getStringExtra(SuicidePreventionActivity.EXTRA_RETURN_QUERY));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java
index 998053b5..08e51b14 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java
@@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.os.Bundle;
@@ -21,6 +22,8 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class SuicidePreventionActivity extends BaseActivity {
+ static final String EXTRA_QUERY = "EQ";
+ static final String EXTRA_RETURN_QUERY = "ERQ";
@BindView(R.id.linear_layout_suicide_prevention_activity)
LinearLayout linearLayout;
@BindView(R.id.quote_text_view_suicide_prevention_activity)
@@ -57,6 +60,9 @@ public class SuicidePreventionActivity extends BaseActivity {
if (doNotShowThisAgainCheckBox.isChecked()) {
mSharedPreferences.edit().putBoolean(SharedPreferencesUtils.SHOW_SUICIDE_PREVENTION_ACTIVITY, false).apply();
}
+ Intent returnIntent = new Intent();
+ returnIntent.putExtra(EXTRA_RETURN_QUERY, getIntent().getStringExtra(EXTRA_QUERY));
+ setResult(RESULT_OK, returnIntent);
finish();
});
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3a694e54..3993d4ad 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1049,7 +1049,7 @@
<string name="restore_settings_failed_cannot_get_file">Cannot access the file</string>
<string name="suicide_prevention_quote">If you are looking for a sign not to kill yourself, this is it.\u2764</string>
- <string name="do_not_show_this_again">Do not show this again</string>
+ <string name="do_not_show_this_again">Don\'t show this again</string>
<string name="continue_suicide_prevention_activity">Continue</string>
</resources>