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

Commit 230fa05c authored by Arnav Gupta's avatar Arnav Gupta
Browse files

QuickContact: onLongClick save item data to clipboard



We should be able to copy phone numbers, email address
etc from the QuickCOntact Dialog itself. Going into
the Contact page to be able to copy that data is
cumbersome.

Change-Id: I3620f156ad0a5e387dc3819adb012f1c945d35e6
Signed-off-by: default avatarArnav Gupta <championswimmer@aokp.co>
parent c30689e8
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">


    <!-- Toast displayed when QuickContact Item is copied by longpressed -->
    <string name="quick_contact_copied_toast">"Copied to clipboard"</string>
</resources>
+23 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.contacts.quickcontact;

import android.app.Fragment;
import android.content.ClipboardManager;
import android.content.ClipData;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -25,12 +28,14 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.contacts.common.ContactPresenceIconUtil;
import com.android.contacts.R;
@@ -44,6 +49,8 @@ public class QuickContactListFragment extends Fragment {
    private RelativeLayout mFragmentContainer;
    private Listener mListener;
    private String mMimeType;
    private ClipboardManager mClipBoard;
    private Toast longPressToast;

    public QuickContactListFragment(String mimeType) {
        setRetainInstance(true);
@@ -58,6 +65,9 @@ public class QuickContactListFragment extends Fragment {
        mListView.setItemsCanFocus(true);

        mFragmentContainer.setOnClickListener(mOutsideClickListener);
        mClipBoard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        longPressToast = Toast.makeText(getActivity(), R.string.quick_contact_copied_toast, Toast.LENGTH_SHORT);

        configureAdapter();
        return mFragmentContainer;
    }
@@ -121,6 +131,7 @@ public class QuickContactListFragment extends Fragment {
                        (ImageView) resultView.findViewById(R.id.presence_icon);

                actionsContainer.setOnClickListener(mPrimaryActionClickListener);
                actionsContainer.setOnLongClickListener(mPrimaryActionLongClickListener);
                actionsContainer.setTag(action);
                alternateActionButton.setOnClickListener(mSecondaryActionClickListener);
                alternateActionButton.setTag(action);
@@ -176,6 +187,18 @@ public class QuickContactListFragment extends Fragment {
        }
    };

    /** A data item was long clicked */
    protected final OnLongClickListener mPrimaryActionLongClickListener = new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            final Action action = (Action) v.getTag();
            ClipData clip = android.content.ClipData.newPlainText(action.getSubtitle(), action.getBody());
            mClipBoard.setPrimaryClip(clip);
            longPressToast.show();
            return true;
        }
    };

    /** A secondary action (SMS) was clicked */
    protected final OnClickListener mSecondaryActionClickListener = new OnClickListener() {
        @Override