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

Commit 79a806d2 authored by The Android Automerger's avatar The Android Automerger
Browse files

Merge branch 'eclair' into eclair-release

parents 021fe3fa f36b8f43
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
@@ -1967,6 +1967,17 @@
 visibility="public"
>
</field>
<field name="autoStart"
 type="int"
 transient="false"
 volatile="false"
 value="16843446"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="autoText"
 type="int"
 transient="false"
@@ -189616,6 +189627,21 @@
<parameter name="parcel" type="android.os.Parcel">
</parameter>
</constructor>
<method name="addView"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
<parameter name="nestedView" type="android.widget.RemoteViews">
</parameter>
</method>
<method name="apply"
 return="android.view.View"
 abstract="false"
@@ -189692,6 +189718,19 @@
<parameter name="v" type="android.view.View">
</parameter>
</method>
<method name="removeAllViews"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
</method>
<method name="setBitmap"
 return="void"
 abstract="false"
@@ -196277,6 +196316,17 @@
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
</constructor>
<method name="isAutoStart"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="isFlipping"
 return="boolean"
 abstract="false"
@@ -196288,6 +196338,19 @@
 visibility="public"
>
</method>
<method name="setAutoStart"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="autoStart" type="boolean">
</parameter>
</method>
<method name="setFlipInterval"
 return="void"
 abstract="false"
