diff options
Diffstat (limited to 'src/com/android')
7 files changed, 265 insertions, 347 deletions
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(); } } } |