Skip to content

Commit

Permalink
Preventing more than five widgets from being added in the carousel (i…
Browse files Browse the repository at this point in the history
…ssue 7502935)

Change-Id: I26e6e154992e56b128d541578ffd3891776a3f7a
  • Loading branch information
Winson Chung authored and Adam Cohen committed Nov 8, 2012
1 parent 9de5901 commit 40f8211
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ public void onUserActivityTimeoutChanged() {
KeyguardHostView.this.onUserActivityTimeoutChanged();
}

@Override
public void onAddView(View v) {
if (numWidgets() >= MAX_WIDGETS) {
setAddWidgetEnabled(false);
}
};

@Override
public void onRemoveView(View v) {
if (numWidgets() < MAX_WIDGETS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public void setCallbacks(Callbacks callbacks) {
public interface Callbacks {
public void userActivity();
public void onUserActivityTimeoutChanged();
public void onAddView(View v);
public void onRemoveView(View v);
}

Expand All @@ -262,6 +263,9 @@ public void onAddView(View v, final int index) {
final int[] pagesRange = new int[mTempVisiblePagesRange.length];
getVisiblePages(pagesRange);
boundByReorderablePages(true, pagesRange);
if (mCallbacks != null) {
mCallbacks.onAddView(v);
}
// Subtract from the index to take into account pages before the reorderable
// pages (e.g. the "add widget" page)
mBackgroundWorkerHandler.post(new Runnable() {
Expand Down

0 comments on commit 40f8211

Please sign in to comment.