Merge "Replace PNG-based seekbar thumb animation with AVD" into mnc-dev
@@ -86,10 +86,10 @@ public abstract class AbsSeekBar extends ProgressBar {
|
||||
public AbsSeekBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, com.android.internal.R.styleable.SeekBar, defStyleAttr, defStyleRes);
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.SeekBar, defStyleAttr, defStyleRes);
|
||||
|
||||
final Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb);
|
||||
final Drawable thumb = a.getDrawable(R.styleable.SeekBar_thumb);
|
||||
setThumb(thumb);
|
||||
|
||||
if (a.hasValue(R.styleable.SeekBar_thumbTintMode)) {
|
||||
@@ -103,18 +103,22 @@ public abstract class AbsSeekBar extends ProgressBar {
|
||||
mHasThumbTint = true;
|
||||
}
|
||||
|
||||
mSplitTrack = a.getBoolean(R.styleable.SeekBar_splitTrack, false);
|
||||
|
||||
// Guess thumb offset if thumb != null, but allow layout to override.
|
||||
final int thumbOffset = a.getDimensionPixelOffset(
|
||||
com.android.internal.R.styleable.SeekBar_thumbOffset, getThumbOffset());
|
||||
final int thumbOffset = a.getDimensionPixelOffset(R.styleable.SeekBar_thumbOffset, getThumbOffset());
|
||||
setThumbOffset(thumbOffset);
|
||||
|
||||
mSplitTrack = a.getBoolean(com.android.internal.R.styleable.SeekBar_splitTrack, false);
|
||||
final boolean useDisabledAlpha = a.getBoolean(R.styleable.SeekBar_useDisabledAlpha, true);
|
||||
a.recycle();
|
||||
|
||||
a = context.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.Theme, 0, 0);
|
||||
mDisabledAlpha = a.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f);
|
||||
a.recycle();
|
||||
if (useDisabledAlpha) {
|
||||
final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Theme, 0, 0);
|
||||
mDisabledAlpha = ta.getFloat(R.styleable.Theme_disabledAlpha, 0.5f);
|
||||
ta.recycle();
|
||||
} else {
|
||||
mDisabledAlpha = 1.0f;
|
||||
}
|
||||
|
||||
applyThumbTint();
|
||||
|
||||
@@ -360,7 +364,7 @@ public abstract class AbsSeekBar extends ProgressBar {
|
||||
super.drawableStateChanged();
|
||||
|
||||
final Drawable progressDrawable = getProgressDrawable();
|
||||
if (progressDrawable != null) {
|
||||
if (progressDrawable != null && mDisabledAlpha < 1.0f) {
|
||||
progressDrawable.setAlpha(isEnabled() ? NO_ALPHA : (int) (NO_ALPHA * mDisabledAlpha));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set
|
||||
xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<objectAnimator
|
||||
android:duration="133"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="1.5"
|
||||
android:valueTo="1.0"
|
||||
android:valueType="floatType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in" />
|
||||
<objectAnimator
|
||||
android:duration="133"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="1.5"
|
||||
android:valueTo="1.0"
|
||||
android:valueType="floatType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in" />
|
||||
</set>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set
|
||||
xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<objectAnimator
|
||||
android:duration="533"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="1.5"
|
||||
android:valueType="floatType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in" />
|
||||
<objectAnimator
|
||||
android:duration="533"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="1.5"
|
||||
android:valueType="floatType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in" />
|
||||
</set>
|
||||
|
Before Width: | Height: | Size: 615 B |
|
Before Width: | Height: | Size: 578 B |
|
Before Width: | Height: | Size: 562 B |
|
Before Width: | Height: | Size: 519 B |
|
Before Width: | Height: | Size: 527 B |
|
Before Width: | Height: | Size: 496 B |
|
Before Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 755 B |
|
Before Width: | Height: | Size: 498 B |
|
Before Width: | Height: | Size: 522 B |
|
Before Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 615 B |
|
Before Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 629 B |
|
Before Width: | Height: | Size: 498 B |
|
Before Width: | Height: | Size: 474 B |
|
Before Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 428 B |
|
Before Width: | Height: | Size: 437 B |
|
Before Width: | Height: | Size: 181 B |
|
Before Width: | Height: | Size: 456 B |
|
Before Width: | Height: | Size: 437 B |
|
Before Width: | Height: | Size: 451 B |
|
Before Width: | Height: | Size: 478 B |
|
Before Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 487 B |
|
Before Width: | Height: | Size: 498 B |
|
Before Width: | Height: | Size: 785 B |
|
Before Width: | Height: | Size: 706 B |
|
Before Width: | Height: | Size: 664 B |
|
Before Width: | Height: | Size: 617 B |
|
Before Width: | Height: | Size: 606 B |
|
Before Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 619 B |
|
Before Width: | Height: | Size: 628 B |
|
Before Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 792 B |
|
Before Width: | Height: | Size: 798 B |
|
Before Width: | Height: | Size: 802 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 989 B |
|
Before Width: | Height: | Size: 900 B |
|
Before Width: | Height: | Size: 808 B |
|
Before Width: | Height: | Size: 824 B |
|
Before Width: | Height: | Size: 803 B |
|
Before Width: | Height: | Size: 388 B |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 815 B |
|
Before Width: | Height: | Size: 847 B |
|
Before Width: | Height: | Size: 1004 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||
<!-- Copyright (C) 2015 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.
|
||||
@@ -14,61 +14,36 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true">
|
||||
<item android:state_enabled="false" android:state_pressed="true">
|
||||
<bitmap android:src="@drawable/scrubber_control_off_mtrl_alpha" android:gravity="center" android:tint="?attr/colorControlActivated" android:alpha="?attr/disabledAlpha" />
|
||||
</item>
|
||||
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false">
|
||||
<bitmap android:src="@drawable/scrubber_control_off_mtrl_alpha" android:gravity="center" android:tint="?attr/colorControlNormal" android:alpha="?attr/disabledAlpha" />
|
||||
<shape
|
||||
android:shape="ring"
|
||||
android:innerRadius="2dp"
|
||||
android:thickness="2dp"
|
||||
android:useLevel="false"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:opticalInsetLeft="3dp"
|
||||
android:opticalInsetRight="3dp">
|
||||
<solid
|
||||
android:color="#ff000000" />
|
||||
<size
|
||||
android:width="18dp"
|
||||
android:height="18dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true" android:id="@+id/pressed">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_005" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:id="@+id/not_pressed">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_000" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<transition android:fromId="@+id/not_pressed" android:toId="@+id/pressed">
|
||||
<animation-list>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_000" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_001" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_002" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_003" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_004" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_to_pressed_mtrl_005" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
</animation-list>
|
||||
</transition>
|
||||
<transition android:fromId="@+id/pressed" android:toId="@+id/not_pressed">
|
||||
<animation-list>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_from_pressed_mtrl_000" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_from_pressed_mtrl_001" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_from_pressed_mtrl_002" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_from_pressed_mtrl_003" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_from_pressed_mtrl_004" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
<item android:duration="15">
|
||||
<bitmap android:src="@drawable/scrubber_control_from_pressed_mtrl_005" android:gravity="center" android:tint="?attr/colorControlActivated" />
|
||||
</item>
|
||||
</animation-list>
|
||||
</transition>
|
||||
<item
|
||||
android:id="@+id/pressed"
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/seekbar_thumb_pressed_to_unpressed" />
|
||||
<item
|
||||
android:id="@+id/unpressed"
|
||||
android:drawable="@drawable/seekbar_thumb_unpressed_to_pressed" />
|
||||
<transition
|
||||
android:fromId="@+id/unpressed"
|
||||
android:toId="@+id/pressed"
|
||||
android:drawable="@drawable/seekbar_thumb_unpressed_to_pressed_animation" />
|
||||
<transition
|
||||
android:fromId="@+id/pressed"
|
||||
android:toId="@+id/unpressed"
|
||||
android:drawable="@drawable/seekbar_thumb_pressed_to_unpressed_animation" />
|
||||
</animated-selector>
|
||||
|
||||
38
core/res/res/drawable/seekbar_thumb_pressed_to_unpressed.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="seekbar_thumb_pressed_to_unpressed"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="18"
|
||||
android:tint="?attr/colorControlActivated"
|
||||
android:opticalInsetLeft="6dp"
|
||||
android:opticalInsetRight="6dp">
|
||||
<group
|
||||
android:name="thumb"
|
||||
android:translateX="9"
|
||||
android:translateY="9"
|
||||
android:scaleX="1.5"
|
||||
android:scaleY="1.5">
|
||||
<path
|
||||
android:name="thumb_path"
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M 0.0,-6.0 c 3.3137084988,0.0 6.0,2.6862915012 6.0,6.0 c 0.0,3.3137084988 -2.6862915012,6.0 -6.0,6.0 c -3.3137084988,0.0 -6.0,-2.6862915012 -6.0,-6.0 c 0.0,-3.3137084988 2.6862915012,-6.0 6.0,-6.0 Z" />
|
||||
</group>
|
||||
</vector>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/seekbar_thumb_pressed_to_unpressed" >
|
||||
<target
|
||||
android:name="thumb"
|
||||
android:animation="@anim/seekbar_thumb_pressed_to_unpressed_thumb_animation" />
|
||||
</animated-vector>
|
||||
36
core/res/res/drawable/seekbar_thumb_unpressed_to_pressed.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="seekbar_thumb_unpressed_to_pressed"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="18"
|
||||
android:tint="?attr/colorControlActivated"
|
||||
android:opticalInsetLeft="6dp"
|
||||
android:opticalInsetRight="6dp">
|
||||
<group
|
||||
android:name="thumb_0"
|
||||
android:translateX="9"
|
||||
android:translateY="9">
|
||||
<path
|
||||
android:name="thumb_path_0"
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M 0.0,-6.0 c 3.3137084988,0.0 6.0,2.6862915012 6.0,6.0 c 0.0,3.3137084988 -2.6862915012,6.0 -6.0,6.0 c -3.3137084988,0.0 -6.0,-2.6862915012 -6.0,-6.0 c 0.0,-3.3137084988 2.6862915012,-6.0 6.0,-6.0 Z" />
|
||||
</group>
|
||||
</vector>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/seekbar_thumb_unpressed_to_pressed" >
|
||||
<target
|
||||
android:name="thumb_0"
|
||||
android:animation="@anim/seekbar_thumb_unpressed_to_pressed_thumb_0_animation" />
|
||||
</animated-vector>
|
||||
@@ -20,7 +20,7 @@
|
||||
<shape android:shape="rectangle"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<size android:height="@dimen/seekbar_track_background_height_material" />
|
||||
<solid android:color="@color/white_disabled_material" />
|
||||
<solid android:color="#ff000000" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@id/secondaryProgress"
|
||||
|
||||
@@ -3909,6 +3909,11 @@
|
||||
<attr name="thumbOffset" format="dimension" />
|
||||
<!-- Whether to split the track and leave a gap for the thumb drawable. -->
|
||||
<attr name="splitTrack" format="boolean" />
|
||||
<!-- Whether to force the track's alpha to ?android:attr/disabledAlpha
|
||||
when disabled. This is required for Holo and Gingerbread, but
|
||||
should always be false for Material and beyond.
|
||||
@hide Developers shouldn't need to change this. -->
|
||||
<attr name="useDisabledAlpha" format="boolean" />
|
||||
<!-- Tint to apply to the button graphic. -->
|
||||
<attr name="thumbTint" format="color" />
|
||||
<!-- Blending mode used to apply the button graphic tint. -->
|
||||
@@ -5118,6 +5123,18 @@
|
||||
<!-- When a tint color is set, specifies its Porter-Duff blending mode. The
|
||||
default value is src_in, which treats the drawable as an alpha mask. -->
|
||||
<attr name="tintMode" />
|
||||
<!-- Left optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetLeft" />
|
||||
<!-- Top optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetTop" />
|
||||
<!-- Right optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetRight" />
|
||||
<!-- Bottom optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetBottom" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Used to specify the size of the shape for GradientDrawable. -->
|
||||
@@ -5579,6 +5596,18 @@
|
||||
<!-- The opacity of the whole vector drawable, as a value between 0
|
||||
(completely transparent) and 1 (completely opaque). -->
|
||||
<attr name="alpha" />
|
||||
<!-- Left optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetLeft" format="dimension" />
|
||||
<!-- Top optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetTop" format="dimension" />
|
||||
<!-- Right optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetRight" format="dimension" />
|
||||
<!-- Bottom optical inset.
|
||||
@hide Until optical insets are fully supported. -->
|
||||
<attr name="opticalInsetBottom" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Defines the group used in VectorDrawables. -->
|
||||
|
||||
@@ -721,6 +721,7 @@ please see styles_device_defaults.xml.
|
||||
<item name="indeterminateDrawable">@drawable/seekbar_track_material</item>
|
||||
<item name="thumb">@drawable/seekbar_thumb_material_anim</item>
|
||||
<item name="splitTrack">true</item>
|
||||
<item name="useDisabledAlpha">false</item>
|
||||
<item name="focusable">true</item>
|
||||
<item name="paddingStart">16dip</item>
|
||||
<item name="paddingEnd">16dip</item>
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.content.res.Resources.Theme;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
@@ -287,6 +288,12 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable {
|
||||
mAnimatedVectorState.mVectorDrawable.getOutline(outline);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Insets getOpticalInsets() {
|
||||
return mAnimatedVectorState.mVectorDrawable.getOpticalInsets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme)
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Paint;
|
||||
@@ -1107,6 +1108,16 @@ public class GradientDrawable extends Drawable {
|
||||
if (tint != null) {
|
||||
state.mTint = tint;
|
||||
}
|
||||
|
||||
final int insetLeft = a.getDimensionPixelSize(
|
||||
R.styleable.GradientDrawable_opticalInsetLeft, state.mOpticalInsets.left);
|
||||
final int insetTop = a.getDimensionPixelSize(
|
||||
R.styleable.GradientDrawable_opticalInsetTop, state.mOpticalInsets.top);
|
||||
final int insetRight = a.getDimensionPixelSize(
|
||||
R.styleable.GradientDrawable_opticalInsetRight, state.mOpticalInsets.right);
|
||||
final int insetBottom = a.getDimensionPixelSize(
|
||||
R.styleable.GradientDrawable_opticalInsetBottom, state.mOpticalInsets.bottom);
|
||||
state.mOpticalInsets = Insets.of(insetLeft, insetTop, insetRight, insetBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1469,6 +1480,12 @@ public class GradientDrawable extends Drawable {
|
||||
return mGradientState.mHeight;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Insets getOpticalInsets() {
|
||||
return mGradientState.mOpticalInsets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantState getConstantState() {
|
||||
mGradientState.mChangingConfigurations = getChangingConfigurations();
|
||||
@@ -1573,6 +1590,7 @@ public class GradientDrawable extends Drawable {
|
||||
public int mInnerRadius = -1;
|
||||
public int mThickness = -1;
|
||||
public boolean mDither = false;
|
||||
public Insets mOpticalInsets = Insets.NONE;
|
||||
|
||||
float mCenterX = 0.5f;
|
||||
float mCenterY = 0.5f;
|
||||
@@ -1631,6 +1649,7 @@ public class GradientDrawable extends Drawable {
|
||||
mInnerRadius = state.mInnerRadius;
|
||||
mThickness = state.mThickness;
|
||||
mDither = state.mDither;
|
||||
mOpticalInsets = state.mOpticalInsets;
|
||||
mCenterX = state.mCenterX;
|
||||
mCenterY = state.mCenterY;
|
||||
mGradientRadius = state.mGradientRadius;
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
@@ -361,6 +362,12 @@ public class VectorDrawable extends Drawable {
|
||||
return (int) mVectorState.mVPathRenderer.mBaseHeight;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Insets getOpticalInsets() {
|
||||
return mVectorState.mVPathRenderer.mOpticalInsets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyTheme() {
|
||||
return (mVectorState != null && mVectorState.canApplyTheme()) || super.canApplyTheme();
|
||||
@@ -524,6 +531,16 @@ public class VectorDrawable extends Drawable {
|
||||
"<vector> tag requires height > 0");
|
||||
}
|
||||
|
||||
final int insetLeft = a.getDimensionPixelSize(
|
||||
R.styleable.VectorDrawable_opticalInsetLeft, pathRenderer.mOpticalInsets.left);
|
||||
final int insetTop = a.getDimensionPixelSize(
|
||||
R.styleable.VectorDrawable_opticalInsetTop, pathRenderer.mOpticalInsets.top);
|
||||
final int insetRight = a.getDimensionPixelSize(
|
||||
R.styleable.VectorDrawable_opticalInsetRight, pathRenderer.mOpticalInsets.right);
|
||||
final int insetBottom = a.getDimensionPixelSize(
|
||||
R.styleable.VectorDrawable_opticalInsetBottom, pathRenderer.mOpticalInsets.bottom);
|
||||
pathRenderer.mOpticalInsets = Insets.of(insetLeft, insetTop, insetRight, insetBottom);
|
||||
|
||||
final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_alpha,
|
||||
pathRenderer.getAlpha());
|
||||
pathRenderer.setAlpha(alphaInFloat);
|
||||
@@ -821,6 +838,7 @@ public class VectorDrawable extends Drawable {
|
||||
float mBaseHeight = 0;
|
||||
float mViewportWidth = 0;
|
||||
float mViewportHeight = 0;
|
||||
Insets mOpticalInsets = Insets.NONE;
|
||||
int mRootAlpha = 0xFF;
|
||||
String mRootName = null;
|
||||
|
||||
@@ -859,6 +877,7 @@ public class VectorDrawable extends Drawable {
|
||||
mBaseHeight = copy.mBaseHeight;
|
||||
mViewportWidth = copy.mViewportWidth;
|
||||
mViewportHeight = copy.mViewportHeight;
|
||||
mOpticalInsets = copy.mOpticalInsets;
|
||||
mChangingConfigurations = copy.mChangingConfigurations;
|
||||
mRootAlpha = copy.mRootAlpha;
|
||||
mRootName = copy.mRootName;
|
||||
|
||||