diff options
author | Sailesh Nepal <sail@google.com> | 2016-02-22 20:47:48 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-02-22 20:47:48 +0000 |
commit | 429e15a3de2e5cfbc2c44071e97981e583f1ed15 (patch) | |
tree | d1646a829c7452dafab67c72c9f63e421d184745 | |
parent | 43c1be9d2b9b8b42d76c603c57a5ab459b0066da (diff) | |
parent | 68d86c656e5522dec1b04e85ebc0e0f78e436c3d (diff) |
[Gradle] Allow dialer to be compiled as a library
am: 68d86c656e
* commit '68d86c656e5522dec1b04e85ebc0e0f78e436c3d':
[Gradle] Allow dialer to be compiled as a library
32 files changed, 432 insertions, 486 deletions
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 1904ab041..d9e474de5 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -54,6 +54,7 @@ import android.widget.PopupMenu.OnDismissListener; import android.widget.PopupMenu.OnMenuItemClickListener; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; +import com.android.dialer.R; import com.android.dialer.compat.CallAudioStateCompat; /** @@ -199,56 +200,40 @@ public class CallButtonFragment int id = view.getId(); Log.d(this, "onClick(View " + view + ", id " + id + ")..."); - switch (id) { - case R.id.audioButton: - onAudioButtonClicked(); - break; - case R.id.addButton: - getPresenter().addCallClicked(); - break; - case R.id.muteButton: { - getPresenter().muteClicked(!mMuteButton.isSelected()); - break; + if (id == R.id.audioButton) { + onAudioButtonClicked(); + } else if (id == R.id.addButton) { + getPresenter().addCallClicked(); + } else if (id == R.id.muteButton) { + getPresenter().muteClicked(!mMuteButton.isSelected()); + } else if (id == R.id.mergeButton) { + getPresenter().mergeClicked(); + mMergeButton.setEnabled(false); + } else if (id == R.id.holdButton) { + getPresenter().holdClicked(!mHoldButton.isSelected()); + } else if (id == R.id.swapButton) { + getPresenter().swapClicked(); + } else if (id == R.id.dialpadButton) { + getPresenter().showDialpadClicked(!mShowDialpadButton.isSelected()); + } else if (id == R.id.changeToVideoButton) { + getPresenter().changeToVideoClicked(); + } else if (id == R.id.changeToVoiceButton) { + getPresenter().changeToVoiceClicked(); + } else if (id == R.id.switchCameraButton) { + getPresenter().switchCameraClicked( + mSwitchCameraButton.isSelected() /* useFrontFacingCamera */); + } else if (id == R.id.pauseVideoButton) { + getPresenter().pauseVideoClicked( + !mPauseVideoButton.isSelected() /* pause */); + } else if (id == R.id.overflowButton) { + if (mOverflowPopup != null) { + mOverflowPopup.show(); } - case R.id.mergeButton: - getPresenter().mergeClicked(); - mMergeButton.setEnabled(false); - break; - case R.id.holdButton: { - getPresenter().holdClicked(!mHoldButton.isSelected()); - break; - } - case R.id.swapButton: - getPresenter().swapClicked(); - break; - case R.id.dialpadButton: - getPresenter().showDialpadClicked(!mShowDialpadButton.isSelected()); - break; - case R.id.changeToVideoButton: - getPresenter().changeToVideoClicked(); - break; - case R.id.changeToVoiceButton: - getPresenter().changeToVoiceClicked(); - break; - case R.id.switchCameraButton: - getPresenter().switchCameraClicked( - mSwitchCameraButton.isSelected() /* useFrontFacingCamera */); - break; - case R.id.pauseVideoButton: - getPresenter().pauseVideoClicked( - !mPauseVideoButton.isSelected() /* pause */); - break; - case R.id.overflowButton: - if (mOverflowPopup != null) { - mOverflowPopup.show(); - } - break; - case R.id.manageVideoCallConferenceButton: - onManageVideoCallConferenceClicked(); - break; - default: - Log.wtf(this, "onClick: unexpected"); - return; + } else if (id == R.id.manageVideoCallConferenceButton) { + onManageVideoCallConferenceClicked(); + } else { + Log.wtf(this, "onClick: unexpected"); + return; } view.performHapticFeedback( @@ -394,34 +379,33 @@ public class CallButtonFragment } private View getButtonById(int id) { - switch (id) { - case BUTTON_AUDIO: - return mAudioButton; - case BUTTON_MUTE: - return mMuteButton; - case BUTTON_DIALPAD: - return mShowDialpadButton; - case BUTTON_HOLD: - return mHoldButton; - case BUTTON_SWAP: - return mSwapButton; - case BUTTON_UPGRADE_TO_VIDEO: - return mChangeToVideoButton; - case BUTTON_DOWNGRADE_TO_AUDIO: - return mChangeToVoiceButton; - case BUTTON_SWITCH_CAMERA: - return mSwitchCameraButton; - case BUTTON_ADD_CALL: - return mAddCallButton; - case BUTTON_MERGE: - return mMergeButton; - case BUTTON_PAUSE_VIDEO: - return mPauseVideoButton; - case BUTTON_MANAGE_VIDEO_CONFERENCE: - return mManageVideoCallConferenceButton; - default: - Log.w(this, "Invalid button id"); - return null; + if (id == BUTTON_AUDIO) { + return mAudioButton; + } else if (id == BUTTON_MUTE) { + return mMuteButton; + } else if (id == BUTTON_DIALPAD) { + return mShowDialpadButton; + } else if (id == BUTTON_HOLD) { + return mHoldButton; + } else if (id == BUTTON_SWAP) { + return mSwapButton; + } else if (id == BUTTON_UPGRADE_TO_VIDEO) { + return mChangeToVideoButton; + } else if (id == BUTTON_DOWNGRADE_TO_AUDIO) { + return mChangeToVoiceButton; + } else if (id == BUTTON_SWITCH_CAMERA) { + return mSwitchCameraButton; + } else if (id == BUTTON_ADD_CALL) { + return mAddCallButton; + } else if (id == BUTTON_MERGE) { + return mMergeButton; + } else if (id == BUTTON_PAUSE_VIDEO) { + return mPauseVideoButton; + } else if (id == BUTTON_MANAGE_VIDEO_CONFERENCE) { + return mManageVideoCallConferenceButton; + } else { + Log.w(this, "Invalid button id"); + return null; } } @@ -540,24 +524,19 @@ public class CallButtonFragment Log.d(this, " title: '" + item.getTitle() + "'"); int mode = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE; - - switch (item.getItemId()) { - case R.id.audio_mode_speaker: - mode = CallAudioStateCompat.ROUTE_SPEAKER; - break; - case R.id.audio_mode_earpiece: - case R.id.audio_mode_wired_headset: - // InCallCallAudioState.ROUTE_EARPIECE means either the handset earpiece, - // or the wired headset (if connected.) - mode = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE; - break; - case R.id.audio_mode_bluetooth: - mode = CallAudioStateCompat.ROUTE_BLUETOOTH; - break; - default: - Log.e(this, "onMenuItemClick: unexpected View ID " + item.getItemId() - + " (MenuItem = '" + item + "')"); - break; + int resId = item.getItemId(); + + if (resId == R.id.audio_mode_speaker) { + mode = CallAudioStateCompat.ROUTE_SPEAKER; + } else if (resId == R.id.audio_mode_earpiece || resId == R.id.audio_mode_wired_headset) { + // InCallCallAudioState.ROUTE_EARPIECE means either the handset earpiece, + // or the wired headset (if connected.) + mode = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE; + } else if (resId == R.id.audio_mode_bluetooth) { + mode = CallAudioStateCompat.ROUTE_BLUETOOTH; + } else { + Log.e(this, "onMenuItemClick: unexpected View ID " + item.getItemId() + + " (MenuItem = '" + item + "')"); } getPresenter().setAudioMode(mode); diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index ad7269059..84a732ccc 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -58,6 +58,7 @@ import android.widget.Toast; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import com.android.contacts.common.widget.FloatingActionButtonController; +import com.android.dialer.R; import com.android.phone.common.animation.AnimUtils; import java.util.List; diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index a77de1e72..dd255e09e 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -45,6 +45,7 @@ import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.ContactDisplayUtils; +import com.android.dialer.R; import com.android.incallui.Call.State; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java index 55a4be6fd..a638e114c 100644 --- a/InCallUI/src/com/android/incallui/CallerInfo.java +++ b/InCallUI/src/com/android/incallui/CallerInfo.java @@ -39,6 +39,7 @@ import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.ContactsUtils.UserType; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.contacts.common.util.TelephonyManagerUtils; +import com.android.dialer.R; import com.android.dialer.calllog.ContactInfoHelper; /** diff --git a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java index be5a275f3..6dbbfc1fb 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java +++ b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java @@ -37,6 +37,7 @@ import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.compat.DirectoryCompat; import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.util.TelephonyManagerUtils; +import com.android.dialer.R; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; diff --git a/InCallUI/src/com/android/incallui/CallerInfoUtils.java b/InCallUI/src/com/android/incallui/CallerInfoUtils.java index ae59d7d2d..aff39566d 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoUtils.java +++ b/InCallUI/src/com/android/incallui/CallerInfoUtils.java @@ -12,6 +12,7 @@ import android.util.Log; import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.contacts.common.model.Contact; import com.android.contacts.common.model.ContactLoader; +import com.android.dialer.R; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; diff --git a/InCallUI/src/com/android/incallui/CircularRevealFragment.java b/InCallUI/src/com/android/incallui/CircularRevealFragment.java index f4a2e91ff..01bd253ec 100644 --- a/InCallUI/src/com/android/incallui/CircularRevealFragment.java +++ b/InCallUI/src/com/android/incallui/CircularRevealFragment.java @@ -34,6 +34,7 @@ import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnPreDrawListener; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; +import com.android.dialer.R; public class CircularRevealFragment extends Fragment { static final String TAG = "CircularRevealFragment"; diff --git a/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java b/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java index f5f52fcb6..fe941c8c5 100644 --- a/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java +++ b/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java @@ -25,6 +25,7 @@ import android.view.ViewGroup; import android.widget.ListView; import com.android.contacts.common.ContactPhotoManager; +import com.android.dialer.R; import java.util.List; diff --git a/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java b/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java index 9d7069d1c..d68ae1f6f 100644 --- a/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java +++ b/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java @@ -37,6 +37,7 @@ import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.ContactDisplayUtils; +import com.android.dialer.R; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import java.lang.ref.WeakReference; diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index ab4150ba4..9d6fc4627 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -40,6 +40,7 @@ import android.util.Pair; import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.util.PhoneNumberHelper; +import com.android.dialer.R; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; diff --git a/InCallUI/src/com/android/incallui/ContactsAsyncHelper.java b/InCallUI/src/com/android/incallui/ContactsAsyncHelper.java index 011eef2ac..d959fadd4 100644 --- a/InCallUI/src/com/android/incallui/ContactsAsyncHelper.java +++ b/InCallUI/src/com/android/incallui/ContactsAsyncHelper.java @@ -30,6 +30,8 @@ import android.os.Looper; import android.os.Message; import android.provider.ContactsContract.Contacts; +import com.android.dialer.R; + import java.io.IOException; import java.io.InputStream; diff --git a/InCallUI/src/com/android/incallui/DialpadFragment.java b/InCallUI/src/com/android/incallui/DialpadFragment.java index ab44cf2ca..ae66a491f 100644 --- a/InCallUI/src/com/android/incallui/DialpadFragment.java +++ b/InCallUI/src/com/android/incallui/DialpadFragment.java @@ -34,6 +34,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; +import com.android.dialer.R; import com.android.phone.common.dialpad.DialpadKeyButton; import com.android.phone.common.dialpad.DialpadView; diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java index 1bd6d3919..342f6b4fd 100644 --- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java +++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java @@ -23,6 +23,7 @@ import android.telecom.VideoProfile; import android.util.AttributeSet; import android.view.View; +import com.android.dialer.R; import com.android.incallui.widget.multiwaveview.GlowPadView; /** @@ -111,31 +112,24 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger public void onTrigger(View v, int target) { Log.d(this, "onTrigger() view=" + v + " target=" + target); final int resId = getResourceIdForTarget(target); - switch (resId) { - case R.drawable.ic_lockscreen_answer: - mAnswerFragment.onAnswer(VideoProfile.STATE_AUDIO_ONLY, getContext()); - mTargetTriggered = true; - break; - case R.drawable.ic_lockscreen_decline: - mAnswerFragment.onDecline(getContext()); - mTargetTriggered = true; - break; - case R.drawable.ic_lockscreen_text: - mAnswerFragment.onText(); - mTargetTriggered = true; - break; - case R.drawable.ic_videocam: - case R.drawable.ic_lockscreen_answer_video: - mAnswerFragment.onAnswer(mVideoState, getContext()); - mTargetTriggered = true; - break; - case R.drawable.ic_lockscreen_decline_video: - mAnswerFragment.onDeclineUpgradeRequest(getContext()); - mTargetTriggered = true; - break; - default: - // Code should never reach here. - Log.e(this, "Trigger detected on unhandled resource. Skipping."); + if (resId == R.drawable.ic_lockscreen_answer) { + mAnswerFragment.onAnswer(VideoProfile.STATE_AUDIO_ONLY, getContext()); + mTargetTriggered = true; + } else if (resId == R.drawable.ic_lockscreen_decline) { + mAnswerFragment.onDecline(getContext()); + mTargetTriggered = true; + } else if (resId == R.drawable.ic_lockscreen_text) { + mAnswerFragment.onText(); + mTargetTriggered = true; + } else if (resId == R.drawable.ic_videocam || resId == R.drawable.ic_lockscreen_answer_video) { + mAnswerFragment.onAnswer(mVideoState, getContext()); + mTargetTriggered = true; + } else if (resId == R.drawable.ic_lockscreen_decline_video) { + mAnswerFragment.onDeclineUpgradeRequest(getContext()); + mTargetTriggered = true; + } else { + // Code should never reach here. + Log.e(this, "Trigger detected on unhandled resource. Skipping."); } } diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index dec1323b2..5cd21a555 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -55,6 +55,7 @@ import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener; +import com.android.dialer.R; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.incallui.Call.State; diff --git a/InCallUI/src/com/android/incallui/InCallContactInteractions.java b/InCallUI/src/com/android/incallui/InCallContactInteractions.java index e62766844..88070fe37 100644 --- a/InCallUI/src/com/android/incallui/InCallContactInteractions.java +++ b/InCallUI/src/com/android/incallui/InCallContactInteractions.java @@ -33,6 +33,8 @@ import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.widget.TextView; +import com.android.dialer.R; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -394,4 +396,4 @@ public class InCallContactInteractions { return listItem; } } -}
\ No newline at end of file +} diff --git a/InCallUI/src/com/android/incallui/InCallDateUtils.java b/InCallUI/src/com/android/incallui/InCallDateUtils.java index da3bb6bf4..e6089d5f1 100644 --- a/InCallUI/src/com/android/incallui/InCallDateUtils.java +++ b/InCallUI/src/com/android/incallui/InCallDateUtils.java @@ -3,6 +3,8 @@ package com.android.incallui; import android.content.Context; import android.content.res.Resources; +import com.android.dialer.R; + /** * Methods to parse time and date information in the InCallUi */ diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 249071faa..5a27b4ca0 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -47,6 +47,7 @@ import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; +import com.android.dialer.R; import com.android.dialer.calllog.CallLogAsyncTaskUtil; import com.android.dialer.calllog.CallLogAsyncTaskUtil.OnCallLogQueryFinishedListener; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; diff --git a/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java b/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java index 44b035f30..9c108b855 100644 --- a/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java +++ b/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java @@ -6,6 +6,7 @@ import android.telecom.PhoneAccount; import com.android.contacts.common.util.MaterialColorMapUtils; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; +import com.android.dialer.R; public class InCallUIMaterialColorMapUtils extends MaterialColorMapUtils { private final TypedArray sPrimaryColors; @@ -14,10 +15,8 @@ public class InCallUIMaterialColorMapUtils extends MaterialColorMapUtils { public InCallUIMaterialColorMapUtils(Resources resources) { super(resources); - sPrimaryColors = resources.obtainTypedArray( - com.android.incallui.R.array.background_colors); - sSecondaryColors = resources.obtainTypedArray( - com.android.incallui.R.array.background_colors_dark); + sPrimaryColors = resources.obtainTypedArray(R.array.background_colors); + sSecondaryColors = resources.obtainTypedArray(R.array.background_colors_dark); mResources = resources; } @@ -53,4 +52,4 @@ public class InCallUIMaterialColorMapUtils extends MaterialColorMapUtils { final int secondaryColor = resources.getColor(R.color.dialer_theme_color_dark); return new MaterialPalette(primaryColor, secondaryColor); } -}
\ No newline at end of file +} diff --git a/InCallUI/src/com/android/incallui/PostCharDialogFragment.java b/InCallUI/src/com/android/incallui/PostCharDialogFragment.java index 400e8d762..6f904ad9e 100644 --- a/InCallUI/src/com/android/incallui/PostCharDialogFragment.java +++ b/InCallUI/src/com/android/incallui/PostCharDialogFragment.java @@ -23,6 +23,8 @@ import android.content.DialogInterface; import android.os.Bundle; import android.view.WindowManager; +import com.android.dialer.R; + /** * Pop up an alert dialog with OK and Cancel buttons to allow user to Accept or Reject the WAIT * inserted as part of the Dial string. diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 6c00164b9..1a4ec0935 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -50,6 +50,7 @@ import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.BitmapUtil; import com.android.contacts.common.util.ContactDisplayUtils; +import com.android.dialer.R; import com.android.incallui.Call.State; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; @@ -520,17 +521,16 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, } private static int getWorkStringFromPersonalString(int resId) { - switch(resId) { - case R.string.notification_ongoing_call: - return R.string.notification_ongoing_work_call; - case R.string.notification_ongoing_call_wifi: - return R.string.notification_ongoing_work_call_wifi; - case R.string.notification_incoming_call_wifi: - return R.string.notification_incoming_work_call_wifi; - case R.string.notification_incoming_call: - return R.string.notification_incoming_work_call; - default: - return resId; + if (resId == R.string.notification_ongoing_call) { + return R.string.notification_ongoing_work_call; + } else if (resId == R.string.notification_ongoing_call_wifi) { + return R.string.notification_ongoing_work_call_wifi; + } else if (resId == R.string.notification_incoming_call_wifi) { + return R.string.notification_incoming_work_call_wifi; + } else if (resId == R.string.notification_incoming_call) { + return R.string.notification_incoming_work_call; + } else { + return resId; } } diff --git a/InCallUI/src/com/android/incallui/VideoCallFragment.java b/InCallUI/src/com/android/incallui/VideoCallFragment.java index f80b04c51..cb8c6449b 100644 --- a/InCallUI/src/com/android/incallui/VideoCallFragment.java +++ b/InCallUI/src/com/android/incallui/VideoCallFragment.java @@ -31,6 +31,7 @@ import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; +import com.android.dialer.R; import com.android.phone.common.animation.AnimUtils; import com.google.common.base.Objects; diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index c9a332881..9a33d80eb 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -33,6 +33,7 @@ import android.widget.ImageView; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.compat.CompatUtils; +import com.android.dialer.R; import com.android.incallui.InCallPresenter.InCallDetailsListener; import com.android.incallui.InCallPresenter.InCallOrientationListener; import com.android.incallui.InCallPresenter.InCallStateListener; diff --git a/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java b/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java index 23200279e..efeb4b7e3 100644 --- a/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java +++ b/InCallUI/src/com/android/incallui/widget/multiwaveview/GlowPadView.java @@ -50,7 +50,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.view.accessibility.AccessibilityNodeProvider; -import com.android.incallui.R; +import com.android.dialer.R; import java.util.ArrayList; import java.util.List; diff --git a/build.gradle b/build-app.gradle index 7e3424b3c..ef019ed35 100644 --- a/build.gradle +++ b/build-app.gradle @@ -29,6 +29,6 @@ dependencies { compile project(':vcard') compile project(':ContactsCommon') - compile project(':PhoneCommon') compile project(':InCallUI') + compile project(':PhoneCommon') } diff --git a/build-library.gradle b/build-library.gradle new file mode 100644 index 000000000..f96ff2bec --- /dev/null +++ b/build-library.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.library' + +android { + defaultConfig { + minSdkVersion 23 + targetSdkVersion 23 + multiDexEnabled true + } + + sourceSets.main { + java.srcDirs = ['src', 'src-pre-N', 'InCallUI/src'] + manifest.srcFile 'AndroidManifest.xml' + res.srcDirs = ['res'] + } +} + +dependencies { + compile 'com.android.support:support-v4:23.1.+' + compile 'com.android.support:support-v13:23.1.+' + compile 'com.android.support:appcompat-v7:23.1.+' + compile 'com.android.support:cardview-v7:23.1.+' + compile 'com.android.support:design:23.1.+' + compile 'com.android.support:recyclerview-v7:23.1.+' + + compile project(':android-common') + compile project(':guava') + compile project(':libphonenumber') + compile project(':jsr305') + compile project(':vcard') + + compile project(':ContactsCommon') + compile project(':InCallUI') + compile project(':PhoneCommon') +} diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 56e29a9d7..e6a29fbe2 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -349,51 +349,45 @@ public class CallDetailActivity extends AppCompatActivity @Override public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.call_detail_delete_menu_item: - if (hasVoicemail()) { - CallLogAsyncTaskUtil.deleteVoicemail( - this, mVoicemailUri, mCallLogAsyncTaskListener); - } else { - final StringBuilder callIds = new StringBuilder(); - for (Uri callUri : getCallLogEntryUris()) { - if (callIds.length() != 0) { - callIds.append(","); - } - callIds.append(ContentUris.parseId(callUri)); + if (item.getItemId() == R.id.call_detail_delete_menu_item) { + if (hasVoicemail()) { + CallLogAsyncTaskUtil.deleteVoicemail( + this, mVoicemailUri, mCallLogAsyncTaskListener); + } else { + final StringBuilder callIds = new StringBuilder(); + for (Uri callUri : getCallLogEntryUris()) { + if (callIds.length() != 0) { + callIds.append(","); } - CallLogAsyncTaskUtil.deleteCalls( - this, callIds.toString(), mCallLogAsyncTaskListener); + callIds.append(ContentUris.parseId(callUri)); } - break; + CallLogAsyncTaskUtil.deleteCalls( + this, callIds.toString(), mCallLogAsyncTaskListener); + } } return true; } @Override public void onClick(View view) { - switch(view.getId()) { - case R.id.call_detail_action_block: - BlockNumberDialogFragment.show( - mBlockedNumberId, - mNumber, - mDetails.countryIso, - mDisplayNumber, - R.id.call_detail, - getFragmentManager(), - this); - break; - case R.id.call_detail_action_copy: - ClipboardUtils.copyText(mContext, null, mNumber, true); - break; - case R.id.call_detail_action_edit_before_call: - Intent dialIntent = new Intent(Intent.ACTION_DIAL, - CallUtil.getCallUri(getDialableNumber())); - DialerUtils.startActivityWithErrorToast(mContext, dialIntent); - break; - default: - Log.wtf(TAG, "Unexpected onClick event from " + view); - break; + int resId = view.getId(); + if (resId == R.id.call_detail_action_block) { + BlockNumberDialogFragment.show( + mBlockedNumberId, + mNumber, + mDetails.countryIso, + mDisplayNumber, + R.id.call_detail, + getFragmentManager(), + this); + } else if (resId == R.id.call_detail_action_copy) { + ClipboardUtils.copyText(mContext, null, mNumber, true); + } else if (resId == R.id.call_detail_action_edit_before_call) { + Intent dialIntent = new Intent(Intent.ACTION_DIAL, + CallUtil.getCallUri(getDialableNumber())); + DialerUtils.startActivityWithErrorToast(mContext, dialIntent); + } else { + Log.wtf(TAG, "Unexpected onClick event from " + view); } } diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 72753bea4..d50748303 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -620,35 +620,30 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onClick(View view) { - switch (view.getId()) { - case R.id.floating_action_button: - if (mListsFragment.getCurrentTabIndex() - == ListsFragment.TAB_INDEX_ALL_CONTACTS && !mInRegularSearch) { - DialerUtils.startActivityWithErrorToast( - this, - IntentUtil.getNewContactIntent(), - R.string.add_contact_not_available); - } else if (!mIsDialpadShown) { - mInCallDialpadUp = false; - showDialpadFragment(true); - } - break; - case R.id.voice_search_button: - try { - startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), - ACTIVITY_REQUEST_CODE_VOICE_SEARCH); - } catch (ActivityNotFoundException e) { - Toast.makeText(DialtactsActivity.this, R.string.voice_search_not_available, - Toast.LENGTH_SHORT).show(); - } - break; - case R.id.dialtacts_options_menu_button: - mOverflowMenu.show(); - break; - default: { - Log.wtf(TAG, "Unexpected onClick event from " + view); - break; + int resId = view.getId(); + if (resId == R.id.floating_action_button) { + if (mListsFragment.getCurrentTabIndex() + == ListsFragment.TAB_INDEX_ALL_CONTACTS && !mInRegularSearch) { + DialerUtils.startActivityWithErrorToast( + this, + IntentUtil.getNewContactIntent(), + R.string.add_contact_not_available); + } else if (!mIsDialpadShown) { + mInCallDialpadUp = false; + showDialpadFragment(true); } + } else if (resId == R.id.voice_search_button) { + try { + startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), + ACTIVITY_REQUEST_CODE_VOICE_SEARCH); + } catch (ActivityNotFoundException e) { + Toast.makeText(DialtactsActivity.this, R.string.voice_search_not_available, + Toast.LENGTH_SHORT).show(); + } + } else if (resId == R.id.dialtacts_options_menu_button) { + mOverflowMenu.show(); + } else { + Log.wtf(TAG, "Unexpected onClick event from " + view); } } @@ -658,41 +653,37 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O return true; } - switch (item.getItemId()) { - case R.id.menu_history: - // Use explicit CallLogActivity intent instead of ACTION_VIEW + - // CONTENT_TYPE, so that we always open our call log from our dialer - final Intent intent = new Intent(this, CallLogActivity.class); - startActivity(intent); - break; - case R.id.menu_add_contact: - DialerUtils.startActivityWithErrorToast( - this, - IntentUtil.getNewContactIntent(), - R.string.add_contact_not_available); - break; - case R.id.menu_import_export: - // We hard-code the "contactsAreAvailable" argument because doing it properly would - // involve querying a {@link ProviderStatusLoader}, which we don't want to do right - // now in Dialtacts for (potential) performance reasons. Compare with how it is - // done in {@link PeopleActivity}. - if (mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_SPEED_DIAL) { - ImportExportDialogFragment.show(getFragmentManager(), true, - DialtactsActivity.class, ImportExportDialogFragment.EXPORT_MODE_FAVORITES); - } else { - ImportExportDialogFragment.show(getFragmentManager(), true, - DialtactsActivity.class, ImportExportDialogFragment.EXPORT_MODE_DEFAULT); - } - Logger.logScreenView(ScreenEvent.IMPORT_EXPORT_CONTACTS, this); - return true; - case R.id.menu_clear_frequents: - ClearFrequentsDialog.show(getFragmentManager()); - Logger.logScreenView(ScreenEvent.CLEAR_FREQUENTS, this); - return true; - case R.id.menu_call_settings: - handleMenuSettings(); - Logger.logScreenView(ScreenEvent.SETTINGS, this); - return true; + int resId = item.getItemId(); + if (resId == R.id.menu_history) {// Use explicit CallLogActivity intent instead of ACTION_VIEW + + // CONTENT_TYPE, so that we always open our call log from our dialer + final Intent intent = new Intent(this, CallLogActivity.class); + startActivity(intent); + } else if (resId == R.id.menu_add_contact) { + DialerUtils.startActivityWithErrorToast( + this, + IntentUtil.getNewContactIntent(), + R.string.add_contact_not_available); + } else if (resId == R.id.menu_import_export) {// We hard-code the "contactsAreAvailable" argument because doing it properly would + // involve querying a {@link ProviderStatusLoader}, which we don't want to do right + // now in Dialtacts for (potential) performance reasons. Compare with how it is + // done in {@link PeopleActivity}. + if (mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_SPEED_DIAL) { + ImportExportDialogFragment.show(getFragmentManager(), true, + DialtactsActivity.class, ImportExportDialogFragment.EXPORT_MODE_FAVORITES); + } else { + ImportExportDialogFragment.show(getFragmentManager(), true, + DialtactsActivity.class, ImportExportDialogFragment.EXPORT_MODE_DEFAULT); + } + Logger.logScreenView(ScreenEvent.IMPORT_EXPORT_CONTACTS, this); + return true; + } else if (resId == R.id.menu_clear_frequents) { + ClearFrequentsDialog.show(getFragmentManager()); + Logger.logScreenView(ScreenEvent.CLEAR_FREQUENTS, this); + return true; + } else if (resId == R.id.menu_call_settings) { + handleMenuSettings(); + Logger.logScreenView(ScreenEvent.SETTINGS, this); + return true; } return false; } diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java index 243eda9b1..1823a5bd3 100644 --- a/src/com/android/dialer/calllog/CallLogActivity.java +++ b/src/com/android/dialer/calllog/CallLogActivity.java @@ -192,15 +192,14 @@ public class CallLogActivity extends TransactionSafeActivity implements ViewPage return true; } - switch (item.getItemId()) { - case android.R.id.home: - final Intent intent = new Intent(this, DialtactsActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - return true; - case R.id.delete_all: - ClearCallLogDialog.show(getFragmentManager()); - return true; + if (item.getItemId() == android.R.id.home) { + final Intent intent = new Intent(this, DialtactsActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + return true; + } else if (item.getItemId() == R.id.delete_all) { + ClearCallLogDialog.show(getFragmentManager()); + return true; } return super.onOptionsItemSelected(item); } diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index cfc937547..1c2744073 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -361,30 +361,30 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder @Override public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.context_menu_block_number: - BlockNumberDialogFragment.show( - blockId, - number, - countryIso, - displayNumber, - R.id.floating_action_button_container, - ((Activity) mContext).getFragmentManager(), - mFilteredNumberDialogCallback); - return true; - case R.id.context_menu_copy_to_clipboard: - ClipboardUtils.copyText(mContext, null, number, true); - return true; - case R.id.context_menu_copy_transcript_to_clipboard: - ClipboardUtils.copyText(mContext, null, - phoneCallDetailsViews.voicemailTranscriptionView.getText(), true); - return true; - case R.id.context_menu_edit_before_call: - final Intent intent = new Intent( - Intent.ACTION_DIAL, CallUtil.getCallUri(number)); - intent.setClass(mContext, DialtactsActivity.class); - DialerUtils.startActivityWithErrorToast(mContext, intent); - return true; + int resId = item.getItemId(); + if (resId == R.id.context_menu_block_number) { + BlockNumberDialogFragment.show( + blockId, + number, + countryIso, + displayNumber, + R.id.floating_action_button_container, + ((Activity) mContext).getFragmentManager(), + mFilteredNumberDialogCallback); + return true; + } else if (resId == R.id.context_menu_copy_to_clipboard) { + ClipboardUtils.copyText(mContext, null, number, true); + return true; + } else if (resId == R.id.context_menu_copy_transcript_to_clipboard) { + ClipboardUtils.copyText(mContext, null, + phoneCallDetailsViews.voicemailTranscriptionView.getText(), true); + return true; + } else if (resId == R.id.context_menu_edit_before_call) { + final Intent intent = new Intent( + Intent.ACTION_DIAL, CallUtil.getCallUri(number)); + intent.setClass(mContext, DialtactsActivity.class); + DialerUtils.startActivityWithErrorToast(mContext, intent); + return true; } return false; } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 246b0d7fa..55d534676 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -822,13 +822,12 @@ public class DialpadFragment extends Fragment @Override public boolean onKey(View view, int keyCode, KeyEvent event) { - switch (view.getId()) { - case R.id.digits: - if (keyCode == KeyEvent.KEYCODE_ENTER) { - handleDialButtonPressed(); - return true; - } - break; + if (view.getId() == R.id.digits) { + if (keyCode == KeyEvent.KEYCODE_ENTER) { + handleDialButtonPressed(); + return true; + } + } return false; } @@ -843,59 +842,33 @@ public class DialpadFragment extends Fragment public void onPressed(View view, boolean pressed) { if (DEBUG) Log.d(TAG, "onPressed(). view: " + view + ", pressed: " + pressed); if (pressed) { - switch (view.getId()) { - case R.id.one: { - keyPressed(KeyEvent.KEYCODE_1); - break; - } - case R.id.two: { - keyPressed(KeyEvent.KEYCODE_2); - break; - } - case R.id.three: { - keyPressed(KeyEvent.KEYCODE_3); - break; - } - case R.id.four: { - keyPressed(KeyEvent.KEYCODE_4); - break; - } - case R.id.five: { - keyPressed(KeyEvent.KEYCODE_5); - break; - } - case R.id.six: { - keyPressed(KeyEvent.KEYCODE_6); - break; - } - case R.id.seven: { - keyPressed(KeyEvent.KEYCODE_7); - break; - } - case R.id.eight: { - keyPressed(KeyEvent.KEYCODE_8); - break; - } - case R.id.nine: { - keyPressed(KeyEvent.KEYCODE_9); - break; - } - case R.id.zero: { - keyPressed(KeyEvent.KEYCODE_0); - break; - } - case R.id.pound: { - keyPressed(KeyEvent.KEYCODE_POUND); - break; - } - case R.id.star: { - keyPressed(KeyEvent.KEYCODE_STAR); - break; - } - default: { - Log.wtf(TAG, "Unexpected onTouch(ACTION_DOWN) event from: " + view); - break; - } + int resId = view.getId(); + if (resId == R.id.one) { + keyPressed(KeyEvent.KEYCODE_1); + } else if (resId == R.id.two) { + keyPressed(KeyEvent.KEYCODE_2); + } else if (resId == R.id.three) { + keyPressed(KeyEvent.KEYCODE_3); + } else if (resId == R.id.four) { + keyPressed(KeyEvent.KEYCODE_4); + } else if (resId == R.id.five) { + keyPressed(KeyEvent.KEYCODE_5); + } else if (resId == R.id.six) { + keyPressed(KeyEvent.KEYCODE_6); + } else if (resId == R.id.seven) { + keyPressed(KeyEvent.KEYCODE_7); + } else if (resId == R.id.eight) { + keyPressed(KeyEvent.KEYCODE_8); + } else if (resId == R.id.nine) { + keyPressed(KeyEvent.KEYCODE_9); + } else if (resId == R.id.zero) { + keyPressed(KeyEvent.KEYCODE_0); + } else if (resId == R.id.pound) { + keyPressed(KeyEvent.KEYCODE_POUND); + } else if (resId == R.id.star) { + keyPressed(KeyEvent.KEYCODE_STAR); + } else { + Log.wtf(TAG, "Unexpected onTouch(ACTION_DOWN) event from: " + view); } mPressedDialpadKeys.add(view); } else { @@ -936,29 +909,21 @@ public class DialpadFragment extends Fragment @Override public void onClick(View view) { - switch (view.getId()) { - case R.id.dialpad_floating_action_button: - view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); - handleDialButtonPressed(); - break; - case R.id.deleteButton: { - keyPressed(KeyEvent.KEYCODE_DEL); - break; - } - case R.id.digits: { - if (!isDigitsEmpty()) { - mDigits.setCursorVisible(true); - } - break; - } - case R.id.dialpad_overflow: { - mOverflowPopupMenu.show(); - break; - } - default: { - Log.wtf(TAG, "Unexpected onClick() event from: " + view); - return; + int resId = view.getId(); + if (resId == R.id.dialpad_floating_action_button) { + view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + handleDialButtonPressed(); + } else if (resId == R.id.deleteButton) { + keyPressed(KeyEvent.KEYCODE_DEL); + } else if (resId == R.id.digits) { + if (!isDigitsEmpty()) { + mDigits.setCursorVisible(true); } + } else if (resId == R.id.dialpad_overflow) { + mOverflowPopupMenu.show(); + } else { + Log.wtf(TAG, "Unexpected onClick() event from: " + view); + return; } } @@ -966,75 +931,61 @@ public class DialpadFragment extends Fragment public boolean onLongClick(View view) { final Editable digits = mDigits.getText(); final int id = view.getId(); - switch (id) { - case R.id.deleteButton: { - digits.clear(); - return true; - } - case R.id.one: { - // '1' may be already entered since we rely on onTouch() event for numeric buttons. - // Just for safety we also check if the digits field is empty or not. - if (isDigitsEmpty() || TextUtils.equals(mDigits.getText(), "1")) { - // We'll try to initiate voicemail and thus we want to remove irrelevant string. - removePreviousDigitIfPossible('1'); - - List<PhoneAccountHandle> subscriptionAccountHandles = - PhoneAccountUtils.getSubscriptionPhoneAccounts(getActivity()); - boolean hasUserSelectedDefault = subscriptionAccountHandles.contains( - TelecomUtil.getDefaultOutgoingPhoneAccount(getActivity(), - PhoneAccount.SCHEME_VOICEMAIL)); - boolean needsAccountDisambiguation = subscriptionAccountHandles.size() > 1 - && !hasUserSelectedDefault; - - if (needsAccountDisambiguation || isVoicemailAvailable()) { - // On a multi-SIM phone, if the user has not selected a default - // subscription, initiate a call to voicemail so they can select an account - // from the "Call with" dialog. - callVoicemail(); - } else if (getActivity() != null) { - // Voicemail is unavailable maybe because Airplane mode is turned on. - // Check the current status and show the most appropriate error message. - final boolean isAirplaneModeOn = - Settings.System.getInt(getActivity().getContentResolver(), - Settings.System.AIRPLANE_MODE_ON, 0) != 0; - if (isAirplaneModeOn) { - DialogFragment dialogFragment = ErrorDialogFragment.newInstance( - R.string.dialog_voicemail_airplane_mode_message); - dialogFragment.show(getFragmentManager(), - "voicemail_request_during_airplane_mode"); - } else { - DialogFragment dialogFragment = ErrorDialogFragment.newInstance( - R.string.dialog_voicemail_not_ready_message); - dialogFragment.show(getFragmentManager(), "voicemail_not_ready"); - } + if (id == R.id.deleteButton) { + digits.clear(); + return true; + } else if (id == R.id.one) { + if (isDigitsEmpty() || TextUtils.equals(mDigits.getText(), "1")) { + // We'll try to initiate voicemail and thus we want to remove irrelevant string. + removePreviousDigitIfPossible('1'); + + List<PhoneAccountHandle> subscriptionAccountHandles = + PhoneAccountUtils.getSubscriptionPhoneAccounts(getActivity()); + boolean hasUserSelectedDefault = subscriptionAccountHandles.contains( + TelecomUtil.getDefaultOutgoingPhoneAccount(getActivity(), + PhoneAccount.SCHEME_VOICEMAIL)); + boolean needsAccountDisambiguation = subscriptionAccountHandles.size() > 1 + && !hasUserSelectedDefault; + + if (needsAccountDisambiguation || isVoicemailAvailable()) { + // On a multi-SIM phone, if the user has not selected a default + // subscription, initiate a call to voicemail so they can select an account + // from the "Call with" dialog. + callVoicemail(); + } else if (getActivity() != null) { + // Voicemail is unavailable maybe because Airplane mode is turned on. + // Check the current status and show the most appropriate error message. + final boolean isAirplaneModeOn = + Settings.System.getInt(getActivity().getContentResolver(), + Settings.System.AIRPLANE_MODE_ON, 0) != 0; + if (isAirplaneModeOn) { + DialogFragment dialogFragment = ErrorDialogFragment.newInstance( + R.string.dialog_voicemail_airplane_mode_message); + dialogFragment.show(getFragmentManager(), + "voicemail_request_during_airplane_mode"); + } else { + DialogFragment dialogFragment = ErrorDialogFragment.newInstance( + R.string.dialog_voicemail_not_ready_message); + dialogFragment.show(getFragmentManager(), "voicemail_not_ready"); } - return true; } - return false; - } - case R.id.zero: { - if (mPressedDialpadKeys.contains(view)) { - // If the zero key is currently pressed, then the long press occurred by touch - // (and not via other means like certain accessibility input methods). - // Remove the '0' that was input when the key was first pressed. - removePreviousDigitIfPossible('0'); - } - - keyPressed(KeyEvent.KEYCODE_PLUS); - - // Stop tone immediately - stopTone(); - mPressedDialpadKeys.remove(view); - return true; } - case R.id.digits: { - // Right now EditText does not show the "paste" option when cursor is not visible. - // To show that, make the cursor visible, and return false, letting the EditText - // show the option by itself. - mDigits.setCursorVisible(true); - return false; + return false; + } else if (id == R.id.zero) { + if (mPressedDialpadKeys.contains(view)) { + // If the zero key is currently pressed, then the long press occurred by touch + // (and not via other means like certain accessibility input methods). + // Remove the '0' that was input when the key was first pressed. + removePreviousDigitIfPossible('0'); } + keyPressed(KeyEvent.KEYCODE_PLUS); + stopTone(); + mPressedDialpadKeys.remove(view); + return true; + } else if (id == R.id.digits) { + mDigits.setCursorVisible(true); + return false; } return false; } @@ -1438,31 +1389,20 @@ public class DialpadFragment extends Fragment DialpadChooserAdapter.ChoiceItem item = (DialpadChooserAdapter.ChoiceItem) parent.getItemAtPosition(position); int itemId = item.id; - switch (itemId) { - case DialpadChooserAdapter.DIALPAD_CHOICE_USE_DTMF_DIALPAD: - // Log.i(TAG, "DIALPAD_CHOICE_USE_DTMF_DIALPAD"); - // Fire off an intent to go back to the in-call UI - // with the dialpad visible. - returnToInCallScreen(true); - break; - - case DialpadChooserAdapter.DIALPAD_CHOICE_RETURN_TO_CALL: - // Log.i(TAG, "DIALPAD_CHOICE_RETURN_TO_CALL"); - // Fire off an intent to go back to the in-call UI - // (with the dialpad hidden). - returnToInCallScreen(false); - break; - - case DialpadChooserAdapter.DIALPAD_CHOICE_ADD_NEW_CALL: - // Log.i(TAG, "DIALPAD_CHOICE_ADD_NEW_CALL"); - // Ok, guess the user really did want to be here (in the - // regular Dialer) after all. Bring back the normal Dialer UI. - showDialpadChooser(false); - break; - - default: - Log.w(TAG, "onItemClick: unexpected itemId: " + itemId); - break; + if (itemId == DialpadChooserAdapter.DIALPAD_CHOICE_USE_DTMF_DIALPAD) {// Log.i(TAG, "DIALPAD_CHOICE_USE_DTMF_DIALPAD"); + // Fire off an intent to go back to the in-call UI + // with the dialpad visible. + returnToInCallScreen(true); + } else if (itemId == DialpadChooserAdapter.DIALPAD_CHOICE_RETURN_TO_CALL) {// Log.i(TAG, "DIALPAD_CHOICE_RETURN_TO_CALL"); + // Fire off an intent to go back to the in-call UI + // (with the dialpad hidden). + returnToInCallScreen(false); + } else if (itemId == DialpadChooserAdapter.DIALPAD_CHOICE_ADD_NEW_CALL) {// Log.i(TAG, "DIALPAD_CHOICE_ADD_NEW_CALL"); + // Ok, guess the user really did want to be here (in the + // regular Dialer) after all. Bring back the normal Dialer UI. + showDialpadChooser(false); + } else { + Log.w(TAG, "onItemClick: unexpected itemId: " + itemId); } } @@ -1506,19 +1446,19 @@ public class DialpadFragment extends Fragment @Override public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_2s_pause: - updateDialString(PAUSE); - return true; - case R.id.menu_add_wait: - updateDialString(WAIT); - return true; - case R.id.menu_call_with_note: - CallSubjectDialog.start(getActivity(), mDigits.getText().toString()); - hideAndClearDialpad(false); - return true; - default: - return false; + int resId = item.getItemId(); + if (resId == R.id.menu_2s_pause) { + updateDialString(PAUSE); + return true; + } else if (resId == R.id.menu_add_wait) { + updateDialString(WAIT); + return true; + } else if (resId == R.id.menu_call_with_note) { + CallSubjectDialog.start(getActivity(), mDigits.getText().toString()); + hideAndClearDialpad(false); + return true; + } else { + return false; } } diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java index e231c6afd..a8786609b 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java +++ b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java @@ -180,22 +180,19 @@ public class BlockedNumbersFragment extends ListFragment return; } - switch (view.getId()) { - case R.id.add_number_linear_layout: - activity.showSearchUi(); - break; - case R.id.view_numbers_button: - activity.showNumbersToImportPreviewUi(); - break; - case R.id.import_button: - FilteredNumbersUtil.importSendToVoicemailContacts(activity, - new ImportSendToVoicemailContactsListener() { - @Override - public void onImportComplete() { - mImportSettings.setVisibility(View.GONE); - } - }); - break; + int resId = view.getId(); + if (resId == R.id.add_number_linear_layout) { + activity.showSearchUi(); + } else if (resId == R.id.view_numbers_button) { + activity.showNumbersToImportPreviewUi(); + } else if (resId == R.id.import_button) { + FilteredNumbersUtil.importSendToVoicemailContacts(activity, + new ImportSendToVoicemailContactsListener() { + @Override + public void onImportComplete() { + mImportSettings.setVisibility(View.GONE); + } + }); } } @Override diff --git a/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java b/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java index 153d73cde..8b24c06da 100644 --- a/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java +++ b/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java @@ -116,21 +116,18 @@ public class ViewNumbersToImportFragment extends ListFragment @Override public void onClick(final View view) { - switch (view.getId()) { - case R.id.import_button: - FilteredNumbersUtil.importSendToVoicemailContacts(getContext(), - new ImportSendToVoicemailContactsListener() { - @Override - public void onImportComplete() { - if (getActivity() != null) { - getActivity().onBackPressed(); - } + if (view.getId() == R.id.import_button) { + FilteredNumbersUtil.importSendToVoicemailContacts(getContext(), + new ImportSendToVoicemailContactsListener() { + @Override + public void onImportComplete() { + if (getActivity() != null) { + getActivity().onBackPressed(); } - }); - break; - case R.id.cancel_button: - getActivity().onBackPressed(); - break; + } + }); + } else if (view.getId() == R.id.cancel_button) { + getActivity().onBackPressed(); } } } |