blob: d733e6886df03c86748e49d2c0f86ab9a626fd46 [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
Daniel Lehmannafeae642010-10-18 14:40:53 -070019import com.android.contacts.model.EntityDelta;
Dmitri Plotnikov4597c922010-11-15 13:03:06 -080020import com.android.contacts.model.AccountType.DataKind;
Jeff Sharkeyaad88482009-08-29 18:19:20 -070021import com.android.contacts.model.EntityDelta.ValuesDelta;
22
23import android.provider.ContactsContract.Data;
24
25/**
26 * Generic definition of something that edits a {@link Data} row through an
27 * {@link ValuesDelta} object.
28 */
29public 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 Sharkey6f8d46b2009-09-10 15:02:32 -070038
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 Parekh47673e82009-09-21 16:57:03 -070046 public static final int FIELD_CHANGED = 2;
Dmitri Plotnikov41f026d2010-08-19 12:05:59 -070047
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 Sharkeyaad88482009-08-29 18:19:20 -070051 }
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 Onuki4b722a92009-11-02 16:44:18 +090058 public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly,
59 ViewIdGenerator vig);
Jeff Sharkeyaad88482009-08-29 18:19:20 -070060
Dmitri Plotnikovd25f9582010-08-19 18:53:24 -070061 public void setDeletable(boolean deletable);
62
Jeff Sharkeyaad88482009-08-29 18:19:20 -070063 /**
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}