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

Commit 6caf23f9 authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

Show device "account" in nav drawer menu

If there are contacts with a "null" account name and type (indicating that they
are device local contacts) then an item is included in the account section of
the nav drawer for "Device" contacts.

Bug 28637652
Bug 28637715
Change-Id: I975d20c8ab2bb14b9a9441e585d13237f7c09cb2
parent 0c8c709c
Loading
Loading
Loading
Loading
+26 −0
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.
-->

<!-- Material design SIM card icon https://design.google.com/icons/#ic_sim_card -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M19.99,4c0,-1.1 -0.89,-2 -1.99,-2h-8L4,8v12c0,1.1 0.9,2 2,2h12.01c1.1,0 1.99,-0.9 1.99,-2l-0.01,-16zM9,19L7,19v-2h2v2zM17,19h-2v-2h2v2zM9,15L7,15v-4h2v4zM13,19h-2v-4h2v4zM13,13h-2v-2h2v2zM17,15h-2v-4h2v4z"/>
</vector>
+5 −0
Original line number Diff line number Diff line
@@ -1115,6 +1115,11 @@
         and will not be synced. [CHAR LIMIT=20]  -->
    <string name="account_phone">Device</string>

    <!-- Title for data source when creating or editing a contact that is stored on the
         devices SIM card. This contact will only exist on the phone and will not be synced.
         [CHAR LIMIT=20]  -->
    <string name="account_sim">SIM</string>

    <!-- Header that expands to list all name types when editing a structured name of a contact
         [CHAR LIMIT=20] -->
    <string name="nameLabelsGroup">Name</string>
+10 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ package com.android.contactsbind;

import com.android.contacts.common.logging.Logger;
import com.android.contacts.common.preference.PreferenceManager;
import com.android.contacts.common.util.DeviceAccountFilter;
import com.android.contacts.common.util.DeviceAccountPresentationValues;

import android.content.Context;

@@ -28,4 +30,12 @@ public class ObjectFactory {
    }

    public static PreferenceManager getPreferenceManager(Context context) { return null; }

    public static DeviceAccountPresentationValues createDeviceAccountPresentationValues(Context context) {
        return new DeviceAccountPresentationValues.Default(context);
    }

    public static DeviceAccountFilter getDeviceAccountFilter(Context context) {
        return DeviceAccountFilter.ONLY_NULL;
    }
}
+9 −4
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.preference.ContactsPreferenceActivity;
import com.android.contacts.common.util.AccountFilterUtil;
import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.common.util.DeviceAccountPresentationValues;
import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.util.ViewUtil;
import com.android.contacts.editor.ContactEditorFragment;
@@ -74,6 +75,7 @@ import com.android.contacts.quickcontact.QuickContactActivity;
import com.android.contacts.util.SharedPreferenceUtil;
import com.android.contactsbind.Assistants;
import com.android.contactsbind.HelpUtils;
import com.android.contactsbind.ObjectFactory;

import java.util.HashMap;
import java.util.Iterator;
@@ -171,6 +173,7 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i

    // The account the new group will be created under.
    private AccountWithDataSet mNewGroupAccount;
    private DeviceAccountPresentationValues mDeviceAccountPresentationValues;

    private int mPositionOfLastGroup;

@@ -183,6 +186,8 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i

        super.setContentView(R.layout.contacts_drawer_activity);

        mDeviceAccountPresentationValues = ObjectFactory.createDeviceAccountPresentationValues(this);

        // Set up the action bar.
        mToolbar = getView(R.id.toolbar);
        setSupportActionBar(mToolbar);
@@ -468,12 +473,12 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i

        int positionOfLastFilter = mPositionOfLastGroup + GAP_BETWEEN_TWO_MENU_GROUPS;

        mDeviceAccountPresentationValues.setFilters(accountFilterItems);

        for (int i = 0; i < accountFilterItems.size(); i++) {
            positionOfLastFilter++;
            final ContactListFilter filter = accountFilterItems.get(i);
            final String menuName =
                    filter.filterType == ContactListFilter.FILTER_TYPE_DEVICE_CONTACTS
                            ? getString(R.string.account_phone) : filter.accountName;
            final CharSequence menuName = mDeviceAccountPresentationValues.getLabel(i);
            final MenuItem menuItem = subMenu.add(R.id.nav_filters_items, Menu.NONE,
                    positionOfLastFilter, menuName);
            mFilterMenuMap.put(filter, menuItem);
@@ -497,7 +502,7 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
                    return true;
                }
            });
            menuItem.setIcon(filter.icon);
            menuItem.setIcon(mDeviceAccountPresentationValues.getIcon(i));
            // Get rid of the default menu item overlay and show original account icons.
            menuItem.getIcon().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
            // Create a dummy action view to attach extra hidden content description to the menuItem
+2 −0
Original line number Diff line number Diff line
@@ -181,6 +181,8 @@ public final class ContactListFilter implements Comparable<ContactListFilter>, P
        int code = filterType;
        if (accountType != null) {
            code = code * 31 + accountType.hashCode();
        }
        if (accountName != null) {
            code = code * 31 + accountName.hashCode();
        }
        if (dataSet != null) {
Loading