Merge "Add setLandscape() method to ButtonInterface" into nyc-mr1-dev

This commit is contained in:
Annie Chin
2016-07-13 23:35:08 +00:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 4 deletions

View File

@@ -49,6 +49,13 @@ public class ButtonDispatcher {
mViews.clear();
}
void addView(View view, boolean landscape) {
addView(view);
if (view instanceof ButtonInterface) {
((ButtonInterface) view).setLandscape(landscape);
}
}
void addView(View view) {
mViews.add(view);
view.setOnClickListener(mClickListener);
@@ -178,5 +185,7 @@ public class ButtonDispatcher {
void setImageDrawable(@Nullable Drawable drawable);
void abortCurrentGesture();
void setLandscape(boolean landscape);
}
}

View File

@@ -280,7 +280,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
params.width = (int) (params.width * size);
}
parent.addView(v);
addToDispatchers(v);
addToDispatchers(v, landscape);
View lastView = landscape ? mLastRot90 : mLastRot0;
if (lastView != null) {
v.setAccessibilityTraversalAfter(lastView.getId());
@@ -327,16 +327,16 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
return buttonSpec.substring(0, buttonSpec.indexOf(SIZE_MOD_START));
}
private void addToDispatchers(View v) {
private void addToDispatchers(View v, boolean landscape) {
if (mButtonDispatchers != null) {
final int indexOfKey = mButtonDispatchers.indexOfKey(v.getId());
if (indexOfKey >= 0) {
mButtonDispatchers.valueAt(indexOfKey).addView(v);
mButtonDispatchers.valueAt(indexOfKey).addView(v, landscape);
} else if (v instanceof ViewGroup) {
final ViewGroup viewGroup = (ViewGroup)v;
final int N = viewGroup.getChildCount();
for (int i = 0; i < N; i++) {
addToDispatchers(viewGroup.getChildAt(i));
addToDispatchers(viewGroup.getChildAt(i), landscape);
}
}
}

View File

@@ -265,6 +265,11 @@ public class KeyButtonView extends ImageView implements ButtonDispatcher.ButtonI
public void setImageDrawable(@Nullable Drawable drawable) {
super.setImageDrawable(drawable);
}
@Override
public void setLandscape(boolean landscape) {
//no op
}
}