Merge "Remove lights out views from nav bar" into nyc-dev

am: 5cac50c3c6

* commit '5cac50c3c658529b703ff1fdf0940ad0dc7e87c7':
  Remove lights out views from nav bar
This commit is contained in:
Jason Monk
2016-02-18 18:38:25 +00:00
committed by android-build-merger
6 changed files with 9 additions and 136 deletions

View File

@@ -41,26 +41,6 @@
</FrameLayout>
<FrameLayout
android:id="@+id/lights_out"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/ends_group_lightsout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/center_group_lightsout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" />
</FrameLayout>
<com.android.systemui.statusbar.policy.DeadZone
android:id="@+id/deadzone"
android:layout_height="match_parent"

View File

@@ -42,26 +42,6 @@
</FrameLayout>
<FrameLayout
android:id="@+id/lights_out"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/ends_group_lightsout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/center_group_lightsout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" />
</FrameLayout>
<com.android.systemui.statusbar.policy.DeadZone
android:id="@+id/deadzone"
android:layout_height="match_parent"

View File

@@ -42,26 +42,6 @@
</FrameLayout>
<FrameLayout
android:id="@+id/lights_out"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.android.systemui.statusbar.phone.ReverseLinearLayout
android:id="@+id/ends_group_lightsout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
<com.android.systemui.statusbar.phone.ReverseLinearLayout
android:id="@+id/center_group_lightsout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" />
</FrameLayout>
<com.android.systemui.statusbar.policy.DeadZone
android:id="@+id/deadzone"
android:layout_height="match_parent"

View File

@@ -163,68 +163,29 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
String[] start = sets[0].split(BUTTON_SEPARATOR);
String[] center = sets[1].split(BUTTON_SEPARATOR);
String[] end = sets[2].split(BUTTON_SEPARATOR);
inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group),
(ViewGroup) mRot0.findViewById(R.id.ends_group_lightsout), false);
inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group),
(ViewGroup) mRot90.findViewById(R.id.ends_group_lightsout), true);
inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group), false);
inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group), true);
inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group),
(ViewGroup) mRot0.findViewById(R.id.center_group_lightsout), false);
inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group),
(ViewGroup) mRot90.findViewById(R.id.center_group_lightsout), true);
inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group), false);
inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group), true);
addGravitySpacer((LinearLayout) mRot0.findViewById(R.id.ends_group));
addGravitySpacer((LinearLayout) mRot90.findViewById(R.id.ends_group));
inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group),
(ViewGroup) mRot0.findViewById(R.id.ends_group_lightsout), false);
inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group),
(ViewGroup) mRot90.findViewById(R.id.ends_group_lightsout), true);
inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group), false);
inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group), true);
}
private void addGravitySpacer(LinearLayout layout) {
layout.addView(new Space(mContext), new LinearLayout.LayoutParams(0, 0, 1));
}
private void inflateButtons(String[] buttons, ViewGroup parent, ViewGroup lightsOutParent,
boolean landscape) {
private void inflateButtons(String[] buttons, ViewGroup parent, boolean landscape) {
for (int i = 0; i < buttons.length; i++) {
copyToLightsout(inflateButton(buttons[i], parent, landscape), lightsOutParent);
inflateButton(buttons[i], parent, landscape);
}
}
private void copyToLightsout(View view, ViewGroup lightsOutParent) {
if (view == null) return;
if (view instanceof FrameLayout) {
// The only ViewGroup we support in here is a FrameLayout, so copy those manually.
FrameLayout original = (FrameLayout) view;
FrameLayout layout = new FrameLayout(view.getContext());
for (int i = 0; i < original.getChildCount(); i++) {
copyToLightsout(original.getChildAt(i), layout);
}
lightsOutParent.addView(layout, copy(view.getLayoutParams()));
} else if (view instanceof Space) {
lightsOutParent.addView(new Space(view.getContext()), copy(view.getLayoutParams()));
} else {
lightsOutParent.addView(generateLightsOutView(view), copy(view.getLayoutParams()));
}
}
private View generateLightsOutView(View view) {
ImageView imageView = new ImageView(view.getContext());
// Copy everything we can about the original view.
imageView.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(),
view.getPaddingBottom());
imageView.setContentDescription(view.getContentDescription());
imageView.setId(view.getId());
// Only home gets a big dot, everything else will be little.
imageView.setImageResource(view.getId() == R.id.home
? R.drawable.ic_sysbar_lights_out_dot_large
: R.drawable.ic_sysbar_lights_out_dot_small);
return imageView;
}
private ViewGroup.LayoutParams copy(ViewGroup.LayoutParams layoutParams) {
if (layoutParams instanceof LinearLayout.LayoutParams) {
return new LinearLayout.LayoutParams(layoutParams.width, layoutParams.height,
@@ -348,9 +309,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
}
}
clearAllChildren((ViewGroup) mRot0.findViewById(R.id.nav_buttons));
clearAllChildren((ViewGroup) mRot0.findViewById(R.id.lights_out));
clearAllChildren((ViewGroup) mRot90.findViewById(R.id.nav_buttons));
clearAllChildren((ViewGroup) mRot90.findViewById(R.id.lights_out));
}
private void clearAllChildren(ViewGroup group) {

View File

@@ -64,42 +64,20 @@ public final class NavigationBarTransitions extends BarTransitions {
mLightsOut = lightsOut;
final View navButtons = mView.getCurrentView().findViewById(R.id.nav_buttons);
final View lowLights = mView.getCurrentView().findViewById(R.id.lights_out);
// ok, everyone, stop it right there
navButtons.animate().cancel();
lowLights.animate().cancel();
final float navButtonsAlpha = lightsOut ? 0f : 1f;
final float lowLightsAlpha = lightsOut ? 1f : 0f;
final float navButtonsAlpha = lightsOut ? 0.5f : 1f;
if (!animate) {
navButtons.setAlpha(navButtonsAlpha);
lowLights.setAlpha(lowLightsAlpha);
lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE);
} else {
final int duration = lightsOut ? LIGHTS_OUT_DURATION : LIGHTS_IN_DURATION;
navButtons.animate()
.alpha(navButtonsAlpha)
.setDuration(duration)
.start();
lowLights.setOnTouchListener(mLightsOutListener);
if (lowLights.getVisibility() == View.GONE) {
lowLights.setAlpha(0f);
lowLights.setVisibility(View.VISIBLE);
}
lowLights.animate()
.alpha(lowLightsAlpha)
.setDuration(duration)
.setInterpolator(new AccelerateInterpolator(2.0f))
.setListener(lightsOut ? null : new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator _a) {
lowLights.setVisibility(View.GONE);
}
})
.start();
}
}

View File

@@ -117,13 +117,9 @@ public class NavBarTuner extends Fragment implements TunerService.Tunable {
if (isRotated) {
mPreview.findViewById(R.id.rot0).setVisibility(View.GONE);
final View rot90 = mPreview.findViewById(R.id.rot90);
rot90.findViewById(R.id.ends_group_lightsout).setVisibility(View.GONE);
rot90.findViewById(R.id.center_group_lightsout).setVisibility(View.GONE);
} else {
mPreview.findViewById(R.id.rot90).setVisibility(View.GONE);
final View rot0 = mPreview.findViewById(R.id.rot0);
rot0.findViewById(R.id.ends_group_lightsout).setVisibility(View.GONE);
rot0.findViewById(R.id.center_group_lightsout).setVisibility(View.GONE);
}
}