diff options
| author | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 00:47:16 +0000 |
|---|---|---|
| committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 05:26:32 +0000 |
| commit | 3cb06ac57579ba579ba4954401a56cf93848d77f (patch) | |
| tree | 48fa4b8f245f175aba9aaa0652d2955e282a4449 /src/com/android/dialer | |
| parent | c05baae39c0d852656075d1eaca59d54ed905aa5 (diff) | |
| parent | 22d574bdded22377a7d1389df1491ace096d1848 (diff) | |
| download | packages_apps_Dialer-3cb06ac57579ba579ba4954401a56cf93848d77f.tar.gz packages_apps_Dialer-3cb06ac57579ba579ba4954401a56cf93848d77f.tar.bz2 packages_apps_Dialer-3cb06ac57579ba579ba4954401a56cf93848d77f.zip | |
Merge tag 'android-6.0.0_r26' into cm-13.0
Android 6.0.0 release 26
Change-Id: I2dce2b8ad58cd52f63a674c690971361b9b89e30
Diffstat (limited to 'src/com/android/dialer')
7 files changed, 100 insertions, 44 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index c6ec8e1a0..56f2cb1dc 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -50,6 +50,7 @@ import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.util.UriUtils; import com.android.dialer.calllog.CallDetailHistoryAdapter; import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener; import com.android.dialer.calllog.CallLogAsyncTaskUtil; @@ -162,7 +163,7 @@ public class CallDetailActivity extends Activity new CallDetailHistoryAdapter(mContext, mInflater, mCallTypeHelper, details)); String lookupKey = contactUri == null ? null - : ContactInfoHelper.getLookupKeyFromUri(contactUri); + : UriUtils.getLookupKeyFromUri(contactUri); final boolean isBusiness = mContactInfoHelper.isBusiness(firstDetails.sourceType); diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 85d1c383a..5a87bc8ce 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -22,6 +22,8 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; +import android.provider.ContactsContract; +import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.v7.widget.RecyclerView; import android.os.Bundle; import android.os.Trace; @@ -526,13 +528,16 @@ public class CallLogAdapter extends GroupingListAdapter views.rowId = c.getLong(CallLogQuery.ID); // Store values used when the actions ViewStub is inflated on expansion. views.number = number; + views.displayNumber = details.displayNumber; views.numberPresentation = numberPresentation; views.callType = c.getInt(CallLogQuery.CALL_TYPE); views.accountHandle = accountHandle; views.voicemailUri = c.getString(CallLogQuery.VOICEMAIL_URI); // Stash away the Ids of the calls so that we can support deleting a row in the call log. views.callIds = getCallIds(c, count); - + views.isBusiness = mContactInfoHelper.isBusiness(info.sourceType); + views.numberType = (String) Phone.getTypeLabel(mContext.getResources(), details.numberType, + details.numberLabel); // Default case: an item in the call log. views.primaryActionView.setVisibility(View.VISIBLE); @@ -563,7 +568,7 @@ public class CallLogAdapter extends GroupingListAdapter nameForDefaultImage = info.name; } views.setPhoto(info.photoId, info.photoUri, info.lookupUri, nameForDefaultImage, - isVoicemailNumber, mContactInfoHelper.isBusiness(info.sourceType)); + isVoicemailNumber, views.isBusiness); mCallLogListItemHelper.setPhoneCallDetails(views, details); } diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 361e1c7a3..0fa5e6d33 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog; +import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.content.Intent; @@ -29,18 +30,16 @@ import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; -import android.view.ViewTreeObserver; import android.widget.QuickContactBadge; import android.widget.ImageView; import android.widget.TextView; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; +import com.android.contacts.common.dialog.CallSubjectDialog; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.UriUtils; import com.android.dialer.R; -import com.android.dialer.calllog.CallLogAsyncTaskUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; @@ -80,6 +79,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public View addToExistingContactButtonView; public View sendMessageView; public View detailsButtonView; + public View callWithNoteButtonView; /** * The row Id for the first call associated with the call log entry. Used as a key for the @@ -100,12 +100,22 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public String number; /** + * The formatted phone number to display. + */ + public String displayNumber; + + /** * The phone number presentation for the current call log entry. Cached here as the call back * intent is set only when the actions ViewStub is inflated. */ public int numberPresentation; /** + * The type of the phone number (e.g. main, work, etc). + */ + public String numberType; + + /** * The type of call for the current call log entry. Cached here as the call back * intent is set only when the actions ViewStub is inflated. */ @@ -131,6 +141,11 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public CharSequence nameOrNumber; /** + * Whether this row is for a business or not. + */ + public boolean isBusiness; + + /** * The contact info for the contact displayed in this list item. */ public ContactInfo info; @@ -245,6 +260,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder detailsButtonView = actionsView.findViewById(R.id.details_action); detailsButtonView.setOnClickListener(this); + + callWithNoteButtonView = actionsView.findViewById(R.id.call_with_note_action); + callWithNoteButtonView.setOnClickListener(this); } bindActionButtons(); @@ -349,6 +367,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder sendMessageView.setTag(IntentProvider.getSendSmsIntentProvider(number)); mCallLogListItemHelper.setActionContentDescriptions(this); + + boolean supportsCallSubject = + mTelecomCallLogCache.doesAccountSupportCallSubject(accountHandle); + boolean isVoicemailNumber = + mTelecomCallLogCache.isVoicemailNumber(accountHandle, number); + callWithNoteButtonView.setVisibility( + supportsCallSubject && !isVoicemailNumber ? View.VISIBLE : View.GONE); } /** @@ -403,7 +428,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder String lookupKey = null; if (contactUri != null) { - lookupKey = ContactInfoHelper.getLookupKeyFromUri(contactUri); + lookupKey = UriUtils.getLookupKeyFromUri(contactUri); } DefaultImageRequest request = new DefaultImageRequest( @@ -423,6 +448,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (view.getId() == R.id.primary_action_button && !TextUtils.isEmpty(voicemailUri)) { mVoicemailPrimaryActionButtonClicked = true; mExpandCollapseListener.onClick(primaryActionView); + } else if (view.getId() == R.id.call_with_note_action) { + CallSubjectDialog.start( + (Activity) mContext, + info.photoId, + info.photoUri, + info.lookupUri, + (String) nameOrNumber /* top line of contact view in call subject dialog */, + isBusiness, + number, /* callable number used for ACTION_CALL intent */ + TextUtils.isEmpty(info.name) ? null : displayNumber, /* second line of contact + view in dialog. */ + numberType, /* phone number type (e.g. mobile) in second line of contact view */ + accountHandle); } else { final IntentProvider intentProvider = (IntentProvider) view.getTag(); if (intentProvider != null) { diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 20d33a003..2e07a03b1 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -394,24 +394,6 @@ public class ContactInfoHelper { } /** - * Parses the given URI to determine the original lookup key of the contact. - */ - public static String getLookupKeyFromUri(Uri lookupUri) { - // Would be nice to be able to persist the lookup key somehow to avoid having to parse - // the uri entirely just to retrieve the lookup key, but every uri is already parsed - // once anyway to check if it is an encoded JSON uri, so this has negligible effect - // on performance. - if (lookupUri != null && !UriUtils.isEncodedContactUri(lookupUri)) { - final List<String> segments = lookupUri.getPathSegments(); - // This returns the third path segment of the uri, where the lookup key is located. - // See {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}. - return (segments.size() < 3) ? null : Uri.encode(segments.get(2)); - } else { - return null; - } - } - - /** * Returns the contact information stored in an entry of the call log. * * @param c A cursor pointing to an entry in the call log. diff --git a/src/com/android/dialer/calllog/PhoneAccountUtils.java b/src/com/android/dialer/calllog/PhoneAccountUtils.java index 7eaa523f4..143d13e86 100644 --- a/src/com/android/dialer/calllog/PhoneAccountUtils.java +++ b/src/com/android/dialer/calllog/PhoneAccountUtils.java @@ -84,6 +84,21 @@ public class PhoneAccountUtils { } /** + * Determine whether a phone account supports call subjects. + * + * @return {@code true} if call subjects are supported, {@code false} otherwise. + */ + public static boolean getAccountSupportsCallSubject(Context context, + PhoneAccountHandle accountHandle) { + TelecomManager telecomManager = + (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); + final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle); + + return account == null ? false : + account.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT); + } + + /** * Retrieve the account metadata, but if the account does not exist or the device has only a * single registered and enabled account, return null. */ diff --git a/src/com/android/dialer/calllog/TelecomCallLogCache.java b/src/com/android/dialer/calllog/TelecomCallLogCache.java index ec1d24191..7071669e5 100644 --- a/src/com/android/dialer/calllog/TelecomCallLogCache.java +++ b/src/com/android/dialer/calllog/TelecomCallLogCache.java @@ -52,6 +52,7 @@ public class TelecomCallLogCache { new HashMap<>(); private final Map<PhoneAccountHandle, String> mPhoneAccountLabelCache = new HashMap<>(); private final Map<PhoneAccountHandle, Integer> mPhoneAccountColorCache = new HashMap<>(); + private final Map<PhoneAccountHandle, Boolean> mPhoneAccountCallWithNoteCache = new HashMap<>(); private boolean mHasCheckedForVideoEnabled; private boolean mIsVideoEnabled; @@ -64,6 +65,7 @@ public class TelecomCallLogCache { mVoicemailQueryCache.clear(); mPhoneAccountLabelCache.clear(); mPhoneAccountColorCache.clear(); + mPhoneAccountCallWithNoteCache.clear(); mHasCheckedForVideoEnabled = false; mIsVideoEnabled = false; @@ -121,4 +123,22 @@ public class TelecomCallLogCache { } return mIsVideoEnabled; } + + /** + * Determines if the PhoneAccount supports specifying a call subject (i.e. calling with a note) + * for outgoing calls. + * + * @param accountHandle The PhoneAccount handle. + * @return {@code true} if calling with a note is supported, {@code false} otherwise. + */ + public boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle) { + if (mPhoneAccountCallWithNoteCache.containsKey(accountHandle)) { + return mPhoneAccountCallWithNoteCache.get(accountHandle); + } else { + Boolean supportsCallWithNote = + PhoneAccountUtils.getAccountSupportsCallSubject(mContext, accountHandle); + mPhoneAccountCallWithNoteCache.put(accountHandle, supportsCallWithNote); + return supportsCallWithNote; + } + } } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index d65e2ebfe..31a3feb30 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -50,6 +50,7 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; import android.util.Log; +import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; @@ -69,6 +70,7 @@ import android.widget.TextView; import com.android.contacts.common.CallUtil; import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.dialog.CallSubjectDialog; import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.util.PhoneNumberFormatter; import com.android.contacts.common.util.StopWatch; @@ -81,7 +83,6 @@ import com.android.dialer.calllog.PhoneAccountUtils; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil; import com.android.phone.common.CallLogAsync; -import com.android.phone.common.HapticFeedback; import com.android.phone.common.animation.AnimUtils; import com.android.phone.common.dialpad.DialpadKeyButton; import com.android.phone.common.dialpad.DialpadView; @@ -224,9 +225,6 @@ public class DialpadFragment extends Fragment // determines if we want to playback local DTMF tones. private boolean mDTMFToneEnabled; - // Vibration (haptic feedback) for dialer key presses. - private final HapticFeedback mHaptic = new HapticFeedback(); - /** Identifier for the "Add Call" intent extra. */ private static final String ADD_CALL_MODE_KEY = "add_call_mode"; @@ -359,13 +357,6 @@ public class DialpadFragment extends Fragment mCurrentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - try { - mHaptic.init(getActivity(), - getResources().getBoolean(R.bool.config_enable_dialer_key_vibration)); - } catch (Resources.NotFoundException nfe) { - Log.e(TAG, "Vibrate control bool missing.", nfe); - } - mProhibitedPhoneNumberRegexp = getResources().getString( R.string.config_prohibited_phone_number_regexp); @@ -690,9 +681,6 @@ public class DialpadFragment extends Fragment stopWatch.lap("dtwd"); - // Retrieve the haptic feedback setting. - mHaptic.checkSystemSetting(); - stopWatch.lap("hptc"); mPressedDialpadKeys.clear(); @@ -826,7 +814,7 @@ public class DialpadFragment extends Fragment break; } - mHaptic.vibrate(); + getView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode); mDigits.onKeyDown(keyCode, event); @@ -937,9 +925,12 @@ public class DialpadFragment extends Fragment boolean enable = !isDigitsEmpty(); for (int i = 0; i < menu.size(); i++) { - menu.getItem(i).setEnabled(enable); + MenuItem item = menu.getItem(i); + item.setEnabled(enable); + if (item.getItemId() == R.id.menu_call_with_note) { + item.setVisible(CallUtil.isCallWithSubjectSupported(getContext())); + } } - super.show(); } }; @@ -953,7 +944,7 @@ public class DialpadFragment extends Fragment * pressed. */ public void dialButtonPressed() { - mHaptic.vibrate(); + getView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); handleDialButtonPressed(); } @@ -1025,7 +1016,7 @@ public class DialpadFragment extends Fragment public void onClick(View view) { switch (view.getId()) { case R.id.dialpad_floating_action_button: - mHaptic.vibrate(); + view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); handleDialButtonPressed(); break; case R.id.deleteButton: { @@ -1602,6 +1593,10 @@ public class DialpadFragment extends Fragment 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; } |
