Skip to content
This repository was archived by the owner on Jan 25, 2018. It is now read-only.

Commit 2c4a5ba

Browse files
committed
Merge pull request #731 from eighthave/master
add panic response
2 parents 4792376 + 13c37e7 commit 2c4a5ba

File tree

6 files changed

+86
-4
lines changed

6 files changed

+86
-4
lines changed

AndroidManifest.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@
185185
<activity
186186
android:name=".ui.AboutActivity"
187187
android:exported="false" />
188+
<activity
189+
android:name=".app.PanicResponderActivity"
190+
android:noHistory="true"
191+
android:theme="@android:style/Theme.NoDisplay">
192+
<intent-filter>
193+
<action android:name="info.guardianproject.panic.action.TRIGGER" />
194+
<category android:name="android.intent.category.DEFAULT" />
195+
</intent-filter>
196+
</activity>
197+
<activity
198+
android:name=".app.ExitActivity"
199+
android:theme="@android:style/Theme.NoDisplay" />
188200

189201
<service
190202
android:name=".plugin.xmpp.XmppImPlugin"

res/xml/preferences.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<PreferenceCategory android:title="@string/pref_group_security_title">
2525

26-
<ListPreference android:title="Chat Encryption"
26+
<ListPreference android:title="@string/chat_encryption_title"
2727
android:key="pref_security_otr_mode"
2828
android:entryValues="@array/otr_options_values"
2929
android:entries="@array/otr_options"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
package info.guardianproject.otr.app.im.app;
3+
4+
import android.annotation.SuppressLint;
5+
import android.app.Activity;
6+
import android.content.Intent;
7+
import android.os.Build;
8+
import android.os.Bundle;
9+
10+
public class ExitActivity extends Activity {
11+
12+
@SuppressLint("NewApi")
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
17+
if (Build.VERSION.SDK_INT >= 21) {
18+
finishAndRemoveTask();
19+
} else {
20+
finish();
21+
}
22+
23+
System.exit(0);
24+
}
25+
26+
public static void exitAndRemoveFromRecentApps(Activity activity) {
27+
Intent intent = new Intent(activity, ExitActivity.class);
28+
29+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
30+
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
31+
| Intent.FLAG_ACTIVITY_CLEAR_TASK
32+
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
33+
34+
activity.startActivity(intent);
35+
}
36+
}

src/info/guardianproject/otr/app/im/app/NewChatActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ public boolean onMenuItemClick(MenuItem item) {
982982

983983
case R.id.menu_exit:
984984
WelcomeActivity.shutdownAndLock(NewChatActivity.this);
985+
ExitActivity.exitAndRemoveFromRecentApps(NewChatActivity.this);
985986
return true;
986987

987988
case R.id.menu_add_contact:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
package info.guardianproject.otr.app.im.app;
3+
4+
import android.annotation.SuppressLint;
5+
import android.app.Activity;
6+
import android.content.Intent;
7+
import android.os.Build;
8+
import android.os.Bundle;
9+
10+
public class PanicResponderActivity extends Activity {
11+
12+
public static final String PANIC_TRIGGER_ACTION = "info.guardianproject.panic.action.TRIGGER";
13+
14+
@SuppressLint("NewApi")
15+
@Override
16+
protected void onCreate(Bundle savedInstanceState) {
17+
super.onCreate(savedInstanceState);
18+
19+
Intent intent = getIntent();
20+
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
21+
WelcomeActivity.shutdownAndLock(this);
22+
ExitActivity.exitAndRemoveFromRecentApps(this);
23+
}
24+
25+
if (Build.VERSION.SDK_INT >= 21) {
26+
finishAndRemoveTask();
27+
} else {
28+
finish();
29+
}
30+
}
31+
}

src/info/guardianproject/otr/app/im/app/WelcomeActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class WelcomeActivity extends ThemeableActivity implements ICacheWordSubs
6161

6262
private boolean mDoSignIn = true;
6363

64+
private ProgressDialog dialog;
65+
6466
static final String[] PROVIDER_PROJECTION = { Imps.Provider._ID, Imps.Provider.NAME,
6567
Imps.Provider.FULLNAME, Imps.Provider.CATEGORY,
6668
Imps.Provider.ACTIVE_ACCOUNT_ID,
@@ -218,6 +220,9 @@ protected void onDestroy() {
218220

219221
if (mCacheWord != null)
220222
mCacheWord.disconnect();
223+
224+
if (dialog != null)
225+
dialog.dismiss();
221226
}
222227

223228
@Override
@@ -445,9 +450,6 @@ private void completeShutdown ()
445450
}
446451
new AsyncTask<String, Void, String>() {
447452

448-
private ProgressDialog dialog;
449-
450-
451453
@Override
452454
protected void onPreExecute() {
453455
if (mApp.getActiveConnections().size() > 0)

0 commit comments

Comments
 (0)