Bring action bar up to spec (E2)
* Reorder delete, link and share and show icons.
* Replace check mark with "Add" TextView in multi select mode of
ContactSelectionActivity
Bug 29831679
Change-Id: I87988019d4fc59d674ae0cf13ce26a7d4ef27db3
diff --git a/res/drawable/ic_menu_delete.xml b/res/drawable/ic_menu_delete.xml
new file mode 100644
index 0000000..e95a5db
--- /dev/null
+++ b/res/drawable/ic_menu_delete.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<!-- A trash can icon (ic_menu_delete) -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
+</vector>
diff --git a/res/drawable/ic_menu_link.xml b/res/drawable/ic_menu_link.xml
new file mode 100644
index 0000000..b962460
--- /dev/null
+++ b/res/drawable/ic_menu_link.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<!-- ic_menu_link -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
+</vector>
diff --git a/res/drawable/ic_menu_share.xml b/res/drawable/ic_menu_share.xml
new file mode 100644
index 0000000..60217e2
--- /dev/null
+++ b/res/drawable/ic_menu_share.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<!-- ic_menu_share -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z"/>
+</vector>
diff --git a/res/layout/selection_bar.xml b/res/layout/selection_bar.xml
index ca81faf..6c11a39 100644
--- a/res/layout/selection_bar.xml
+++ b/res/layout/selection_bar.xml
@@ -39,4 +39,15 @@
android:layout_gravity="center_vertical|start"
style="@style/ContactsActionBarTitleTextAppCompat" />
+ <TextView
+ android:id="@+id/add_contacts"
+ android:layout_marginEnd="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:layout_gravity="center_vertical|end"
+ android:text="@string/menu_add_contacts"
+ android:textColor="@color/actionbar_text_color"
+ android:textStyle="bold"/>
+
</FrameLayout>
diff --git a/res/menu/group_member_picker.xml b/res/menu/group_member_picker.xml
index ab1fadf..9e623f6 100644
--- a/res/menu/group_member_picker.xml
+++ b/res/menu/group_member_picker.xml
@@ -18,12 +18,6 @@
xmlns:contacts="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_done"
- android:icon="@drawable/ic_done_wht_24dp"
- android:title="@string/menu_addContactsToGroup"
- contacts:showAsAction="always" />
-
- <item
android:id="@+id/menu_select"
android:title="@string/menu_selectForGroup" />
contacts:showAsAction="never" />
diff --git a/res/menu/people_options.xml b/res/menu/people_options.xml
index 46d6856..a2402b9 100644
--- a/res/menu/people_options.xml
+++ b/res/menu/people_options.xml
@@ -28,15 +28,21 @@
android:showAsAction="never" />
<item
- android:id="@+id/menu_join"
- android:title="@string/menu_joinAggregate" />
+ android:id="@+id/menu_share"
+ android:icon="@drawable/ic_menu_share"
+ android:title="@string/menu_share"
+ contacts:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_delete"
- android:title="@string/menu_deleteContact" />
+ android:icon="@drawable/ic_menu_delete"
+ android:title="@string/menu_deleteContact"
+ contacts:showAsAction="ifRoom"/>
<item
- android:id="@+id/menu_share"
- android:title="@string/menu_share" />
+ android:id="@+id/menu_join"
+ android:icon="@drawable/ic_menu_link"
+ android:title="@string/menu_joinAggregate"
+ contacts:showAsAction="ifRoom"/>
</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 06e4ad7..b9a5f58 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -438,6 +438,9 @@
<!-- The menu item to add the the currently viewed contact to your contacts [CHAR LIMIT=30] -->
<string name="menu_add_contact">Add to contacts</string>
+ <!-- The menu item to add the the currently selected contacts to a label [CHAR LIMIT=10] -->
+ <string name="menu_add_contacts">Add</string>
+
<!-- Dialog title when picking the application to share one or multiple contacts with. [CHAR LIMIT=40] -->
<plurals name="title_share_via">
<item quantity="one">Share contact via</item>
diff --git a/src/com/android/contacts/activities/ActionBarAdapter.java b/src/com/android/contacts/activities/ActionBarAdapter.java
index 669735c..be94860 100644
--- a/src/com/android/contacts/activities/ActionBarAdapter.java
+++ b/src/com/android/contacts/activities/ActionBarAdapter.java
@@ -156,6 +156,10 @@
return mSearchView;
}
+ public View getSelectionContainer() {
+ return mSelectionContainer;
+ }
+
private void setupTabs(Context context) {
final TypedArray attributeArray = context.obtainStyledAttributes(
new int[]{android.R.attr.actionBarSize});
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index 22d9f7a..dae57fc 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -31,6 +31,7 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.contacts.AppCompatContactsActivity;
@@ -441,13 +442,34 @@
@Override
public void onSelectedContactIdsChanged() {
if (mListFragment instanceof MultiSelectContactsListFragment) {
- mActionBarAdapter.setSelectionCount(((MultiSelectContactsListFragment) mListFragment)
- .getSelectedContactIds().size());
+ final int count = getMultiSelectListFragment().getSelectedContactIds().size();
+ mActionBarAdapter.setSelectionCount(count);
+ updateAddContactsButton(count);
+
// Show or hide the multi select "Done" button
invalidateOptionsMenu();
}
}
+ private void updateAddContactsButton(int count) {
+ final TextView textView = (TextView) mActionBarAdapter.getSelectionContainer()
+ .findViewById(R.id.add_contacts);
+ if (count > 0) {
+ textView.setVisibility(View.VISIBLE);
+ textView.setAllCaps(true);
+ textView.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final long[] contactIds =
+ getMultiSelectListFragment().getSelectedContactIdsArray();
+ returnSelectedContacts(contactIds);
+ }
+ });
+ } else {
+ textView.setVisibility(View.GONE);
+ }
+ }
+
@Override
public void onStopDisplayingCheckBoxes() {
mActionBarAdapter.setSelectionMode(false);
@@ -532,9 +554,7 @@
@Override
public void onGroupMembersSelected(long[] contactIds) {
- final Intent intent = new Intent();
- intent.putExtra(UiIntentActions.TARGET_CONTACT_IDS_EXTRA_KEY, contactIds);
- returnPickerResult(intent);
+ returnSelectedContacts(contactIds);
}
@Override
@@ -543,6 +563,12 @@
}
}
+ private void returnSelectedContacts(long[] contactIds) {
+ final Intent intent = new Intent();
+ intent.putExtra(UiIntentActions.TARGET_CONTACT_IDS_EXTRA_KEY, contactIds);
+ returnPickerResult(intent);
+ }
+
private final class PostalAddressPickerActionListener implements
OnPostalAddressPickerActionListener {
@Override
diff --git a/src/com/android/contacts/list/GroupMemberPickerFragment.java b/src/com/android/contacts/list/GroupMemberPickerFragment.java
index d981de0..519a6a9 100644
--- a/src/com/android/contacts/list/GroupMemberPickerFragment.java
+++ b/src/com/android/contacts/list/GroupMemberPickerFragment.java
@@ -279,9 +279,6 @@
// Added in ContactSelectionActivity but we must account for selection mode
setVisible(menu, R.id.menu_search, !isSearchMode && !isSelectionMode);
-
- setVisible(menu, R.id.menu_done, isSelectionMode &&
- getAdapter().getSelectedContactIds().size() > 0);
setVisible(menu, R.id.menu_select, !isSearchMode && !isSelectionMode);
}
@@ -310,12 +307,6 @@
}
return true;
}
- case R.id.menu_done: {
- if (mListener != null) {
- mListener.onGroupMembersSelected(getAdapter().getSelectedContactIdsArray());
- }
- return true;
- }
case R.id.menu_select: {
if (mListener != null) {
mListener.onSelectGroupMembers();