Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef2f04cc authored by blong's avatar blong Committed by Xiaojing Zhang
Browse files

Support editing the contact phone number before calling it

- Allow user to edit the phone number via long click in the
  contact detailed view before dialing

Change-Id: Ic901842fc134470ffcddfd0a10a10f8c3b947a0e
parent e2b1f7c7
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -938,6 +938,7 @@ public class ExpandingEntryCardView extends CardView {
        private final String mMimeType;
        private final long mId;
        private final boolean mIsSuperPrimary;
        private String mData;

        public EntryContextMenuInfo(String copyText, String copyLabel, String mimeType, long id,
                boolean isSuperPrimary) {
@@ -948,6 +949,16 @@ public class ExpandingEntryCardView extends CardView {
            mIsSuperPrimary = isSuperPrimary;
        }

        public EntryContextMenuInfo(String copyText, String copyLabel,String mimeType, long id,
                boolean isSuperPrimary, String data) {
            mCopyText = copyText;
            mCopyLabel = copyLabel;
            mMimeType = mimeType;
            mId = id;
            mIsSuperPrimary = isSuperPrimary;
            mData = data;
        }

        public String getCopyText() {
            return mCopyText;
        }
@@ -966,6 +977,11 @@ public class ExpandingEntryCardView extends CardView {

        public boolean isSuperPrimary() {
            return mIsSuperPrimary;
        
        }

        public String getData() {
            return mData;
        }
    }

+15 −2
Original line number Diff line number Diff line
@@ -302,7 +302,6 @@ public class QuickContactActivity extends ContactsActivity {
    private static final int MIN_NUM_COLLAPSED_RECENT_ENTRIES_SHOWN = 3;
    private static final int CARD_ENTRY_ID_EDIT_CONTACT = -2;


    private static final int[] mRecentLoaderIds = new int[]{
        LOADER_SMS_ID,
        LOADER_CALENDAR_ID,
@@ -396,6 +395,7 @@ public class QuickContactActivity extends ContactsActivity {
        static final int COPY_TEXT = 0;
        static final int CLEAR_DEFAULT = 1;
        static final int SET_DEFAULT = 2;
        static final int EDIT_BEFORE_CALL = 3;
    }

    private final OnCreateContextMenuListener mEntryContextMenuListener =
@@ -434,6 +434,10 @@ public class QuickContactActivity extends ContactsActivity {
            } else if (!onlyOneOfMimeType) {
                menu.add(ContextMenu.NONE, ContextMenuIds.SET_DEFAULT,
                        ContextMenu.NONE, getString(R.string.set_default));

            if (Phone.CONTENT_ITEM_TYPE.equals(info.getMimeType())) {
                menu.add(ContextMenu.NONE, ContextMenuIds.EDIT_BEFORE_CALL,
                        ContextMenu.NONE, getString(R.string.edit_before_call));
            }
        }
    };
@@ -463,6 +467,9 @@ public class QuickContactActivity extends ContactsActivity {
                        menuInfo.getId());
                this.startService(clearIntent);
                return true;
            case ContextMenuIds.EDIT_BEFORE_CALL:
                callByEdit(menuInfo.getData());
                return true;
            default:
                throw new IllegalArgumentException("Unknown menu option " + item.getItemId());
        }
@@ -1382,7 +1389,7 @@ public class QuickContactActivity extends ContactsActivity {
                        TextDirectionHeuristics.LTR);
                entryContextMenuInfo = new EntryContextMenuInfo(header,
                        res.getString(R.string.phoneLabelsGroup), dataItem.getMimeType(),
                        dataItem.getId(), dataItem.isSuperPrimary());
                        dataItem.getId(), dataItem.isSuperPrimary(), header);
                if (phone.hasKindTypeColumn(kind)) {
                    text = Phone.getTypeLabel(res, phone.getKindTypeColumn(kind),
                            phone.getLabel()).toString();
@@ -2057,6 +2064,12 @@ public class QuickContactActivity extends ContactsActivity {
        }
    }

    private void callByEdit(String data) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts(PhoneAccount.SCHEME_TEL,
                data, null));
        startActivity(intent);
    }

    /**
     * Creates a launcher shortcut with the current contact.
     */