Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Added Lockdown Status Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
FiryDragon1 committed May 26, 2020
1 parent 7f17307 commit 96e9704
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion app/src/main/java/at/tacticaldevc/oat/utils/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Prefs {
private final static String KEY_COMMAND_PASSWORD_SALT = "pwdsalt";
private final static String KEY_COMMAND_TRIGGER = "cmd-trigger";
private final static String KEY_MISSING_PERMISSIONS_TO_REQUEST_ON_STARTUP = "missing-permission";
private final static String KEY_LOCKDOWN_STATUS = "lockdown-status";

// Basic Data

Expand Down Expand Up @@ -137,7 +138,7 @@ public static String saveCommandTriggerWord(Context context, String trigger) {
ensureNotNull(context, "Application Context");
ensureStringIsValid(trigger, "Application trigger");
if (trigger.contains(" "))
throw new IllegalArgumentException("trigger cannot contain ' '!");
throw new IllegalArgumentException("trigger cannot contain a space character!");

SharedPreferences prefs = context.getSharedPreferences(DOCUMENT_NAME_DATA, Context.MODE_PRIVATE);
SharedPreferences.Editor edit = prefs.edit();
Expand All @@ -161,6 +162,38 @@ public static String fetchCommandTriggerWord(Context context) {
return prefs.getString(KEY_COMMAND_TRIGGER, "oat");
}

// App state

/**
* Fetches the status, if the Phone is under lockdown
*
* @param context the Context of the Application
* @return true if the phone is under lockdown, false if the phone is not under lockdown
*/
public static boolean getLockdownStatus(Context context) {
ensureNotNull(context, "Application Context");

SharedPreferences prefs = context.getSharedPreferences(DOCUMENT_NAME_DATA, Context.MODE_PRIVATE);
return prefs.getBoolean(KEY_LOCKDOWN_STATUS, false);
}

/**
* Saves the Loockdown status of the phone (if lockdown is enabled)
*
* @param context the Application Context
* @param lockdownStatus true if lockdown was enabled, false if it was disabled
*/
public static void setLockdownStatus(Context context, boolean lockdownStatus) {
ensureNotNull(context, "Application Context");

SharedPreferences prefs = context.getSharedPreferences(DOCUMENT_NAME_DATA, Context.MODE_PRIVATE);
SharedPreferences.Editor edit = prefs.edit();

edit.putBoolean(KEY_LOCKDOWN_STATUS, lockdownStatus);

edit.apply();
}

// Trusted Contacts

/**
Expand Down

0 comments on commit 96e9704

Please sign in to comment.