summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2012-05-31 22:28:38 -0400
committerSteve Kondik <shade@chemlab.org>2012-06-09 19:33:57 -0700
commit0d5796958ccf014101f9d8f526bf46c55dcf8cd9 (patch)
treeda215c35dfaa058049af2e2b6eadc17bad5cc7b9
parentc92309145e3335a9becfcc7a28747641553d727d (diff)
downloadframeworks_base-0d5796958ccf014101f9d8f526bf46c55dcf8cd9.zip
frameworks_base-0d5796958ccf014101f9d8f526bf46c55dcf8cd9.tar.gz
frameworks_base-0d5796958ccf014101f9d8f526bf46c55dcf8cd9.tar.bz2
Framework : Lockscreen background customization (1/2)
Allow user to customize lockscreen background (port from cm7) Part 2 : http://review.cyanogenmod.com/#/c/16914/ Part 3 : Minor edits Part 4 : Fix crash on tablets. Added nullcheck to ViewGroup Layout Part 5 : Add missing id to layout Part 6 : Reordering/renaming of setBackground Change-Id: I3f904486b8c7bcfcb63f54937810f6ee9c1721ef
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml3
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml3
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml3
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml1
-rw-r--r--core/res/res/layout/keyguard_screen_password_portrait.xml1
-rw-r--r--core/res/res/layout/keyguard_screen_tab_unlock.xml1
-rw-r--r--core/res/res/layout/keyguard_screen_unlock_portrait.xml1
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/LockScreen.java25
-rw-r--r--policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java3
-rw-r--r--policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java3
11 files changed, 45 insertions, 5 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5deaf1a..01ff137 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2432,6 +2432,12 @@ public final class Settings {
public static final String QUIET_HOURS_DIM = "quiet_hours_dim";
/**
+ * Sets the lockscreen background style
+ * @hide
+ */
+ public static final String LOCKSCREEN_BACKGROUND = "lockscreen_background";
+
+ /**
* Show the weather on the lock screen
* @hide
*/
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml b/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml
index 568933c..b8deb4b 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml
@@ -21,7 +21,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:id="@+id/root">
<!-- left side: status and music -->
<RelativeLayout
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml b/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml
index 335a641..2594873 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml
@@ -20,7 +20,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:id="@+id/root">
<!-- top: status and emergency/forgot pattern buttons -->
<RelativeLayout
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml b/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml
index 802ef82..e13495a 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml
@@ -25,7 +25,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:id="@+id/root">
<!-- left side: status and music -->
<RelativeLayout
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml b/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml
index 47a9953..18489af 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml
@@ -20,6 +20,7 @@
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
+ android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml
index 053acb2..3a1ad48 100644
--- a/core/res/res/layout/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_password_portrait.xml
@@ -21,6 +21,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:id="@+id/root"
android:gravity="center_horizontal">
<com.android.internal.widget.DigitalClock android:id="@+id/time"
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock.xml b/core/res/res/layout/keyguard_screen_tab_unlock.xml
index 535188e..51bacea 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock.xml
@@ -27,6 +27,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:id="@+id/root"
android:gravity="center_horizontal">
<com.android.internal.widget.DigitalClock android:id="@+id/time"
diff --git a/core/res/res/layout/keyguard_screen_unlock_portrait.xml b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
index 336faa1..0ea680b 100644
--- a/core/res/res/layout/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
@@ -25,6 +25,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:id="@+id/root"
android:gravity="center_horizontal">
<com.android.internal.widget.DigitalClock android:id="@+id/time"
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 5ee84d3..410fb9e 100755
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -33,7 +33,9 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
+import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
@@ -493,6 +495,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true);
}
+ setBackground(mContext, (ViewGroup) findViewById(R.id.root));
+
mStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor, mLockPatternUtils,
mCallback, false);
@@ -537,6 +541,27 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
+ (mUnlockWidget.isHardwareAccelerated() ? "on":"off"));
}
+ static void setBackground(Context context, ViewGroup layout) {
+ String lockBack = Settings.System.getString(context.getContentResolver(), Settings.System.LOCKSCREEN_BACKGROUND);
+ if (lockBack != null) {
+ if (!lockBack.isEmpty()) {
+ try {
+ layout.setBackgroundColor(Integer.parseInt(lockBack));
+ } catch(NumberFormatException e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ Context settingsContext = context.createPackageContext("com.android.settings", 0);
+ String wallpaperFile = settingsContext.getFilesDir() + "/lockwallpaper";
+ Bitmap background = BitmapFactory.decodeFile(wallpaperFile);
+ layout.setBackgroundDrawable(new BitmapDrawable(background));
+ } catch (NameNotFoundException e) {
+ }
+ }
+ }
+ }
+
private boolean isSilentMode() {
return mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
}
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index dcfdb39..6b89711 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -38,6 +38,7 @@ import android.text.method.TextKeyListener;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -97,7 +98,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
} else {
layoutInflater.inflate(R.layout.keyguard_screen_password_landscape, this, true);
}
-
+ LockScreen.setBackground(context, (ViewGroup) findViewById(R.id.root));
mStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor, mLockPatternUtils,
mCallback, true);
diff --git a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
index 9a6d2cc..e366f23 100644
--- a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
@@ -24,6 +24,7 @@ import android.security.KeyStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.MotionEvent;
+import android.view.ViewGroup;
import android.widget.Button;
import android.util.Log;
import com.android.internal.R;
@@ -169,7 +170,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
Log.d(TAG, "landscape mode");
inflater.inflate(R.layout.keyguard_screen_unlock_landscape, this, true);
}
-
+ LockScreen.setBackground(context, (ViewGroup) findViewById(R.id.root));
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor,
mLockPatternUtils, mCallback, true);