forked from bpellin/keepassdroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
app/src/main/java/com/keepassdroid/PanicResponderActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |