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

Commit 9b81f1d8 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Reduce number of views in call log.

Use only one image for the secondary action and configure it at
run-time.

Bug: 5099652
Change-Id: Ibcc9f2f0abbf4d7d409ba5d574d88387836fc0bf
parent b7a508f9
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -74,24 +74,12 @@
                android:background="@drawable/ic_divider_dashed_holo_dark"
            />
            <ImageView
                android:id="@+id/call_icon"
                android:id="@+id/secondary_action_icon"
                android:layout_width="@dimen/call_log_call_action_width"
                android:layout_height="@dimen/call_log_call_action_height"
                android:layout_gravity="center_vertical"
                android:scaleType="center"
                android:src="@drawable/ic_ab_dialer_holo_dark"
                android:background="@drawable/list_selector"
                android:contentDescription="@string/description_call_log_call_button"
            />
            <ImageView
                android:id="@+id/play_icon"
                android:layout_width="@dimen/call_log_call_action_width"
                android:layout_height="@dimen/call_log_call_action_height"
                android:layout_gravity="center_vertical"
                android:scaleType="center"
                android:src="@drawable/ic_play_holo_dark"
                android:background="@drawable/list_selector"
                android:contentDescription="@string/description_call_log_play_button"
            />
        </LinearLayout>
        <LinearLayout
+7 −9
Original line number Diff line number Diff line
@@ -327,7 +327,8 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
            PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(
                    resources, callTypeHelper, mPhoneNumberHelper);
            mCallLogViewsHelper =
                    new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberHelper);
                    new CallLogListItemHelper(
                            phoneCallDetailsHelper, mPhoneNumberHelper, resources);
            mCallLogGroupBuilder = new CallLogGroupBuilder(this);
        }

@@ -660,8 +661,7 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
        private void findAndCacheViews(View view) {
            // Get the views to bind to.
            CallLogListItemViews views = CallLogListItemViews.fromView(view);
            views.callView.setOnClickListener(mCallPlayOnClickListener);
            views.playView.setOnClickListener(mCallPlayOnClickListener);
            views.secondaryActionView.setOnClickListener(mCallPlayOnClickListener);
            view.setTag(views);
        }

@@ -703,17 +703,15 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
            if (callType == Calls.VOICEMAIL_TYPE) {
                String voicemailUri = c.getString(CallLogQuery.VOICEMAIL_URI);
                final long rowId = c.getLong(CallLogQuery.ID);
                views.playView.setTag(
                views.secondaryActionView.setTag(
                        IntentProvider.getPlayVoicemailIntentProvider(rowId, voicemailUri));
                views.callView.setTag(null);
            } else if (!TextUtils.isEmpty(number)) {
                // Store away the number so we can call it directly if you click on the call icon.
                views.callView.setTag(IntentProvider.getReturnCallIntentProvider(number));
                views.playView.setTag(null);
                views.secondaryActionView.setTag(
                        IntentProvider.getReturnCallIntentProvider(number));
            } else {
                // No action enabled.
                views.callView.setTag(null);
                views.playView.setTag(null);
                views.secondaryActionView.setTag(null);
            }

            // Lookup contacts with this number
+26 −8
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@ package com.android.contacts.calllog;

import com.android.contacts.PhoneCallDetails;
import com.android.contacts.PhoneCallDetailsHelper;
import com.android.contacts.R;

import android.content.res.Resources;
import android.provider.CallLog.Calls;
import android.view.View;

@@ -30,6 +32,8 @@ import android.view.View;
    private final PhoneCallDetailsHelper mPhoneCallDetailsHelper;
    /** Helper for handling phone numbers. */
    private final PhoneNumberHelper mPhoneNumberHelper;
    /** Resources to look up strings. */
    private final Resources mResources;

    /**
     * Creates a new helper instance.
@@ -38,9 +42,10 @@ import android.view.View;
     * @param phoneNumberHelper used to process phone number
     */
    public CallLogListItemHelper(PhoneCallDetailsHelper phoneCallDetailsHelper,
            PhoneNumberHelper phoneNumberHelper) {
            PhoneNumberHelper phoneNumberHelper, Resources resources) {
        mPhoneCallDetailsHelper = phoneCallDetailsHelper;
        mPhoneNumberHelper= phoneNumberHelper;
        mResources = resources;
    }

    /**
@@ -59,22 +64,35 @@ import android.view.View;

        if (canPlay) {
            // Playback action takes preference.
            views.callView.setVisibility(View.GONE);
            views.playView.setVisibility(View.VISIBLE);
            configurePlaySecondaryAction(views);
            views.unheardView.setVisibility(isHighlighted ? View.VISIBLE : View.GONE);
            views.dividerView.setVisibility(View.VISIBLE);
        } else if (canCall) {
            // Call is the main action.
            views.callView.setVisibility(View.VISIBLE);
            views.playView.setVisibility(View.GONE);
            // Call is the secondary action.
            configureCallSecondaryAction(views);
            views.unheardView.setVisibility(View.GONE);
            views.dividerView.setVisibility(View.VISIBLE);
        } else {
            // No action available.
            views.callView.setVisibility(View.GONE);
            views.playView.setVisibility(View.GONE);
            views.secondaryActionView.setVisibility(View.GONE);
            views.unheardView.setVisibility(View.GONE);
            views.dividerView.setVisibility(View.GONE);
        }
    }

    /** Sets the secondary action to correspond to the call button. */
    private void configureCallSecondaryAction(CallLogListItemViews views) {
        views.secondaryActionView.setVisibility(View.VISIBLE);
        views.secondaryActionView.setImageResource(R.drawable.ic_ab_dialer_holo_dark);
        views.secondaryActionView.setContentDescription(
                mResources.getString(R.string.description_call_log_call_button));
    }

    /** Sets the secondary action to correspond to the play button. */
    private void configurePlaySecondaryAction(CallLogListItemViews views) {
        views.secondaryActionView.setVisibility(View.VISIBLE);
        views.secondaryActionView.setImageResource(R.drawable.ic_play_holo_dark);
        views.secondaryActionView.setContentDescription(
                mResources.getString(R.string.description_call_log_play_button));
    }
}
+8 −12
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.contacts.R;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.QuickContactBadge;
import android.widget.TextView;

