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 | |
Chiao Cheng | e0b2f1e | 2012-06-12 13:07:56 -0700 | [diff] [blame] | 19 | import android.provider.ContactsContract.Data; |
| 20 | |
Yorke Lee | cd321f6 | 2013-10-28 15:20:15 -0700 | [diff] [blame] | 21 | import com.android.contacts.common.model.RawContactDelta; |
Chiao Cheng | 738ff86 | 2012-11-30 12:06:03 -0800 | [diff] [blame] | 22 | import com.android.contacts.common.model.ValuesDelta; |
Chiao Cheng | 428f008 | 2012-11-13 18:38:56 -0800 | [diff] [blame] | 23 | import com.android.contacts.common.model.dataitem.DataKind; |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 24 | |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Generic definition of something that edits a {@link Data} row through an |
| 27 | * {@link ValuesDelta} object. |
| 28 | */ |
| 29 | public interface Editor { |
Katherine Kuan | 2591436 | 2011-04-29 19:42:01 -0700 | [diff] [blame] | 30 | |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 31 | public interface EditorListener { |
| 32 | /** |
Katherine Kuan | 2293e55 | 2011-07-21 20:25:44 -0700 | [diff] [blame] | 33 | * Called when the given {@link Editor} is requested to be deleted by the user. |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 34 | */ |
Katherine Kuan | 2293e55 | 2011-07-21 20:25:44 -0700 | [diff] [blame] | 35 | public void onDeleteRequested(Editor editor); |
Jeff Sharkey | 6f8d46b | 2009-09-10 15:02:32 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Called when the given {@link Editor} has a request, for example it |
| 39 | * wants to select a photo. |
| 40 | */ |
| 41 | public void onRequest(int request); |
| 42 | |
Brian Attwell | 7e67082 | 2014-11-07 16:36:30 -0800 | [diff] [blame] | 43 | public static final int REQUEST_PICK_PRIMARY_PHOTO = 0; |
Jeff Sharkey | 6f8d46b | 2009-09-10 15:02:32 -0700 | [diff] [blame] | 44 | public static final int REQUEST_PICK_PHOTO = 1; |
Neel Parekh | 47673e8 | 2009-09-21 16:57:03 -0700 | [diff] [blame] | 45 | public static final int FIELD_CHANGED = 2; |
Katherine Kuan | 2591436 | 2011-04-29 19:42:01 -0700 | [diff] [blame] | 46 | public static final int FIELD_TURNED_EMPTY = 3; |
| 47 | public static final int FIELD_TURNED_NON_EMPTY = 4; |
Dmitri Plotnikov | 41f026d | 2010-08-19 12:05:59 -0700 | [diff] [blame] | 48 | |
| 49 | // The editor has switched between different representations of the same |
| 50 | // data, e.g. from full name to structured name |
Katherine Kuan | 2591436 | 2011-04-29 19:42:01 -0700 | [diff] [blame] | 51 | public static final int EDITOR_FORM_CHANGED = 5; |
Brian Attwell | d690dff | 2014-12-02 15:04:56 -0800 | [diff] [blame] | 52 | |
| 53 | // Focus has changed inside the editor. |
| 54 | public static final int EDITOR_FOCUS_CHANGED = 6; |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | /** |
Katherine Kuan | 2591436 | 2011-04-29 19:42:01 -0700 | [diff] [blame] | 58 | * Returns whether or not all the fields are empty in this {@link Editor}. |
Katherine Kuan | 1b22073 | 2011-04-28 18:45:39 -0700 | [diff] [blame] | 59 | */ |
Katherine Kuan | 2591436 | 2011-04-29 19:42:01 -0700 | [diff] [blame] | 60 | public boolean isEmpty(); |
Katherine Kuan | 1b22073 | 2011-04-28 18:45:39 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Prepares this editor for the given {@link ValuesDelta}, which |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 64 | * builds any needed views. Any changes performed by the user will be |
| 65 | * written back to that same object. |
| 66 | */ |
Maurice Chu | 851222a | 2012-06-21 11:43:08 -0700 | [diff] [blame] | 67 | public void setValues(DataKind kind, ValuesDelta values, RawContactDelta state, boolean readOnly, |
Makoto Onuki | 4b722a9 | 2009-11-02 16:44:18 +0900 | [diff] [blame] | 68 | ViewIdGenerator vig); |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 69 | |
Dmitri Plotnikov | d25f958 | 2010-08-19 18:53:24 -0700 | [diff] [blame] | 70 | public void setDeletable(boolean deletable); |
| 71 | |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 72 | /** |
| 73 | * Add a specific {@link EditorListener} to this {@link Editor}. |
| 74 | */ |
| 75 | public void setEditorListener(EditorListener listener); |
| 76 | |
| 77 | /** |
| 78 | * Called internally when the contents of a specific field have changed, |
| 79 | * allowing advanced editors to persist data in a specific way. |
| 80 | */ |
| 81 | public void onFieldChanged(String column, String value); |
Katherine Kuan | 2293e55 | 2011-07-21 20:25:44 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
Walter Jang | 23a34d1 | 2015-07-08 09:41:05 -0700 | [diff] [blame] | 84 | * Marks the underlying ValuesDelta as deleted, but does not update the view. |
| 85 | */ |
| 86 | public void markDeleted(); |
| 87 | |
| 88 | /** |
| 89 | * Performs the delete operation for this {@link Editor}, which involves both |
| 90 | * marking the underlying ValuesDelta as deleted and updating the view. |
Katherine Kuan | 2293e55 | 2011-07-21 20:25:44 -0700 | [diff] [blame] | 91 | */ |
| 92 | public void deleteEditor(); |
| 93 | |
| 94 | /** |
| 95 | * Clears all fields in this {@link Editor}. |
| 96 | */ |
| 97 | public void clearAllFields(); |
Josh Gargus | 26918da | 2012-02-02 16:58:04 -0800 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * Called internally when the user has added a new field. This |
| 101 | * allows the appropriate editor UI to be presented immediately. |
| 102 | * For example, if a new "event" is added, a date-picker will |
| 103 | * immediately pop up. |
| 104 | */ |
| 105 | public void editNewlyAddedField(); |
| 106 | |
Jeff Sharkey | aad8848 | 2009-08-29 18:19:20 -0700 | [diff] [blame] | 107 | } |