diff options
-rw-r--r-- | res/layout-land/compact_contact_editor_fragment.xml | 59 | ||||
-rw-r--r-- | res/layout/compact_contact_editor_fields.xml | 86 | ||||
-rw-r--r-- | res/layout/compact_contact_editor_fragment.xml | 73 | ||||
-rw-r--r-- | src/com/android/contacts/editor/CompactPhotoEditorView.java (renamed from src/com/android/contacts/editor/CompactHeaderView.java) | 24 | ||||
-rw-r--r-- | src/com/android/contacts/editor/CompactRawContactsEditorView.java | 19 |
5 files changed, 175 insertions, 86 deletions
diff --git a/res/layout-land/compact_contact_editor_fragment.xml b/res/layout-land/compact_contact_editor_fragment.xml new file mode 100644 index 000000000..ffc8f4f4d --- /dev/null +++ b/res/layout-land/compact_contact_editor_fragment.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2015 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. +--> + +<com.android.contacts.editor.CompactRawContactsEditorView + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/editors" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/background_primary" + android:orientation="horizontal" + android:visibility="invisible"> + + <com.android.contacts.editor.CompactPhotoEditorView + android:id="@+id/photo_editor" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center_horizontal" + android:orientation="vertical"> + + <com.android.contacts.widget.QuickContactImageView + android:id="@+id/photo" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clickable="true" + android:scaleType="centerCrop"/> + + </com.android.contacts.editor.CompactPhotoEditorView> + + <ScrollView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fadingEdge="none" + android:fillViewport="true"> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <include layout="@layout/compact_contact_editor_fields"/> + + </LinearLayout> + + </ScrollView> + +</com.android.contacts.editor.CompactRawContactsEditorView>
\ No newline at end of file diff --git a/res/layout/compact_contact_editor_fields.xml b/res/layout/compact_contact_editor_fields.xml new file mode 100644 index 000000000..aa0b32509 --- /dev/null +++ b/res/layout/compact_contact_editor_fields.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2015 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. +--> + +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + + <LinearLayout + android:id="@+id/names" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout + android:id="@+id/phonetic_names" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout + android:id="@+id/nicknames" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout + android:id="@+id/phone_numbers" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout + android:id="@+id/emails" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout + android:id="@+id/other" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout + style="@style/SelectableItem" + android:id="@+id/more_fields" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/divider_line_height" + android:background="@color/divider_line_color_light"/> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="@dimen/expanding_entry_card_item_image_spacing" + android:gravity="center_vertical" + android:paddingBottom="@dimen/expanding_entry_card_button_padding_vertical" + android:paddingTop="@dimen/expanding_entry_card_button_padding_vertical" + android:text="@string/compact_editor_more_fields" + android:textColor="@color/expanding_entry_card_button_text_color" + android:textSize="@dimen/expanding_entry_card_title_text_size"/> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/divider_line_height" + android:background="@color/divider_line_color_light"/> + + </LinearLayout> + +</merge>
\ No newline at end of file diff --git a/res/layout/compact_contact_editor_fragment.xml b/res/layout/compact_contact_editor_fragment.xml index 1a0788e73..d38184b44 100644 --- a/res/layout/compact_contact_editor_fragment.xml +++ b/res/layout/compact_contact_editor_fragment.xml @@ -29,9 +29,8 @@ android:orientation="vertical" android:visibility="invisible"> - <!-- TODO: remove hard coded dimensions when we have a split screen layout in landscape --> - <com.android.contacts.editor.CompactHeaderView - android:id="@+id/header" + <com.android.contacts.editor.CompactPhotoEditorView + android:id="@+id/photo_editor" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" @@ -44,73 +43,9 @@ android:clickable="true" android:scaleType="centerCrop"/> - </com.android.contacts.editor.CompactHeaderView> + </com.android.contacts.editor.CompactPhotoEditorView> - <LinearLayout - android:id="@+id/names" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"/> - - <LinearLayout - android:id="@+id/phonetic_names" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"/> - - <LinearLayout - android:id="@+id/nicknames" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"/> - - <LinearLayout - android:id="@+id/phone_numbers" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"/> - - <LinearLayout - android:id="@+id/emails" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"/> - - <LinearLayout - android:id="@+id/other" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"/> - - <LinearLayout - style="@style/SelectableItem" - android:id="@+id/more_fields" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" > - - <View - android:layout_width="match_parent" - android:layout_height="@dimen/divider_line_height" - android:background="@color/divider_line_color_light" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingStart="@dimen/expanding_entry_card_item_image_spacing" - android:gravity="center_vertical" - android:paddingBottom="@dimen/expanding_entry_card_button_padding_vertical" - android:paddingTop="@dimen/expanding_entry_card_button_padding_vertical" - android:text="@string/compact_editor_more_fields" - android:textColor="@color/expanding_entry_card_button_text_color" - android:textSize="@dimen/expanding_entry_card_title_text_size" /> - - <View - android:layout_width="match_parent" - android:layout_height="@dimen/divider_line_height" - android:background="@color/divider_line_color_light" /> - - </LinearLayout> + <include layout="@layout/compact_contact_editor_fields" /> </com.android.contacts.editor.CompactRawContactsEditorView> diff --git a/src/com/android/contacts/editor/CompactHeaderView.java b/src/com/android/contacts/editor/CompactPhotoEditorView.java index caac07af9..38e4f8721 100644 --- a/src/com/android/contacts/editor/CompactHeaderView.java +++ b/src/com/android/contacts/editor/CompactPhotoEditorView.java @@ -48,7 +48,7 @@ import android.widget.LinearLayout; /** * Displays the primary photo. */ -public class CompactHeaderView extends LinearLayout implements View.OnClickListener { +public class CompactPhotoEditorView extends LinearLayout implements View.OnClickListener { private static final String TAG = CompactContactEditorFragment.TAG; @@ -65,11 +65,11 @@ public class CompactHeaderView extends LinearLayout implements View.OnClickListe private QuickContactImageView mPhotoImageView; - public CompactHeaderView(Context context) { + public CompactPhotoEditorView(Context context) { this(context, null); } - public CompactHeaderView(Context context, AttributeSet attrs) { + public CompactPhotoEditorView(Context context, AttributeSet attrs) { super(context, attrs); final TypedValue landscapePhotoRatio = new TypedValue(); @@ -136,15 +136,25 @@ public class CompactHeaderView extends LinearLayout implements View.OnClickListe mPhotoImageView.setTint(color); } - // Make the photo a square + // Adjust the photo dimensions following the same logic as in + // MultiShrinkScroll.initialize SchedulingUtils.doOnPreDraw(this, /* drawNextFrame =*/ false, new Runnable() { @Override public void run() { - final int photoHeight = mIsTwoPanel - ? (int) (getWidth() * mLandscapePhotoRatio) : getWidth(); + + final int photoHeight, photoWidth; + if (mIsTwoPanel) { + // Make the photo slightly more narrow than it is tall + photoHeight = getHeight(); + photoWidth = (int) (photoHeight * mLandscapePhotoRatio); + } else { + // Make the photo a square + photoHeight = getHeight(); + photoWidth = photoHeight; + } final ViewGroup.LayoutParams layoutParams = getLayoutParams(); layoutParams.height = photoHeight; - layoutParams.width = photoHeight; + layoutParams.width = photoWidth; setLayoutParams(layoutParams); } }); diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java index 3173c8c5a..44cf698ce 100644 --- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java +++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java @@ -73,7 +73,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O private ViewIdGenerator mViewIdGenerator; private MaterialColorMapUtils.MaterialPalette mMaterialPalette; - private CompactHeaderView mHeader; + private CompactPhotoEditorView mPhoto; private ViewGroup mNames; private ViewGroup mPhoneticNames; private ViewGroup mNicknames; @@ -108,7 +108,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O mLayoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mHeader = (CompactHeaderView) findViewById(R.id.header); + mPhoto = (CompactPhotoEditorView) findViewById(R.id.photo_editor); mNames = (LinearLayout) findViewById(R.id.names); mPhoneticNames = (LinearLayout) findViewById(R.id.phonetic_names); mNicknames = (LinearLayout) findViewById(R.id.nicknames); @@ -148,24 +148,24 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O } /** - * Pass through to {@link CompactHeaderView#setPhotoHandler}. + * Pass through to {@link CompactPhotoEditorView#setPhotoHandler}. */ public void setPhotoHandler(PhotoHandler photoHandler) { - mHeader.setPhotoHandler(photoHandler); + mPhoto.setPhotoHandler(photoHandler); } /** - * Pass through to {@link CompactHeaderView#setPhoto}. + * Pass through to {@link CompactPhotoEditorView#setPhoto}. */ public void setPhoto(Bitmap bitmap) { - mHeader.setPhoto(bitmap); + mPhoto.setPhoto(bitmap); } /** - * Pass through to {@link CompactHeaderView#isWritablePhotoSet}. + * Pass through to {@link CompactPhotoEditorView#isWritablePhotoSet}. */ public boolean isWritablePhotoSet() { - return mHeader.isWritablePhotoSet(); + return mPhoto.isWritablePhotoSet(); } /** @@ -220,7 +220,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O mPhotoRawContactId = rawContactDelta.getRawContactId(); final ValuesDelta valuesDelta = rawContactDelta.getSuperPrimaryEntry( dataKind.mimeType, /* forceSelection =*/ true); - mHeader.setValues(dataKind, valuesDelta, rawContactDelta, + mPhoto.setValues(dataKind, valuesDelta, rawContactDelta, /* readOnly =*/ !dataKind.editable, mMaterialPalette, viewIdGenerator); return; } @@ -327,7 +327,6 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O } } - // TODO: remove this after KindSectionView is rewritten private static boolean isEmptyEditorView(View view) { if (view instanceof TextFieldsEditorView) { final TextFieldsEditorView textFieldsEditorView = (TextFieldsEditorView) view; |