diff options
author | Wenyi Wang <wenyiw@google.com> | 2016-02-17 21:35:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-17 21:35:13 +0000 |
commit | 504f8e54d352b688623b4bf09c22a75ca5a8009e (patch) | |
tree | 2cc884029f48cf6f3d366961bd19eb767be6cc1c | |
parent | 144a4d16daf88dded258063bc33810b20c57f81d (diff) | |
parent | fe4f03cd0ca38e446f7690e1b5e076e65530bb37 (diff) | |
download | android_packages_apps_Contacts-504f8e54d352b688623b4bf09c22a75ca5a8009e.tar.gz android_packages_apps_Contacts-504f8e54d352b688623b4bf09c22a75ca5a8009e.tar.bz2 android_packages_apps_Contacts-504f8e54d352b688623b4bf09c22a75ca5a8009e.zip |
Merge "Set number of columns of photo picker dynamically" into nyc-dev
-rw-r--r-- | res/layout/all_photos_button.xml | 4 | ||||
-rw-r--r-- | res/layout/compact_photo_selection_fragment.xml | 2 | ||||
-rw-r--r-- | res/layout/compact_photo_selection_item.xml | 4 | ||||
-rw-r--r-- | res/layout/take_a_photo_button.xml | 4 | ||||
-rw-r--r-- | res/values/dimens.xml | 4 | ||||
-rw-r--r-- | src/com/android/contacts/editor/CompactPhotoSelectionFragment.java | 22 |
6 files changed, 15 insertions, 25 deletions
diff --git a/res/layout/all_photos_button.xml b/res/layout/all_photos_button.xml index 6ccdca53d..83578c3a1 100644 --- a/res/layout/all_photos_button.xml +++ b/res/layout/all_photos_button.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="135dp" - android:layout_height="135dp" + android:layout_width="@dimen/photo_picker_item_ideal_width" + android:layout_height="@dimen/photo_picker_item_ideal_width" android:background="@color/google_grey_600" android:orientation="vertical"> diff --git a/res/layout/compact_photo_selection_fragment.xml b/res/layout/compact_photo_selection_fragment.xml index b35dae5b0..42f5b963a 100644 --- a/res/layout/compact_photo_selection_fragment.xml +++ b/res/layout/compact_photo_selection_fragment.xml @@ -22,7 +22,7 @@ android:numColumns="auto_fit" android:verticalSpacing="3dp" android:horizontalSpacing="3dp" - android:stretchMode="none" + android:stretchMode="columnWidth" android:gravity="center" android:paddingTop="3dp" android:drawSelectorOnTop="true"/> diff --git a/res/layout/compact_photo_selection_item.xml b/res/layout/compact_photo_selection_item.xml index c625765b7..aea8ff611 100644 --- a/res/layout/compact_photo_selection_item.xml +++ b/res/layout/compact_photo_selection_item.xml @@ -21,8 +21,8 @@ <ImageView android:id="@+id/image" - android:layout_width="135dp" - android:layout_height="135dp" + android:layout_width="match_parent" + android:layout_height="@dimen/photo_picker_item_ideal_width" android:adjustViewBounds="true" android:layout_centerInParent="true" android:scaleType="centerCrop" /> diff --git a/res/layout/take_a_photo_button.xml b/res/layout/take_a_photo_button.xml index 28ec60bd4..b837e850c 100644 --- a/res/layout/take_a_photo_button.xml +++ b/res/layout/take_a_photo_button.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="135dp" - android:layout_height="135dp" + android:layout_width="@dimen/photo_picker_item_ideal_width" + android:layout_height="@dimen/photo_picker_item_ideal_width" android:background="@color/google_grey_600" android:orientation="vertical"> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 8fe5c72b5..7b4cd12d8 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -280,8 +280,8 @@ of ListView's will not match the padding inside list items --> <dimen name="contact_browser_list_item_padding_top_or_bottom">12dp</dimen> - <!-- Width of padding between columns of photos in photo picker --> - <dimen name="photo_picker_column_padding_width">1dp</dimen> + <!-- Ideal item width in photo picker --> + <dimen name="photo_picker_item_ideal_width">135dp</dimen> <!-- Margin between name field and whatever fields are above it. --> <dimen name="compact_editor_name_top_margin">8dp</dimen> diff --git a/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java b/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java index bc9435b57..3f157a47c 100644 --- a/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java +++ b/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java @@ -28,7 +28,6 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.provider.ContactsContract; -import android.text.TextUtils; import android.util.DisplayMetrics; import android.view.Display; import android.view.LayoutInflater; @@ -53,9 +52,6 @@ public class CompactPhotoSelectionFragment extends Fragment { private final int VIEW_TYPE_TAKE_PHOTO = 0; private final int VIEW_TYPE_ALL_PHOTOS = 1; private final int VIEW_TYPE_IMAGE = 2; - private final int NUMBER_OF_COLUMNS_PORTRAIT = 3; - private final int NUMBER_OF_COLUMNS_LANDSCAPE = 5; - private int mNumberOfColumns; /** * Callbacks hosts this Fragment. @@ -295,7 +291,7 @@ public class CompactPhotoSelectionFragment extends Fragment { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final PhotoSourceDialogFragment.Listener listener = (PhotoSourceDialogFragment.Listener) getActivity(); - if (position == 0){ + if (position == 0) { listener.onTakePhotoChosen(); } else if (position == 1) { listener.onPickFromGalleryChosen(); @@ -312,17 +308,11 @@ public class CompactPhotoSelectionFragment extends Fragment { final Display display = getActivity().getWindowManager().getDefaultDisplay(); final DisplayMetrics outMetrics = new DisplayMetrics (); - display.getMetrics(outMetrics); - - // portrait -- 3 columns; landscape -- 5 columns. - mNumberOfColumns = outMetrics.heightPixels > outMetrics.widthPixels ? - NUMBER_OF_COLUMNS_PORTRAIT : NUMBER_OF_COLUMNS_LANDSCAPE; - final int paddingWidth = (int) getResources().getDimension(R.dimen - .photo_picker_column_padding_width); - float density = getResources().getDisplayMetrics().density; - float dpColumnWidth = (outMetrics.widthPixels - paddingWidth * (mNumberOfColumns - 1) * - density) / mNumberOfColumns; - mGridView.setColumnWidth((int) dpColumnWidth); + display.getRealMetrics(outMetrics); // real metrics include the navigation Bar + + final float numColumns = outMetrics.widthPixels / + getResources().getDimension(R.dimen.photo_picker_item_ideal_width); + mGridView.setNumColumns(Math.round(numColumns)); return view; } |