Skip to content

Commit f69320a

Browse files
Adam CohenAndroid (Google) Code Review
authored andcommitted
Merge "Preventing more than five widgets from being added in the carousel (issue 7502935)" into jb-mr1-dev
2 parents 3e9cba4 + 40f8211 commit f69320a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ public void onUserActivityTimeoutChanged() {
323323
KeyguardHostView.this.onUserActivityTimeoutChanged();
324324
}
325325

326+
@Override
327+
public void onAddView(View v) {
328+
if (numWidgets() >= MAX_WIDGETS) {
329+
setAddWidgetEnabled(false);
330+
}
331+
};
332+
326333
@Override
327334
public void onRemoveView(View v) {
328335
if (numWidgets() < MAX_WIDGETS) {

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ public void setCallbacks(Callbacks callbacks) {
236236
public interface Callbacks {
237237
public void userActivity();
238238
public void onUserActivityTimeoutChanged();
239+
public void onAddView(View v);
239240
public void onRemoveView(View v);
240241
}
241242

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

0 commit comments

Comments
 (0)