blob: 711fbc057ee9d79ec7fc6a7d2bb7a6fb05ba8184 [file] [log] [blame]
Jeff Sharkeyaad88482009-08-29 18:19:20 -07001/*
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 Plotnikov18ffaa22010-12-03 14:28:00 -080017package com.android.contacts.editor;
Jeff Sharkeyaad88482009-08-29 18:19:20 -070018
Chiao Chenge0b2f1e2012-06-12 13:07:56 -070019import android.provider.ContactsContract.Data;
20
Gary Mai69c182a2016-12-05 13:07:03 -080021import com.android.contacts.model.RawContactDelta;
22import com.android.contacts.model.ValuesDelta;
23import com.android.contacts.model.dataitem.DataKind;
Jeff Sharkeyaad88482009-08-29 18:19:20 -070024
Jeff Sharkeyaad88482009-08-29 18:19:20 -070025/**
26 * Generic definition of something that edits a {@link Data} row through an
27 * {@link ValuesDelta} object.
28 */
29public interface Editor {
Katherine Kuan25914362011-04-29 19:42:01 -070030
Jeff Sharkeyaad88482009-08-29 18:19:20 -070031 public interface EditorListener {
32 /**
Katherine Kuan2293e552011-07-21 20:25:44 -070033 * Called when the given {@link Editor} is requested to be deleted by the user.
Jeff Sharkeyaad88482009-08-29 18:19:20 -070034 */
Katherine Kuan2293e552011-07-21 20:25:44 -070035 public void onDeleteRequested(Editor editor);
Jeff Sharkey6f8d46b2009-09-10 15:02:32 -070036
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 Attwell7e670822014-11-07 16:36:30 -080043 public static final int REQUEST_PICK_PRIMARY_PHOTO = 0;
Jeff Sharkey6f8d46b2009-09-10 15:02:32 -070044 public static final int REQUEST_PICK_PHOTO = 1;
Neel Parekh47673e82009-09-21 16:57:03 -070045 public static final int FIELD_CHANGED = 2;
Katherine Kuan25914362011-04-29 19:42:01 -070046 public static final int FIELD_TURNED_EMPTY = 3;
47 public static final int FIELD_TURNED_NON_EMPTY = 4;
Dmitri Plotnikov41f026d2010-08-19 12:05:59 -070048
49 // The editor has switched between different representations of the same
50 // data, e.g. from full name to structured name
Katherine Kuan25914362011-04-29 19:42:01 -070051 public static final int EDITOR_FORM_CHANGED = 5;
Brian Attwelld690dff2014-12-02 15:04:56 -080052
53 // Focus has changed inside the editor.
54 public static final int EDITOR_FOCUS_CHANGED = 6;
Jeff Sharkeyaad88482009-08-29 18:19:20 -070055 }
56
57 /**
Katherine Kuan25914362011-04-29 19:42:01 -070058 * Returns whether or not all the fields are empty in this {@link Editor}.
Katherine Kuan1b220732011-04-28 18:45:39 -070059 */
Katherine Kuan25914362011-04-29 19:42:01 -070060 public boolean isEmpty();
Katherine Kuan1b220732011-04-28 18:45:39 -070061
62 /**
63 * Prepares this editor for the given {@link ValuesDelta}, which
Jeff Sharkeyaad88482009-08-29 18:19:20 -070064 * builds any needed views. Any changes performed by the user will be
65 * written back to that same object.
66 */
Maurice Chu851222a2012-06-21 11:43:08 -070067 public void setValues(DataKind kind, ValuesDelta values, RawContactDelta state, boolean readOnly,
Makoto Onuki4b722a92009-11-02 16:44:18 +090068 ViewIdGenerator vig);
Jeff Sharkeyaad88482009-08-29 18:19:20 -070069
Dmitri Plotnikovd25f9582010-08-19 18:53:24 -070070 public void setDeletable(boolean deletable);
71
Jeff Sharkeyaad88482009-08-29 18:19:20 -070072 /**
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 Kuan2293e552011-07-21 20:25:44 -070082
83 /**
Walter Jang23a34d12015-07-08 09:41:05 -070084 * 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 Kuan2293e552011-07-21 20:25:44 -070091 */
92 public void deleteEditor();
93
94 /**
95 * Clears all fields in this {@link Editor}.
96 */
97 public void clearAllFields();
Josh Gargus26918da2012-02-02 16:58:04 -080098
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 Sharkeyaad88482009-08-29 18:19:20 -0700107}