mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Finish adding SuicidePreventionActivity.
This commit is contained in:
parent
31f4739a17
commit
7ceb83d408
@ -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,8 +252,14 @@ 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 {
|
||||
openSearchResult(query);
|
||||
}
|
||||
}
|
||||
|
||||
private void openSearchResult(String query) {
|
||||
if (searchOnlySubreddits) {
|
||||
Intent intent = new Intent(SearchActivity.this, SearchSubredditsResultActivity.class);
|
||||
intent.putExtra(SearchSubredditsResultActivity.EXTRA_QUERY, query);
|
||||
@ -277,7 +284,6 @@ public class SearchActivity extends BaseActivity {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user