-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathPrivacyScreenPlugin.java
More file actions
55 lines (48 loc) · 1.67 KB
/
PrivacyScreenPlugin.java
File metadata and controls
55 lines (48 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* PrivacyScreenPlugin.java Cordova Plugin Implementation
* Created by Tommy-Carlos Williams on 18/07/14.
* Copyright (c) 2014 Tommy-Carlos Williams. All rights reserved.
* MIT Licensed
*/
package org.devgeeks.privacyscreen;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaWebView;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.os.Bundle;
/**
* This class sets the FLAG_SECURE flag on the window to make the app
* private when shown in the task switcher
*/
public class PrivacyScreenPlugin extends CordovaPlugin {
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Activity activity = this.cordova.getActivity();
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
//Not used in Android
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if ("setTimer".equals(action)) {
callbackContext.success();
return true;
}
else if ("hidePrivacyScreen".equals(action)) {
callbackContext.success();
return true;
}
else if ("showPrivacyScreen".equals(action)) {
callbackContext.success();
return true;
}
return false; // Returning false results in a "MethodNotFound" error.
}
}