diff options
author | Tyler Gunn <tgunn@google.com> | 2015-05-06 09:50:12 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2015-05-06 09:50:12 -0700 |
commit | 139f6e12e3cf37947a5219853c3bbce0621b0677 (patch) | |
tree | 994568be7ad3bce759e73a67441877ddfe892d58 /InCallUI | |
parent | 770bd50b45272b62b27ecca40a9c3538cc9bb1bc (diff) |
Fix issue where fast 180 degree landscape rotation is not detected.
- Cleaned up imports in InCallActivity.
- Added new OrientationEventListener to listen for orientation changes
to the device. This listener returns the current device rotation in
degrees. Use the windowManager to get the current display rotation (e.g.
in coarse 90 degree, 180, etc).
- This solves the problem - can now detect rotation from landscape to
landscape.
Bug: 20727115
Change-Id: I14450e628a7cf7230821a9f3c2d31c6a50f01170
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallList.java | 7 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 63 |
2 files changed, 46 insertions, 24 deletions
diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index 02c8fbf08..f7a9e5cc3 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -513,7 +513,12 @@ public class CallList { */ public void notifyCallsOfDeviceRotation(int rotation) { for (Call call : mCallById.values()) { - if (call.getVideoCall() != null) { + // First, ensure a VideoCall is set on the call so that the change can be sent to the + // provider (a VideoCall can be present for a call that does not currently have video, + // but can be upgraded to video). + // Second, ensure that the call videoState has video enabled (there is no need to set + // device orientation on a voice call which has not yet been upgraded to video). + if (call.getVideoCall() != null && CallUtils.isVideoCall(call)) { call.getVideoCall().setDeviceOrientation(rotation); } } diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 601a5155d..3050dc127 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -21,22 +21,20 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.FragmentManager; import android.app.FragmentTransaction; -import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnCancelListener; import android.content.Intent; import android.content.res.Configuration; -import android.content.res.Resources; import android.graphics.Point; -import android.net.Uri; +import android.hardware.SensorManager; import android.os.Bundle; import android.telecom.DisconnectCause; import android.telecom.PhoneAccountHandle; -import android.telecom.TelecomManager; -import android.telephony.PhoneNumberUtils; import android.text.TextUtils; +import android.view.Display; import android.view.MenuItem; +import android.view.OrientationEventListener; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.KeyEvent; @@ -48,8 +46,6 @@ import android.view.accessibility.AccessibilityEvent; import com.android.phone.common.animation.AnimUtils; import com.android.phone.common.animation.AnimationListenerAdapter; import com.android.contacts.common.interactions.TouchPointManager; -import com.android.contacts.common.util.MaterialColorMapUtils; -import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener; import com.android.incallui.Call.State; @@ -104,10 +100,13 @@ public class InCallActivity extends Activity { } }; + /** Listener for orientation changes. */ + private OrientationEventListener mOrientationEventListener; + /** - * Used to determine if a change in orientation has occurred. + * Used to determine if a change in rotation has occurred. */ - private static int sCurrentOrientation = Configuration.ORIENTATION_UNDEFINED; + private static int sPreviousRotation = -1; @Override protected void onCreate(Bundle icicle) { @@ -172,6 +171,28 @@ public class InCallActivity extends Activity { mAnimateDialpadOnShow = false; mDtmfText = icicle.getString(DIALPAD_TEXT_EXTRA); } + + mOrientationEventListener = new OrientationEventListener(this, + SensorManager.SENSOR_DELAY_NORMAL) { + @Override + public void onOrientationChanged(int orientation) { + // Orientation is the current device orientation in degrees. Ultimately we want + // the rotation (in fixed 90 degree intervals). + Display display = getWindowManager().getDefaultDisplay(); + int newRotation = display.getRotation(); + if (newRotation != sPreviousRotation) { + doOrientationChanged(newRotation); + } + } + }; + + if (mOrientationEventListener.canDetectOrientation()) { + Log.v(this, "Orientation detection enabled."); + mOrientationEventListener.enable(); + } else { + Log.v(this, "Orientation detection disabled."); + mOrientationEventListener.disable(); + } Log.d(this, "onCreate(): exit"); } @@ -192,9 +213,6 @@ public class InCallActivity extends Activity { // setting activity should be last thing in setup process InCallPresenter.getInstance().setActivity(this); - // It is possible that the activity restarted because orientation changed. - // Notify listeners if orientation changed. - doOrientationChanged(getResources().getConfiguration().orientation); InCallPresenter.getInstance().onActivityStarted(); } @@ -449,20 +467,19 @@ public class InCallActivity extends Activity { } /** - * Handles changes in device orientation. + * Handles changes in device rotation. * - * @param orientation The new device orientation. + * @param rotation The new device rotation. */ - private void doOrientationChanged(int orientation) { - Log.d(this, "doOrientationChanged prevOrientation=" + sCurrentOrientation + - " newOrientation=" + orientation); - // Check to see if the orientation changed to prevent triggering orientation change events + private void doOrientationChanged(int rotation) { + Log.d(this, "doOrientationChanged prevOrientation=" + sPreviousRotation + + " newOrientation=" + rotation); + // Check to see if the rotation changed to prevent triggering rotation change events // for other configuration changes. - if (orientation != sCurrentOrientation) { - sCurrentOrientation = orientation; - InCallPresenter.getInstance().onDeviceRotationChange( - getWindowManager().getDefaultDisplay().getRotation()); - InCallPresenter.getInstance().onDeviceOrientationChange(sCurrentOrientation); + if (rotation != sPreviousRotation) { + sPreviousRotation = rotation; + InCallPresenter.getInstance().onDeviceRotationChange(rotation); + InCallPresenter.getInstance().onDeviceOrientationChange(sPreviousRotation); } } |