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

Commit 35888165 authored by Danesh M's avatar Danesh M
Browse files

Dialpad : T9 layout/functionality fixes

This patchset addresses the following :

Highlight matches in results (Based on m0viefreak's commit)
Switch topbar to a listview to maintain consistency (Based on m0viefreak's commit)
Fix overlay issue where if list view open, and via preferences t9 is turned off and returned to dialer
Fix issue where t9 uses last input rather than re-querying
Adjust layout for more space for contacts with long names

Patchset 2 : New toggle drawables by prash

Change-Id: I00f2a6aed2d7ae0213efab8c2e2028be133551c2
parent 87fed5cf
Loading
Loading
Loading
Loading
−1.7 KiB (1.8 KiB)
Loading image diff...
−1.66 KiB (1.79 KiB)
Loading image diff...
+8 −19
Original line number Diff line number Diff line
@@ -37,32 +37,21 @@
        android:layout_gravity="center"
        android:gravity="center"
        android:layout_weight="0.3">
        <QuickContactBadge
            android:id="@+id/t9badge"
            android:layout_width="40dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_height="40dp"
        <ListView
            android:id="@+id/t9listtop"
            android:visibility="invisible"
            android:layout_centerVertical="true"
            android:focusable="true" />
        <TextView
            android:id="@+id/t9result"
            android:divider="@null"
            android:gravity="center_vertical"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:gravity="center"
            android:visibility="invisible"
            android:layout_width="0dp"
            android:clickable="true"
            android:background="@drawable/t9result_state"
            android:layout_height="match_parent" />
            android:layout_height="40dp" />
        <ToggleButton
            android:id="@+id/t9toggle"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:visibility="invisible"
            android:scaleType="centerInside"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="5dp"
            android:textOn=""
            android:textOff=""
            android:background="@drawable/t9toggle_state"
+9 −21
Original line number Diff line number Diff line
@@ -62,35 +62,23 @@
        android:layout_height="0px"
        android:id="@+id/t9topbar"
        android:background="@drawable/dialpad_background"
        android:layout_gravity="center"
        android:gravity="center"
        android:gravity="center_vertical"
        android:layout_weight="0.1">
        <QuickContactBadge
            android:id="@+id/t9badge"
            android:layout_width="40dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_height="40dp"
        <ListView
            android:id="@+id/t9listtop"
            android:visibility="invisible"
            android:layout_centerVertical="true"
            android:focusable="true" />
        <TextView
            android:id="@+id/t9result"
            android:divider="@null"
            android:gravity="center_vertical"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:gravity="center"
            android:visibility="invisible"
            android:layout_width="0dp"
            android:clickable="true"
            android:background="@drawable/t9result_state"
            android:layout_height="match_parent" />
            android:layout_height="40dp" />
        <ToggleButton
            android:id="@+id/t9toggle"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:visibility="invisible"
            android:scaleType="centerInside"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="5dp"
            android:textOn=""
            android:textOff=""
            android:background="@drawable/t9toggle_state"
+39 −56
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.contacts.dialpad;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -82,6 +84,7 @@ import com.android.contacts.R;
import com.android.contacts.SpecialCharSequenceMgr;
import com.android.contacts.activities.DialtactsActivity;
import com.android.contacts.activities.DialtactsActivity.ViewPagerVisibilityListener;
import com.android.contacts.dialpad.T9Search.ContactItem;
import com.android.contacts.dialpad.T9Search.T9Adapter;
import com.android.contacts.dialpad.T9Search.T9SearchResult;
import com.android.contacts.util.PhoneNumberFormatter;
@@ -139,9 +142,9 @@ public class DialpadFragment extends Fragment
    private ContactPhotoManager mPhotoLoader;
    private ToggleButton mT9Toggle;
    private ListView mT9List;
    private TextView mT9Result;
    private QuickContactBadge mT9ResultBadge;
    private ListView mT9ListTop;
    private T9Adapter mT9Adapter;
    private T9Adapter mT9AdapterTop;
    private ViewSwitcher mT9Flipper;
    private LinearLayout mT9Top;

@@ -271,15 +274,14 @@ public class DialpadFragment extends Fragment
        mDigits.setOnKeyListener(this);
        mDigits.setOnLongClickListener(this);
        mDigits.addTextChangedListener(this);
        mT9Result = (TextView) fragmentView.findViewById(R.id.t9result);
        if (mT9Result != null) {
            mT9Result.setOnClickListener(this);
        }
        mT9ResultBadge = (QuickContactBadge) fragmentView.findViewById(R.id.t9badge);
        mT9List = (ListView) fragmentView.findViewById(R.id.t9list);
        if (mT9List!= null) {
            mT9List.setOnItemClickListener(this);
        }
        mT9ListTop = (ListView) fragmentView.findViewById(R.id.t9listtop);
        if (mT9ListTop != null) {
            mT9ListTop.setOnItemClickListener(this);
        }
        mT9Toggle = (ToggleButton) fragmentView.findViewById(R.id.t9toggle);
        if (mT9Toggle != null) {
            mT9Toggle.setOnClickListener(this);
@@ -707,6 +709,7 @@ public class DialpadFragment extends Fragment
    private void hideT9 () {
        if (mDigitsContainer == null) {
            if (!isT9On()) {
                toggleT9();
                mT9Top.setVisibility(View.GONE);
            }else{
                mT9Top.setVisibility(View.VISIBLE);
@@ -714,6 +717,7 @@ public class DialpadFragment extends Fragment
        } else {
            LinearLayout.LayoutParams digitsLayout = (LayoutParams) mDigitsContainer.getLayoutParams();
            if (!isT9On()) {
                toggleT9();
                digitsLayout.weight = 0.2f;
                mT9Top.setVisibility(View.GONE);
            } else {
@@ -729,10 +733,6 @@ public class DialpadFragment extends Fragment
     * Toggles between expanded list and dialpad
     */
    private void toggleT9() {
        if (!isT9On()) {
            hideT9();
            return;
        }
        if (mT9Flipper.getCurrentView() == mT9List) {
            mT9Toggle.setChecked(false);
            animateT9();
@@ -751,37 +751,9 @@ public class DialpadFragment extends Fragment
            if (sT9Search != null) {
                T9SearchResult result = sT9Search.search(mDigits.getText().toString());
                if (result != null) {
                    T9Search.ContactItem contact = result.getTopContact();
                    mT9Result.setText(contact.name + " : " + contact.normalNumber, TextView.BufferType.SPANNABLE);
                    Spannable WordtoSpan = (Spannable) mT9Result.getText();
                    String normalizedInput = T9Search.removeNonDigits(mDigits.getText().toString());
                    int normalizedLength = normalizedInput.length();
                    if (contact.nameMatchId != -1) {
                        int nameStart = contact.normalName.indexOf(normalizedInput);
                        WordtoSpan.setSpan(new ForegroundColorSpan(getResources().getColor(android.R.color.holo_blue_dark)), nameStart,
                                nameStart + normalizedLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                    }
                    if (contact.numberMatchId != -1) {
                        int numberStart = contact.name.length() + 3 + contact.numberMatchId;
                        WordtoSpan.setSpan(new ForegroundColorSpan(getResources().getColor(android.R.color.holo_blue_dark)),
                                numberStart, numberStart + normalizedLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                    }
                    mT9Result.setText(WordtoSpan);
                    mT9ResultBadge.assignContactFromPhone(contact.number, true);
                    mT9ResultBadge.setTag(contact.number);
                    if (contact.photo != null)
                        mPhotoLoader.loadPhoto(mT9ResultBadge, contact.photo, false, true);
                    else
                        mT9ResultBadge.setImageResource(ContactPhotoManager.getDefaultAvatarResId(false, true));
                    if (result.getNumResults()>  1) {
                        mT9Toggle.setVisibility(View.VISIBLE);
                    } else {
                        mT9Toggle.setVisibility(View.GONE);
                    }
                    if (mT9Adapter == null) {
                        mT9Adapter = new T9Adapter(getActivity(), 0, result.getResults(),getActivity().getLayoutInflater(), mPhotoLoader);
                        mT9Adapter = sT9Search.new T9Adapter(getActivity(), 0, result.getResults(),getActivity().getLayoutInflater(), mPhotoLoader);
                        mT9Adapter.setNotifyOnChange(true);
                        mT9List.setAdapter(mT9Adapter);
                    } else {
                        mT9Adapter.clear();
                        mT9Adapter.addAll(result.getResults());
@@ -789,18 +761,31 @@ public class DialpadFragment extends Fragment
                    if (mT9List.getAdapter() == null) {
                        mT9List.setAdapter(mT9Adapter);
                    }
                    mT9ResultBadge.setVisibility(View.VISIBLE);
                    mT9Result.setVisibility(View.VISIBLE);
                    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);
                    }
                } else {
                    mT9ResultBadge.setVisibility(View.INVISIBLE);
                    mT9Result.setVisibility(View.INVISIBLE);
                    mT9ListTop.setVisibility(View.INVISIBLE);
                    mT9Toggle.setVisibility(View.INVISIBLE);
                    toggleT9();
                }
            }
        } else {
            mT9ResultBadge.setVisibility(View.INVISIBLE);
            mT9Result.setVisibility(View.INVISIBLE);
            mT9ListTop.setVisibility(View.INVISIBLE);
            mT9Toggle.setVisibility(View.INVISIBLE);
            toggleT9();
        }
@@ -875,6 +860,7 @@ public class DialpadFragment extends Fragment
                    dialButtonPressed();
                    return true;
                }
                searchContacts();
                break;
        }
        return false;
@@ -976,13 +962,6 @@ public class DialpadFragment extends Fragment
                animateT9();
                return;
            }
            case R.id.t9result: {
                setFormattedDigits(mT9ResultBadge.getTag().toString(),null);
                if (dialOnTap()) {
                    dialButtonPressed();
                }
                return;
            }
        }
    }

@@ -1263,7 +1242,7 @@ public class DialpadFragment extends Fragment
            }
            mDialpadChooser.setAdapter(mDialpadChooserAdapter);
        } else {
            if (isT9On() && !mDigits.getText().toString().isEmpty()) {
            if (isT9On()) {
                if (mT9Flipper.getCurrentView() != mT9List) {
                    mT9Toggle.setChecked(false);
                    searchContacts();
@@ -1389,8 +1368,12 @@ public class DialpadFragment extends Fragment
     * Handle clicks from the dialpad chooser.
     */
    public void onItemClick(AdapterView parent, View v, int position, long id) {
        if (parent == mT9List || parent == mT9ListTop) {
            if (parent == mT9List) {
                setFormattedDigits(mT9Adapter.getItem(position).number,null);
            } else {
                setFormattedDigits(mT9AdapterTop.getItem(position).number,null);
            }
            if (dialOnTap()) {
                dialButtonPressed();
            }
Loading