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

Commit 9650aeaa authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "Dialpad : T9 add to contact if no match found" into ics

parents e51760f6 19306cb6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -18,11 +18,13 @@
		<TextView
			android:id="@+id/rowName"
			android:layout_weight="0.5"
			android:gravity="center_vertical"
			android:layout_width="match_parent"
			android:layout_height="match_parent" />
		<TextView
			android:id="@+id/rowNumber"
			android:layout_weight="0.5"
			android:gravity="center_vertical"
			android:layout_width="match_parent"
			android:layout_height="match_parent" />
	</LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
    <string name="t9_state_summary">Enable T9 searching in dialer</string>
    <string name="t9_dial_click_title">Dial selected contact</string>
    <string name="t9_dial_click_summary">Dial the selected contact for T9</string>
    <string name="t9_add_to_contacts">Add to contacts</string>
    <string name="t9_map_row_2">2abcàáâäåɑæçǽćčá</string>
    <string name="t9_map_row_3">3deféèêë</string>
    <string name="t9_map_row_4">4ghiíìïîǵ</string>
+22 −18
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -48,11 +47,9 @@ import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.DialerKeyListener;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -73,7 +70,6 @@ import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.QuickContactBadge;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.widget.ViewSwitcher;
@@ -281,6 +277,7 @@ public class DialpadFragment extends Fragment
        mT9ListTop = (ListView) fragmentView.findViewById(R.id.t9listtop);
        if (mT9ListTop != null) {
            mT9ListTop.setOnItemClickListener(this);
            mT9ListTop.setTag(new ContactItem());
        }
        mT9Toggle = (ToggleButton) fragmentView.findViewById(R.id.t9toggle);
        if (mT9Toggle != null) {
@@ -750,6 +747,12 @@ public class DialpadFragment extends Fragment
        if (length > 0) {
            if (sT9Search != null) {
                T9SearchResult result = sT9Search.search(mDigits.getText().toString());
                if (mT9AdapterTop == null) {
                    mT9AdapterTop = sT9Search.new T9Adapter(getActivity(), 0, new ArrayList<ContactItem>(), getActivity().getLayoutInflater(), mPhotoLoader);
                    mT9AdapterTop.setNotifyOnChange(true);
                } else {
                    mT9AdapterTop.clear();
                }
                if (result != null) {
                    if (mT9Adapter == null) {
                        mT9Adapter = sT9Search.new T9Adapter(getActivity(), 0, result.getResults(),getActivity().getLayoutInflater(), mPhotoLoader);
@@ -761,28 +764,24 @@ public class DialpadFragment extends Fragment
                    if (mT9List.getAdapter() == null) {
                        mT9List.setAdapter(mT9Adapter);
                    }
                    if (mT9AdapterTop == null) {
                        mT9AdapterTop = sT9Search.new T9Adapter(getActivity(), 0, new ArrayList<ContactItem>(), getActivity().getLayoutInflater(), mPhotoLoader);
                        mT9AdapterTop.setNotifyOnChange(true);
                    } else {
                        mT9AdapterTop.clear();
                    }
                    mT9AdapterTop.add(result.getTopContact());
                    if (mT9ListTop.getAdapter() == null) {
                        mT9ListTop.setAdapter(mT9AdapterTop);
                    }

                    mT9ListTop.setVisibility(View.VISIBLE);
                    if (result.getNumResults()>  1) {
                        mT9Toggle.setVisibility(View.VISIBLE);
                    } else {
                        mT9Toggle.setVisibility(View.GONE);
                    }
                    mT9Toggle.setTag(null);
                } else {
                    mT9ListTop.setVisibility(View.INVISIBLE);
                    mT9Toggle.setVisibility(View.INVISIBLE);
                    ((ContactItem) mT9ListTop.getTag()).number = mDigits.getText().toString();
                    mT9AdapterTop.add((ContactItem) mT9ListTop.getTag());
                    mT9Toggle.setTag(new Boolean(true));
                    mT9Toggle.setVisibility(View.GONE);
                    toggleT9();
                }
                mT9ListTop.setVisibility(View.VISIBLE);
                if (mT9ListTop.getAdapter() == null) {
                    mT9ListTop.setAdapter(mT9AdapterTop);
                }
            }
        } else {
            mT9ListTop.setVisibility(View.INVISIBLE);
@@ -1373,7 +1372,12 @@ public class DialpadFragment extends Fragment
            if (parent == mT9List) {
                setFormattedDigits(mT9Adapter.getItem(position).number,null);
            } else {
                if (mT9Toggle.getTag() == null) {
                    setFormattedDigits(mT9AdapterTop.getItem(position).number,null);
                } else {
                    startActivity(getAddToContactIntent(mDigits.getText()));
                    return;
                }
            }
            if (dialOnTap()) {
                dialButtonPressed();
+28 −21
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import java.util.Set;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -294,8 +293,15 @@ class T9Search {
                holder = (ViewHolder) convertView.getTag();
            }
            ContactItem o = mItems.get(position);
            if (o.name == null) {
                holder.name.setText(mContext.getResources().getString(R.string.t9_add_to_contacts));
                holder.number.setVisibility(View.GONE);
                holder.icon.setImageResource(R.drawable.ic_menu_add_field_holo_light);
                holder.icon.assignContactFromPhone(o.number, true);
            } else {
                holder.name.setText(o.name, TextView.BufferType.SPANNABLE);
                holder.number.setText(o.normalNumber + " (" + o.groupType + ")", TextView.BufferType.SPANNABLE);
                holder.number.setVisibility(View.VISIBLE);
                if (o.nameMatchId != -1) {
                    Spannable s = (Spannable) holder.name.getText();
                    int nameStart = o.normalName.indexOf(mPrevInput);
@@ -315,6 +321,7 @@ class T9Search {
                else
                    holder.icon.setImageResource(ContactPhotoManager.getDefaultAvatarResId(false, true));
                holder.icon.assignContactFromPhone(o.number, true);
            }
            return convertView;
        }