1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.contacts.model; 18 19 import com.android.contacts.model.ContactsSource.DataKind; 20 import com.android.contacts.model.EntityDelta.ValuesDelta; 21 import com.android.contacts.ui.ViewIdGenerator; 22 23 import android.provider.ContactsContract.Data; 24 25 /** 26 * Generic definition of something that edits a {@link Data} row through an 27 * {@link ValuesDelta} object. 28 */ 29 public interface Editor { 30 /** 31 * Listener for an {@link Editor}, usually to handle deleted items. 32 */ 33 public interface EditorListener { 34 /** 35 * Called when the given {@link Editor} has been deleted. 36 */ 37 public void onDeleted(Editor editor); 38 39 /** 40 * Called when the given {@link Editor} has a request, for example it 41 * wants to select a photo. 42 */ 43 public void onRequest(int request); 44 45 public static final int REQUEST_PICK_PHOTO = 1; 46 public static final int FIELD_CHANGED = 2; 47 } 48 49 /** 50 * Prepare this editor for the given {@link ValuesDelta}, which 51 * builds any needed views. Any changes performed by the user will be 52 * written back to that same object. 53 */ 54 public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly, 55 ViewIdGenerator vig); 56 57 /** 58 * Add a specific {@link EditorListener} to this {@link Editor}. 59 */ 60 public void setEditorListener(EditorListener listener); 61 62 /** 63 * Called internally when the contents of a specific field have changed, 64 * allowing advanced editors to persist data in a specific way. 65 */ 66 public void onFieldChanged(String column, String value); 67 } 68