summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml6
-rw-r--r--res/values/cm_strings.xml11
-rw-r--r--res/xml/device_admin_lockscreen.xml6
-rw-r--r--res/xml/lockscreen_interface_settings.xml140
-rw-r--r--src/com/android/settings/SettingsPreferenceFragment.java7
-rw-r--r--src/com/android/settings/cyanogenmod/LockscreenInterface.java60
6 files changed, 160 insertions, 70 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4939009..eeee2a5 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -96,6 +96,12 @@
android:hardwareAccelerated="true"
android:supportsRtl="true">
+ <receiver android:name=".cyanogenmod.LockscreenInterface$DeviceAdminLockscreenReceiver"
+ android:permission="android.permission.BIND_DEVICE_ADMIN">
+ <meta-data android:name="android.app.device_admin"
+ android:resource="@xml/device_admin_lockscreen" />
+ </receiver>
+
<!-- Only system/su can open this activity -->
<!-- This activity will then call the MultitaskSuRequestActivity to create a new task stack -->
<activity
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 6e1f4b8..0aa84be 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -187,8 +187,6 @@
<string name="lockscreen_battery_status_title">Battery status</string>
<string name="lockscreen_battery_status_charging">Only when charging</string>
<string name="lockscreen_battery_status_alwayson">Always on</string>
- <string name="lockscreen_music_controls_title">Music controls</string>
- <string name="lockscreen_music_controls_summary">Show player controls while music is playing</string>
<!-- Profiles settings -->
<string name="profiles_settings_title">Profiles</string>
@@ -795,8 +793,17 @@
<string name="stylus_icon_enabled_title">Show icon when using stylus</string>
<string name="stylus_icon_enabled_summary">Show the pointer icon when hovering or drawing with the stylus</string>
+ <!-- Lock screen widgets -->
+ <string name="lockscreen_widgets_category_title">Widgets</string>
<string name="lockscreen_maximize_widgets_title">Maximize widgets</string>
<string name="lockscreen_maximize_widgets_summary">Show widgets maximized and the unlock minimized when the screen is turned on</string>
+ <string name="lockscreen_other_category_title">Other</string>
+ <string name="lockscreen_enable_widgets_title">Widget pager</string>
+ <string name="lockscreen_enable_widgets_summary">Allow multiple widget pages to be added and selected</string>
+ <string name="lockscreen_enable_camera_title">Camera widget</string>
+ <string name="lockscreen_enable_camera_summary">Show the camera widget to the right of the unlock screen</string>
+ <string name="lockscreen_music_controls_title">Music controls</string>
+ <string name="lockscreen_music_controls_summary">Show player controls while music is playing</string>
<!-- Custom lock screen background -->
<string name="lockscreen_custom_background_title">Background</string>
diff --git a/res/xml/device_admin_lockscreen.xml b/res/xml/device_admin_lockscreen.xml
new file mode 100644
index 0000000..fb665d3
--- /dev/null
+++ b/res/xml/device_admin_lockscreen.xml
@@ -0,0 +1,6 @@
+<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
+ <uses-policies>
+ <disable-keyguard-features/>
+ <disable-camera />
+ </uses-policies>
+</device-admin>
diff --git a/res/xml/lockscreen_interface_settings.xml b/res/xml/lockscreen_interface_settings.xml
index 333824f..6bd1373 100644
--- a/res/xml/lockscreen_interface_settings.xml
+++ b/res/xml/lockscreen_interface_settings.xml
@@ -17,63 +17,87 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/themes_settings_title" >
- <PreferenceScreen
- android:key="screen_security"
- android:fragment="com.android.settings.SecuritySettings"
- android:title="@string/screen_security_category"
- android:summary="@string/screen_security_summary">
- <extra android:name="cm_security" android:value="true" />
- </PreferenceScreen>
-
- <ListPreference
- android:key="lockscreen_background"
- android:persistent="false"
- android:dialogTitle="@string/lockscreen_custom_background_title"
- android:title="@string/lockscreen_custom_background_title"
- android:entries="@array/lockscreen_background_entries"
- android:entryValues="@array/lockscreen_background_values" />
-
- <ListPreference
- android:key="lockscreen_battery_status"
- android:persistent="false"
- android:dialogTitle="@string/lockscreen_battery_status_title"
- android:title="@string/lockscreen_battery_status_title"
- android:entries="@array/lockscreen_battery_status_entries"
- android:entryValues="@array/lockscreen_battery_status_values"
- android:defaultValue="0" />
-
- <!-- Lock clock -->
- <PreferenceScreen
- android:key="lock_clock"
- android:title="@string/lock_clock_title"
- android:summary="@string/lock_clock_summary">
- <intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.cyanogenmod.lockclock"
- android:targetClass="com.cyanogenmod.lockclock.preference.Preferences" />
- </PreferenceScreen>
-
- <CheckBoxPreference
- android:key="lockscreen_maximize_widgets"
- android:persistent="false"
- android:title="@string/lockscreen_maximize_widgets_title"
- android:summary="@string/lockscreen_maximize_widgets_summary" />
-
- <CheckBoxPreference
- android:key="lockscreen_music_controls"
- android:persistent="false"
- android:title="@string/lockscreen_music_controls_title"
- android:summary="@string/lockscreen_music_controls_summary" />
-
- <Preference
- android:fragment="com.android.settings.cyanogenmod.LockscreenTargets"
- android:key="lockscreen_targets"
- android:summary="@string/lockscreen_target_summary"
- android:title="@string/lockscreen_target_title" />
-
- <PreferenceScreen
- android:fragment="com.android.settings.cyanogenmod.LockscreenButtons"
- android:key="lockscreen_buttons"
- android:title="@string/lockscreen_buttons_title"
- android:summary="@string/lockscreen_buttons_summary" />
+ <PreferenceCategory
+ android:title="@string/title_general"
+ android:key="lockscreen_general_category" >
+ <PreferenceScreen
+ android:key="screen_security"
+ android:fragment="com.android.settings.SecuritySettings"
+ android:title="@string/screen_security_category"
+ android:summary="@string/screen_security_summary">
+ <extra android:name="cm_security" android:value="true" />
+ </PreferenceScreen>
+
+ <ListPreference
+ android:key="lockscreen_background"
+ android:persistent="false"
+ android:dialogTitle="@string/lockscreen_custom_background_title"
+ android:title="@string/lockscreen_custom_background_title"
+ android:entries="@array/lockscreen_background_entries"
+ android:entryValues="@array/lockscreen_background_values" />
+
+ <ListPreference
+ android:key="lockscreen_battery_status"
+ android:persistent="false"
+ android:dialogTitle="@string/lockscreen_battery_status_title"
+ android:title="@string/lockscreen_battery_status_title"
+ android:entries="@array/lockscreen_battery_status_entries"
+ android:entryValues="@array/lockscreen_battery_status_values"
+ android:defaultValue="0" />
+
+ <Preference
+ android:fragment="com.android.settings.cyanogenmod.LockscreenTargets"
+ android:key="lockscreen_targets"
+ android:summary="@string/lockscreen_target_summary"
+ android:title="@string/lockscreen_target_title" />
+
+ <PreferenceScreen
+ android:fragment="com.android.settings.cyanogenmod.LockscreenButtons"
+ android:key="lockscreen_buttons"
+ android:title="@string/lockscreen_buttons_title"
+ android:summary="@string/lockscreen_buttons_summary" />
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:title="@string/lockscreen_widgets_category_title"
+ android:key="lockscreen_widgets_category" >
+
+ <PreferenceScreen
+ android:key="lock_clock"
+ android:summary="@string/lock_clock_summary"
+ android:title="@string/lock_clock_title" >
+
+ <intent
+ android:action="android.intent.action.MAIN"
+ android:targetClass="com.cyanogenmod.lockclock.preference.Preferences"
+ android:targetPackage="com.cyanogenmod.lockclock" />
+ </PreferenceScreen>
+
+ <CheckBoxPreference
+ android:key="lockscreen_maximize_widgets"
+ android:persistent="false"
+ android:summary="@string/lockscreen_maximize_widgets_summary"
+ android:title="@string/lockscreen_maximize_widgets_title" />
+
+ <CheckBoxPreference
+ android:key="lockscreen_enable_widgets"
+ android:persistent="false"
+ android:title="@string/lockscreen_enable_widgets_title"
+ android:summary="@string/lockscreen_enable_widgets_summary" />
+
+ <CheckBoxPreference
+ android:key="lockscreen_enable_camera"
+ android:persistent="false"
+ android:title="@string/lockscreen_enable_camera_title"
+ android:summary="@string/lockscreen_enable_camera_summary" />
+
+ <CheckBoxPreference
+ android:key="lockscreen_music_controls"
+ android:persistent="false"
+ android:title="@string/lockscreen_music_controls_title"
+ android:summary="@string/lockscreen_music_controls_summary" />
+
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index b961bbc..3a225f3 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -29,6 +29,7 @@ import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.text.TextUtils;
import android.util.Log;
@@ -313,6 +314,10 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
}
public boolean removePreferenceIfPackageNotInstalled(Preference preference) {
+ return removePreferenceIfPackageNotInstalled(preference, getPreferenceScreen());
+ }
+
+ public boolean removePreferenceIfPackageNotInstalled(Preference preference, PreferenceGroup parent) {
String intentUri = ((PreferenceScreen) preference).getIntent().toUri(1);
Pattern pattern = Pattern.compile("component=([^/]+)/");
Matcher matcher = pattern.matcher(intentUri);
@@ -323,7 +328,7 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
getPackageManager().getPackageInfo(packageName, 0);
} catch (NameNotFoundException e) {
Log.e(TAG, "package " + packageName + " not installed, hiding preference.");
- getPreferenceScreen().removePreference(preference);
+ parent.removePreference(preference);
return true;
}
}
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 {}
}