+26 −27
Original line number Diff line number Diff line
@@ -59,10 +59,11 @@ public final class AssetManager {
    private static final String TAG = "AssetManager";
    private static final boolean localLOGV = Config.LOGV || false;
    
    private static final Object mSync = new Object();
    private static final TypedValue mValue = new TypedValue();
    private static final long[] mOffsets = new long[2];
    private static AssetManager mSystem = null;
    private static final Object sSync = new Object();
    private static AssetManager sSystem = null;

    private final TypedValue mValue = new TypedValue();
    private final long[] mOffsets = new long[2];
    
    // For communication with native code.
    private int mObject;
@@ -71,8 +72,6 @@ public final class AssetManager {
    
    private int mNumRefs = 1;
    private boolean mOpen = true;
    private String mAssetDir;
    private String mAppName;
 
    /**
     * Create a new AssetManager containing only the basic system assets.
@@ -82,7 +81,7 @@ public final class AssetManager {
     * {@hide}
     */
    public AssetManager() {
        synchronized (mSync) {
        synchronized (this) {
            init();
            if (localLOGV) Log.v(TAG, "New asset manager: " + this);
            ensureSystemAssets();
@@ -90,11 +89,11 @@ public final class AssetManager {
    }

    private static void ensureSystemAssets() {
        synchronized (mSync) {
            if (mSystem == null) {
        synchronized (sSync) {
            if (sSystem == null) {
                AssetManager system = new AssetManager(true);
                system.makeStringBlocks(false);
                mSystem = system;
                sSystem = system;
            }
        }
    }
@@ -111,14 +110,14 @@ public final class AssetManager {
     */
    public static AssetManager getSystem() {
        ensureSystemAssets();
        return mSystem;
        return sSystem;
    }

    /**
     * Close this asset manager.
     */
    public void close() {
        synchronized(mSync) {
        synchronized(this) {
            //System.out.println("Release: num=" + mNumRefs
            //                   + ", released=" + mReleased);
            if (mOpen) {
@@ -133,7 +132,7 @@ public final class AssetManager {
     * identifier for the current configuration / skin.
     */
    /*package*/ final CharSequence getResourceText(int ident) {
        synchronized (mSync) {
        synchronized (this) {
            TypedValue tmpValue = mValue;
            int block = loadResourceValue(ident, tmpValue, true);
            if (block >= 0) {
@@ -151,7 +150,7 @@ public final class AssetManager {
     * identifier for the current configuration / skin.
     */
    /*package*/ final CharSequence getResourceBagText(int ident, int bagEntryId) {
        synchronized (mSync) {
        synchronized (this) {
            TypedValue tmpValue = mValue;
            int block = loadResourceBagValue(ident, bagEntryId, tmpValue, true);
            if (block >= 0) {
@@ -229,7 +228,7 @@ public final class AssetManager {

    /*package*/ final void ensureStringBlocks() {
        if (mStringBlocks == null) {
            synchronized (mSync) {
            synchronized (this) {
                if (mStringBlocks == null) {
                    makeStringBlocks(true);
                }
@@ -238,14 +237,14 @@ public final class AssetManager {
    }

    private final void makeStringBlocks(boolean copyFromSystem) {
        final int sysNum = copyFromSystem ? mSystem.mStringBlocks.length : 0;
        final int sysNum = copyFromSystem ? sSystem.mStringBlocks.length : 0;
        final int num = getStringBlockCount();
        mStringBlocks = new StringBlock[num];
        if (localLOGV) Log.v(TAG, "Making string blocks for " + this
                + ": " + num);
        for (int i=0; i<num; i++) {
            if (i < sysNum) {
                mStringBlocks[i] = mSystem.mStringBlocks[i];
                mStringBlocks[i] = sSystem.mStringBlocks[i];
            } else {
                mStringBlocks[i] = new StringBlock(getNativeStringBlock(i), true);
            }
@@ -293,7 +292,7 @@ public final class AssetManager {
     */
    public final InputStream open(String fileName, int accessMode)
        throws IOException {
        synchronized (mSync) {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
@@ -308,7 +307,7 @@ public final class AssetManager {

    public final AssetFileDescriptor openFd(String fileName)
            throws IOException {
        synchronized (mSync) {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
@@ -384,7 +383,7 @@ public final class AssetManager {
     */
    public final InputStream openNonAsset(int cookie, String fileName, int accessMode)
        throws IOException {
        synchronized (mSync) {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
@@ -404,7 +403,7 @@ public final class AssetManager {
    
    public final AssetFileDescriptor openNonAssetFd(int cookie,
            String fileName) throws IOException {
        synchronized (mSync) {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
@@ -463,7 +462,7 @@ public final class AssetManager {
     */
    /*package*/ final XmlBlock openXmlBlockAsset(int cookie, String fileName)
        throws IOException {
        synchronized (mSync) {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
@@ -477,13 +476,13 @@ public final class AssetManager {
    }

    /*package*/ void xmlBlockGone() {
        synchronized (mSync) {
        synchronized (this) {
            decRefsLocked();
        }
    }

    /*package*/ final int createTheme() {
        synchronized (mSync) {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
@@ -493,7 +492,7 @@ public final class AssetManager {
    }

    /*package*/ final void releaseTheme(int theme) {
        synchronized (mSync) {
        synchronized (this) {
            deleteTheme(theme);
            decRefsLocked();
        }
@@ -523,7 +522,7 @@ public final class AssetManager {
            return len > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)len;
        }
        public final void close() throws IOException {
            synchronized (AssetManager.mSync) {
            synchronized (AssetManager.this) {
                if (mAsset != 0) {
                    destroyAsset(mAsset);
                    mAsset = 0;
+68 −1
Original line number Diff line number Diff line
@@ -457,6 +457,46 @@ public class RemoteViews implements Parcelable, Filter {
        }
    }

    /**
     * Equivalent to calling {@link ViewGroup#addView(View)} after inflating the
     * given {@link RemoteViews}, or calling {@link ViewGroup#removeAllViews()}
     * when null. This allows users to build "nested" {@link RemoteViews}.
     */
    private class ViewGroupAction extends Action {
        public ViewGroupAction(int viewId, RemoteViews nestedViews) {
            this.viewId = viewId;
            this.nestedViews = nestedViews;
        }

        public ViewGroupAction(Parcel parcel) {
            viewId = parcel.readInt();
            nestedViews = parcel.readParcelable(null);
        }

        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(TAG);
            dest.writeInt(viewId);
            dest.writeParcelable(nestedViews, 0 /* no flags */);
        }

        @Override
        public void apply(View root) {
            final Context context = root.getContext();
            final ViewGroup target = (ViewGroup) root.findViewById(viewId);
            if (nestedViews != null) {
                // Inflate nested views and add as children
                target.addView(nestedViews.apply(context, target));
            } else if (target != null) {
                // Clear all children when nested views omitted
                target.removeAllViews();
            }
        }

        int viewId;
        RemoteViews nestedViews;

        public final static int TAG = 4;
    }

    /**
     * Create a new RemoteViews object that will display the views contained
@@ -493,6 +533,9 @@ public class RemoteViews implements Parcelable, Filter {
                case ReflectionAction.TAG:
                    mActions.add(new ReflectionAction(parcel));
                    break;
                case ViewGroupAction.TAG:
                    mActions.add(new ViewGroupAction(parcel));
                    break;
                default:
                    throw new ActionException("Tag " + tag + " not found");
                }
@@ -520,6 +563,30 @@ public class RemoteViews implements Parcelable, Filter {
        mActions.add(a);
    }

    /**
     * Equivalent to calling {@link ViewGroup#addView(View)} after inflating the
     * given {@link RemoteViews}. This allows users to build "nested"
     * {@link RemoteViews}. In cases where consumers of {@link RemoteViews} may
     * recycle layouts, use {@link #removeAllViews(int)} to clear any existing
     * children.
     *
     * @param viewId The id of the parent {@link ViewGroup} to add child into.
     * @param nestedView {@link RemoteViews} that describes the child.
     */
    public void addView(int viewId, RemoteViews nestedView) {
        addAction(new ViewGroupAction(viewId, nestedView));
    }

    /**
     * Equivalent to calling {@link ViewGroup#removeAllViews()}.
     *
     * @param viewId The id of the parent {@link ViewGroup} to remove all
     *            children from.
     */
    public void removeAllViews(int viewId) {
        addAction(new ViewGroupAction(viewId, null));
    }

    /**
     * Equivalent to calling View.setVisibility
     * 
+21 −4
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public class ViewAnimator extends FrameLayout {

    public ViewAnimator(Context context) {
        super(context);
        initViewAnimator();
        initViewAnimator(context, null);
    }

    public ViewAnimator(Context context, AttributeSet attrs) {
@@ -61,11 +61,28 @@ public class ViewAnimator extends FrameLayout {
        }
        a.recycle();

        initViewAnimator();
        initViewAnimator(context, attrs);
    }

    private void initViewAnimator() {
    /**
     * Initialize this {@link ViewAnimator}, possibly setting
     * {@link #setMeasureAllChildren(boolean)} based on {@link FrameLayout} flags.
     */
    private void initViewAnimator(Context context, AttributeSet attrs) {
        if (attrs == null) {
            // For compatibility, always measure children when undefined.
            mMeasureAllChildren = true;
            return;
        }

        // For compatibility, default to measure children, but allow XML
        // attribute to override.
        final TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.FrameLayout);
        final boolean measureAllChildren = a.getBoolean(
                com.android.internal.R.styleable.FrameLayout_measureAllChildren, true);
        setMeasureAllChildren(measureAllChildren);
        a.recycle();
    }
    
    /**
+113 −15
Original line number Diff line number Diff line
@@ -16,12 +16,15 @@

package android.widget;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.RemoteViews.RemoteView;

/**
@@ -30,10 +33,22 @@ import android.widget.RemoteViews.RemoteView;
 * requested, can automatically flip between each child at a regular interval.
 *
 * @attr ref android.R.styleable#ViewFlipper_flipInterval
 * @attr ref android.R.styleable#ViewFlipper_autoStart
 */
@RemoteView
public class ViewFlipper extends ViewAnimator {
    private int mFlipInterval = 3000;
    private boolean mKeepFlipping = false;
    private static final String TAG = "ViewFlipper";
    private static final boolean LOGD = true;

    private static final int DEFAULT_INTERVAL = 3000;

    private int mFlipInterval = DEFAULT_INTERVAL;
    private boolean mAutoStart = false;

    private boolean mRunning = false;
    private boolean mStarted = false;
    private boolean mVisible = false;
    private boolean mUserPresent = true;

    public ViewFlipper(Context context) {
        super(context);
@@ -44,11 +59,59 @@ public class ViewFlipper extends ViewAnimator {

        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.ViewFlipper);
        mFlipInterval = a.getInt(com.android.internal.R.styleable.ViewFlipper_flipInterval,
                3000);
        mFlipInterval = a.getInt(
                com.android.internal.R.styleable.ViewFlipper_flipInterval, DEFAULT_INTERVAL);
        mAutoStart = a.getBoolean(
                com.android.internal.R.styleable.ViewFlipper_autoStart, false);
        a.recycle();
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            if (Intent.ACTION_SCREEN_OFF.equals(action)) {
                mUserPresent = false;
                updateRunning();
            } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
                mUserPresent = true;
                updateRunning();
            }
        }
    };

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        // Listen for broadcasts related to user-presence
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_USER_PRESENT);
        getContext().registerReceiver(mReceiver, filter);

        if (mAutoStart) {
            // Automatically start when requested
            startFlipping();
        }
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mVisible = false;

        getContext().unregisterReceiver(mReceiver);
        updateRunning();
    }

    @Override
    protected void onWindowVisibilityChanged(int visibility) {
        super.onWindowVisibilityChanged(visibility);
        mVisible = visibility == VISIBLE;
        updateRunning();
    }

    /**
     * How long to wait before flipping to the next view
     *
@@ -64,26 +127,61 @@ public class ViewFlipper extends ViewAnimator {
     * Start a timer to cycle through child views
     */
    public void startFlipping() {
        if (!mKeepFlipping) {
            mKeepFlipping = true;
            showOnly(mWhichChild);
            Message msg = mHandler.obtainMessage(FLIP_MSG);
            mHandler.sendMessageDelayed(msg, mFlipInterval);
        }
        mStarted = true;
        updateRunning();
    }

    /**
     * No more flips
     */
    public void stopFlipping() {
        mKeepFlipping = false;
        mStarted = false;
        updateRunning();
    }

    /**
     * Internal method to start or stop dispatching flip {@link Message} based
     * on {@link #mRunning} and {@link #mVisible} state.
     */
    private void updateRunning() {
        boolean running = mVisible && mStarted && mUserPresent;
        if (running != mRunning) {
            if (running) {
                showOnly(mWhichChild);
                Message msg = mHandler.obtainMessage(FLIP_MSG);
                mHandler.sendMessageDelayed(msg, mFlipInterval);
            } else {
                mHandler.removeMessages(FLIP_MSG);
            }
            mRunning = running;
        }
        if (LOGD) {
            Log.d(TAG, "updateRunning() mVisible=" + mVisible + ", mStarted=" + mStarted
                    + ", mUserPresent=" + mUserPresent + ", mRunning=" + mRunning);
        }
    }

    /**
     * Returns true if the child views are flipping.
     */
    public boolean isFlipping() {
        return mKeepFlipping;
        return mStarted;
    }

    /**
     * Set if this view automatically calls {@link #startFlipping()} when it
     * becomes attached to a window.
     */
    public void setAutoStart(boolean autoStart) {
        mAutoStart = autoStart;
    }

    /**
     * Returns true if this view automatically calls {@link #startFlipping()}
     * when it becomes attached to a window.
     */
    public boolean isAutoStart() {
        return mAutoStart;
    }

    private final int FLIP_MSG = 1;
@@ -92,7 +190,7 @@ public class ViewFlipper extends ViewAnimator {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == FLIP_MSG) {
                if (mKeepFlipping) {
                if (mRunning) {
                    showNext();
                    msg = obtainMessage(FLIP_MSG);
                    sendMessageDelayed(msg, mFlipInterval);
Loading