@@ -30,13 +31,11 @@ import android.widget.TextView;
public final class CallLogListItemViews {
    /** The quick contact badge for the contact. */
    public final QuickContactBadge quickContactView;
    /** The main action button on the entry. */
    public final View callView;
    /** The play action button used for voicemail. */
    public final View playView;
    /** The secondary action button on the entry. */
    public final ImageView secondaryActionView;
    /** The icon used for unheard voicemail. */
    public final View unheardView;
    /** The divider between callView and playView. */
    /** The divider between the primary and secondary actions. */
    public final View dividerView;
    /** The details of the phone call. */
    public final PhoneCallDetailsViews phoneCallDetailsViews;
@@ -46,12 +45,11 @@ public final class CallLogListItemViews {
    public final TextView listHeaderTextView;

    private CallLogListItemViews(QuickContactBadge quickContactView,
            View callView, View playView, View unheardView, View dividerView,
            ImageView secondaryActionView, View unheardView, View dividerView,
            PhoneCallDetailsViews phoneCallDetailsViews, View listItemView,
            TextView listHeaderTextView) {
        this.quickContactView = quickContactView;
        this.callView = callView;
        this.playView = playView;
        this.secondaryActionView = secondaryActionView;
        this.unheardView = unheardView;
        this.dividerView = dividerView;
        this.phoneCallDetailsViews = phoneCallDetailsViews;
@@ -62,8 +60,7 @@ public final class CallLogListItemViews {
    public static CallLogListItemViews fromView(View view) {
        return new CallLogListItemViews(
                (QuickContactBadge) view.findViewById(R.id.quick_contact_photo),
                view.findViewById(R.id.call_icon),
                view.findViewById(R.id.play_icon),
                (ImageView) view.findViewById(R.id.secondary_action_icon),
                view.findViewById(R.id.unheard_icon),
                view.findViewById(R.id.divider),
                PhoneCallDetailsViews.fromView(view),
@@ -74,8 +71,7 @@ public final class CallLogListItemViews {
    public static CallLogListItemViews createForTest(Context context) {
        return new CallLogListItemViews(
                new QuickContactBadge(context),
                new View(context),
                new View(context),
                new ImageView(context),
                new View(context),
                new View(context),
                PhoneCallDetailsViews.createForTest(context),
+7 −7
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ public class CallLogActivityTests
        insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
        View view = mAdapter.newGroupView(getActivity(), mParentView);
        mAdapter.bindGroupView(view, getActivity(), mCursor, 3, false);
        assertNotNull(view.findViewById(R.id.call_icon));
        assertNotNull(view.findViewById(R.id.secondary_action_icon));
    }

    @MediumTest
@@ -183,7 +183,7 @@ public class CallLogActivityTests
        insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
        View view = mAdapter.newStandAloneView(getActivity(), mParentView);
        mAdapter.bindStandAloneView(view, getActivity(), mCursor);
        assertNotNull(view.findViewById(R.id.call_icon));
        assertNotNull(view.findViewById(R.id.secondary_action_icon));
    }

    @MediumTest
@@ -192,7 +192,7 @@ public class CallLogActivityTests
        insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
        View view = mAdapter.newChildView(getActivity(), mParentView);
        mAdapter.bindChildView(view, getActivity(), mCursor);
        assertNotNull(view.findViewById(R.id.call_icon));
        assertNotNull(view.findViewById(R.id.secondary_action_icon));
    }

    @MediumTest
@@ -303,7 +303,7 @@ public class CallLogActivityTests
        mAdapter.bindStandAloneView(view, getActivity(), mCursor);

        CallLogListItemViews views = (CallLogListItemViews) view.getTag();
        IntentProvider intentProvider = (IntentProvider) views.callView.getTag();
        IntentProvider intentProvider = (IntentProvider) views.secondaryActionView.getTag();
        Intent intent = intentProvider.getIntent(mActivity);
        // Starts a call.
        assertEquals(Intent.ACTION_CALL_PRIVILEGED, intent.getAction());
@@ -319,7 +319,7 @@ public class CallLogActivityTests
        mAdapter.bindStandAloneView(view, getActivity(), mCursor);

        CallLogListItemViews views = (CallLogListItemViews) view.getTag();
        IntentProvider intentProvider = (IntentProvider) views.playView.getTag();
        IntentProvider intentProvider = (IntentProvider) views.secondaryActionView.getTag();
        Intent intent = intentProvider.getIntent(mActivity);
        // Starts the call detail activity.
        assertEquals(new ComponentName(mActivity, CallDetailActivity.class),
@@ -357,9 +357,9 @@ public class CallLogActivityTests
            String number = getPhoneNumberForListEntry(i);
            if (CallerInfo.PRIVATE_NUMBER.equals(number) ||
                CallerInfo.UNKNOWN_NUMBER.equals(number)) {
                assertFalse(View.VISIBLE == mItem.callView.getVisibility());
                assertFalse(View.VISIBLE == mItem.secondaryActionView.getVisibility());
            } else {
                assertEquals(View.VISIBLE, mItem.callView.getVisibility());
                assertEquals(View.VISIBLE, mItem.secondaryActionView.getVisibility());
            }
        }
    }
Loading