diff options
-rw-r--r-- | java/com/android/incallui/InCallActivity.java | 28 | ||||
-rw-r--r-- | java/com/android/incallui/InCallActivityCommon.java | 57 | ||||
-rw-r--r-- | java/com/android/incallui/InCallOrientationEventListener.java | 15 |
3 files changed, 49 insertions, 51 deletions
diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index f9311f8d3..a55770c41 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -81,6 +81,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity public static final int PENDING_INTENT_REQUEST_CODE_BUBBLE = 2; private static final String TAG_ANSWER_SCREEN = "tag_answer_screen"; + private static final String TAG_DIALPAD_FRAGMENT = "tag_dialpad_fragment"; private static final String TAG_INTERNATIONAL_CALL_ON_WIFI = "tag_international_call_on_wifi"; private static final String TAG_IN_CALL_SCREEN = "tag_in_call_screen"; private static final String TAG_VIDEO_CALL_SCREEN = "tag_video_call_screen"; @@ -92,6 +93,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity private static final String CONFIG_ANSWER_AND_RELEASE_ENABLED = "answer_and_release_enabled"; private final InCallActivityCommon common; + private InCallOrientationEventListener inCallOrientationEventListener; private boolean didShowAnswerScreen; private boolean didShowInCallScreen; private boolean didShowVideoCallScreen; @@ -144,6 +146,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity } common.onCreate(icicle); + inCallOrientationEventListener = new InCallOrientationEventListener(this); getWindow() .getDecorView() @@ -346,7 +349,21 @@ public class InCallActivity extends TransactionSafeFragmentActivity } public boolean isDialpadVisible() { - return common.isDialpadVisible(); + DialpadFragment dialpadFragment = getDialpadFragment(); + return dialpadFragment != null && dialpadFragment.isVisible(); + } + + /** + * Returns the {@link DialpadFragment} that's shown by this activity, or {@code null} + * TODO(a bug): Make this method private after InCallActivityCommon is deleted. + */ + @Nullable + DialpadFragment getDialpadFragment() { + FragmentManager fragmentManager = getDialpadFragmentManager(); + if (fragmentManager == null) { + return null; + } + return (DialpadFragment) fragmentManager.findFragmentByTag(TAG_DIALPAD_FRAGMENT); } public void onForegroundCallChanged(DialerCall newForegroundCall) { @@ -489,8 +506,13 @@ public class InCallActivity extends TransactionSafeFragmentActivity needDismissPendingDialogs = false; } - private void enableInCallOrientationEventListener(boolean enable) { - common.enableInCallOrientationEventListener(enable); + // TODO(a bug): Make this method private after InCallActivityCommon is deleted. + void enableInCallOrientationEventListener(boolean enable) { + if (enable) { + inCallOrientationEventListener.enable(true /* notifyDeviceOrientationChange */); + } else { + inCallOrientationEventListener.disable(); + } } public void setExcludeFromRecents(boolean exclude) { diff --git a/java/com/android/incallui/InCallActivityCommon.java b/java/com/android/incallui/InCallActivityCommon.java index 5e68ce8a6..f92e78534 100644 --- a/java/com/android/incallui/InCallActivityCommon.java +++ b/java/com/android/incallui/InCallActivityCommon.java @@ -107,7 +107,6 @@ public class InCallActivityCommon { private String showPostCharWaitDialogChars; private Dialog errorDialog; private SelectPhoneAccountDialogFragment selectPhoneAccountDialogFragment; - private InCallOrientationEventListener inCallOrientationEventListener; private Animation dialpadSlideInAnimation; private Animation dialpadSlideOutAnimation; private boolean animateDialpadOnShow; @@ -242,14 +241,12 @@ public class InCallActivityCommon { "InCallActivityCommon.onCreate", "international fragment exists attaching callback"); existingInternationalFragment.setCallback(internationalCallOnWifiCallback); } - - inCallOrientationEventListener = new InCallOrientationEventListener(inCallActivity); } public void onSaveInstanceState(Bundle out) { // TODO: The dialpad fragment should handle this as part of its own state - out.putBoolean(INTENT_EXTRA_SHOW_DIALPAD, isDialpadVisible()); - DialpadFragment dialpadFragment = getDialpadFragment(); + out.putBoolean(INTENT_EXTRA_SHOW_DIALPAD, inCallActivity.isDialpadVisible()); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); if (dialpadFragment != null) { out.putString(DIALPAD_TEXT_KEY, dialpadFragment.getDtmfText()); } @@ -259,7 +256,7 @@ public class InCallActivityCommon { Trace.beginSection("InCallActivityCommon.onStart"); // setting activity should be last thing in setup process InCallPresenter.getInstance().setActivity(inCallActivity); - enableInCallOrientationEventListener( + inCallActivity.enableInCallOrientationEventListener( inCallActivity.getRequestedOrientation() == InCallOrientationEventListener.ACTIVITY_PREFERENCE_ALLOW_ROTATION); @@ -288,20 +285,20 @@ public class InCallActivityCommon { inCallActivity.showDialpadFragment(true /* show */, animateDialpadOnShow /* animate */); animateDialpadOnShow = false; - DialpadFragment dialpadFragment = getDialpadFragment(); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); if (dialpadFragment != null) { dialpadFragment.setDtmfText(dtmfTextToPreopulate); dtmfTextToPreopulate = null; } } else { LogUtil.i("InCallActivityCommon.onResume", "force hide dialpad"); - if (getDialpadFragment() != null) { + if (inCallActivity.getDialpadFragment() != null) { inCallActivity.showDialpadFragment(false /* show */, false /* animate */); } } showDialpadRequest = DIALPAD_REQUEST_NONE; } - updateNavigationBar(isDialpadVisible()); + updateNavigationBar(inCallActivity.isDialpadVisible()); if (showPostCharWaitDialogOnResume) { showPostCharWaitDialog(showPostCharWaitDialogCallId, showPostCharWaitDialogChars); @@ -316,7 +313,7 @@ public class InCallActivityCommon { // onPause is guaranteed to be called when the InCallActivity goes // in the background. public void onPause() { - DialpadFragment dialpadFragment = getDialpadFragment(); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); if (dialpadFragment != null) { dialpadFragment.onDialerKeyUp(null); } @@ -340,7 +337,7 @@ public class InCallActivityCommon { } } - enableInCallOrientationEventListener(false); + inCallActivity.enableInCallOrientationEventListener(false); InCallPresenter.getInstance().updateIsChangingConfigurations(); InCallPresenter.getInstance().onActivityStopped(); if (!isRecreating) { @@ -392,7 +389,7 @@ public class InCallActivityCommon { return true; } - DialpadFragment dialpadFragment = getDialpadFragment(); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); if (dialpadFragment != null && dialpadFragment.isVisible()) { inCallActivity.showDialpadFragment(false /* show */, true /* animate */); return true; @@ -410,7 +407,7 @@ public class InCallActivityCommon { } public boolean onKeyUp(int keyCode, KeyEvent event) { - DialpadFragment dialpadFragment = getDialpadFragment(); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); // push input to the dialer. if (dialpadFragment != null && (dialpadFragment.isVisible()) @@ -515,7 +512,7 @@ public class InCallActivityCommon { // As soon as the user starts typing valid dialable keys on the // keyboard (presumably to type DTMF tones) we start passing the // key events to the DTMFDialer's onDialerKeyDown. - DialpadFragment dialpadFragment = getDialpadFragment(); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); if (dialpadFragment != null && dialpadFragment.isVisible()) { return dialpadFragment.onDialerKeyDown(event); } @@ -602,14 +599,6 @@ public class InCallActivityCommon { CallList.getInstance().onErrorDialogDismissed(); } - public void enableInCallOrientationEventListener(boolean enable) { - if (enable) { - inCallOrientationEventListener.enable(true); - } else { - inCallOrientationEventListener.disable(); - } - } - public void setExcludeFromRecents(boolean exclude) { List<AppTask> tasks = inCallActivity.getSystemService(ActivityManager.class).getAppTasks(); int taskId = inCallActivity.getTaskId(); @@ -717,7 +706,7 @@ public class InCallActivityCommon { public boolean showDialpadFragment(boolean show, boolean animate) { // If the dialpad is already visible, don't animate in. If it's gone, don't animate out. - boolean isDialpadVisible = isDialpadVisible(); + boolean isDialpadVisible = inCallActivity.isDialpadVisible(); LogUtil.i( "InCallActivityCommon.showDialpadFragment", "show: %b, animate: %b, " + "isDialpadVisible: %b", @@ -746,9 +735,10 @@ public class InCallActivityCommon { } else { if (show) { performShowDialpadFragment(dialpadFragmentManager); - getDialpadFragment().animateShowDialpad(); + inCallActivity.getDialpadFragment().animateShowDialpad(); } - getDialpadFragment() + inCallActivity + .getDialpadFragment() .getView() .startAnimation(show ? dialpadSlideInAnimation : dialpadSlideOutAnimation); } @@ -763,7 +753,7 @@ public class InCallActivityCommon { private void performShowDialpadFragment(@NonNull FragmentManager dialpadFragmentManager) { FragmentTransaction transaction = dialpadFragmentManager.beginTransaction(); - DialpadFragment dialpadFragment = getDialpadFragment(); + DialpadFragment dialpadFragment = inCallActivity.getDialpadFragment(); if (dialpadFragment == null) { transaction.add( inCallActivity.getDialpadContainerId(), new DialpadFragment(), TAG_DIALPAD_FRAGMENT); @@ -796,21 +786,6 @@ public class InCallActivityCommon { updateNavigationBar(false /* isDialpadVisible */); } - public boolean isDialpadVisible() { - DialpadFragment dialpadFragment = getDialpadFragment(); - return dialpadFragment != null && dialpadFragment.isVisible(); - } - - /** Returns the {@link DialpadFragment} that's shown by this activity, or {@code null} */ - @Nullable - private DialpadFragment getDialpadFragment() { - FragmentManager fragmentManager = inCallActivity.getDialpadFragmentManager(); - if (fragmentManager == null) { - return null; - } - return (DialpadFragment) fragmentManager.findFragmentByTag(TAG_DIALPAD_FRAGMENT); - } - public void updateTaskDescription() { Resources resources = inCallActivity.getResources(); int color; diff --git a/java/com/android/incallui/InCallOrientationEventListener.java b/java/com/android/incallui/InCallOrientationEventListener.java index e6b0bc027..8aae6fb37 100644 --- a/java/com/android/incallui/InCallOrientationEventListener.java +++ b/java/com/android/incallui/InCallOrientationEventListener.java @@ -126,12 +126,13 @@ public class InCallOrientationEventListener extends OrientationEventListener { } /** - * Enables the OrientationEventListener and notifies listeners of current orientation if notify - * flag is true + * Enables the OrientationEventListener and optionally notifies listeners of the current + * orientation. * - * @param notify true or false. Notify device orientation changed if true. + * @param notifyDeviceOrientationChange Whether to notify listeners that the device orientation is + * changed. */ - public void enable(boolean notify) { + public void enable(boolean notifyDeviceOrientationChange) { if (mEnabled) { Log.v(this, "enable: Orientation listener is already enabled. Ignoring..."); return; @@ -139,15 +140,15 @@ public class InCallOrientationEventListener extends OrientationEventListener { super.enable(); mEnabled = true; - if (notify) { + if (notifyDeviceOrientationChange) { InCallPresenter.getInstance().onDeviceOrientationChange(sCurrentOrientation); } } - /** Enables the OrientationEventListener with notify flag defaulting to false. */ + /** Enables the OrientationEventListener. */ @Override public void enable() { - enable(false); + enable(false /* notifyDeviceOrientationChange */); } /** Disables the OrientationEventListener. */ |