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

Commit 81067f50 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Bring account view up to spec (E2)

* Use elevation instead of divider for list header
* Change icon size and margin programmatically.

Bug 30358448

Change-Id: Ib707c116c23ee39d43c265a5c26184d6944bedc0
parent 5de24579
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2016 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/list_item_account_header_border_color" />
        </shape>
    </item>
    <item android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/background_primary" />
        </shape>
    </item>
</layer-list>
 No newline at end of file
+0 −3
Original line number Diff line number Diff line
@@ -60,9 +60,6 @@
    <!-- Background color of pinned header items. -->
    <color name="list_item_pinned_header_color">@color/background_primary</color>

    <!-- 8% black. -->
    <color name="list_item_account_header_border_color">#15000000</color>

    <!-- Color of the mime-type icons inside the editor. 50% black. -->
    <color name="editor_icon_color">#7f7f7f</color>

+3 −0
Original line number Diff line number Diff line
@@ -292,4 +292,7 @@

    <!-- Minimum height for group name EditText -->
    <dimen name="group_name_edit_text_min_height">48dp</dimen>

    <!-- Elevation of contact list header -->
    <dimen name="contact_list_header_elevation">2dp</dimen>
</resources>
+44 −5
Original line number Diff line number Diff line
@@ -30,12 +30,13 @@ import com.android.contacts.common.model.account.GoogleAccountType;

import android.content.Context;
import android.database.Cursor;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.v4.view.ViewCompat;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AbsListView;
import android.widget.ImageView;
@@ -291,11 +292,10 @@ public abstract class MultiSelectContactsListFragment<T extends MultiSelectEntry
            return;
        }
        if (firstVisibleItem == 0) {
            accountFilterContainer.setBackground(
                    new ColorDrawable(getResources().getColor(R.color.background_primary)));
            ViewCompat.setElevation(accountFilterContainer, 0);
        } else {
            accountFilterContainer.setBackground(
                    getResources().getDrawable(R.drawable.account_header_background));
            ViewCompat.setElevation(accountFilterContainer,
                    getResources().getDimension(R.dimen.contact_list_header_elevation));
        }
    }

@@ -343,10 +343,49 @@ public abstract class MultiSelectContactsListFragment<T extends MultiSelectEntry
        final Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null;
        final ImageView accountFilterHeaderIcon = (ImageView) accountFilterContainer
                .findViewById(R.id.account_filter_icon);

        // If it's a writable Google account, we set icon size as 24dp; otherwise, we set it as
        // 20dp. And we need to change margin accordingly. This is because the Google icon looks
        // smaller when the icons are of the same size.
        if (accountType instanceof GoogleAccountType) {
            accountFilterHeaderIcon.getLayoutParams().height = getResources()
                    .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size);
            accountFilterHeaderIcon.getLayoutParams().width =
                    accountFilterHeaderIcon.getLayoutParams().height;

            setMargins(accountFilterHeaderIcon,
                    getResources().getDimensionPixelOffset(
                            R.dimen.contact_browser_list_header_icon_left_margin),
                    getResources().getDimensionPixelOffset(
                            R.dimen.contact_browser_list_header_icon_right_margin));
        } else {
            accountFilterHeaderIcon.getLayoutParams().height = getResources()
                    .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size_alt);
            accountFilterHeaderIcon.getLayoutParams().width =
                    accountFilterHeaderIcon.getLayoutParams().height;

            setMargins(accountFilterHeaderIcon,
                    getResources().getDimensionPixelOffset(
                            R.dimen.contact_browser_list_header_icon_left_margin_alt),
                    getResources().getDimensionPixelOffset(
                            R.dimen.contact_browser_list_header_icon_right_margin_alt));
        }
        accountFilterHeaderIcon.requestLayout();

        accountFilterHeaderIcon.setVisibility(View.VISIBLE);
        accountFilterHeaderIcon.setImageDrawable(icon);
    }

    private void setMargins(View v, int l, int r) {
        if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
            p.setMarginStart(l);
            p.setMarginEnd(r);
            v.setLayoutParams(p);
            v.requestLayout();
        }
    }

    private void bindListHeaderCommon(View listView, View accountFilterContainer) {
        // Show header and remove top padding of the list
        accountFilterContainer.setVisibility(View.VISIBLE);