From d99993213962df64c9d76005df86c2fb83fca074 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 19 Jul 2013 09:22:03 -0700 Subject: Style and layout changes to match redlines * Swapped out some icons with newly added assets. * Changed search view into edit text with accompanying close button so that it can be more easily styled. * Changed various background colors. * Tweaked padding values to match redlines * Removed margins from PhoneFavoriteRegularRowView and PhoneFavoriteTileView and instead use a standardized set of margins for all rows in PhoneFavoritesTileAdapter * Added bottom_border_background drawable to create a bordered background. * Remove PhoneFavoritesTileAdapter.ViewTypes.STARRED/STARRED_PHONE since they are no longer relevant Change-Id: I65dfd5adf6cfbcb2c9d283aef2bd10e5d2a82dc7 --- src/com/android/dialer/NewDialtactsActivity.java | 142 ++++++++++----------- .../dialer/calllog/NewCallLogListItemHelper.java | 4 +- .../dialer/list/NewPhoneFavoriteMergedAdapter.java | 2 - .../dialer/list/PhoneFavoritesTileAdapter.java | 54 +++++--- 4 files changed, 102 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/NewDialtactsActivity.java b/src/com/android/dialer/NewDialtactsActivity.java index 66cbe8530..54e7df258 100644 --- a/src/com/android/dialer/NewDialtactsActivity.java +++ b/src/com/android/dialer/NewDialtactsActivity.java @@ -28,6 +28,7 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; import android.os.RemoteException; @@ -37,7 +38,9 @@ import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents.UI; import android.provider.Settings; +import android.text.Editable; import android.text.TextUtils; +import android.text.TextWatcher; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -46,6 +49,8 @@ import android.view.View.OnFocusChangeListener; import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodManager; import android.widget.AbsListView.OnScrollListener; +import android.widget.EditText; +import android.widget.ImageView; import android.widget.PopupMenu; import android.widget.SearchView; import android.widget.SearchView.OnCloseListener; @@ -145,7 +150,9 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie * {@link PhoneNumberPickerFragment}). */ private boolean mInSearchUi; - private SearchView mSearchView; + private View mSearchViewContainer; + private View mSearchViewCloseButton; + private EditText mSearchView; /** * The index of the Fragment (or, the tab) that has last been manually selected. @@ -181,61 +188,42 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie /** * Listener used to send search queries to the phone search fragment. */ - private final OnQueryTextListener mPhoneSearchQueryTextListener = - new OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String query) { - View view = getCurrentFocus(); - if (view != null) { - hideInputMethod(view); - view.clearFocus(); - } - return true; + private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + final boolean smartDialSearch = isDialpadShowing(); + final String newText = s.toString(); + // Show search result with non-empty text. Show a bare list otherwise. + if (TextUtils.isEmpty(newText) && mInSearchUi) { + exitSearchUi(); + mSearchViewCloseButton.setVisibility(View.GONE); + return; + } else if (!TextUtils.isEmpty(newText) && !mInSearchUi) { + enterSearchUi(smartDialSearch); } - @Override - public boolean onQueryTextChange(String newText) { - final boolean smartDialSearch = isDialpadShowing(); - - // Show search result with non-empty text. Show a bare list otherwise. - if (TextUtils.isEmpty(newText) && mInSearchUi) { - exitSearchUi(); - return true; - } else if (!TextUtils.isEmpty(newText) && !mInSearchUi) { - enterSearchUi(smartDialSearch); - } - - if (isDialpadShowing()) { - mSmartDialSearchFragment.setQueryString(newText, false); - } else { - mRegularSearchFragment.setQueryString(newText, false); - } - return true; + if (isDialpadShowing()) { + mSmartDialSearchFragment.setQueryString(newText, false); + } else { + mRegularSearchFragment.setQueryString(newText, false); } + mSearchViewCloseButton.setVisibility(View.VISIBLE); + return; + } + + @Override + public void afterTextChanged(Editable s) { + } }; private boolean isDialpadShowing() { return mDialpadFragment.isVisible(); } - /** - * Listener used to handle the "close" button on the right side of {@link SearchView}. - * If some text is in the search view, this will clean it up. Otherwise this will exit - * the search UI and let users go back to usual Phone UI. - * - * This does _not_ handle back button. - */ - private final OnCloseListener mPhoneSearchCloseListener = - new OnCloseListener() { - @Override - public boolean onClose() { - if (!TextUtils.isEmpty(mSearchView.getQuery())) { - mSearchView.setQuery(null, true); - } - return true; - } - }; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -362,6 +350,12 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie final Intent intent = new Intent(this, NewCallLogActivity.class); startActivity(intent); break; + case R.id.search_close_button: + // Clear the search field + if (!TextUtils.isEmpty(mSearchView.getText())) { + mSearchView.setText(""); + } + break; default: { Log.wtf(TAG, "Unexpected onClick event from " + view); break; @@ -384,20 +378,14 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie } private void prepareSearchView() { - mSearchView = (SearchView) findViewById(R.id.search_view); - mSearchView.setOnQueryTextListener(mPhoneSearchQueryTextListener); - mSearchView.setOnCloseListener(mPhoneSearchCloseListener); - // Since we're using a custom layout for showing SearchView instead of letting the - // search menu icon do that job, we need to manually configure the View so it looks - // "shown via search menu". - // - it should be iconified by default - // - it should not be iconified at this time - // See also comments for onActionViewExpanded()/onActionViewCollapsed() - mSearchView.setIconifiedByDefault(true); - mSearchView.setQueryHint(getString(R.string.dialer_hint_find_contact)); - mSearchView.setIconified(false); - mSearchView.clearFocus(); - mSearchView.setOnQueryTextFocusChangeListener(new OnFocusChangeListener() { + mSearchViewContainer = findViewById(R.id.search_view_container); + mSearchViewCloseButton = findViewById(R.id.search_close_button); + mSearchViewCloseButton.setClickable(true); + mSearchViewCloseButton.setOnClickListener(this); + mSearchView = (EditText) findViewById(R.id.search_view); + mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); + mSearchView.setHint(getString(R.string.dialer_hint_find_contact)); + mSearchView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { @@ -416,19 +404,19 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie final AnimatorListener mHideListener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - mSearchView.setVisibility(View.GONE); + mSearchViewContainer.setVisibility(View.GONE); } }; public void hideSearchBar() { - mSearchView.animate().cancel(); - mSearchView.setAlpha(1); - mSearchView.setTranslationY(0); - mSearchView.animate().withLayer().alpha(0).translationY(-mSearchView.getHeight()). - setDuration(200).setListener(mHideListener); + mSearchViewContainer.animate().cancel(); + mSearchViewContainer.setAlpha(1); + mSearchViewContainer.setTranslationY(0); + mSearchViewContainer.animate().withLayer().alpha(0).translationY(-mSearchView.getHeight()) + .setDuration(200).setListener(mHideListener); mPhoneFavoriteFragment.getView().animate().withLayer() - .translationY(-mSearchView.getHeight()).setDuration(200).setListener( + .translationY(-mSearchViewContainer.getHeight()).setDuration(200).setListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -439,18 +427,18 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie } public void showSearchBar() { - mSearchView.animate().cancel(); - mSearchView.setAlpha(0); - mSearchView.setTranslationY(-mSearchView.getHeight()); - mSearchView.animate().withLayer().alpha(1).translationY(0).setDuration(200) + mSearchViewContainer.animate().cancel(); + mSearchViewContainer.setAlpha(0); + mSearchViewContainer.setTranslationY(-mSearchViewContainer.getHeight()); + mSearchViewContainer.animate().withLayer().alpha(1).translationY(0).setDuration(200) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - mSearchView.setVisibility(View.VISIBLE); + mSearchViewContainer.setVisibility(View.VISIBLE); } }); - mPhoneFavoriteFragment.getView().setTranslationY(-mSearchView.getHeight()); + mPhoneFavoriteFragment.getView().setTranslationY(-mSearchViewContainer.getHeight()); mPhoneFavoriteFragment.getView().animate().withLayer().translationY(0).setDuration(200) .setListener( new AnimatorListenerAdapter() { @@ -728,7 +716,7 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie if (mDialpadFragment.isVisible()) { hideDialpadFragment(); } else if (mInSearchUi) { - mSearchView.setQuery(null, false); + mSearchView.setText(null); } else if (isTaskRoot()) { // Instead of stopping, simply push this to the back of the stack. // This is only done when running at the top of the stack; @@ -744,8 +732,8 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie public void onDialpadQueryChanged(String query) { final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query, SmartDialNameMatcher.LATIN_SMART_DIAL_MAP); - if (!TextUtils.equals(mSearchView.getQuery(), normalizedQuery)) { - mSearchView.setQuery(normalizedQuery, false); + if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) { + mSearchView.setText(normalizedQuery); } } diff --git a/src/com/android/dialer/calllog/NewCallLogListItemHelper.java b/src/com/android/dialer/calllog/NewCallLogListItemHelper.java index 6cb80a051..6b4f10151 100644 --- a/src/com/android/dialer/calllog/NewCallLogListItemHelper.java +++ b/src/com/android/dialer/calllog/NewCallLogListItemHelper.java @@ -84,7 +84,7 @@ import com.android.dialer.R; private void configureCallSecondaryAction(CallLogListItemViews views, PhoneCallDetails details) { views.secondaryActionView.setVisibility(View.VISIBLE); - views.secondaryActionView.setImageResource(R.drawable.ic_ab_dialer_holo_dark); + views.secondaryActionView.setImageResource(R.drawable.ic_ab_dialer_holo_light); views.secondaryActionView.setContentDescription(getCallActionDescription(details)); } @@ -104,7 +104,7 @@ import com.android.dialer.R; private void configurePlaySecondaryAction(CallLogListItemViews views, boolean isHighlighted) { views.secondaryActionView.setVisibility(View.VISIBLE); views.secondaryActionView.setImageResource( - isHighlighted ? R.drawable.ic_play_active_holo_dark : R.drawable.ic_play_holo_dark); + isHighlighted ? R.drawable.ic_play_active_holo_dark : R.drawable.ic_play_holo_light); views.secondaryActionView.setContentDescription( mResources.getString(R.string.description_call_log_play_button)); } diff --git a/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java index 49d46a851..fff5c9f7c 100644 --- a/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java +++ b/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java @@ -250,13 +250,11 @@ public class NewPhoneFavoriteMergedAdapter extends BaseAdapter implements Sectio final int frequentHeaderPosition = mContactTileAdapter.getFrequentHeaderPosition(); // TODO krelease: Get rid of frequent header position, we don't need it anymore if (position >= frequentHeaderPosition) { - // Views for "frequent" contacts use FrameLayout's margins instead of padding. final FrameLayout frameLayout = (FrameLayout) view; final View child = frameLayout.getChildAt(0); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); - params.setMargins(mItemPaddingLeft, 0, mItemPaddingRight, 0); child.setLayoutParams(params); } return view; diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 36fc34608..48660ff02 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -43,7 +43,6 @@ import java.util.ArrayList; * * This adapter has been rewritten to only support a maximum of one row for favorites. * - * TODO Krelease: Move to PhoneContactTileAdapter in Dialer package. */ public class PhoneFavoritesTileAdapter extends BaseAdapter { private static final String TAG = ContactTileAdapter.class.getSimpleName(); @@ -98,7 +97,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { // Converting padding in dips to padding in pixels mPaddingInPixels = mContext.getResources() - .getDimensionPixelSize(R.dimen.contact_tile_divider_padding); + .getDimensionPixelSize(R.dimen.phone_contact_tile_divider_padding); bindColumnIndices(); } @@ -322,7 +321,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { switch (viewType) { case ViewTypes.FREQUENT: return R.layout.phone_favorite_regular_row_view; - case ViewTypes.STARRED_PHONE: + case ViewTypes.TOP: return R.layout.phone_favorite_tile_view; default: throw new IllegalArgumentException("Unrecognized viewType " + viewType); @@ -336,7 +335,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { @Override public int getItemViewType(int position) { if (position < getRowCount(mDividerPosition)) { - return ViewTypes.STARRED_PHONE; + return ViewTypes.TOP; } else { return ViewTypes.FREQUENT; } @@ -358,12 +357,31 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { private class ContactTileRow extends FrameLayout { private int mItemViewType; private int mLayoutResId; + private final int mRowPaddingStart; + private final int mRowPaddingEnd; + private final int mRowPaddingTop; + private final int mRowPaddingBottom; public ContactTileRow(Context context, int itemViewType) { super(context); mItemViewType = itemViewType; mLayoutResId = getLayoutResourceId(mItemViewType); + final Resources resources = mContext.getResources(); + mRowPaddingStart = resources.getDimensionPixelSize( + R.dimen.favorites_row_start_padding); + mRowPaddingEnd = resources.getDimensionPixelSize( + R.dimen.favorites_row_end_padding); + mRowPaddingTop = resources.getDimensionPixelSize( + R.dimen.favorites_row_top_padding); + mRowPaddingBottom = resources.getDimensionPixelSize( + R.dimen.favorites_row_bottom_padding); + + setBackgroundResource(R.drawable.bottom_border_background); + + setPaddingRelative(mRowPaddingStart, mRowPaddingTop, mRowPaddingEnd, + mRowPaddingBottom); + // Remove row (but not children) from accessibility node tree. setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } @@ -390,7 +408,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null); // Note: the layoutparam set here is only actually used for FREQUENT. // We override onMeasure() for STARRED and we don't care the layout param there. - Resources resources = mContext.getResources(); + final Resources resources = mContext.getResources(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); @@ -409,11 +427,10 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { } contactTile.loadFromContact(entry); switch (mItemViewType) { - case ViewTypes.STARRED_PHONE: + case ViewTypes.TOP: // Setting divider visibilities contactTile.setPaddingRelative(0, 0, - childIndex >= mColumnCount - 1 ? 0 : mPaddingInPixels, - isLastRow ? 0 : mPaddingInPixels); + childIndex >= mColumnCount - 1 ? 0 : mPaddingInPixels, 0); break; case ViewTypes.FREQUENT: contactTile.setHorizontalDividerVisibility( @@ -427,7 +444,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { switch (mItemViewType) { - case ViewTypes.STARRED_PHONE: + case ViewTypes.TOP: onLayoutForTiles(); return; default: @@ -440,7 +457,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { final int count = getChildCount(); // Just line up children horizontally. - int childLeft = 0; + int childLeft = getPaddingStart(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); @@ -454,8 +471,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { switch (mItemViewType) { - case ViewTypes.STARRED_PHONE: - case ViewTypes.STARRED: + case ViewTypes.TOP: onMeasureForTiles(widthMeasureSpec); return; default: @@ -484,7 +500,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { // Let width = given width. // Let height = image size + bottom paddding. - final int totalPaddingsInPixels = (mColumnCount - 1) * mPaddingInPixels; + final int totalPaddingsInPixels = (mColumnCount - 1) * mPaddingInPixels + + mRowPaddingStart + mRowPaddingEnd; // Preferred width / height for images (excluding the padding). // The actual width may be 1 pixel larger than this if we have a remainder. @@ -496,20 +513,19 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { final int childWidth = imageSize + child.getPaddingRight() // Compensate for the remainder + (i < remainder ? 1 : 0); - final int childHeight = imageSize + child.getPaddingBottom(); + final int childHeight = imageSize; child.measure( MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY) ); } - setMeasuredDimension(width, imageSize + getChildAt(0).getPaddingBottom()); + setMeasuredDimension(width, imageSize + getPaddingTop() + getPaddingBottom()); } } protected static class ViewTypes { - public static final int COUNT = 3; - public static final int STARRED = 0; - public static final int FREQUENT = 1; - public static final int STARRED_PHONE = 2; + public static final int COUNT = 2; + public static final int FREQUENT = 0; + public static final int TOP = 1; } } -- cgit v1.2.3