OSDN Git Service

Make volume dialog only fade in/out in landscape
authorMike Digman <digman@google.com>
Tue, 27 Mar 2018 19:10:35 +0000 (12:10 -0700)
committerMike Digman <digman@google.com>
Tue, 27 Mar 2018 20:47:06 +0000 (20:47 +0000)
The sliding motion in landscape doesn't reinforce the
connection to the hardware keys. The motion also appears
clipped when the navbar background is transparent. Remove
the sliding motion when in landscape while leaving in fade.

Test: manual
Bug: 76438403
Change-Id: I6e49539080407d71ddfa44a9aba25cd7b4a6c0a2

packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java

index d9cad0e..71c7f80 100644 (file)
@@ -36,6 +36,7 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.res.ColorStateList;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Color;
 import android.graphics.PixelFormat;
@@ -60,6 +61,7 @@ import android.view.View;
 import android.view.View.AccessibilityDelegate;
 import android.view.View.OnAttachStateChangeListener;
 import android.view.ViewGroup;
+import android.view.ViewPropertyAnimator;
 import android.view.Window;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
@@ -192,7 +194,7 @@ public class VolumeDialogImpl implements VolumeDialog {
         mDialog.setCanceledOnTouchOutside(true);
         mDialog.setContentView(R.layout.volume_dialog);
         mDialog.setOnShowListener(dialog -> {
-            mDialogView.setTranslationX(mDialogView.getWidth() / 2);
+            if (!isLandscape()) mDialogView.setTranslationX(mDialogView.getWidth() / 2);
             mDialogView.setAlpha(0);
             mDialogView.animate()
                     .alpha(1)
@@ -254,6 +256,11 @@ public class VolumeDialogImpl implements VolumeDialog {
         return ColorStateList.valueOf(mContext.getColor(colorResId));
     }
 
+    private boolean isLandscape() {
+        return mContext.getResources().getConfiguration().orientation ==
+                Configuration.ORIENTATION_LANDSCAPE;
+    }
+
     public void setStreamImportant(int stream, boolean important) {
         mHandler.obtainMessage(H.SET_STREAM_IMPORTANT, stream, important ? 1 : 0).sendToTarget();
     }
@@ -509,16 +516,16 @@ public class VolumeDialogImpl implements VolumeDialog {
 
         mDialogView.setTranslationX(0);
         mDialogView.setAlpha(1);
-        mDialogView.animate()
+        ViewPropertyAnimator animator = mDialogView.animate()
                 .alpha(0)
-                .translationX(mDialogView.getWidth() / 2)
                 .setDuration(250)
                 .setInterpolator(new SystemUIInterpolators.LogAccelerateInterpolator())
                 .withEndAction(() -> mHandler.postDelayed(() -> {
                     if (D.BUG) Log.d(TAG, "mDialog.dismiss()");
                     mDialog.dismiss();
-                }, 50))
-                .start();
+                }, 50));
+        if (!isLandscape()) animator.translationX(mDialogView.getWidth() / 2);
+        animator.start();
 
         Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason);
         mController.notifyVisible(false);