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

Commit 8ebfa3d1 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Improvement to visual layout of call details.

Changes the styling for the call and SMS row, the history items, and
fixes the alignment of the name on top of the picture.

Bug: 5039572
Bug: 5121168
Change-Id: Ibeaa0621a7662d7537db0573a370f61f8a00e385
parent 6c70ef04
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -89,11 +89,12 @@
        android:layout_width="wrap_content"
        android:layout_height="0dip"
        android:layout_alignLeft="@id/photo_text_bar"
        android:layout_alignTop="@id/photo_text_bar"
        android:layout_toLeftOf="@id/main_action"
        android:layout_alignTop="@id/photo_text_bar"
        android:layout_alignBottom="@id/photo_text_bar"
        android:layout_marginRight="@dimen/call_log_inner_margin"
        android:layout_marginLeft="@dimen/call_detail_contact_name_margin"
        android:gravity="center_vertical"
        android:textColor="?attr/call_log_primary_text_color"
        android:textSize="18sp"
        android:singleLine="true"
@@ -113,14 +114,16 @@
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/voicemail_container"
        android:layout_marginTop="@dimen/call_log_icon_margin"
        android:background="?attr/call_log_primary_background_color"
    />
    <ListView
        android:id="@+id/history"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/call_log_icon_margin"
        android:layout_alignParentLeft="true"
        android:layout_below="@android:id/list"
        android:background="?attr/call_log_secondary_background_color"
        android:background="@android:color/black"
    />
</RelativeLayout>
+27 −26
Original line number Diff line number Diff line
@@ -14,45 +14,46 @@
     limitations under the License.
-->

<RelativeLayout
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:background="?attr/call_log_secondary_background_color"
    android:padding="@dimen/call_log_indent_margin"
    android:minHeight="@dimen/call_log_list_item_height"
    android:paddingTop="@dimen/call_log_icon_margin"
    android:paddingLeft="@dimen/call_log_indent_margin"
    android:paddingRight="@dimen/call_log_outer_margin"
    android:orientation="vertical"
>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
    >
        <view
            class="com.android.contacts.calllog.CallTypeIconsView"
            android:id="@+id/call_type_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="@dimen/call_log_icon_margin"
            android:layout_gravity="center_vertical"
        />
        <TextView
            android:id="@+id/call_type_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@id/call_type_icon"
        android:textColor="?attr/call_log_secondary_text_color"
            android:layout_marginLeft="@dimen/call_log_icon_margin"
            android:textColor="@color/secondary_text_color"
        />
    </LinearLayout>
    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/call_type_text"
        android:layout_alignLeft="@id/call_type_text"
        android:textColor="?attr/call_log_secondary_text_color"
        android:textColor="@color/secondary_text_color"
    />
    <TextView
        android:id="@+id/duration"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/date"
        android:layout_alignLeft="@id/date"
        android:textColor="?attr/call_log_secondary_text_color"
        android:textColor="@color/secondary_text_color"
    />
</RelativeLayout>
</LinearLayout>
+22 −12
Original line number Diff line number Diff line
@@ -16,22 +16,22 @@

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_height="@dimen/call_log_list_item_height"
    android:orientation="horizontal"
    android:paddingLeft="9dip"
    android:paddingRight="5dip"
    android:layout_marginTop="@dimen/call_log_icon_margin"
    android:gravity="center_vertical"
    android:background="@drawable/dialpad_background"
>

    <LinearLayout
    <LinearLayout android:id="@+id/main_action"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:layout_marginRight="5dip"
        android:paddingTop="5dip"
        android:paddingBottom="7dip"
        android:paddingLeft="@dimen/call_log_indent_margin"
        android:orientation="vertical"
        android:gravity="center_vertical"
        android:focusable="true"
        android:background="@drawable/btn_dial"
    >

        <TextView android:id="@android:id/text1"
