diff options
author | David van Tonder <david.vantonder@gmail.com> | 2013-07-03 08:09:41 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-07-03 08:09:41 -0700 |
commit | 649eda098b87ba4e1ce8834405c044e78a76a12b (patch) | |
tree | 9fac9ff0559d4ff8b4449540873effb144c778b5 /src/com/android/settings/cyanogenmod | |
parent | deff1bd108333b3c997751a5dfb2f7731d7f6bda (diff) | |
parent | f6b181905d42a0360e612b4655e75253ecfa83bb (diff) | |
download | packages_apps_settings-649eda098b87ba4e1ce8834405c044e78a76a12b.zip packages_apps_settings-649eda098b87ba4e1ce8834405c044e78a76a12b.tar.gz packages_apps_settings-649eda098b87ba4e1ce8834405c044e78a76a12b.tar.bz2 |
Merge "Lockscreen options : Camera/widgets toggle" into cm-10.1
Diffstat (limited to 'src/com/android/settings/cyanogenmod')
-rw-r--r-- | src/com/android/settings/cyanogenmod/LockscreenInterface.java | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/src/com/android/settings/cyanogenmod/LockscreenInterface.java b/src/com/android/settings/cyanogenmod/LockscreenInterface.java index 37d56e8..806a342 100644 --- a/src/com/android/settings/cyanogenmod/LockscreenInterface.java +++ b/src/com/android/settings/cyanogenmod/LockscreenInterface.java @@ -21,8 +21,12 @@ import java.io.IOException; import android.app.Activity; import android.app.AlertDialog; +import android.app.admin.DeviceAdminReceiver; +import android.app.admin.DevicePolicyManager; import android.content.ActivityNotFoundException; +import android.content.ComponentName; import android.content.ContentResolver; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; @@ -34,6 +38,7 @@ import android.os.UserHandle; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; +import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.provider.MediaStore; import android.provider.Settings; @@ -64,13 +69,22 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements private static final String KEY_BACKGROUND = "lockscreen_background"; private static final String KEY_SCREEN_SECURITY = "screen_security"; + private static final String LOCKSCREEN_GENERAL_CATEGORY = "lockscreen_general_category"; + private static final String LOCKSCREEN_WIDGETS_CATEGORY = "lockscreen_widgets_category"; + private static final String KEY_LOCKSCREEN_ENABLE_WIDGETS = "lockscreen_enable_widgets"; + private static final String KEY_LOCKSCREEN_ENABLE_CAMERA = "lockscreen_enable_camera"; + private ListPreference mCustomBackground; private ListPreference mBatteryStatus; private CheckBoxPreference mMaximizeWidgets; private CheckBoxPreference mMusicControls; + private CheckBoxPreference mEnableWidgets; + private CheckBoxPreference mEnableCamera; private File mWallpaperImage; private File mWallpaperTemporary; + private DevicePolicyManager mDPM; + private ComponentName mDpmAdminName; private boolean mIsPrimary; @@ -83,6 +97,8 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.lockscreen_interface_settings); + PreferenceCategory generalCategory = (PreferenceCategory) findPreference(LOCKSCREEN_GENERAL_CATEGORY); + PreferenceCategory widgetsCategory = (PreferenceCategory) findPreference(LOCKSCREEN_WIDGETS_CATEGORY); // Determine which user is logged in mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER; @@ -93,9 +109,9 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements mBatteryStatus.setOnPreferenceChangeListener(this); } - mMaximizeWidgets = (CheckBoxPreference)findPreference(KEY_LOCKSCREEN_MAXIMIZE_WIDGETS); + mMaximizeWidgets = (CheckBoxPreference) findPreference(KEY_LOCKSCREEN_MAXIMIZE_WIDGETS); if (!Utils.isPhone(getActivity())) { - getPreferenceScreen().removePreference(mMaximizeWidgets); + widgetsCategory.removePreference(mMaximizeWidgets); mMaximizeWidgets = null; } else { mMaximizeWidgets.setOnPreferenceChangeListener(this); @@ -106,15 +122,14 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements PreferenceScreen lockscreenButtons = (PreferenceScreen) findPreference(KEY_LOCKSCREEN_BUTTONS); if (!hasButtons()) { - getPreferenceScreen().removePreference(lockscreenButtons); + generalCategory.removePreference(lockscreenButtons); } } else { // Secondary user is logged in, remove all primary user specific preferences - PreferenceScreen prefScreen = getPreferenceScreen(); - prefScreen.removePreference(findPreference(KEY_SCREEN_SECURITY)); - prefScreen.removePreference(findPreference(KEY_ALWAYS_BATTERY)); - prefScreen.removePreference(findPreference(KEY_LOCKSCREEN_BUTTONS)); - prefScreen.removePreference(findPreference(KEY_LOCKSCREEN_MAXIMIZE_WIDGETS)); + generalCategory.removePreference(findPreference(KEY_SCREEN_SECURITY)); + widgetsCategory.removePreference(findPreference(KEY_LOCKSCREEN_MAXIMIZE_WIDGETS)); + generalCategory.removePreference(findPreference(KEY_ALWAYS_BATTERY)); + generalCategory.removePreference(findPreference(KEY_LOCKSCREEN_BUTTONS)); } // This applies to all users @@ -122,11 +137,23 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements mCustomBackground.setOnPreferenceChangeListener(this); updateCustomBackgroundSummary(); + mEnableWidgets = (CheckBoxPreference) findPreference(KEY_LOCKSCREEN_ENABLE_WIDGETS); + mEnableWidgets.setOnPreferenceChangeListener(this); + mEnableCamera = (CheckBoxPreference) findPreference(KEY_LOCKSCREEN_ENABLE_CAMERA); + mEnableCamera.setOnPreferenceChangeListener(this); + + mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); + mDpmAdminName = new ComponentName(getActivity(), DeviceAdminLockscreenReceiver.class); + + boolean widgetsEnabled = mDPM.getKeyguardDisabledFeatures(null) == 0; + mEnableWidgets.setChecked(widgetsEnabled); + mEnableCamera.setChecked(!mDPM.getCameraDisabled(null)); + mWallpaperImage = new File(getActivity().getFilesDir() + "/lockwallpaper"); mWallpaperTemporary = new File(getActivity().getCacheDir() + "/lockwallpaper.tmp"); // Don't display the lock clock preference if its not installed - removePreferenceIfPackageNotInstalled(findPreference(KEY_LOCK_CLOCK)); + removePreferenceIfPackageNotInstalled(findPreference(KEY_LOCK_CLOCK), widgetsCategory); } private void updateCustomBackgroundSummary() { @@ -216,7 +243,20 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements } else if (preference == mCustomBackground) { int selection = mCustomBackground.findIndexOfValue(objValue.toString()); return handleBackgroundSelection(selection); + } else if (preference == mEnableCamera) { + boolean value = (Boolean) objValue; + mDPM.setActiveAdmin(mDpmAdminName, true); + mDPM.setCameraDisabled(mDpmAdminName, !value); + return true; + } else if (preference == mEnableWidgets) { + boolean value = (Boolean) objValue; + mDPM.setActiveAdmin(mDpmAdminName, true); + mDPM.setKeyguardDisabledFeatures(mDpmAdminName, value + ? DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE + : DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_ALL); + return true; } + return false; } @@ -295,4 +335,6 @@ public class LockscreenInterface extends SettingsPreferenceFragment implements return false; } + + public static class DeviceAdminLockscreenReceiver extends DeviceAdminReceiver {} } |