Merge "Horizontal editor layout"
diff --git a/res/layout-xlarge/item_contact_editor.xml b/res/layout-xlarge/item_contact_editor.xml
index f543b61..f350f36 100644
--- a/res/layout-xlarge/item_contact_editor.xml
+++ b/res/layout-xlarge/item_contact_editor.xml
@@ -121,6 +121,7 @@
android:layout_height="wrap_content"
android:paddingLeft="230dip"
android:orientation="vertical"
+ android:paddingRight="?android:attr/scrollbarSize"
/>
<View
diff --git a/res/layout-xlarge/item_kind_section.xml b/res/layout-xlarge/item_kind_section.xml
new file mode 100644
index 0000000..3728067
--- /dev/null
+++ b/res/layout-xlarge/item_kind_section.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<!-- the body surrounding all editors for a specific kind -->
+
+<com.android.contacts.ui.widget.KindSectionView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/kind_title"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="marquee" />
+
+ <LinearLayout
+ android:id="@+id/kind_editors"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="bottom"
+ android:orientation="vertical" />
+
+ <ImageButton
+ android:id="@+id/kind_plus"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ style="@style/PlusButton" />
+</com.android.contacts.ui.widget.KindSectionView>
diff --git a/res/layout/item_kind_section.xml b/res/layout/item_kind_section.xml
index a78896b..d801160 100644
--- a/res/layout/item_kind_section.xml
+++ b/res/layout/item_kind_section.xml
@@ -53,7 +53,7 @@
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
- <ImageView
+ <ImageButton
android:id="@+id/kind_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/src/com/android/contacts/ui/widget/GenericEditorView.java b/src/com/android/contacts/ui/widget/GenericEditorView.java
index 92c815c..2c731ff 100644
--- a/src/com/android/contacts/ui/widget/GenericEditorView.java
+++ b/src/com/android/contacts/ui/widget/GenericEditorView.java
@@ -129,8 +129,8 @@
final boolean hasDelete = mDelete != null;
if (hasDelete) {
mDelete.layout(
- r1 - mDelete.getMeasuredWidth(), t1,
- r1, t1 + mDelete.getMeasuredHeight());
+ r1 - mDelete.getMeasuredWidth(), b1 - mDelete.getMeasuredHeight(),
+ r1, b1);
}
// MoreOrLess Button
@@ -147,7 +147,7 @@
final int r2 = r1 - Math.max(
hasDelete ? mDelete.getMeasuredWidth() : 0,
hasMoreOrLess ? mMoreOrLess.getMeasuredWidth() : 0);
- int y = 0;
+ int y = t1;
if (mFieldEditTexts != null) {
for (EditText editText : mFieldEditTexts) {
if (editText.getVisibility() != View.GONE) {
@@ -225,7 +225,7 @@
}
/**
- * Creates or removes the type/label button. Doesn't do anything if already correctly configured
+ * Creates or removes the remove button. Doesn't do anything if already correctly configured
*/
private void setupDeleteButton(boolean shouldExist) {
if (shouldExist && mDelete == null) {
@@ -245,17 +245,12 @@
// Keep around in model, but mark as deleted
mEntry.markDeleted();
-// final ViewGroupAnimator animator = ViewGroupAnimator.captureView(getRootView());
-
-// animator.removeView(GenericEditorView.this);
((ViewGroup) getParent()).removeView(GenericEditorView.this);
if (mListener != null) {
// Notify listener when present
mListener.onDeleted(GenericEditorView.this);
}
-
-// animator.animate();
}
});
addView(mDelete);
diff --git a/src/com/android/contacts/ui/widget/KindSectionView.java b/src/com/android/contacts/ui/widget/KindSectionView.java
index cd0b6fb..3e13bd8 100644
--- a/src/com/android/contacts/ui/widget/KindSectionView.java
+++ b/src/com/android/contacts/ui/widget/KindSectionView.java
@@ -34,7 +34,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.widget.ImageView;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -48,8 +48,7 @@
private static int sCachedThemePaddingRight = -1;
private ViewGroup mEditors;
- private View mAdd;
- private ImageView mAddPlusButton;
+ private ImageButton mAddPlusButton;
private TextView mTitle;
private DataKind mKind;
@@ -74,15 +73,13 @@
mEditors = (ViewGroup)findViewById(R.id.kind_editors);
- mAdd = findViewById(R.id.kind_header);
- mAdd.setOnClickListener(new OnClickListener() {
+ mAddPlusButton = (ImageButton) findViewById(R.id.kind_plus);
+ mAddPlusButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
addItem();
}
});
- mAddPlusButton = (ImageView) findViewById(R.id.kind_plus);
-
mTitle = (TextView)findViewById(R.id.kind_title);
}
@@ -109,7 +106,7 @@
mTitle.setText(kind.titleRes);
// Only show the add button if this is a list
- mAddPlusButton.setVisibility(mKind.isList ? View.VISIBLE : View.GONE);
+ mAddPlusButton.setVisibility(mKind.isList ? View.VISIBLE : View.INVISIBLE);
rebuildFromState();
updateAddEnabled();
@@ -150,7 +147,6 @@
}
}
- view.setPadding(0, 0, getThemeScrollbarSize(mContext), 0);
if (view instanceof Editor) {
Editor editor = (Editor) view;
editor.setValues(mKind, entry, mState, mReadOnly, mViewIdGenerator);
@@ -177,23 +173,6 @@
return true;
}
- /**
- * Reads the scrollbarSize of the current theme
- */
- private static int getThemeScrollbarSize(Context context) {
- if (sCachedThemePaddingRight == -1) {
- final TypedValue outValue = new TypedValue();
- context.getTheme().resolveAttribute(android.R.attr.scrollbarSize, outValue, true);
- final WindowManager windowManager =
- (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- final DisplayMetrics metrics = new DisplayMetrics();
- windowManager.getDefaultDisplay().getMetrics(metrics);
- sCachedThemePaddingRight = (int) TypedValue.complexToDimension(outValue.data, metrics);
- }
-
- return sCachedThemePaddingRight;
- }
-
private void updateVisible() {
setVisibility(getEditorCount() != 0 ? VISIBLE : GONE);
}
@@ -203,7 +182,7 @@
// Set enabled state on the "add" view
final boolean canInsert = EntityModifier.canInsert(mState, mKind);
final boolean isEnabled = !mReadOnly && canInsert;
- mAdd.setEnabled(isEnabled);
+ mAddPlusButton.setEnabled(isEnabled);
}
public void addItem() {