@@ -63,12 +63,22 @@

    </LinearLayout>

    <ImageView android:id="@+id/icon"
        android:layout_width="32dip"
    <View android:id="@+id/divider"
        android:layout_width="1px"
        android:layout_height="32dip"
        android:layout_marginLeft="5dip"
        android:background="@drawable/ic_divider_dashed_holo_dark"
        android:layout_gravity="center_vertical"
    />

    <ImageView android:id="@+id/icon"
        android:layout_width="@color/call_log_voicemail_highlight_color"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/call_log_inner_margin"
        android:paddingRight="@dimen/call_log_outer_margin"
        android:gravity="center"
        android:scaleType="centerInside"
        android:focusable="true"
        android:background="@drawable/btn_dial"
    />

</LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@
    <dimen name="call_log_inner_margin">8dip</dimen>
    <dimen name="call_log_outer_margin">16dip</dimen>
    <dimen name="call_log_indent_margin">24dip</dimen>
    <dimen name="call_log_list_item_height">56dip</dimen>
    <dimen name="call_log_list_contact_photo_size">64dip</dimen>
    <dimen name="call_detail_contact_background_height">174dip</dimen>
    <dimen name="call_detail_contact_name_margin">24dip</dimen>
+75 −50
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.os.Bundle;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.Contacts.Intents.Insert;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.VoicemailContract.Voicemails;
@@ -54,7 +55,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -71,8 +71,7 @@ import java.util.List;
 * This activity can be either started with the URI of a single call log entry, or with the
 * {@link #EXTRA_CALL_LOG_IDS} extra to specify a group of call log entries.
 */
public class CallDetailActivity extends ListActivity implements
        AdapterView.OnItemClickListener {
public class CallDetailActivity extends ListActivity {
    private static final String TAG = "CallDetail";

    /** A long array extra containing ids of call log entries to display. */
@@ -169,7 +168,6 @@ public class CallDetailActivity extends ListActivity implements
        mContactBackgroundView = (ImageView) findViewById(R.id.contact_background);
        mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this);
        mContactPhotoManager = ContactPhotoManager.getInstance(this);
        getListView().setOnItemClickListener(this);
        configureActionBar();
        optionallyHandleVoicemail();
    }
@@ -292,12 +290,13 @@ public class CallDetailActivity extends ListActivity implements
        }

        // We know that all calls are from the same number and the same contact, so pick the first.
        mNumber = details[0].number.toString();
        final long personId = details[0].personId;
        final Uri photoUri = details[0].photoUri;
        PhoneCallDetails firstDetails = details[0];
        mNumber = firstDetails.number.toString();
        final long personId = firstDetails.personId;
        final Uri photoUri = firstDetails.photoUri;

        // Set the details header, based on the first phone call.
        mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, details[0]);
        mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, firstDetails);

        // Cache the details about the phone number.
        final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
@@ -310,7 +309,7 @@ public class CallDetailActivity extends ListActivity implements
        final Intent mainActionIntent;
        final int mainActionIcon;

        if (details[0].personId != -1) {
        if (firstDetails.personId != -1) {
            Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, personId);
            mainActionIntent = new Intent(Intent.ACTION_VIEW, personUri);
            mainActionIcon = R.drawable.ic_contacts_holo_dark;
@@ -361,17 +360,28 @@ public class CallDetailActivity extends ListActivity implements

        // This action allows to call the number that places the call.
        if (canPlaceCallsTo) {
            actions.add(new ViewEntry(android.R.drawable.sym_action_call,
                    getString(R.string.menu_callNumber, mNumber),
                    new Intent(Intent.ACTION_CALL_PRIVILEGED, numberCallUri)));
            final CharSequence displayNumber =
                    mPhoneNumberHelper.getDisplayNumber(
                            firstDetails.number, firstDetails.formattedNumber);

            ViewEntry entry = new ViewEntry(
                    getString(R.string.menu_callNumber, displayNumber),
                    new Intent(Intent.ACTION_CALL_PRIVILEGED, numberCallUri));

            // Only show a label if the number is shown and it is not a SIP address.
            if (!TextUtils.isEmpty(firstDetails.number)
                    && !PhoneNumberUtils.isUriNumber(firstDetails.number.toString())) {
                entry.label = Phone.getTypeLabel(mResources, firstDetails.numberType,
                        firstDetails.numberLabel);
            }

        // This action allows to send an SMS to the number that placed the call.
            // The secondary action allows to send an SMS to the number that placed the call.
            if (mPhoneNumberHelper.canSendSmsTo(mNumber)) {
            Intent smsIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("sms", mNumber, null));
            actions.add(new ViewEntry(R.drawable.sym_action_sms,
                    getString(R.string.menu_sendTextMessage), smsIntent));
                entry.setSecondaryAction(R.drawable.ic_text_holo_dark,
                        new Intent(Intent.ACTION_SENDTO, Uri.fromParts("sms", mNumber, null)));
            }

            actions.add(entry);
        }

        mHasEditNumberBeforeCall = canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
