LabeledEditorView.java revision 79c9c5a8f849908d2b141c30af15923ea2b60f5b
1392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann/* 2392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Copyright (C) 2010 The Android Open Source Project 3392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * 4392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Licensed under the Apache License, Version 2.0 (the "License"); 5392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * you may not use this file except in compliance with the License. 6392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * You may obtain a copy of the License at 7392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * 8392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * http://www.apache.org/licenses/LICENSE-2.0 9392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * 10392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Unless required by applicable law or agreed to in writing, software 11392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * distributed under the License is distributed on an "AS IS" BASIS, 12392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * See the License for the specific language governing permissions and 14392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * limitations under the License. 15392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 16392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 17392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannpackage com.android.contacts.views.editor; 18392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 19392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.ContactsUtils; 20392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.R; 21392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.model.BaseAccountType.DataKind; 22392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.model.BaseAccountType.EditType; 23392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.model.EntityDelta; 24392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.model.EntityDelta.ValuesDelta; 25392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.model.EntityModifier; 26392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.util.DialogManager; 2779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannimport com.android.contacts.util.ThemeUtils; 28392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport com.android.contacts.util.DialogManager.DialogShowingView; 29392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 30392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.app.AlertDialog; 31392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.app.Dialog; 32392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.content.Context; 33392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.content.DialogInterface; 34392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.content.Entity; 35392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.content.res.Resources; 36392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.os.Bundle; 3779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmannimport android.os.Handler; 38392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.util.AttributeSet; 39cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmannimport android.view.Gravity; 40392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.view.Menu; 41392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.view.MenuItem; 42392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.view.View; 43392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.view.ViewGroup; 44392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.view.inputmethod.EditorInfo; 45392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.widget.Button; 46392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.widget.EditText; 47392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.widget.ImageButton; 48392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport android.widget.PopupMenu; 49392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 50392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannimport java.util.List; 51392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 52392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann/** 53392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Base class for editors that handles labels and values. 54392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Uses {@link ValuesDelta} to read any existing 55392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * {@link Entity} values, and to correctly write any changes values. 56392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 57392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmannpublic abstract class LabeledEditorView extends ViewGroup implements Editor, DialogShowingView { 58392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected static final String DIALOG_ID_KEY = "dialog_id"; 59392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private static final int DIALOG_ID_CUSTOM = 1; 60392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 61392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private static final int INPUT_TYPE_CUSTOM = EditorInfo.TYPE_CLASS_TEXT 62392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann | EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS; 63392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 64392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private Button mLabel; 65392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private ImageButton mDelete; 66392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 67392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private DataKind mKind; 68392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private ValuesDelta mEntry; 69392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private EntityDelta mState; 70392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private boolean mReadOnly; 71392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 72392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private EditType mType; 73392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Used only when a user tries to use custom label. 74392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private EditType mPendingType; 75392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 76392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private ViewIdGenerator mViewIdGenerator; 77392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private DialogManager mDialogManager = null; 78392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private EditorListener mListener; 79392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 80392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public LabeledEditorView(Context context) { 81392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann super(context); 82392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 83392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 84392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public LabeledEditorView(Context context, AttributeSet attrs) { 85392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann super(context, attrs); 86392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 87392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 88392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public LabeledEditorView(Context context, AttributeSet attrs, int defStyle) { 89392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann super(context, attrs, defStyle); 90392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 91392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 92392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 93392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected void onLayout(boolean changed, int l, int t, int r, int b) { 94392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Subtract padding from the borders ==> x1 variables 95392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann int t1 = getPaddingTop(); 96392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann int r1 = getMeasuredWidth() - getPaddingRight(); 97392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann int b1 = getMeasuredHeight() - getPaddingBottom(); 98392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 99cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann final int r2; 100cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann if (mDelete != null) { 101cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann r2 = r1 - mDelete.getMeasuredWidth(); 102cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann mDelete.layout( 103cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann r2, b1 - mDelete.getMeasuredHeight(), 104cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann r1, b1); 105cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann } else { 106cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann r2 = r1; 107cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann } 108392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 109cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann if (mLabel != null) { 110392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel.layout( 111cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann r2 - mLabel.getMeasuredWidth(), t1, 112cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann r2, t1 + mLabel.getMeasuredHeight()); 113392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 114392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 115392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 116392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 117392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 118392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 119392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann measureChildren(widthMeasureSpec, heightMeasureSpec); 120392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 121392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final int padding = getPaddingTop() + getPaddingBottom(); 122392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final int deleteHeight = mDelete != null ? mDelete.getMeasuredHeight() : 0; 123392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final int labelHeight = mLabel != null ? mLabel.getMeasuredHeight() : 0; 124392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 125392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final int height = padding + 126392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann Math.max(Math.max(deleteHeight, labelHeight), getEditorHeight()); 127392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 128392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), 129392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann resolveSize(height, heightMeasureSpec)); 130392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 131392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 132392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected abstract int getEditorHeight(); 133392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 134392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 135392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Creates or removes the type/label button. Doesn't do anything if already correctly configured 136392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 137392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private void setupLabelButton(boolean shouldExist) { 138392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (shouldExist && mLabel == null) { 139f7ce5978a6a6314028fe9bbb1da99338b111750fDaniel Lehmann mLabel = new Button(mContext, null, android.R.attr.dropDownSpinnerStyle); 140392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final int width = 141392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mContext.getResources().getDimensionPixelSize(R.dimen.editor_type_label_width); 142392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel.setLayoutParams(new LayoutParams(width, LayoutParams.WRAP_CONTENT)); 143cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann mLabel.setGravity(Gravity.RIGHT); 144cfb525b3f18d71d6cc5d4ef36d704b3ba9e9a6f3Daniel Lehmann mLabel.setTextColor(getResources().getColor(R.color.editor_label_text_color)); 145392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel.setOnClickListener(new OnClickListener() { 146392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 147392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void onClick(View v) { 148392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann showLabelPopupMenu(); 149392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 150392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann }); 151392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann addView(mLabel); 152392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } else if (!shouldExist && mLabel != null) { 153392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann removeView(mLabel); 154392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel = null; 155392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 156392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 157392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 158392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 159392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Creates or removes the remove button. Doesn't do anything if already correctly configured 160392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 161392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private void setupDeleteButton(boolean shouldExist) { 162392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (shouldExist && mDelete == null) { 163392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDelete = new ImageButton(mContext); 164915ffc5ae1d10a7ed06d5541fe81da023fa3228fDaniel Lehmann mDelete.setImageResource(R.drawable.ic_menu_remove_field_holo_light); 16579c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann mDelete.setBackgroundResource( 16679c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann ThemeUtils.getSelectableItemBackground(mContext.getTheme())); 167392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final Resources resources = mContext.getResources(); 168392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDelete.setPadding( 169392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann resources.getDimensionPixelOffset(R.dimen.editor_round_button_padding_left), 170392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann resources.getDimensionPixelOffset(R.dimen.editor_round_button_padding_top), 171392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann resources.getDimensionPixelOffset(R.dimen.editor_round_button_padding_right), 172392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann resources.getDimensionPixelOffset(R.dimen.editor_round_button_padding_bottom)); 173392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDelete.setContentDescription( 174392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann getResources().getText(R.string.description_minus_button)); 175392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDelete.setLayoutParams( 176392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 177392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDelete.setOnClickListener(new OnClickListener() { 178392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 179392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void onClick(View v) { 18079c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann // defer removal of this button so that the pressed state is visible shortly 18179c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann new Handler().post(new Runnable() { 18279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann @Override 18379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann public void run() { 18479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann // Keep around in model, but mark as deleted 18579c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann mEntry.markDeleted(); 18679c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 18779c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann ((ViewGroup) getParent()).removeView(LabeledEditorView.this); 18879c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann 18979c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann if (mListener != null) { 19079c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann // Notify listener when present 19179c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann mListener.onDeleted(LabeledEditorView.this); 19279c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann } 19379c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann } 19479c9c5a8f849908d2b141c30af15923ea2b60f5bDaniel Lehmann }); 195392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 196392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann }); 197392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann addView(mDelete); 198392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } else if (!shouldExist && mDelete != null) { 199392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann removeView(mDelete); 200392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDelete = null; 201392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 202392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 203392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 204392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected void onOptionalFieldVisibilityChange() { 205392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mListener != null) { 206392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mListener.onRequest(EditorListener.EDITOR_FORM_CHANGED); 207392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 208392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 209392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 210392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 211392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void setEditorListener(EditorListener listener) { 212392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mListener = listener; 213392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 214392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 215392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 216392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void setDeletable(boolean deletable) { 217392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setupDeleteButton(deletable); 218392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 219392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 220392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 221392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void setEnabled(boolean enabled) { 222392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mLabel != null) mLabel.setEnabled(enabled); 223392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 224392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mDelete != null) mDelete.setEnabled(enabled); 225392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 226392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 227392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public Button getLabel() { 228392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mLabel; 229392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 230392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 231392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public ImageButton getDelete() { 232392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mDelete; 233392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 234392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 235392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected DataKind getKind() { 236392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mKind; 237392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 238392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 239392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected ValuesDelta getEntry() { 240392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mEntry; 241392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 242392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 243392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected EditType getType() { 244392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mType; 245392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 246392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 247392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 248392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Build the current label state based on selected {@link EditType} and 249392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * possible custom label string. 250392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 251392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private void rebuildLabel() { 252392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mLabel == null) return; 253392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Handle undetected types 254392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mType == null) { 255392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel.setText(R.string.unknown); 256392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return; 257392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 258392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 259392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mType.customColumn != null) { 260392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Use custom label string when present 261392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final String customText = mEntry.getAsString(mType.customColumn); 262392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (customText != null) { 263392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel.setText(customText); 264392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return; 265392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 266392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 267392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 268392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Otherwise fall back to using default label 269392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mLabel.setText(mType.labelRes); 270392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 271392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 272392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** {@inheritDoc} */ 273392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 274392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void onFieldChanged(String column, String value) { 275392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Field changes are saved directly 276392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mEntry.put(column, value); 277392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mListener != null) { 278392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mListener.onRequest(EditorListener.FIELD_CHANGED); 279392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 280392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 281392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 282392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected void rebuildValues() { 283392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setValues(mKind, mEntry, mState, mReadOnly, mViewIdGenerator); 284392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 285392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 286392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 287392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Prepare this editor using the given {@link DataKind} for defining 288392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * structure and {@link ValuesDelta} describing the content to edit. 289392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 290392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 291392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void setValues(DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly, 292392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann ViewIdGenerator vig) { 293392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mKind = kind; 294392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mEntry = entry; 295392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mState = state; 296392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mReadOnly = readOnly; 297392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mViewIdGenerator = vig; 298392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setId(vig.getId(state, kind, entry, ViewIdGenerator.NO_VIEW_INDEX)); 299392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 300392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (!entry.isVisible()) { 301392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Hide ourselves entirely if deleted 302392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setVisibility(View.GONE); 303392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return; 304392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 305392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setVisibility(View.VISIBLE); 306392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 307392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Display label selector if multiple types available 308392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final boolean hasTypes = EntityModifier.hasEditTypes(kind); 309392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann setupLabelButton(hasTypes); 310392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mLabel != null) mLabel.setEnabled(!readOnly); 311392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (hasTypes) { 312392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mType = EntityModifier.getCurrentType(entry, kind); 313392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann rebuildLabel(); 314392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 315392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 316392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 317392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public ValuesDelta getValues() { 318392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mEntry; 319392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 320392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 321392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 322392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Prepare dialog for entering a custom label. The input value is trimmed: white spaces before 323392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * and after the input text is removed. 324392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * <p> 325392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * If the final value is empty, this change request is ignored; 326392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * no empty text is allowed in any custom label. 327392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 328392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private Dialog createCustomDialog() { 329392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final EditText customType = new EditText(mContext); 330392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann customType.setInputType(INPUT_TYPE_CUSTOM); 331392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann customType.requestFocus(); 332392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 333392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 334392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann builder.setTitle(R.string.customLabelPickerTitle); 335392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann builder.setView(customType); 336392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 337392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 338392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 339392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void onClick(DialogInterface dialog, int which) { 340392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final String customText = customType.getText().toString().trim(); 341392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (ContactsUtils.isGraphic(customText)) { 342392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Now we're sure it's ok to actually change the type value. 343392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mType = mPendingType; 344392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mPendingType = null; 345392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mEntry.put(mKind.typeColumn, mType.rawValue); 346392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mEntry.put(mType.customColumn, customText); 347392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann rebuildLabel(); 348392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann requestFocusForFirstEditField(); 349392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann onLabelRebuilt(); 350392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 351392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 352392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann }); 353392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 354392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann builder.setNegativeButton(android.R.string.cancel, null); 355392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 356392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return builder.create(); 357392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 358392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 359392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 360392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Called after the label has changed (either chosen from the list or entered in the Dialog) 361392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 362392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected void onLabelRebuilt() { 363392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 364392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 365392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /** 366392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * Show PopupMenu for picking a new {@link EditType} or entering a 367392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * custom label. This dialog is limited to the valid types as determined 368392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann * by {@link EntityModifier}. 369392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann */ 370392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public void showLabelPopupMenu() { 371392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Build list of valid types, including the current value 372392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final List<EditType> validTypes = EntityModifier.getValidTypes(mState, mKind, mType); 373392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 374392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final PopupMenu popupMenu = new PopupMenu(getContext(), mLabel); 375392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final Menu menu = popupMenu.getMenu(); 376392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 377392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann for (int i = 0; i < validTypes.size(); i++) { 378392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final EditType type = validTypes.get(i); 379392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann menu.add(Menu.NONE, i, Menu.NONE, type.labelRes); 380392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 381392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 382392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 383392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 384392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public boolean onMenuItemClick(MenuItem item) { 385392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann final EditType selected = validTypes.get(item.getItemId()); 386392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (selected.customColumn != null) { 387392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Show custom label dialog if requested by type. 388392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // 389392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // Only when the custum value input in the next step is correct one. 390392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // this method also set the type value to what the user requested here. 391392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mPendingType = selected; 392392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann showDialog(DIALOG_ID_CUSTOM); 393392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } else { 394392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann // User picked type, and we're sure it's ok to actually write the entry. 395392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mType = selected; 396392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mEntry.put(mKind.typeColumn, mType.rawValue); 397392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann rebuildLabel(); 398392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann requestFocusForFirstEditField(); 399392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann onLabelRebuilt(); 400392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 401392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return true; 402392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 403392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann }); 404392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 405392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann popupMenu.show(); 406392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 407392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 408392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann /* package */ 409392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann void showDialog(int bundleDialogId) { 410392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann Bundle bundle = new Bundle(); 411392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann bundle.putInt(DIALOG_ID_KEY, bundleDialogId); 412392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann getDialogManager().showDialogInView(this, bundle); 413392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 414392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 415392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann private DialogManager getDialogManager() { 416392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (mDialogManager == null) { 417392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann Context context = getContext(); 418392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (!(context instanceof DialogManager.DialogShowingViewActivity)) { 419392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann throw new IllegalStateException( 420392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann "View must be hosted in an Activity that implements " + 421392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann "DialogManager.DialogShowingViewActivity"); 422392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 423392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann mDialogManager = ((DialogManager.DialogShowingViewActivity)context).getDialogManager(); 424392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 425392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return mDialogManager; 426392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 427392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 428392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann @Override 429392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann public Dialog createDialog(Bundle bundle) { 430392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann if (bundle == null) throw new IllegalArgumentException("bundle must not be null"); 431392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann int dialogId = bundle.getInt(DIALOG_ID_KEY); 432392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann switch (dialogId) { 433392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann case DIALOG_ID_CUSTOM: 434392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann return createCustomDialog(); 435392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann default: 436392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann throw new IllegalArgumentException("Invalid dialogId: " + dialogId); 437392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 438392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann } 439392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann 440392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann protected abstract void requestFocusForFirstEditField(); 441392ccec3b56e8074a5a028af28106134b39f64bcDaniel Lehmann} 442