Skip to content

Commit

Permalink
See pull request [72](bpellin#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
crr0004 committed Oct 1, 2017
1 parent 5d03050 commit 63dd973
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 7 deletions.
27 changes: 20 additions & 7 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/flavor1Debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/flavor1Debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/flavor1Debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/flavor1/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/flavor1/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFlavor1Debug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFlavor1Debug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFlavor1Debug/assets" type="java-test-resource" />
Expand All @@ -68,6 +61,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/testFlavor1Debug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFlavor1Debug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFlavor1Debug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/flavor1/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/flavor1/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/flavor1/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/flavor1/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/flavor1/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/flavor1/assets" type="java-resource" />
Expand Down Expand Up @@ -132,16 +132,29 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/cmake" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/sourceFolderJavaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="com.keepassdroid.PanicResponderActivity"
android:launchMode="singleInstance" android:noHistory="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="info.guardianproject.panic.action.TRIGGER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.keepassdroid.ExitActivity" android:theme="@android:style/Theme.NoDisplay"></activity>
<activity android:name="com.keepassdroid.settings.AppSettingsActivity"
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.GeneratePasswordActivity"
Expand Down
41 changes: 41 additions & 0 deletions app/src/main/java/com/keepassdroid/ExitActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

package com.keepassdroid;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

public class ExitActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (Build.VERSION.SDK_INT >= 21) {
finishAndRemoveTask();
} else {
finish();
}

System.exit(0);
}

public static void exitAndRemoveFromRecentApps(Activity activity) {
Intent intent = new Intent(activity, ExitActivity.class);
int flags = Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;

if(Build.VERSION.SDK_INT >= 5){
flags |= Intent.FLAG_ACTIVITY_NO_ANIMATION;
}
if(Build.VERSION.SDK_INT >= 11){
flags |= Intent.FLAG_ACTIVITY_CLEAR_TASK;
}

intent.addFlags(flags);

activity.startActivity(intent);
}

}
35 changes: 35 additions & 0 deletions app/src/main/java/com/keepassdroid/PanicResponderActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

package com.keepassdroid;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

import com.android.keepass.KeePass;
import com.keepassdroid.app.App;

public class PanicResponderActivity extends Activity {

public static final String PANIC_TRIGGER_ACTION = "info.guardianproject.panic.action.TRIGGER";

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = getIntent();
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
App.setShutdown();
setResult(KeePass.EXIT_LOCK);
ExitActivity.exitAndRemoveFromRecentApps(this);
}

if (Build.VERSION.SDK_INT >= 21) {
finishAndRemoveTask();
} else {
finish();
}
}
}

0 comments on commit 63dd973

Please sign in to comment.