@@ -380,6 +390,7 @@ public class CallDetailActivity extends ListActivity implements
            // Set the actions for this phone number.
            setListAdapter(new ViewAdapter(this, actions));
            getListView().setVisibility(View.VISIBLE);
            getListView().setItemsCanFocus(true);
        } else {
            getListView().setVisibility(View.GONE);
        }
@@ -474,36 +485,50 @@ public class CallDetailActivity extends ListActivity implements
    }

    static final class ViewEntry {
        public final int icon;
        public final String text;
        public final Intent intent;
        public final View.OnClickListener action;
        public final Intent primaryIntent;

        public String label = null;
        public CharSequence label = null;
        public String number = null;
        /** Icon for the secondary action. */
        public int secondaryIcon = 0;
        /** Intent for the secondary action. If not null, an icon must be defined. */
        public Intent secondaryIntent = null;

        public ViewEntry(int icon, String text, Intent intent) {
            this.icon = icon;
        public ViewEntry(String text, Intent intent) {
            this.text = text;
            this.intent = intent;
            this.action = null;
            this.primaryIntent = intent;
        }

        public ViewEntry(int icon, String text, View.OnClickListener listener) {
            this.icon = icon;
            this.text = text;
            this.intent = null;
            this.action = listener;
        public void setSecondaryAction(int icon, Intent intent) {
            secondaryIcon = icon;
            secondaryIntent = intent;
        }
    }

    static final class ViewAdapter extends BaseAdapter {

    private static final class ViewAdapter extends BaseAdapter {
        private final Context mContext;
        private final List<ViewEntry> mActions;

        private final LayoutInflater mInflater;

        private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ViewEntry entry = (ViewEntry) view.getTag();
                mContext.startActivity(entry.primaryIntent);
            }
        };

        private final View.OnClickListener mSecondaryActionListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ViewEntry entry = (ViewEntry) view.getTag();
                mContext.startActivity(entry.secondaryIntent);
            }
        };

        public ViewAdapter(Context context, List<ViewEntry> actions) {
            mContext = context;
            mActions = actions;
            mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
@@ -532,12 +557,25 @@ public class CallDetailActivity extends ListActivity implements

            // Fill action with icon and text.
            ViewEntry entry = mActions.get(position);
            convertView.setTag(entry);

            ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
            View divider = convertView.findViewById(R.id.divider);
            TextView text = (TextView) convertView.findViewById(android.R.id.text1);

            icon.setImageResource(entry.icon);
            View mainAction = convertView.findViewById(R.id.main_action);
            mainAction.setOnClickListener(mPrimaryActionListener);
            mainAction.setTag(entry);

            if (entry.secondaryIntent != null) {
                icon.setOnClickListener(mSecondaryActionListener);
                icon.setImageResource(entry.secondaryIcon);
                icon.setVisibility(View.VISIBLE);
                icon.setTag(entry);
                divider.setVisibility(View.VISIBLE);
            } else {
                icon.setVisibility(View.GONE);
                divider.setVisibility(View.GONE);
            }
            text.setText(entry.text);

            View line2 = convertView.findViewById(R.id.line2);
@@ -564,19 +602,6 @@ public class CallDetailActivity extends ListActivity implements
        }
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        // Handle passing action off to correct handler.
        if (view.getTag() instanceof ViewEntry) {
            ViewEntry entry = (ViewEntry) view.getTag();
            if (entry.intent != null) {
                startActivity(entry.intent);
            } else if (entry.action != null) {
                entry.action.onClick(view);
            }
        }
    }

    @Override
    public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
            boolean globalSearch) {
Loading