Merge "Removing the plus page when we reach the max number of allowable widgets. (Bug 7564782)" into jb-mr1.1-dev
Before Width: | Height: | Size: 971 B After Width: | Height: | Size: 970 B |
BIN
core/res/res/drawable-hdpi/kg_add_widget_disabled.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
core/res/res/drawable-hdpi/kg_add_widget_pressed.png
Normal file
After Width: | Height: | Size: 1004 B |
Before Width: | Height: | Size: 776 B After Width: | Height: | Size: 788 B |
BIN
core/res/res/drawable-mdpi/kg_add_widget_disabled.png
Normal file
After Width: | Height: | Size: 832 B |
BIN
core/res/res/drawable-mdpi/kg_add_widget_pressed.png
Normal file
After Width: | Height: | Size: 809 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
core/res/res/drawable-xhdpi/kg_add_widget_disabled.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
core/res/res/drawable-xhdpi/kg_add_widget_pressed.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
21
core/res/res/drawable/keyguard_add_widget_button.xml
Normal file
@ -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>
|
@ -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>
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|