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

Commit 4452f979 authored by Danesh Mondegarian's avatar Danesh Mondegarian Committed by Gerrit Code Review
Browse files

Dialer : Fix T9 add to contacts

Use activity context rather than application
QuickContactBadge can only function with an activity context,
in its current state, it crashes with :

E/AndroidRuntime(12944): FATAL EXCEPTION: main
E/AndroidRuntime(12944): android.util.AndroidRuntimeException:
Calling startActivity() from outside of an Activity  context requires
the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

Patchset 2 : only use activity context for adapter

Patchset 3: Get rid of mContext variable and rearrange parameters

Change-Id: If6dec5a5e12e7006637331861e8d3d4275c31cd0
parent 5a6b835f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -829,7 +829,7 @@ public class DialpadFragment extends Fragment
        if (length > 0) {
            T9SearchResult result = mT9Search.search(mDigits.getText().toString());
            if (mT9AdapterTop == null) {
                mT9AdapterTop = mT9Search.createT9Adapter(new ArrayList<ContactItem>());
                mT9AdapterTop = mT9Search.createT9Adapter(getActivity(), new ArrayList<ContactItem>());
                mT9AdapterTop.setNotifyOnChange(true);
            } else {
                mT9AdapterTop.clear();
@@ -837,7 +837,7 @@ public class DialpadFragment extends Fragment

            if (result != null) {
                if (mT9Adapter == null) {
                    mT9Adapter = mT9Search.createT9Adapter(result.getResults());
                    mT9Adapter = mT9Search.createT9Adapter(getActivity(), result.getResults());
                    mT9Adapter.setNotifyOnChange(true);
                } else {
                    mT9Adapter.clear();
+7 −7
Original line number Diff line number Diff line
@@ -508,8 +508,8 @@ public class T9SearchCache implements ComponentCallbacks2 {
        return sb.toString();
    }

    public T9Adapter createT9Adapter(ArrayList<ContactItem> items) {
        return new T9Adapter(items);
    public T9Adapter createT9Adapter(Context context, ArrayList<ContactItem> items) {
        return new T9Adapter(context, items);
    }

    protected class T9Adapter extends ArrayAdapter<ContactItem> {
@@ -519,10 +519,10 @@ public class T9SearchCache implements ComponentCallbacks2 {
        private ContactPhotoManager mPhotoLoader;
        private View mLoadingView;

        protected T9Adapter(ArrayList<ContactItem> items) {
            super(mContext, 0, items);
            mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mPhotoLoader = ContactPhotoManager.getInstance(mContext);
        protected T9Adapter(Context context, ArrayList<ContactItem> items) {
            super(context, 0, items);
            mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mPhotoLoader = ContactPhotoManager.getInstance(context);
            mItems = items;
        }

@@ -550,7 +550,7 @@ public class T9SearchCache implements ComponentCallbacks2 {

            ContactItem o = mItems.get(position);
            if (o.nameEntries.isEmpty()) {
                holder.name.setText(mContext.getResources().getString(R.string.t9_add_to_contacts));
                holder.name.setText(getContext().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);