Merge changes from topics "presubmit-am-2762060c253b4c4db3c4db805c2e5b6e", "presubmit-am-3d21c3ff86734d9ba296b2671441db03", "presubmit-am-681cf6c0b8f240f59da390f09a7ef2ed", "presubmit-am-82dac8e1bb1747dcb76dbda3f29e55c9", "presubmit-am-c01cdff8b5e44804ab8a37c5cdc295d5" into tm-dev

* changes:
  Fix remaining lint erros under a.i.navigationbar
  Fix camel-case-related lint erros under a.i.navigationbar
  Fix whitespace-related lint erros under a.i.navigationbar
  Fix modifier-related lint erros under a.i.navigationbar
  Fix Javadoc-related lint erros under a.i.navigationbar
This commit is contained in:
Yohei Yukawa
2022-03-09 18:43:54 +00:00
committed by Android (Google) Code Review
9 changed files with 97 additions and 92 deletions

View File

@@ -67,7 +67,7 @@ final class ButtonDispatcher {
}
};
public ButtonDispatcher(int id) {
ButtonDispatcher(int id) {
mId = id;
}
@@ -125,8 +125,8 @@ final class ButtonDispatcher {
public void setImageDrawable(KeyButtonDrawable drawable) {
mImageDrawable = drawable;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
if (mViews.get(i) instanceof ButtonInterface) {
((ButtonInterface) mViews.get(i)).setImageDrawable(mImageDrawable);
}
@@ -143,8 +143,8 @@ final class ButtonDispatcher {
}
mVisibility = visibility;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setVisibility(mVisibility);
}
}
@@ -188,8 +188,8 @@ final class ButtonDispatcher {
int nextAlpha = (int) (alpha * 255);
if (prevAlpha != nextAlpha) {
mAlpha = nextAlpha / 255f;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setAlpha(mAlpha);
}
}
@@ -198,8 +198,8 @@ final class ButtonDispatcher {
public void setDarkIntensity(float darkIntensity) {
mDarkIntensity = darkIntensity;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
if (mViews.get(i) instanceof ButtonInterface) {
((ButtonInterface) mViews.get(i)).setDarkIntensity(darkIntensity);
}
@@ -208,8 +208,8 @@ final class ButtonDispatcher {
public void setDelayTouchFeedback(boolean delay) {
mDelayTouchFeedback = delay;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
if (mViews.get(i) instanceof ButtonInterface) {
((ButtonInterface) mViews.get(i)).setDelayTouchFeedback(delay);
}
@@ -218,55 +218,55 @@ final class ButtonDispatcher {
public void setOnClickListener(View.OnClickListener clickListener) {
mClickListener = clickListener;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setOnClickListener(mClickListener);
}
}
public void setOnTouchListener(View.OnTouchListener touchListener) {
mTouchListener = touchListener;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setOnTouchListener(mTouchListener);
}
}
public void setLongClickable(boolean isLongClickable) {
mLongClickable = isLongClickable;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setLongClickable(mLongClickable);
}
}
public void setOnLongClickListener(View.OnLongClickListener longClickListener) {
mLongClickListener = longClickListener;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setOnLongClickListener(mLongClickListener);
}
}
public void setOnHoverListener(View.OnHoverListener hoverListener) {
mOnHoverListener = hoverListener;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setOnHoverListener(mOnHoverListener);
}
}
public void setAccessibilityDelegate(AccessibilityDelegate delegate) {
mAccessibilityDelegate = delegate;
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
mViews.get(i).setAccessibilityDelegate(delegate);
}
}
public void setTranslation(int x, int y, int z) {
final int N = mViews.size();
for (int i = 0; i < N; i++) {
final int numViews = mViews.size();
for (int i = 0; i < numViews; i++) {
final View view = mViews.get(i);
view.setTranslationX(x);
view.setTranslationY(y);

View File

@@ -82,7 +82,7 @@ final class DeadZone {
}
};
public DeadZone(NavigationBarView view) {
DeadZone(NavigationBarView view) {
mNavigationBarView = view;
onConfigurationChanged(Surface.ROTATION_0);
}
@@ -92,13 +92,15 @@ final class DeadZone {
}
private float getSize(long now) {
if (mSizeMax == 0)
if (mSizeMax == 0) {
return 0;
}
long dt = (now - mLastPokeTime);
if (dt > mHold + mDecay)
if (dt > mHold + mDecay) {
return mSizeMin;
if (dt < mHold)
} else if (dt < mHold) {
return mSizeMax;
}
return (int) lerp(mSizeMax, mSizeMin, (float) (dt - mHold) / mDecay);
}
@@ -177,8 +179,9 @@ final class DeadZone {
private void poke(MotionEvent event) {
mLastPokeTime = event.getEventTime();
if (DEBUG)
if (DEBUG) {
Log.v(TAG, "poked! size=" + getSize(mLastPokeTime));
}
if (mShouldFlash) mNavigationBarView.postInvalidate();
}

View File

@@ -54,30 +54,30 @@ import android.view.View;
final class KeyButtonDrawable extends Drawable {
public static final FloatProperty<KeyButtonDrawable> KEY_DRAWABLE_ROTATE =
new FloatProperty<KeyButtonDrawable>("KeyButtonRotation") {
@Override
public void setValue(KeyButtonDrawable drawable, float degree) {
drawable.setRotation(degree);
}
new FloatProperty<KeyButtonDrawable>("KeyButtonRotation") {
@Override
public void setValue(KeyButtonDrawable drawable, float degree) {
drawable.setRotation(degree);
}
@Override
public Float get(KeyButtonDrawable drawable) {
return drawable.getRotation();
}
};
@Override
public Float get(KeyButtonDrawable drawable) {
return drawable.getRotation();
}
};
public static final FloatProperty<KeyButtonDrawable> KEY_DRAWABLE_TRANSLATE_Y =
new FloatProperty<KeyButtonDrawable>("KeyButtonTranslateY") {
@Override
public void setValue(KeyButtonDrawable drawable, float y) {
drawable.setTranslationY(y);
}
new FloatProperty<KeyButtonDrawable>("KeyButtonTranslateY") {
@Override
public void setValue(KeyButtonDrawable drawable, float y) {
drawable.setTranslationY(y);
}
@Override
public Float get(KeyButtonDrawable drawable) {
return drawable.getTranslationY();
}
};
@Override
public Float get(KeyButtonDrawable drawable) {
return drawable.getTranslationY();
}
};
private final Paint mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
@@ -100,7 +100,7 @@ final class KeyButtonDrawable extends Drawable {
}
};
public KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor,
KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor,
boolean horizontalFlip, Color ovalBackgroundColor) {
this(d, new ShadowDrawableState(lightColor, darkColor,
d instanceof AnimatedVectorDrawable, horizontalFlip, ovalBackgroundColor));
@@ -433,8 +433,8 @@ final class KeyButtonDrawable extends Drawable {
final boolean mSupportsAnimation;
final Color mOvalBackgroundColor;
public ShadowDrawableState(@ColorInt int lightColor, @ColorInt int darkColor,
boolean animated, boolean horizontalFlip, Color ovalBackgroundColor) {
ShadowDrawableState(@ColorInt int lightColor, @ColorInt int darkColor, boolean animated,
boolean horizontalFlip, Color ovalBackgroundColor) {
mLightColor = lightColor;
mDarkColor = darkColor;
mSupportsAnimation = animated;

View File

@@ -90,7 +90,7 @@ final class KeyButtonRipple extends Drawable {
private Type mType = Type.ROUNDED_RECT;
public KeyButtonRipple(Context ctx, View targetView, @DimenRes int maxWidthResource) {
KeyButtonRipple(Context ctx, View targetView, @DimenRes int maxWidthResource) {
mMaxWidthResource = maxWidthResource;
mMaxWidth = ctx.getResources().getDimensionPixelSize(maxWidthResource);
mTargetView = targetView;
@@ -126,7 +126,7 @@ final class KeyButtonRipple extends Drawable {
private void drawSoftware(Canvas canvas) {
if (mGlowAlpha > 0f) {
final Paint p = getRipplePaint();
p.setAlpha((int)(mGlowAlpha * 255f));
p.setAlpha((int) (mGlowAlpha * 255f));
final float w = getBounds().width();
final float h = getBounds().height();
@@ -412,7 +412,7 @@ final class KeyButtonRipple extends Drawable {
mDrawingHardwareGlow = true;
setExtendStart(CanvasProperty.createFloat(getExtendSize() / 2));
final RenderNodeAnimator startAnim = new RenderNodeAnimator(getExtendStart(),
getExtendSize()/2 - GLOW_MAX_SCALE_FACTOR * getRippleSize()/2);
getExtendSize() / 2 - GLOW_MAX_SCALE_FACTOR * getRippleSize() / 2);
startAnim.setDuration(ANIMATION_DURATION_SCALE);
startAnim.setInterpolator(mInterpolator);
startAnim.addListener(mAnimatorListener);
@@ -420,7 +420,7 @@ final class KeyButtonRipple extends Drawable {
setExtendEnd(CanvasProperty.createFloat(getExtendSize() / 2));
final RenderNodeAnimator endAnim = new RenderNodeAnimator(getExtendEnd(),
getExtendSize()/2 + GLOW_MAX_SCALE_FACTOR * getRippleSize()/2);
getExtendSize() / 2 + GLOW_MAX_SCALE_FACTOR * getRippleSize() / 2);
endAnim.setDuration(ANIMATION_DURATION_SCALE);
endAnim.setInterpolator(mInterpolator);
endAnim.addListener(mAnimatorListener);
@@ -430,13 +430,13 @@ final class KeyButtonRipple extends Drawable {
if (isHorizontal()) {
mTopProp = CanvasProperty.createFloat(0f);
mBottomProp = CanvasProperty.createFloat(getBounds().height());
mRxProp = CanvasProperty.createFloat(getBounds().height()/2);
mRyProp = CanvasProperty.createFloat(getBounds().height()/2);
mRxProp = CanvasProperty.createFloat(getBounds().height() / 2);
mRyProp = CanvasProperty.createFloat(getBounds().height() / 2);
} else {
mLeftProp = CanvasProperty.createFloat(0f);
mRightProp = CanvasProperty.createFloat(getBounds().width());
mRxProp = CanvasProperty.createFloat(getBounds().width()/2);
mRyProp = CanvasProperty.createFloat(getBounds().width()/2);
mRxProp = CanvasProperty.createFloat(getBounds().width() / 2);
mRyProp = CanvasProperty.createFloat(getBounds().width() / 2);
}
mGlowScale = GLOW_MAX_SCALE_FACTOR;

View File

@@ -200,8 +200,8 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
break;
case MotionEvent.ACTION_MOVE:
x = (int)ev.getRawX();
y = (int)ev.getRawY();
x = (int) ev.getRawX();
y = (int) ev.getRawY();
float slop = getQuickStepTouchSlopPx(getContext());
if (Math.abs(x - mTouchDownX) > slop || Math.abs(y - mTouchDownY) > slop) {
@@ -272,12 +272,13 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
: KeyButtonRipple.Type.ROUNDED_RECT);
}
@Override
public void playSoundEffect(int soundConstant) {
if (!mPlaySounds) return;
mAudioManager.playSoundEffect(soundConstant);
}
public void sendEvent(int action, int flags) {
private void sendEvent(int action, int flags) {
sendEvent(action, flags, SystemClock.uptimeMillis());
}
@@ -309,8 +310,8 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
switch (action) {
case KeyEvent.ACTION_DOWN:
handled = ims.onKeyDown(ev.getKeyCode(), ev);
mTracking = handled && ev.getRepeatCount() == 0 &&
(ev.getFlags() & KeyEvent.FLAG_START_TRACKING) != 0;
mTracking = handled && ev.getRepeatCount() == 0
&& (ev.getFlags() & KeyEvent.FLAG_START_TRACKING) != 0;
break;
case KeyEvent.ACTION_UP:
handled = ims.onKeyUp(ev.getKeyCode(), ev);

View File

@@ -59,4 +59,4 @@ public final class NavigationBarFrame extends FrameLayout {
}
return super.dispatchTouchEvent(event);
}
}
}

View File

@@ -121,7 +121,7 @@ public final class NavigationBarInflaterView extends FrameLayout {
return CONFIG_NAV_BAR_LAYOUT_HANDLE;
}
public void setButtonDispatchers(SparseArray<ButtonDispatcher> buttonDispatchers) {
void setButtonDispatchers(SparseArray<ButtonDispatcher> buttonDispatchers) {
mButtonDispatchers = buttonDispatchers;
for (int i = 0; i < buttonDispatchers.size(); i++) {
initiallyFill(buttonDispatchers.valueAt(i));
@@ -376,7 +376,7 @@ public final class NavigationBarInflaterView extends FrameLayout {
}
*/
public static String extractSize(String buttonSpec) {
private static String extractSize(String buttonSpec) {
if (!buttonSpec.contains(SIZE_MOD_START)) {
return null;
}
@@ -384,7 +384,7 @@ public final class NavigationBarInflaterView extends FrameLayout {
return buttonSpec.substring(sizeStart + 1, buttonSpec.indexOf(SIZE_MOD_END));
}
public static String extractButton(String buttonSpec) {
private static String extractButton(String buttonSpec) {
if (!buttonSpec.contains(SIZE_MOD_START)) {
return buttonSpec;
}
@@ -398,9 +398,9 @@ public final class NavigationBarInflaterView extends FrameLayout {
mButtonDispatchers.valueAt(indexOfKey).addView(v);
}
if (v instanceof ViewGroup) {
final ViewGroup viewGroup = (ViewGroup)v;
final int N = viewGroup.getChildCount();
for (int i = 0; i < N; i++) {
final ViewGroup viewGroup = (ViewGroup) v;
final int numChildViews = viewGroup.getChildCount();
for (int i = 0; i < numChildViews; i++) {
addToDispatchers(viewGroup.getChildAt(i));
}
}

View File

@@ -48,8 +48,8 @@ import java.util.function.Consumer;
* @hide
*/
public final class NavigationBarView extends FrameLayout {
final static boolean DEBUG = false;
final static String TAG = "NavBarView";
private static final boolean DEBUG = false;
private static final String TAG = "NavBarView";
// Copied from com.android.systemui.animation.Interpolators#FAST_OUT_SLOW_IN
private static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
@@ -139,7 +139,7 @@ public final class NavigationBarView extends FrameLayout {
}
/**
* Applies {@param consumer} to each of the nav bar views.
* Applies {@code consumer} to each of the nav bar views.
*/
public void forEachView(Consumer<View> consumer) {
if (mHorizontal != null) {
@@ -181,7 +181,7 @@ public final class NavigationBarView extends FrameLayout {
}
}
public KeyButtonDrawable getBackDrawable() {
private KeyButtonDrawable getBackDrawable() {
KeyButtonDrawable drawable = getDrawable(com.android.internal.R.drawable.ic_ime_nav_back);
orientBackButton(drawable);
return drawable;
@@ -211,7 +211,7 @@ public final class NavigationBarView extends FrameLayout {
// Animate the back button's rotation to the new degrees and only in portrait move up the
// back button to line up with the other buttons
float targetY = useAltBack
? - dpToPx(NAVBAR_BACK_BUTTON_IME_OFFSET, getResources())
? -dpToPx(NAVBAR_BACK_BUTTON_IME_OFFSET, getResources())
: 0;
ObjectAnimator navBarAnimator = ObjectAnimator.ofPropertyValuesHolder(drawable,
PropertyValuesHolder.ofFloat(KeyButtonDrawable.KEY_DRAWABLE_ROTATE, degrees),
@@ -233,6 +233,11 @@ public final class NavigationBarView extends FrameLayout {
super.setLayoutDirection(layoutDirection);
}
/**
* Updates the navigation icons based on {@code hints}.
*
* @param hints bit flags defined in {@link StatusBarManager}.
*/
public void setNavigationIconHints(int hints) {
if (hints == mNavigationIconHints) return;
final boolean newBackAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
@@ -250,15 +255,7 @@ public final class NavigationBarView extends FrameLayout {
updateNavButtonIcons();
}
public void setDisabledFlags(int disabledFlags) {
if (mDisabledFlags == disabledFlags) return;
mDisabledFlags = disabledFlags;
updateNavButtonIcons();
}
public void updateNavButtonIcons() {
private void updateNavButtonIcons() {
// We have to replace or restore the back and home button icons when exiting or entering
// carmode, respectively. Recents are not available in CarMode in nav bar so change
// to recent icon is not required.
@@ -319,7 +316,7 @@ public final class NavigationBarView extends FrameLayout {
mHorizontal.setVisibility(View.GONE);
}
public void reorient() {
private void reorient() {
updateCurrentView();
final android.inputmethodservice.navigationbar.NavigationBarFrame frame =
@@ -372,6 +369,11 @@ public final class NavigationBarView extends FrameLayout {
}
}
/**
* Updates the dark intensity.
*
* @param intensity The intensity of darkness from {@code 0.0f} to {@code 1.0f}.
*/
public void setDarkIntensity(@FloatRange(from = 0.0f, to = 1.0f) float intensity) {
for (int i = 0; i < mButtonDispatchers.size(); ++i) {
mButtonDispatchers.valueAt(i).setDarkIntensity(intensity);

View File

@@ -30,9 +30,8 @@ import java.util.ArrayList;
/**
* Automatically reverses the order of children as they are added.
* Also reverse the width and height values of layout params
* @hide
*/
public class ReverseLinearLayout extends LinearLayout {
class ReverseLinearLayout extends LinearLayout {
/** If true, the layout is reversed vs. a regular linear layout */
private boolean mIsLayoutReverse;
@@ -40,7 +39,7 @@ public class ReverseLinearLayout extends LinearLayout {
/** If true, the layout is opposite to it's natural reversity from the layout direction */
private boolean mIsAlternativeOrder;
public ReverseLinearLayout(Context context, @Nullable AttributeSet attrs) {
ReverseLinearLayout(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
@@ -129,7 +128,7 @@ public class ReverseLinearLayout extends LinearLayout {
public static class ReverseRelativeLayout extends RelativeLayout implements Reversible {
public ReverseRelativeLayout(Context context) {
ReverseRelativeLayout(Context context) {
super(context);
}