OSDN Git Service

Fix 5045008: replace "ring/silence" target in LockScreen with camera app
authorJim Miller <jaggies@google.com>
Thu, 4 Aug 2011 23:10:50 +0000 (16:10 -0700)
committerJim Miller <jaggies@google.com>
Fri, 5 Aug 2011 01:00:14 +0000 (18:00 -0700)
This change replaces the ring/silence target with a camera target.  It
is disabled and falls back to the old behavior when any device policy
disables the camera.

Updated with latest icons.

Change-Id: I2374eba08f85ff1d1b0bad2859efa30bb166fb60

25 files changed:
core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
core/res/res/drawable-hdpi/ic_lockscreen_camera_activated.png [new file with mode: 0644]
core/res/res/drawable-hdpi/ic_lockscreen_camera_normal.png [new file with mode: 0644]
core/res/res/drawable-hdpi/ic_lockscreen_silent_activated.png
core/res/res/drawable-hdpi/ic_lockscreen_soundon_activated.png
core/res/res/drawable-hdpi/ic_lockscreen_text_activated.png
core/res/res/drawable-hdpi/ic_lockscreen_unlock_activated.png
core/res/res/drawable-mdpi/ic_lockscreen_camera_activated.png [new file with mode: 0644]
core/res/res/drawable-mdpi/ic_lockscreen_camera_normal.png [new file with mode: 0644]
core/res/res/drawable-mdpi/ic_lockscreen_silent_activated.png
core/res/res/drawable-mdpi/ic_lockscreen_soundon_activated.png
core/res/res/drawable-mdpi/ic_lockscreen_text_activated.png
core/res/res/drawable-mdpi/ic_lockscreen_unlock_activated.png
core/res/res/drawable-xhdpi/ic_lockscreen_camera_activated.png [new file with mode: 0644]
core/res/res/drawable-xhdpi/ic_lockscreen_camera_normal.png [new file with mode: 0644]
core/res/res/drawable-xhdpi/ic_lockscreen_silent_activated.png
core/res/res/drawable-xhdpi/ic_lockscreen_soundon_activated.png
core/res/res/drawable-xhdpi/ic_lockscreen_text_activated.png
core/res/res/drawable-xhdpi/ic_lockscreen_unlock_activated.png
core/res/res/drawable/ic_lockscreen_camera.xml [new file with mode: 0644]
core/res/res/layout/keyguard_screen_tab_unlock.xml
core/res/res/layout/keyguard_screen_tab_unlock_land.xml
core/res/res/values-land/arrays.xml
core/res/res/values/arrays.xml
policy/src/com/android/internal/policy/impl/LockScreen.java

index 0510023..ec926e4 100644 (file)
@@ -127,6 +127,7 @@ public class MultiWaveView extends View {
             mAnimatingTargets = false;
         }
     };
+    private int mTargetResourceId;
 
     public MultiWaveView(Context context) {
         this(context, null);
@@ -474,6 +475,7 @@ public class MultiWaveView extends View {
             Drawable drawable = array.getDrawable(i);
             targetDrawables.add(new TargetDrawable(res, drawable));
         }
+        mTargetResourceId = resourceId;
         mTargetDrawables = targetDrawables;
         updateTargetPositions();
     }
@@ -492,6 +494,10 @@ public class MultiWaveView extends View {
         }
     }
 
