Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 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 | |
Dmitri Plotnikov | 18ffaa2 | 2010-12-03 14:28:00 -0800 | [diff] [blame^] | 17 | package com.android.contacts.editor; |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 18 | |
Daniel Lehmann | afeae64 | 2010-10-18 14:40:53 -0700 | [diff] [blame] | 19 | import com.android.contacts.model.EntityDelta; |
Dmitri Plotnikov | 4597c92 | 2010-11-15 13:03:06 -0800 | [diff] [blame] | 20 | import com.android.contacts.model.AccountType.DataKind; |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 21 | import com.android.contacts.model.EntityDelta.ValuesDelta; |
| 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); |
Jeff Sharkey | 6f8d46b | 2009-09-10 15:02:32 -0700 | [diff] [blame] | 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; |
Neel Parekh | 47673e8 | 2009-09-21 16:57:03 -0700 | [diff] [blame] | 46 | public static final int FIELD_CHANGED = 2; |
Dmitri Plotnikov | 41f026d | 2010-08-19 12:05:59 -0700 | [diff] [blame] | 47 | |
| 48 | // The editor has switched between different representations of the same |
| 49 | // data, e.g. from full name to structured name |
| 50 | public static final int EDITOR_FORM_CHANGED = 3; |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Prepare this editor for the given {@link ValuesDelta}, which |
| 55 | * builds any needed views. Any changes performed by the user will be |
| 56 | * written back to that same object. |
| 57 | */ |
Makoto Onuki | 4b722a9 | 2009-11-02 16:44:18 +0900 | [diff] [blame] | 58 | public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly, |
| 59 | ViewIdGenerator vig); |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 60 | |
Dmitri Plotnikov | d25f958 | 2010-08-19 18:53:24 -0700 | [diff] [blame] | 61 | public void setDeletable(boolean deletable); |
| 62 | |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Add a specific {@link EditorListener} to this {@link Editor}. |
| 65 | */ |
| 66 | public void setEditorListener(EditorListener listener); |
| 67 | |
| 68 | /** |
| 69 | * Called internally when the contents of a specific field have changed, |
| 70 | * allowing advanced editors to persist data in a specific way. |
| 71 | */ |
| 72 | public void onFieldChanged(String column, String value); |
| 73 | } |