diff options
14 files changed, 68 insertions, 21 deletions
diff --git a/core/res/res/drawable-hdpi/kg_add_widget.png b/core/res/res/drawable-hdpi/kg_add_widget.png Binary files differindex 723d97a3a981..68971a58c5ac 100644 --- a/core/res/res/drawable-hdpi/kg_add_widget.png +++ b/core/res/res/drawable-hdpi/kg_add_widget.png diff --git a/core/res/res/drawable-hdpi/kg_add_widget_disabled.png b/core/res/res/drawable-hdpi/kg_add_widget_disabled.png Binary files differnew file mode 100644 index 000000000000..f24cf6423ff9 --- /dev/null +++ b/core/res/res/drawable-hdpi/kg_add_widget_disabled.png diff --git a/core/res/res/drawable-hdpi/kg_add_widget_pressed.png b/core/res/res/drawable-hdpi/kg_add_widget_pressed.png Binary files differnew file mode 100644 index 000000000000..55112ca7ea9a --- /dev/null +++ b/core/res/res/drawable-hdpi/kg_add_widget_pressed.png diff --git a/core/res/res/drawable-mdpi/kg_add_widget.png b/core/res/res/drawable-mdpi/kg_add_widget.png Binary files differindex 5b0a5a485450..136ae1740410 100644 --- a/core/res/res/drawable-mdpi/kg_add_widget.png +++ b/core/res/res/drawable-mdpi/kg_add_widget.png diff --git a/core/res/res/drawable-mdpi/kg_add_widget_disabled.png b/core/res/res/drawable-mdpi/kg_add_widget_disabled.png Binary files differnew file mode 100644 index 000000000000..02e0f0ecc260 --- /dev/null +++ b/core/res/res/drawable-mdpi/kg_add_widget_disabled.png diff --git a/core/res/res/drawable-mdpi/kg_add_widget_pressed.png b/core/res/res/drawable-mdpi/kg_add_widget_pressed.png Binary files differnew file mode 100644 index 000000000000..34a7aaa535a2 --- /dev/null +++ b/core/res/res/drawable-mdpi/kg_add_widget_pressed.png diff --git a/core/res/res/drawable-xhdpi/kg_add_widget.png b/core/res/res/drawable-xhdpi/kg_add_widget.png Binary files differindex 9c84de2e1d40..ca48be2793df 100644 --- a/core/res/res/drawable-xhdpi/kg_add_widget.png +++ b/core/res/res/drawable-xhdpi/kg_add_widget.png diff --git a/core/res/res/drawable-xhdpi/kg_add_widget_disabled.png b/core/res/res/drawable-xhdpi/kg_add_widget_disabled.png Binary files differnew file mode 100644 index 000000000000..55fa1acc5806 --- /dev/null +++ b/core/res/res/drawable-xhdpi/kg_add_widget_disabled.png diff --git a/core/res/res/drawable-xhdpi/kg_add_widget_pressed.png b/core/res/res/drawable-xhdpi/kg_add_widget_pressed.png Binary files differnew file mode 100644 index 000000000000..4b86727bc899 --- /dev/null +++ b/core/res/res/drawable-xhdpi/kg_add_widget_pressed.png diff --git a/core/res/res/drawable/keyguard_add_widget_button.xml b/core/res/res/drawable/keyguard_add_widget_button.xml new file mode 100644 index 000000000000..c26f81dd9d66 --- /dev/null +++ b/core/res/res/drawable/keyguard_add_widget_button.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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_pressed="true" android:drawable="@drawable/kg_add_widget_pressed" /> + <item android:state_enabled="false" android:drawable="@drawable/kg_add_widget_disabled" /> + <item android:drawable="@drawable/kg_add_widget" /> +</selector> diff --git a/core/res/res/layout/keyguard_add_widget.xml b/core/res/res/layout/keyguard_add_widget.xml index db166ac015ea..d043fdbf6e84 100644 --- a/core/res/res/layout/keyguard_add_widget.xml +++ b/core/res/res/layout/keyguard_add_widget.xml @@ -36,7 +36,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:padding="24dp" - android:src="@drawable/kg_add_widget" + android:src="@drawable/keyguard_add_widget_button" android:contentDescription="@string/keyguard_accessibility_add_widget"/> </FrameLayout> </com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame> diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index 84f3d61cd016..11ed5bc8bdb4 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -271,7 +271,7 @@ public class KeyguardHostView extends KeyguardViewBase { addWidgetsFromSettings(); if (numWidgets() >= MAX_WIDGETS) { - setAddWidgetEnabled(false); + mAppWidgetContainer.setAddWidgetEnabled(false); } checkAppWidgetConsistency(); mSwitchPageRunnable.run(); @@ -365,15 +365,12 @@ public class KeyguardHostView extends KeyguardViewBase { @Override public void onAddView(View v) { if (numWidgets() >= MAX_WIDGETS) { - setAddWidgetEnabled(false); + mAppWidgetContainer.setAddWidgetEnabled(false); } - }; + } @Override public void onRemoveView(View v, boolean deletePermanently) { - if (numWidgets() < MAX_WIDGETS) { - setAddWidgetEnabled(true); - } if (deletePermanently) { final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId(); if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID && @@ -382,6 +379,13 @@ public class KeyguardHostView extends KeyguardViewBase { } } } + + @Override + public void onRemoveViewAnimationCompleted() { + if (numWidgets() < MAX_WIDGETS) { + mAppWidgetContainer.setAddWidgetEnabled(true); + } + } }; public void userActivity() { @@ -1055,15 +1059,6 @@ public class KeyguardHostView extends KeyguardViewBase { return widgetCount; } - - private void setAddWidgetEnabled(boolean clickable) { - View addWidget = mAppWidgetContainer.findViewById(R.id.keyguard_add_widget); - if (addWidget != null) { - View addWidgetButton = addWidget.findViewById(R.id.keyguard_add_widget_view); - addWidgetButton.setEnabled(clickable); - } - } - private void addDefaultWidgets() { LayoutInflater inflater = LayoutInflater.from(mContext); inflater.inflate(R.layout.keyguard_transport_control_view, this, true); diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java index 5b00dd23e21e..b4fe0c7aaca4 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java @@ -72,6 +72,11 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit private int mWidgetToResetAfterFadeOut; protected boolean mShowingInitialHints = false; + // A temporary handle to the Add-Widget view + private View mAddWidgetView; + private int mLastWidthMeasureSpec; + private int mLastHeightMeasureSpec; + // Bouncer private int mBouncerZoomInOutDuration = 250; private float BOUNCER_SCALE_FACTOR = 0.67f; @@ -239,6 +244,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit public void onUserActivityTimeoutChanged(); public void onAddView(View v); public void onRemoveView(View v, boolean deletePermanently); + public void onRemoveViewAnimationCompleted(); } public void addWidget(View widget) { @@ -258,6 +264,13 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit }); } + @Override + public void onRemoveViewAnimationCompleted() { + if (mCallbacks != null) { + mCallbacks.onRemoveViewAnimationCompleted(); + } + } + public void onAddView(View v, final int index) { final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId(); final int[] pagesRange = new int[mTempVisiblePagesRange.length]; @@ -597,12 +610,10 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit mHasMeasure = false; } - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - } - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + mLastWidthMeasureSpec = widthMeasureSpec; + mLastHeightMeasureSpec = heightMeasureSpec; + int maxChallengeTop = -1; View parent = (View) getParent(); boolean challengeShowing = false; @@ -814,6 +825,24 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit } } + void setAddWidgetEnabled(boolean enabled) { + if (mAddWidgetView != null && enabled) { + addView(mAddWidgetView, 0); + // We need to force measure the PagedView so that the calls to update the scroll + // position below work + measure(mLastWidthMeasureSpec, mLastHeightMeasureSpec); + // Bump up the current page to account for the addition of the new page + setCurrentPage(mCurrentPage + 1); + mAddWidgetView = null; + } else if (mAddWidgetView == null && !enabled) { + View addWidget = findViewById(com.android.internal.R.id.keyguard_add_widget); + if (addWidget != null) { + mAddWidgetView = addWidget; + removeView(addWidget); + } + } + } + boolean isAddPage(int pageIndex) { View v = getChildAt(pageIndex); return v != null && v.getId() == com.android.internal.R.id.keyguard_add_widget; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java index 0b06306419c0..33c2456180c3 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java @@ -1588,6 +1588,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc //public abstract void onFlingToDelete(View v); public abstract void onRemoveView(View v, boolean deletePermanently); + public abstract void onRemoveViewAnimationCompleted(); public abstract void onAddView(View v, int index); private void resetTouchState() { @@ -2383,6 +2384,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc public void run() { mDeferringForDelete = false; onEndReordering(); + onRemoveViewAnimationCompleted(); } }; zoomIn(onCompleteRunnable); |