Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a02fdf1b authored by Adam Cohen's avatar Adam Cohen
Browse files

Adding widget auto-advance capability

Change-Id: I058573f40a48fd7b5c2efa5f1041a1199919a51a
parent ec4d8204
Loading
Loading
Loading
Loading
+44 −1
Original line number Diff line number Diff line
@@ -2363,6 +2363,17 @@
 visibility="public"
>
</field>
<field name="autoAdvanceViewId"
 type="int"
 transient="false"
 volatile="false"
 value="16843551"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="autoCompleteTextViewStyle"
 type="int"
 transient="false"
@@ -36517,6 +36528,16 @@
 visibility="public"
>
</field>
<field name="autoAdvanceViewId"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="configure"
 type="android.content.ComponentName"
 transient="false"
@@ -227411,6 +227432,17 @@
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
</constructor>
<method name="advance"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getAdapter"
 return="android.widget.Adapter"
 abstract="false"
@@ -227523,6 +227555,17 @@
 visibility="public"
>
</method>
<method name="onWillBeAdvancedByHost"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="setAdapter"
 return="void"
 abstract="false"
@@ -245998,7 +246041,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="arg0" type="T">
<parameter name="t" type="T">
</parameter>
</method>
</interface>
+9 −6
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ public class AppWidgetProviderInfo implements Parcelable {
     */
    public int icon;

    
    /**
     * The previous name, if any, of the app widget receiver. If not supplied, it will be
     * ignored.
@@ -111,6 +110,11 @@ public class AppWidgetProviderInfo implements Parcelable {
     */
    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 + ")";
    }
}

+8 −1
Original line number Diff line number Diff line
@@ -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() {
    }
}
+9 −1
Original line number Diff line number Diff line
@@ -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);
    }
}
+38 −0
Original line number Diff line number Diff line
/*
 * 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();
}
Loading