Loading core/java/android/widget/Switch.java +35 −29 Original line number Diff line number Diff line Loading @@ -511,15 +511,18 @@ public class Switch extends CompoundButton { if (mOnLayout == null) { mOnLayout = makeLayout(mTextOn); } if (mOffLayout == null) { mOffLayout = makeLayout(mTextOff); } mTrackDrawable.getPadding(mTempRect); final int maxTextWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth()); final int switchWidth = Math.max(mSwitchMinWidth, maxTextWidth * 2 + mThumbTextPadding * 4 + mTempRect.left + mTempRect.right); final int switchHeight = mTrackDrawable.getIntrinsicHeight(); final int switchHeight = Math.max(mTrackDrawable.getIntrinsicHeight(), mThumbDrawable.getIntrinsicHeight()); mThumbWidth = maxTextWidth + mThumbTextPadding * 2; Loading Loading @@ -772,48 +775,51 @@ public class Switch extends CompoundButton { protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Draw the switch int switchLeft = mSwitchLeft; int switchTop = mSwitchTop; int switchRight = mSwitchRight; int switchBottom = mSwitchBottom; mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom); mTrackDrawable.draw(canvas); final Rect tempRect = mTempRect; final Drawable trackDrawable = mTrackDrawable; final Drawable thumbDrawable = mThumbDrawable; canvas.save(); mTrackDrawable.getPadding(mTempRect); int switchInnerLeft = switchLeft + mTempRect.left; int switchInnerTop = switchTop + mTempRect.top; int switchInnerRight = switchRight - mTempRect.right; int switchInnerBottom = switchBottom - mTempRect.bottom; // Draw the switch final int switchLeft = mSwitchLeft; final int switchTop = mSwitchTop; final int switchRight = mSwitchRight; final int switchBottom = mSwitchBottom; trackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom); trackDrawable.draw(canvas); final int saveCount = canvas.save(); trackDrawable.getPadding(tempRect); final int switchInnerLeft = switchLeft + tempRect.left; final int switchInnerTop = switchTop + tempRect.top; final int switchInnerRight = switchRight - tempRect.right; final int switchInnerBottom = switchBottom - tempRect.bottom; canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom); // Relies on mTempRect, MUST be called first! final int thumbPos = getThumbOffset(); mThumbDrawable.getPadding(mTempRect); int thumbLeft = switchInnerLeft - mTempRect.left + thumbPos; int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right; mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); mThumbDrawable.draw(canvas); thumbDrawable.getPadding(tempRect); int thumbLeft = switchInnerLeft - tempRect.left + thumbPos; int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + tempRect.right; thumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); thumbDrawable.draw(canvas); // mTextColors should not be null, but just in case final int drawableState[] = getDrawableState(); if (mTextColors != null) { mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(), mTextColors.getDefaultColor())); mTextPaint.setColor(mTextColors.getColorForState(drawableState, 0)); } mTextPaint.drawableState = getDrawableState(); mTextPaint.drawableState = drawableState; Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; final Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; if (switchText != null) { canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2); final int left = (thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2; final int top = (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2; canvas.translate(left, top); switchText.draw(canvas); } canvas.restore(); canvas.restoreToCount(saveCount); } @Override Loading core/res/res/drawable-xxhdpi/btn_star_qntm_alpha.png 0 → 100644 +913 B Loading image diff... core/res/res/drawable-xxhdpi/expander_close_qntm_alpha.9.png 0 → 100644 +473 B Loading image diff... core/res/res/drawable-xxhdpi/expander_open_qntm_alpha.9.png 0 → 100644 +519 B Loading image diff... core/res/res/drawable-xxhdpi/ic_ab_back_quantum_am_alpha.png→core/res/res/drawable-xxhdpi/ic_ab_back_qntm_am_alpha.png (358 B) File moved. View file Loading
core/java/android/widget/Switch.java +35 −29 Original line number Diff line number Diff line Loading @@ -511,15 +511,18 @@ public class Switch extends CompoundButton { if (mOnLayout == null) { mOnLayout = makeLayout(mTextOn); } if (mOffLayout == null) { mOffLayout = makeLayout(mTextOff); } mTrackDrawable.getPadding(mTempRect); final int maxTextWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth()); final int switchWidth = Math.max(mSwitchMinWidth, maxTextWidth * 2 + mThumbTextPadding * 4 + mTempRect.left + mTempRect.right); final int switchHeight = mTrackDrawable.getIntrinsicHeight(); final int switchHeight = Math.max(mTrackDrawable.getIntrinsicHeight(), mThumbDrawable.getIntrinsicHeight()); mThumbWidth = maxTextWidth + mThumbTextPadding * 2; Loading Loading @@ -772,48 +775,51 @@ public class Switch extends CompoundButton { protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Draw the switch int switchLeft = mSwitchLeft; int switchTop = mSwitchTop; int switchRight = mSwitchRight; int switchBottom = mSwitchBottom; mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom); mTrackDrawable.draw(canvas); final Rect tempRect = mTempRect; final Drawable trackDrawable = mTrackDrawable; final Drawable thumbDrawable = mThumbDrawable; canvas.save(); mTrackDrawable.getPadding(mTempRect); int switchInnerLeft = switchLeft + mTempRect.left; int switchInnerTop = switchTop + mTempRect.top; int switchInnerRight = switchRight - mTempRect.right; int switchInnerBottom = switchBottom - mTempRect.bottom; // Draw the switch final int switchLeft = mSwitchLeft; final int switchTop = mSwitchTop; final int switchRight = mSwitchRight; final int switchBottom = mSwitchBottom; trackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom); trackDrawable.draw(canvas); final int saveCount = canvas.save(); trackDrawable.getPadding(tempRect); final int switchInnerLeft = switchLeft + tempRect.left; final int switchInnerTop = switchTop + tempRect.top; final int switchInnerRight = switchRight - tempRect.right; final int switchInnerBottom = switchBottom - tempRect.bottom; canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom); // Relies on mTempRect, MUST be called first! final int thumbPos = getThumbOffset(); mThumbDrawable.getPadding(mTempRect); int thumbLeft = switchInnerLeft - mTempRect.left + thumbPos; int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right; mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); mThumbDrawable.draw(canvas); thumbDrawable.getPadding(tempRect); int thumbLeft = switchInnerLeft - tempRect.left + thumbPos; int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + tempRect.right; thumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); thumbDrawable.draw(canvas); // mTextColors should not be null, but just in case final int drawableState[] = getDrawableState(); if (mTextColors != null) { mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(), mTextColors.getDefaultColor())); mTextPaint.setColor(mTextColors.getColorForState(drawableState, 0)); } mTextPaint.drawableState = getDrawableState(); mTextPaint.drawableState = drawableState; Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; final Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; if (switchText != null) { canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2); final int left = (thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2; final int top = (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2; canvas.translate(left, top); switchText.draw(canvas); } canvas.restore(); canvas.restoreToCount(saveCount); } @Override Loading
core/res/res/drawable-xxhdpi/ic_ab_back_quantum_am_alpha.png→core/res/res/drawable-xxhdpi/ic_ab_back_qntm_am_alpha.png (358 B) File moved. View file