-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathAppLockManager.java
More file actions
49 lines (40 loc) · 1.49 KB
/
AppLockManager.java
File metadata and controls
49 lines (40 loc) · 1.49 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
package org.wordpress.passcodelock;
import android.app.Application;
public class AppLockManager {
private static AppLockManager instance;
private AbstractAppLock currentAppLocker;
public static AppLockManager getInstance() {
if (instance == null) {
instance = new AppLockManager();
}
return instance;
}
public void enableDefaultAppLockIfAvailable(Application currentApp) {
if (!DefaultAppLock.isSupportedApi()) return;
currentAppLocker = new DefaultAppLock(currentApp);
currentAppLocker.enable();
}
public boolean isDefaultLock() {
return getAppLock() != null && getAppLock() instanceof DefaultAppLock;
}
/**
* @return true when an App lock is available. It could be either a the Default App lock on
* Android-v14 or higher, or a non default App lock
*/
public boolean isAppLockFeatureEnabled() {
return getAppLock() != null && (!isDefaultLock() || DefaultAppLock.isSupportedApi());
}
public void setCurrentAppLock(AbstractAppLock newAppLocker) {
if( currentAppLocker != null ) {
currentAppLocker.disable(); //disable the old applocker if available
}
currentAppLocker = newAppLocker;
}
public AbstractAppLock getAppLock() {
return currentAppLocker;
}
public void setExtendedTimeout(){
if (getAppLock() == null) return;
getAppLock().setOneTimeTimeout(AbstractAppLock.EXTENDED_TIMEOUT_S);
}
}