Commit 9be7136c authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Contacts Picker: Polish the UI.

Use Back arrow for both Normal and Search mode.
Add padding to the Close button to the right of the search window.

Bug: 988276, 860467
Change-Id: I4eb65d19d685d1b4f19d6b06576c44371c10eedf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1776032Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692005}
parent 04177634
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="0dp"> android:paddingEnd="8dp">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -19,32 +19,45 @@ import java.util.List; ...@@ -19,32 +19,45 @@ import java.util.List;
* Handles toolbar functionality for the {@ContactsPickerDialog}. * Handles toolbar functionality for the {@ContactsPickerDialog}.
*/ */
public class ContactsPickerToolbar extends SelectableListToolbar<ContactDetails> { public class ContactsPickerToolbar extends SelectableListToolbar<ContactDetails> {
// Our parent dialog.
ContactsPickerDialog mDialog;
public ContactsPickerToolbar(Context context, AttributeSet attrs) { public ContactsPickerToolbar(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }
/**
* Set the parent dialog for this toolbar.
*/
public void setParentDialog(ContactsPickerDialog dialog) {
mDialog = dialog;
}
/**
* Shows the Back arrow navigation button in the upper left corner.
*/
public void showBackArrow() {
setNavigationButton(NAVIGATION_BUTTON_BACK);
}
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
showCloseButton();
TextView up = (TextView) mNumberRollView.findViewById(R.id.up); TextView up = (TextView) mNumberRollView.findViewById(R.id.up);
TextView down = (TextView) mNumberRollView.findViewById(R.id.down); TextView down = (TextView) mNumberRollView.findViewById(R.id.down);
ApiCompatibilityUtils.setTextAppearance(up, R.style.TextAppearance_BlackHeadline); ApiCompatibilityUtils.setTextAppearance(up, R.style.TextAppearance_BlackHeadline);
ApiCompatibilityUtils.setTextAppearance(down, R.style.TextAppearance_BlackHeadline); ApiCompatibilityUtils.setTextAppearance(down, R.style.TextAppearance_BlackHeadline);
} }
/**
* Shows the Close or 'X' navigation button in the upper left corner.
*/
public void showCloseButton() {
setNavigationIcon(R.drawable.btn_close);
setNavigationContentDescription(R.string.close);
}
@Override @Override
protected void setNavigationButton(int navigationButton) {} public void onNavigationBack() {
if (isSearching()) {
super.onNavigationBack();
} else {
mDialog.cancel();
}
}
@Override @Override
protected void showSelectionView( protected void showSelectionView(
...@@ -58,5 +71,7 @@ public class ContactsPickerToolbar extends SelectableListToolbar<ContactDetails> ...@@ -58,5 +71,7 @@ public class ContactsPickerToolbar extends SelectableListToolbar<ContactDetails>
Button done = (Button) findViewById(R.id.done); Button done = (Button) findViewById(R.id.done);
done.setEnabled(selectedItems.size() > 0); done.setEnabled(selectedItems.size() > 0);
showBackArrow();
} }
} }
...@@ -155,6 +155,7 @@ public class PickerCategoryView extends RelativeLayout ...@@ -155,6 +155,7 @@ public class PickerCategoryView extends RelativeLayout
false); false);
mToolbar.setNavigationOnClickListener(this); mToolbar.setNavigationOnClickListener(this);
mToolbar.initializeSearchView(this, R.string.contacts_picker_search, 0); mToolbar.initializeSearchView(this, R.string.contacts_picker_search, 0);
mToolbar.showBackArrow();
mSearchButton = (ImageView) mToolbar.findViewById(R.id.search); mSearchButton = (ImageView) mToolbar.findViewById(R.id.search);
mSearchButton.setOnClickListener(this); mSearchButton.setOnClickListener(this);
...@@ -182,6 +183,8 @@ public class PickerCategoryView extends RelativeLayout ...@@ -182,6 +183,8 @@ public class PickerCategoryView extends RelativeLayout
mDialog = dialog; mDialog = dialog;
mListener = listener; mListener = listener;
mToolbar.setParentDialog(mDialog);
mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
...@@ -210,7 +213,6 @@ public class PickerCategoryView extends RelativeLayout ...@@ -210,7 +213,6 @@ public class PickerCategoryView extends RelativeLayout
public void onEndSearch() { public void onEndSearch() {
mPickerAdapter.setSearchString(""); mPickerAdapter.setSearchString("");
mPickerAdapter.setSearchMode(false); mPickerAdapter.setSearchMode(false);
mToolbar.showCloseButton();
mToolbar.setNavigationOnClickListener(this); mToolbar.setNavigationOnClickListener(this);
mDoneButton.setVisibility(VISIBLE); mDoneButton.setVisibility(VISIBLE);
mSearchButton.setVisibility(VISIBLE); mSearchButton.setVisibility(VISIBLE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment