Update SIM import UI to match designs am: 7217e6986c
am: 3b35556e71
Change-Id: Ib423cbf2371b37a42fc049be5fcd3f683e7cf156
diff --git a/res/drawable/ic_arrow_drop_down_black_24dp.xml b/res/drawable/ic_arrow_drop_down_black_24dp.xml
new file mode 100644
index 0000000..ebf2123
--- /dev/null
+++ b/res/drawable/ic_arrow_drop_down_black_24dp.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<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="M7,10l5,5 5,-5z"/>
+</vector>
diff --git a/res/drawable/ic_close_24dp.xml b/res/drawable/ic_close_24dp.xml
index 52070d5..bcbb759 100644
--- a/res/drawable/ic_close_24dp.xml
+++ b/res/drawable/ic_close_24dp.xml
@@ -18,7 +18,7 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0">
+ android:viewportHeight="24.0" >
<path
android:fillColor="@android:color/white"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
diff --git a/res/layout/fragment_sim_import.xml b/res/layout/fragment_sim_import.xml
index 00336dd..d6d3acf 100644
--- a/res/layout/fragment_sim_import.xml
+++ b/res/layout/fragment_sim_import.xml
@@ -26,14 +26,13 @@
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
- style="@style/ContactsToolbarStyle"
+ style="@style/LightToolbarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- android:elevation="4dp"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
+ android:elevation="3dp"
+ android:theme="@style/LightToolbarThemeOverlay"
app:navigationContentDescription="@string/sim_import_cancel_content_description"
- app:navigationIcon="@drawable/ic_close_dk"
+ app:navigationIcon="@drawable/ic_close_24dp"
app:title="@string/sim_import_title_none_selected">
<Button
@@ -46,14 +45,51 @@
/>
</android.support.v7.widget.Toolbar>
- <FrameLayout
+
+ <!-- This is managed by AccountHeaderPresenter so the IDs in this section must
+ match the equivalent views in layout/editor_account_header.xml -->
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/account_header_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
- android:elevation="4dp">
+ android:minHeight="48dp"
+ android:orientation="horizontal"
+ android:paddingEnd="32dp"
+ android:paddingStart="16dp">
- <include layout="@layout/editor_account_header"/>
- </FrameLayout>
+ <ImageView
+ android:id="@+id/account_type_icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="32dp"/>
+
+ <TextView
+ android:id="@+id/account_name"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1"
+ android:ellipsize="end"
+ android:gravity="center_vertical"
+ android:lines="1"
+ android:maxLines="1"
+ android:textColor="@color/secondary_text_color"
+ android:textSize="16sp"/>
+
+ <ImageView
+ android:id="@+id/account_expander_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="9dp"
+ android:layout_gravity="center_vertical"
+ android:scaleType="center"
+ android:src="@drawable/ic_arrow_drop_down_black_24dp"
+ android:tint="?android:textColorSecondary"
+ android:visibility="gone"/>
+ </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a402d68..21fcc1e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1850,9 +1850,6 @@
<!-- Toolbar title shown when importing SIM contacts and none are selected -->
<string name="sim_import_title_none_selected">Select contacts</string>
- <!-- Toolbar title shown when importing SIM contacts and some are selected -->
- <string name="sim_import_title_some_selected_fmt"><xliff:g id="count">%d</xliff:g> Selected</string>
-
<!-- Message shown when the SIM import screen is displayed but there are no contacts on the
SIM card -->
<string name="sim_import_empty_message">No contacts on your SIM card</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index ab1a4ba..b762177 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -231,6 +231,21 @@
<item name="titleTextAppearance">@style/ContactsActionBarTitleTextAppCompat</item>
</style>
+ <style name="LightToolbarNavigationButtonStyle" parent="@style/Widget.AppCompat.Toolbar.Button.Navigation">
+ <item name="android:tint">?android:textColorSecondary</item>
+ </style>
+
+ <style name="LightToolbarThemeOverlay" parent="@style/ThemeOverlay.AppCompat.ActionBar">
+ <item name="toolbarNavigationButtonStyle">@style/LightToolbarNavigationButtonStyle</item>
+ </style>
+
+ <style name="LightToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
+ <item name="android:background">@color/contextual_selection_bar_color</item>
+ <item name="background">@color/contextual_selection_bar_color</item>
+ <item name="android:titleTextAppearance">@style/ContactsActionBarTitleTextBlack</item>
+ <item name="titleTextAppearance">@style/ContactsActionBarTitleTextBlack</item>
+ </style>
+
<!-- Text in the action bar at the top of the screen -->
<style name="ContactsActionBarTitleText"
parent="@android:style/TextAppearance.Material.Widget.ActionBar.Title">
diff --git a/src/com/android/contacts/SimImportFragment.java b/src/com/android/contacts/SimImportFragment.java
index d9030a8..71fe1f5 100644
--- a/src/com/android/contacts/SimImportFragment.java
+++ b/src/com/android/contacts/SimImportFragment.java
@@ -27,11 +27,13 @@
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.util.ArrayMap;
+import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ContentLoadingProgressBar;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListView;
@@ -60,7 +62,7 @@
*/
public class SimImportFragment extends DialogFragment
implements LoaderManager.LoaderCallbacks<SimImportFragment.LoaderResult>,
- MultiSelectEntryContactListAdapter.SelectedContactsListener {
+ MultiSelectEntryContactListAdapter.SelectedContactsListener, AbsListView.OnScrollListener {
private static final String KEY_SELECTED_IDS = "selectedIds";
private static final String ARG_SUBSCRIPTION_ID = "subscriptionId";
@@ -68,7 +70,9 @@
private ContactsPreferences mPreferences;
private AccountTypeManager mAccountTypeManager;
private SimContactAdapter mAdapter;
+ private View mAccountHeaderContainer;
private AccountHeaderPresenter mAccountHeaderPresenter;
+ private float mAccountScrolledElevationPixels;
private ContentLoadingProgressBar mLoadingIndicator;
private Toolbar mToolbar;
private ListView mListView;
@@ -121,8 +125,11 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_sim_import, container, false);
+ mAccountHeaderContainer = view.findViewById(R.id.account_header_container);
+ mAccountScrolledElevationPixels = getResources()
+ .getDimension(R.dimen.contact_list_header_elevation);
mAccountHeaderPresenter = new AccountHeaderPresenter(
- view.findViewById(R.id.account_header_container));
+ mAccountHeaderContainer);
if (savedInstanceState != null) {
mAccountHeaderPresenter.onRestoreInstanceState(savedInstanceState);
} else {
@@ -139,6 +146,7 @@
mAdapter.setAccount(mAccountHeaderPresenter.getCurrentAccount());
mListView = (ListView) view.findViewById(R.id.list);
+ mListView.setOnScrollListener(this);
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@@ -160,7 +168,8 @@
dismiss();
}
});
- mImportButton.setEnabled(mAdapter.getSelectedContactIds().size() > 0);
+ mImportButton.setVisibility(mAdapter.getSelectedContactIds().size() > 0 ?
+ View.VISIBLE : View.GONE);
mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@@ -240,11 +249,10 @@
if (selectedCount == 0) {
mToolbar.setTitle(R.string.sim_import_title_none_selected);
} else {
- mToolbar.setTitle(getString(R.string.sim_import_title_some_selected_fmt,
- selectedCount));
+ mToolbar.setTitle(String.valueOf(selectedCount));
}
if (mImportButton != null) {
- mImportButton.setEnabled(selectedCount > 0);
+ mImportButton.setVisibility(selectedCount > 0 ? View.VISIBLE : View.GONE);
}
}
@@ -255,6 +263,24 @@
return getActivity();
}
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) { }
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
+ int totalItemCount) {
+ int firstCompletelyVisibleItem = firstVisibleItem;
+ if (view != null && view.getChildAt(0) != null && view.getChildAt(0).getTop() < 0) {
+ firstCompletelyVisibleItem++;
+ }
+
+ if (firstCompletelyVisibleItem == 0) {
+ ViewCompat.setElevation(mAccountHeaderContainer, 0);
+ } else {
+ ViewCompat.setElevation(mAccountHeaderContainer, mAccountScrolledElevationPixels);
+ }
+ }
+
/**
* Creates a fragment that will display contacts stored on the default SIM card
*/
diff --git a/src/com/android/contacts/editor/AccountHeaderPresenter.java b/src/com/android/contacts/editor/AccountHeaderPresenter.java
index 5323c60..d4f613b 100644
--- a/src/com/android/contacts/editor/AccountHeaderPresenter.java
+++ b/src/com/android/contacts/editor/AccountHeaderPresenter.java
@@ -76,6 +76,8 @@
public AccountHeaderPresenter(View container) {
mContext = container.getContext();
mAccountHeaderContainer = container;
+ // mAccountHeaderType is optional and may not be in the container view in which case
+ // the variable will be null
mAccountHeaderType = (TextView) container.findViewById(R.id.account_type);
mAccountHeaderName = (TextView) container.findViewById(R.id.account_name);
mAccountHeaderIcon = (ImageView) container.findViewById(R.id.account_type_icon);
@@ -144,7 +146,9 @@
// Set the account type
final String selectorTitle = mContext.getResources().getString(mSelectorTitle);
- mAccountHeaderType.setText(selectorTitle);
+ if (mAccountHeaderType != null) {
+ mAccountHeaderType.setText(selectorTitle);
+ }
// Set the icon
final AccountDisplayInfo displayInfo = mAccountDisplayInfoFactory