Merge "Breaking out contact deletion into a separate object."
diff --git a/res/layout/contact_detail_activity.xml b/res/layout/contact_detail_activity.xml
index 9b63fec..c13603f 100644
--- a/res/layout/contact_detail_activity.xml
+++ b/res/layout/contact_detail_activity.xml
@@ -14,14 +14,12 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.android.contacts.views.detail.ContactDetailFragment"
android:id="@+id/contact_detail_fragment"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
-</LinearLayout>
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</FrameLayout>
diff --git a/res/layout/contact_editor_activity.xml b/res/layout/contact_editor_activity.xml
index 3768f6a..a2cdead 100644
--- a/res/layout/contact_editor_activity.xml
+++ b/res/layout/contact_editor_activity.xml
@@ -14,14 +14,12 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.android.contacts.views.editor.ContactEditorFragment"
android:id="@+id/contact_editor_fragment"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
-</LinearLayout>
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</FrameLayout>
diff --git a/res/layout/contact_editor_fragment.xml b/res/layout/contact_editor_fragment.xml
index 6a360ac..602f7f9 100644
--- a/res/layout/contact_editor_fragment.xml
+++ b/res/layout/contact_editor_fragment.xml
@@ -14,16 +14,14 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
>
<ScrollView
android:layout_width="match_parent"
- android:layout_height="1px"
- android:layout_weight="1"
+ android:layout_height="match_parent"
android:fillViewport="true"
>
@@ -34,28 +32,4 @@
/>
</ScrollView>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- style="@android:style/ButtonBar"
- >
-
- <Button android:id="@+id/btn_done"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/menu_done"
- />
-
- <Button android:id="@+id/btn_discard"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/menu_doNotSave"
- />
-
- </LinearLayout>
-
-</LinearLayout>
+</FrameLayout>
diff --git a/res/layout/item_generic_editor.xml b/res/layout/item_generic_editor.xml
index 329ad28..e62612f 100644
--- a/res/layout/item_generic_editor.xml
+++ b/res/layout/item_generic_editor.xml
@@ -35,7 +35,7 @@
android:layout_alignParentRight="true"
style="@style/MinusButton" />
- <LinearLayout
+ <FrameLayout
android:id="@+id/edit_fields"
android:layout_width="0dip"
android:layout_height="wrap_content"
@@ -43,7 +43,6 @@
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@id/edit_label"
android:layout_toLeftOf="@id/edit_delete"
- android:orientation="vertical"
android:baselineAligned="false"
android:gravity="center_vertical" />
diff --git a/res/layout/two_pane_activity.xml b/res/layout/two_pane_activity.xml
index 407360b..dbac12f 100644
--- a/res/layout/two_pane_activity.xml
+++ b/res/layout/two_pane_activity.xml
@@ -35,7 +35,7 @@
android:layout_weight="1" />
<!-- Holder for detail- or editor-fragment. -->
- <LinearLayout
+ <FrameLayout
android:id="@+id/two_pane_right_view"
android:orientation="horizontal"
android:layout_width="0px"
diff --git a/src/com/android/contacts/DialtactsActivity.java b/src/com/android/contacts/DialtactsActivity.java
index 758a3b5..882a4fb 100644
--- a/src/com/android/contacts/DialtactsActivity.java
+++ b/src/com/android/contacts/DialtactsActivity.java
@@ -102,7 +102,7 @@
setCurrentTab(intent);
- if (intent.getAction().equals(UI.FILTER_CONTACTS_ACTION)
+ if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction())
&& icicle == null) {
setupFilterText(intent);
}
@@ -275,7 +275,7 @@
fixIntent(newIntent);
setCurrentTab(newIntent);
final String action = newIntent.getAction();
- if (action.equals(UI.FILTER_CONTACTS_ACTION)) {
+ if (UI.FILTER_CONTACTS_ACTION.equals(action)) {
setupFilterText(newIntent);
} else if (isDialIntent(newIntent)) {
setupDialUri(newIntent);
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
index 2bac145..4369160 100644
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorActivity.java
@@ -25,7 +25,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
-import android.view.MenuItem;
import android.widget.Toast;
public class ContactEditorActivity extends Activity {
@@ -59,14 +58,6 @@
}
@Override
- public boolean onContextItemSelected(MenuItem item) {
- // TODO: This is too hardwired.
- if (mFragment.onContextItemSelected(item)) return true;
-
- return super.onContextItemSelected(item);
- }
-
- @Override
public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
boolean globalSearch) {
if (globalSearch) {
diff --git a/src/com/android/contacts/ui/widget/GenericEditorView.java b/src/com/android/contacts/ui/widget/GenericEditorView.java
index 5c2f9b7..1a981a8 100644
--- a/src/com/android/contacts/ui/widget/GenericEditorView.java
+++ b/src/com/android/contacts/ui/widget/GenericEditorView.java
@@ -51,7 +51,9 @@
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.EditText;
+import android.widget.FrameLayout;
import android.widget.ImageButton;
+import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -78,7 +80,7 @@
| EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS;
protected TextView mLabel;
- protected ViewGroup mFields;
+ protected FrameLayout mFields;
protected View mDelete;
protected ImageButton mMoreOrLess;
@@ -86,6 +88,7 @@
protected ValuesDelta mEntry;
protected EntityDelta mState;
protected boolean mReadOnly;
+ private EditText[] mFieldEditTexts = null;
protected boolean mHideOptional = true;
@@ -113,7 +116,7 @@
mLabel = (TextView)findViewById(R.id.edit_label);
mLabel.setOnClickListener(this);
- mFields = (ViewGroup)findViewById(R.id.edit_fields);
+ mFields = (FrameLayout)findViewById(R.id.edit_fields);
mDelete = findViewById(R.id.edit_delete);
mDelete.setOnClickListener(this);
@@ -135,10 +138,12 @@
@Override
public void setEnabled(boolean enabled) {
mLabel.setEnabled(enabled);
- final int count = mFields.getChildCount();
- for (int pos = 0; pos < count; pos++) {
- final View v = mFields.getChildAt(pos);
- v.setEnabled(enabled);
+ if (mFields.getChildCount() == 0) return;
+
+ if (mFieldEditTexts != null) {
+ for (int index = 0; index < mFieldEditTexts.length; index++) {
+ mFieldEditTexts[index].setEnabled(enabled);
+ }
}
mMoreOrLess.setEnabled(enabled);
}
@@ -177,11 +182,12 @@
}
public boolean isAnyFieldFilledOut() {
- int childCount = mFields.getChildCount();
- for (int i = 0; i < childCount; i++) {
- EditText editorView = (EditText) mFields.getChildAt(i);
- if (!TextUtils.isEmpty(editorView.getText())) {
- return true;
+ if (mFieldEditTexts != null) {
+ for (int index = 0; index < mFieldEditTexts.length; index++) {
+ final EditText editText = mFieldEditTexts[index];
+ if (!TextUtils.isEmpty(editText.getText())) {
+ return true;
+ }
}
}
return false;
@@ -226,11 +232,27 @@
// Build out set of fields
mFields.removeAllViews();
boolean hidePossible = false;
- int n = 0;
- for (EditField field : kind.fieldList) {
+
+ // If there is one field, put it directly into the FrameLayout mFields. If there are
+ // several or 0, put them into a LinearLayout
+ final ViewGroup container;
+ if (kind.fieldList.size() == 1) {
+ container = mFields;
+ } else {
+ final LinearLayout linearLayout = new LinearLayout(mContext);
+ linearLayout.setOrientation(LinearLayout.VERTICAL);
+ linearLayout.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.WRAP_CONTENT));
+ mFields.addView(linearLayout);
+ container = linearLayout;
+ }
+ mFieldEditTexts = new EditText[kind.fieldList.size()];
+ for (int index = 0; index < kind.fieldList.size(); index++) {
+ final EditField field = kind.fieldList.get(index);
// Inflate field from definition
- EditText fieldView = (EditText)mInflater.inflate(RES_FIELD, mFields, false);
- fieldView.setId(vig.getId(state, kind, entry, n++));
+ EditText fieldView = (EditText)mInflater.inflate(RES_FIELD, container, false);
+ mFieldEditTexts[index] = fieldView;
+ fieldView.setId(vig.getId(state, kind, entry, index));
if (field.titleRes > 0) {
fieldView.setHint(field.titleRes);
}
@@ -267,7 +289,7 @@
fieldView.setEnabled(enabled);
hidePossible = hidePossible || couldHide;
- mFields.addView(fieldView);
+ container.addView(fieldView);
}
// When hiding fields, place expandable
diff --git a/src/com/android/contacts/views/detail/ContactDetailFragment.java b/src/com/android/contacts/views/detail/ContactDetailFragment.java
index a35285f..cb6eba6 100644
--- a/src/com/android/contacts/views/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/views/detail/ContactDetailFragment.java
@@ -796,10 +796,12 @@
}
}
+ @Override
public void onCreateOptionsMenu(Menu menu, final MenuInflater inflater) {
inflater.inflate(R.menu.view, menu);
}
+ @Override
public void onPrepareOptionsMenu(Menu menu) {
// Only allow edit when we have at least one raw_contact id
final boolean hasRawContact = (mRawContactIds.size() > 0);
diff --git a/src/com/android/contacts/views/editor/ContactEditorFragment.java b/src/com/android/contacts/views/editor/ContactEditorFragment.java
index 5b281fc..d6baa9c 100644
--- a/src/com/android/contacts/views/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/views/editor/ContactEditorFragment.java
@@ -77,7 +77,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
@@ -164,16 +163,7 @@
mContent = (LinearLayout) view.findViewById(R.id.editors);
- view.findViewById(R.id.btn_done).setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- doSaveAction(SAVE_MODE_DEFAULT);
- }
- });
- view.findViewById(R.id.btn_discard).setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- doRevertAction();
- }
- });
+ setHasOptionsMenu(true);
return view;
}