+    public int getTargetResourceId() {
+        return mTargetResourceId;
+    }
+
     /**
      * Enable or disable vibrate on touch.
      *
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_camera_activated.png b/core/res/res/drawable-hdpi/ic_lockscreen_camera_activated.png
new file mode 100644 (file)
index 0000000..d510e1d
Binary files /dev/null and b/core/res/res/drawable-hdpi/ic_lockscreen_camera_activated.png differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_camera_normal.png b/core/res/res/drawable-hdpi/ic_lockscreen_camera_normal.png
new file mode 100644 (file)
index 0000000..36d766d
Binary files /dev/null and b/core/res/res/drawable-hdpi/ic_lockscreen_camera_normal.png differ
index fce4980..d1938b9 100644 (file)
Binary files a/core/res/res/drawable-hdpi/ic_lockscreen_silent_activated.png and b/core/res/res/drawable-hdpi/ic_lockscreen_silent_activated.png differ
index 73f01c9..f6ccbd2 100644 (file)
Binary files a/core/res/res/drawable-hdpi/ic_lockscreen_soundon_activated.png and b/core/res/res/drawable-hdpi/ic_lockscreen_soundon_activated.png differ
index d01bdb2..10b3268 100644 (file)
Binary files a/core/res/res/drawable-hdpi/ic_lockscreen_text_activated.png and b/core/res/res/drawable-hdpi/ic_lockscreen_text_activated.png differ
index d333946..d1f3015 100644 (file)
Binary files a/core/res/res/drawable-hdpi/ic_lockscreen_unlock_activated.png and b/core/res/res/drawable-hdpi/ic_lockscreen_unlock_activated.png differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_camera_activated.png b/core/res/res/drawable-mdpi/ic_lockscreen_camera_activated.png
new file mode 100644 (file)
index 0000000..1437798
Binary files /dev/null and b/core/res/res/drawable-mdpi/ic_lockscreen_camera_activated.png differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_camera_normal.png b/core/res/res/drawable-mdpi/ic_lockscreen_camera_normal.png
new file mode 100644 (file)
index 0000000..b718258
Binary files /dev/null and b/core/res/res/drawable-mdpi/ic_lockscreen_camera_normal.png differ
index 3b2f3fc..2bc3f52 100644 (file)
Binary files a/core/res/res/drawable-mdpi/ic_lockscreen_silent_activated.png and b/core/res/res/drawable-mdpi/ic_lockscreen_silent_activated.png differ
index 03f524d..637eec6 100644 (file)
Binary files a/core/res/res/drawable-mdpi/ic_lockscreen_soundon_activated.png and b/core/res/res/drawable-mdpi/ic_lockscreen_soundon_activated.png differ
index dbfc5ba..878ff1f 100644 (file)
Binary files a/core/res/res/drawable-mdpi/ic_lockscreen_text_activated.png and b/core/res/res/drawable-mdpi/ic_lockscreen_text_activated.png differ
index df47993..0d3f756 100644 (file)
Binary files a/core/res/res/drawable-mdpi/ic_lockscreen_unlock_activated.png and b/core/res/res/drawable-mdpi/ic_lockscreen_unlock_activated.png differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_camera_activated.png b/core/res/res/drawable-xhdpi/ic_lockscreen_camera_activated.png
new file mode 100644 (file)
index 0000000..d545883
Binary files /dev/null and b/core/res/res/drawable-xhdpi/ic_lockscreen_camera_activated.png differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_camera_normal.png b/core/res/res/drawable-xhdpi/ic_lockscreen_camera_normal.png
new file mode 100644 (file)
index 0000000..8de7b84
Binary files /dev/null and b/core/res/res/drawable-xhdpi/ic_lockscreen_camera_normal.png differ
index fd81211..2900045 100644 (file)
Binary files a/core/res/res/drawable-xhdpi/ic_lockscreen_silent_activated.png and b/core/res/res/drawable-xhdpi/ic_lockscreen_silent_activated.png differ
index 9edc70b..da2adc2 100644 (file)
Binary files a/core/res/res/drawable-xhdpi/ic_lockscreen_soundon_activated.png and b/core/res/res/drawable-xhdpi/ic_lockscreen_soundon_activated.png differ
index 29c4572..ddebe3e 100644 (file)
Binary files a/core/res/res/drawable-xhdpi/ic_lockscreen_text_activated.png and b/core/res/res/drawable-xhdpi/ic_lockscreen_text_activated.png differ
index fa0be96..73d7af3 100644 (file)
Binary files a/core/res/res/drawable-xhdpi/ic_lockscreen_unlock_activated.png and b/core/res/res/drawable-xhdpi/ic_lockscreen_unlock_activated.png differ
diff --git a/core/res/res/drawable/ic_lockscreen_camera.xml b/core/res/res/drawable/ic_lockscreen_camera.xml
new file mode 100644 (file)
index 0000000..0e3ef37
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:state_enabled="true"
+        android:state_active="false"
+        android:state_focused="false"
+        android:drawable="@drawable/ic_lockscreen_camera_normal" />
+
+    <item
+        android:state_enabled="true"
+        android:state_active="true"
+        android:state_focused="false"
+        android:drawable="@drawable/ic_lockscreen_camera_activated" />
+
+</selector>
index 05c768d..6016d4e 100644 (file)
             android:layout_height="match_parent"
             android:layout_alignParentBottom="true"
 
-            android:targetDrawables="@array/lockscreen_targets_when_silent"
+            android:targetDrawables="@array/lockscreen_targets_with_camera"
             android:handleDrawable="@drawable/ic_lockscreen_handle"
             android:waveDrawable="@drawable/ic_lockscreen_outerring"
             android:outerRadius="@dimen/multiwaveview_target_placement_radius"
index 6440726..168bd1a 100644 (file)
         android:layout_height="match_parent"
         android:layout_rowSpan="7"
 
-        android:targetDrawables="@array/lockscreen_targets_when_silent"
+        android:targetDrawables="@array/lockscreen_targets_with_camera"
         android:handleDrawable="@drawable/ic_lockscreen_handle"
         android:waveDrawable="@drawable/ic_lockscreen_outerring"
         android:outerRadius="@dimen/multiwaveview_target_placement_radius"
index 92d5a87..fd492ec 100644 (file)
         <item>@drawable/ic_lockscreen_silent</item>
     </array>
 
+    <array name="lockscreen_targets_with_camera">
+        <item>@null</item>
+        <item>@drawable/ic_lockscreen_unlock</item>
+        <item>@null</item>
+        <item>@drawable/ic_lockscreen_camera</item>
+    </array>
+
 </resources>
index 73103a6..fa9f1d1 100644 (file)
         <item>@null</item>"
     </array>
 
+    <array name="lockscreen_targets_with_camera">
+        <item>@drawable/ic_lockscreen_unlock</item>
+        <item>@null</item>
+        <item>@drawable/ic_lockscreen_camera</item>
+        <item>@null</item>"
+    </array>
+
 </resources>
index 4a14dd9..9d360ac 100644 (file)
@@ -23,7 +23,9 @@ import com.android.internal.widget.WaveView;
 import com.android.internal.widget.multiwaveview.MultiWaveView;
 
 import android.app.ActivityManager;
+import android.content.ActivityNotFoundException;
 import android.content.Context;
+import android.content.Intent;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.view.KeyEvent;
@@ -181,14 +183,33 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
             UnlockWidgetCommonMethods {
 
         private final MultiWaveView mMultiWaveView;
+        private boolean mCameraDisabled;
 
         MultiWaveViewMethods(MultiWaveView multiWaveView) {
             mMultiWaveView = multiWaveView;
+            final boolean cameraDisabled = mLockPatternUtils.getDevicePolicyManager()
+                    .getCameraDisabled(null);
+            if (cameraDisabled) {
+                Log.v(TAG, "Camera disabled by Device Policy");
+                mCameraDisabled = true;
+            } else {
+                // Camera is enabled if resource is initially defined for MultiWaveView
+                // in the lockscreen layout file
+                mCameraDisabled = mMultiWaveView.getTargetResourceId()
+                        != R.array.lockscreen_targets_with_camera;
+            }
         }
 
         public void updateResources() {
-            mMultiWaveView.setTargetResources(mSilentMode ? R.array.lockscreen_targets_when_silent
-                    : R.array.lockscreen_targets_when_soundon);
+            int resId;
+            if (mCameraDisabled) {
+                // Fall back to showing ring/silence if camera is disabled by DPM...
+                resId = mSilentMode ? R.array.lockscreen_targets_when_silent
+                    : R.array.lockscreen_targets_when_soundon;
+            } else {
+                resId = R.array.lockscreen_targets_with_camera;
+            }
+            mMultiWaveView.setTargetResources(resId);
         }
 
         public void onGrabbed(View v, int handle) {
@@ -200,12 +221,19 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
         }
 
         public void onTrigger(View v, int target) {
-            if (target == 0) { // TODO: Use resources to determine which handle was used
+            if (target == 0 || target == 1) { // 0 = unlock/portrait, 1 = unlock/landscape
                 mCallback.goToUnlockScreen();
-            } else if (target == 2) {
-                toggleRingMode();
-                mUnlockWidgetMethods.updateResources();
-                mCallback.pokeWakelock();
+            } else if (target == 2 || target == 3) { // 2 = alt/portrait, 3 = alt/landscape
+                if (!mCameraDisabled) {
+                    // Broadcast an intent to start the Camera
+                    Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
+                    mContext.sendOrderedBroadcast(intent, null);
+                    mCallback.goToUnlockScreen();
+                } else {
+                    toggleRingMode();
+                    mUnlockWidgetMethods.updateResources();
+                    mCallback.pokeWakelock();
+                }
             }
         }