diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/appwidget/AppWidgetProviderInfo.java | 15 | ||||
-rw-r--r-- | core/java/android/widget/AdapterViewAnimator.java | 9 | ||||
-rw-r--r-- | core/java/android/widget/AdapterViewFlipper.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/Advanceable.java | 38 | ||||
-rw-r--r-- | core/java/android/widget/StackView.java | 3 |
5 files changed, 67 insertions, 8 deletions
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java index 396e92d..a3db01d 100644 --- a/core/java/android/appwidget/AppWidgetProviderInfo.java +++ b/core/java/android/appwidget/AppWidgetProviderInfo.java @@ -98,8 +98,7 @@ public class AppWidgetProviderInfo implements Parcelable { * the <code><receiver></code> element in the AndroidManifest.xml file. */ public int icon; - - + /** * The previous name, if any, of the app widget receiver. If not supplied, it will be * ignored. @@ -110,7 +109,12 @@ public class AppWidgetProviderInfo implements Parcelable { * @hide Pending API approval */ public String oldName; - + + /** + * The view id of the AppWidget subview which should be auto-advanced by the widget's host. + */ + public int autoAdvanceViewId; + /** * A preview of what the AppWidget will look like after it's configured. * If not supplied, the AppWidget's icon will be used. @@ -142,9 +146,9 @@ public class AppWidgetProviderInfo implements Parcelable { this.label = in.readString(); this.icon = in.readInt(); this.previewImage = in.readInt(); + this.autoAdvanceViewId = in.readInt(); } - public void writeToParcel(android.os.Parcel out, int flags) { if (this.provider != null) { out.writeInt(1); @@ -165,6 +169,7 @@ public class AppWidgetProviderInfo implements Parcelable { out.writeString(this.label); out.writeInt(this.icon); out.writeInt(this.previewImage); + out.writeInt(this.autoAdvanceViewId); } public int describeContents() { @@ -192,5 +197,3 @@ public class AppWidgetProviderInfo implements Parcelable { return "AppWidgetProviderInfo(provider=" + this.provider + ")"; } } - - diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java index 1f98c88..7d78777 100644 --- a/core/java/android/widget/AdapterViewAnimator.java +++ b/core/java/android/widget/AdapterViewAnimator.java @@ -45,7 +45,7 @@ import android.view.ViewGroup; * @attr ref android.R.styleable#AdapterViewAnimator_loopViews */ public abstract class AdapterViewAnimator extends AdapterView<Adapter> - implements RemoteViewsAdapter.RemoteAdapterConnectionCallback { + implements RemoteViewsAdapter.RemoteAdapterConnectionCallback, Advanceable { private static final String TAG = "RemoteViewAnimator"; /** @@ -965,4 +965,11 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter> setAdapter(mRemoteViewsAdapter); } } + + public void advance() { + showNext(); + } + + public void willBeAdvancedByHost() { + } } diff --git a/core/java/android/widget/AdapterViewFlipper.java b/core/java/android/widget/AdapterViewFlipper.java index b09ade7..7721688 100644 --- a/core/java/android/widget/AdapterViewFlipper.java +++ b/core/java/android/widget/AdapterViewFlipper.java @@ -52,6 +52,7 @@ public class AdapterViewFlipper extends AdapterViewAnimator { private boolean mStarted = false; private boolean mVisible = false; private boolean mUserPresent = true; + private boolean mAdvancedByHost = false; public AdapterViewFlipper(Context context) { super(context); @@ -203,7 +204,8 @@ public class AdapterViewFlipper extends AdapterViewAnimator { * true. */ private void updateRunning(boolean flipNow) { - boolean running = mVisible && mStarted && mUserPresent && mAdapter != null; + boolean running = !mAdvancedByHost && mVisible && mStarted && mUserPresent + && mAdapter != null; if (running != mRunning) { if (running) { showOnly(mWhichChild, flipNow); @@ -255,4 +257,10 @@ public class AdapterViewFlipper extends AdapterViewAnimator { } } }; + + @Override + public void willBeAdvancedByHost() { + mAdvancedByHost = true; + updateRunning(false); + } } diff --git a/core/java/android/widget/Advanceable.java b/core/java/android/widget/Advanceable.java new file mode 100644 index 0000000..bb162de --- /dev/null +++ b/core/java/android/widget/Advanceable.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +package android.widget; + +/** + * This interface can be implemented by any collection-type view which has a notion of + * progressing through its set of children. The interface exists to give AppWidgetHosts a way of + * taking responsibility for automatically advancing such collections. + * + * @hide + */ +public interface Advanceable { + + /** + * Advances this collection, eg. shows the next view. + */ + public void advance(); + + /** + * Called by the AppWidgetHost once before it begins to call advance(), allowing the + * collection to do any required setup. + */ + public void willBeAdvancedByHost(); +} diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index a27e1cc..01044d9 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -674,6 +674,8 @@ public class StackView extends AdapterViewAnimator { r = Math.max(0, r); mYProgress = r; + if (mView == null) return; + final LayoutParams viewLp = (LayoutParams) mView.getLayoutParams(); final LayoutParams highlightLp = (LayoutParams) mHighlight.getLayoutParams(); @@ -722,6 +724,7 @@ public class StackView extends AdapterViewAnimator { mXProgress = r; + if (mView == null) return; final LayoutParams viewLp = (LayoutParams) mView.getLayoutParams(); final LayoutParams highlightLp = (LayoutParams) mHighlight.getLayoutParams(); |