am 05ebcb51: Merge change 5609 into donut
Merge commit '05ebcb5172679a6c196cbf23d7174c04dd9f6ae0' * commit '05ebcb5172679a6c196cbf23d7174c04dd9f6ae0': Update spinner's drawables. Clean up resources, pave the way for new animation.
@@ -33,7 +33,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -107,7 +106,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
private Button mGoButton;
|
||||
private ImageButton mVoiceButton;
|
||||
private View mSearchPlate;
|
||||
private AnimationDrawable mWorkingSpinner;
|
||||
private Drawable mWorkingSpinner;
|
||||
|
||||
// interaction with searchable application
|
||||
private SearchableInfo mSearchable;
|
||||
@@ -188,7 +187,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
mGoButton = (Button) findViewById(com.android.internal.R.id.search_go_btn);
|
||||
mVoiceButton = (ImageButton) findViewById(com.android.internal.R.id.search_voice_btn);
|
||||
mSearchPlate = findViewById(com.android.internal.R.id.search_plate);
|
||||
mWorkingSpinner = (AnimationDrawable) getContext().getResources().
|
||||
mWorkingSpinner = getContext().getResources().
|
||||
getDrawable(com.android.internal.R.drawable.search_spinner);
|
||||
|
||||
// attach listeners
|
||||
@@ -423,11 +422,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
if (working) {
|
||||
mSearchAutoComplete.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null, null, mWorkingSpinner, null);
|
||||
mWorkingSpinner.start();
|
||||
// mWorkingSpinner.start();
|
||||
} else {
|
||||
mSearchAutoComplete.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null, null, null, null);
|
||||
mWorkingSpinner.stop();
|
||||
// mWorkingSpinner.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,7 +600,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
mSearchPlate.getPaddingBottom());
|
||||
} else {
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
Drawable icon = null;
|
||||
Drawable icon;
|
||||
try {
|
||||
ActivityInfo info = pm.getActivityInfo(mLaunchComponent, 0);
|
||||
icon = pm.getApplicationIcon(info.applicationInfo);
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/* //device/apps/common/res/drawable/progress.xml
|
||||
**
|
||||
** Copyright 2007, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:drawable/progress_circular_background" />
|
||||
<item>
|
||||
<shape android:shape="ring"
|
||||
android:innerRadiusRatio="3.4"
|
||||
android:thicknessRatio="6.0">
|
||||
<gradient
|
||||
android:useLevel="true"
|
||||
android:type="sweep"
|
||||
android:startColor="#ff000000"
|
||||
android:endColor="#ffffffff" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<rotate
|
||||
android:pivotX="50%" android:pivotY="50%"
|
||||
android:fromDegrees="0" android:toDegrees="360"
|
||||
android:drawable="@android:drawable/progress_particle" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 2.3 KiB |
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/* //device/apps/common/res/drawable/progress.xml
|
||||
**
|
||||
** Copyright 2007, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:drawable="@android:drawable/progress_circular_background" />
|
||||
|
||||
<item><rotate
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:fromDegrees="0"
|
||||
android:toDegrees="360"
|
||||
android:drawable="@android:drawable/progress_circular_indeterminate" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB |
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2008, The Android Open Source Project
|
||||
** Copyright 2009, 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.
|
||||
@@ -17,20 +17,9 @@
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<animation-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:oneshot="false">
|
||||
<item android:drawable="@drawable/search_spinner_anim1" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim2" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim3" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim4" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim5" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim6" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim7" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim8" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim9" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim10" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim11" android:duration="150" />
|
||||
<item android:drawable="@drawable/search_spinner_anim12" android:duration="150" />
|
||||
</animation-list>
|
||||
|
||||
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/spinner_black_20"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:framesCount="12"
|
||||
android:frameDuration="100" />
|
||||
|
||||
|
Before Width: | Height: | Size: 529 B |
|
Before Width: | Height: | Size: 525 B |
|
Before Width: | Height: | Size: 527 B |
|
Before Width: | Height: | Size: 525 B |
|
Before Width: | Height: | Size: 522 B |
|
Before Width: | Height: | Size: 519 B |
|
Before Width: | Height: | Size: 521 B |
|
Before Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 517 B |
|
Before Width: | Height: | Size: 533 B |
|
Before Width: | Height: | Size: 534 B |
|
Before Width: | Height: | Size: 523 B After Width: | Height: | Size: 523 B |
@@ -2327,6 +2327,15 @@
|
||||
<attr name="drawable" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AnimatedRotateDrawable">
|
||||
<attr name="visible" />
|
||||
<attr name="frameDuration" format="integer" />
|
||||
<attr name="framesCount" format="integer" />
|
||||
<attr name="pivotX" />
|
||||
<attr name="pivotY" />
|
||||
<attr name="drawable" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="InsetDrawable">
|
||||
<attr name="visible" />
|
||||
<attr name="drawable" />
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.graphics.drawable;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.util.Log;
|
||||
import android.os.SystemClock;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public class AnimatedRotateDrawable extends Drawable implements Drawable.Callback, Runnable {
|
||||
private AnimatedRotateState mState;
|
||||
private boolean mMutated;
|
||||
private float mCurrentDegrees;
|
||||
private float mIncrement;
|
||||
|
||||
public AnimatedRotateDrawable() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private AnimatedRotateDrawable(AnimatedRotateState rotateState) {
|
||||
mState = new AnimatedRotateState(rotateState, this);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
final AnimatedRotateState state = mState;
|
||||
mIncrement = 360.0f / (float) state.mFramesCount;
|
||||
final Drawable drawable = state.mDrawable;
|
||||
if (drawable != null) {
|
||||
drawable.setFilterBitmap(true);
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
((BitmapDrawable) drawable).setAntiAlias(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas) {
|
||||
int saveCount = canvas.save();
|
||||
|
||||
final AnimatedRotateState st = mState;
|
||||
final Drawable drawable = st.mDrawable;
|
||||
final Rect bounds = drawable.getBounds();
|
||||
|
||||
int w = bounds.right - bounds.left;
|
||||
int h = bounds.bottom - bounds.top;
|
||||
|
||||
float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
|
||||
float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;
|
||||
|
||||
canvas.rotate(mCurrentDegrees, px, py);
|
||||
|
||||
drawable.draw(canvas);
|
||||
|
||||
canvas.restoreToCount(saveCount);
|
||||
|
||||
nextFrame();
|
||||
}
|
||||
|
||||
private void nextFrame() {
|
||||
unscheduleSelf(this);
|
||||
scheduleSelf(this, SystemClock.uptimeMillis() + mState.mFrameDuration);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// TODO: This should be computed in draw(Canvas), based on the amount
|
||||
// of time since the last frame drawn
|
||||
mCurrentDegrees += mIncrement;
|
||||
if (mCurrentDegrees > (360.0f - mIncrement)) {
|
||||
mCurrentDegrees = 0.0f;
|
||||
}
|
||||
nextFrame();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setVisible(boolean visible, boolean restart) {
|
||||
mState.mDrawable.setVisible(visible, restart);
|
||||
boolean changed = super.setVisible(visible, restart);
|
||||
if (visible) {
|
||||
if (changed || restart) {
|
||||
mCurrentDegrees = 0.0f;
|
||||
nextFrame();
|
||||
}
|
||||
} else {
|
||||
unscheduleSelf(this);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawable rotated by this RotateDrawable.
|
||||
*/
|
||||
public Drawable getDrawable() {
|
||||
return mState.mDrawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChangingConfigurations() {
|
||||
return super.getChangingConfigurations()
|
||||
| mState.mChangingConfigurations
|
||||
| mState.mDrawable.getChangingConfigurations();
|
||||
}
|
||||
|
||||
public void setAlpha(int alpha) {
|
||||
mState.mDrawable.setAlpha(alpha);
|
||||
}
|
||||
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
mState.mDrawable.setColorFilter(cf);
|
||||
}
|
||||
|
||||
public int getOpacity() {
|
||||
return mState.mDrawable.getOpacity();
|
||||
}
|
||||
|
||||
public void invalidateDrawable(Drawable who) {
|
||||
if (mCallback != null) {
|
||||
mCallback.invalidateDrawable(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleDrawable(Drawable who, Runnable what, long when) {
|
||||
if (mCallback != null) {
|
||||
mCallback.scheduleDrawable(this, what, when);
|
||||
}
|
||||
}
|
||||
|
||||
public void unscheduleDrawable(Drawable who, Runnable what) {
|
||||
if (mCallback != null) {
|
||||
mCallback.unscheduleDrawable(this, what);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPadding(Rect padding) {
|
||||
return mState.mDrawable.getPadding(padding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStateful() {
|
||||
return mState.mDrawable.isStateful();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
mState.mDrawable.setBounds(bounds.left, bounds.top, bounds.right, bounds.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return mState.mDrawable.getIntrinsicWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return mState.mDrawable.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantState getConstantState() {
|
||||
if (mState.canConstantState()) {
|
||||
mState.mChangingConfigurations = super.getChangingConfigurations();
|
||||
return mState;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
final TypedArray a = r.obtainAttributes(attrs, R.styleable.AnimatedRotateDrawable);
|
||||
|
||||
super.inflateWithAttributes(r, parser, a, R.styleable.AnimatedRotateDrawable_visible);
|
||||
|
||||
TypedValue tv = a.peekValue(R.styleable.AnimatedRotateDrawable_pivotX);
|
||||
final boolean pivotXRel = tv.type == TypedValue.TYPE_FRACTION;
|
||||
final float pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
|
||||
|
||||
tv = a.peekValue(R.styleable.AnimatedRotateDrawable_pivotY);
|
||||
final boolean pivotYRel = tv.type == TypedValue.TYPE_FRACTION;
|
||||
final float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
|
||||
|
||||
final int framesCount = a.getInt(R.styleable.AnimatedRotateDrawable_framesCount, 12);
|
||||
final int frameDuration = a.getInt(R.styleable.AnimatedRotateDrawable_frameDuration, 150);
|
||||
|
||||
final int res = a.getResourceId(R.styleable.AnimatedRotateDrawable_drawable, 0);
|
||||
Drawable drawable = null;
|
||||
if (res > 0) {
|
||||
drawable = r.getDrawable(res);
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
||||
int outerDepth = parser.getDepth();
|
||||
int type;
|
||||
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT &&
|
||||
(type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
|
||||
|
||||
if (type != XmlPullParser.START_TAG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((drawable = Drawable.createFromXmlInner(r, parser, attrs)) == null) {
|
||||
Log.w("drawable", "Bad element under <animated-rotate>: "
|
||||
+ parser .getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (drawable == null) {
|
||||
Log.w("drawable", "No drawable specified for <animated-rotate>");
|
||||
}
|
||||
|
||||
final AnimatedRotateState rotateState = mState;
|
||||
rotateState.mDrawable = drawable;
|
||||
rotateState.mPivotXRel = pivotXRel;
|
||||
rotateState.mPivotX = pivotX;
|
||||
rotateState.mPivotYRel = pivotYRel;
|
||||
rotateState.mPivotY = pivotY;
|
||||
rotateState.mFramesCount = framesCount;
|
||||
rotateState.mFrameDuration = frameDuration;
|
||||
|
||||
init();
|
||||
|
||||
if (drawable != null) {
|
||||
drawable.setCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable mutate() {
|
||||
if (!mMutated && super.mutate() == this) {
|
||||
mState.mDrawable.mutate();
|
||||
mMutated = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
final static class AnimatedRotateState extends Drawable.ConstantState {
|
||||
Drawable mDrawable;
|
||||
|
||||
int mChangingConfigurations;
|
||||
|
||||
boolean mPivotXRel;
|
||||
float mPivotX;
|
||||
boolean mPivotYRel;
|
||||
float mPivotY;
|
||||
int mFrameDuration;
|
||||
int mFramesCount;
|
||||
|
||||
private boolean mCanConstantState;
|
||||
private boolean mCheckedConstantState;
|
||||
|
||||
public AnimatedRotateState(AnimatedRotateState source, AnimatedRotateDrawable owner) {
|
||||
if (source != null) {
|
||||
mDrawable = source.mDrawable.getConstantState().newDrawable();
|
||||
mDrawable.setCallback(owner);
|
||||
mPivotXRel = source.mPivotXRel;
|
||||
mPivotX = source.mPivotX;
|
||||
mPivotYRel = source.mPivotYRel;
|
||||
mPivotY = source.mPivotY;
|
||||
mFramesCount = source.mFramesCount;
|
||||
mFrameDuration = source.mFrameDuration;
|
||||
mCanConstantState = mCheckedConstantState = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable newDrawable() {
|
||||
return new AnimatedRotateDrawable(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChangingConfigurations() {
|
||||
return mChangingConfigurations;
|
||||
}
|
||||
|
||||
public boolean canConstantState() {
|
||||
if (!mCheckedConstantState) {
|
||||
mCanConstantState = mDrawable.getConstantState() != null;
|
||||
mCheckedConstantState = true;
|
||||
}
|
||||
|
||||
return mCanConstantState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -745,6 +745,8 @@ public abstract class Drawable {
|
||||
drawable = new ClipDrawable();
|
||||
} else if (name.equals("rotate")) {
|
||||
drawable = new RotateDrawable();
|
||||
} else if (name.equals("animated-rotate")) {
|
||||
drawable = new AnimatedRotateDrawable();
|
||||
} else if (name.equals("animation-list")) {
|
||||
drawable = new AnimationDrawable();
|
||||
} else if (name.equals("inset")) {
|
||||
|
||||