Editor.java revision 405671a7b42d97ebf7ae7c0eeb4721f881139673
1b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o/*
2b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * Copyright (C) 2009 The Android Open Source Project
3b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o *
4b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * Licensed under the Apache License, Version 2.0 (the "License");
5b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * you may not use this file except in compliance with the License.
6b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * You may obtain a copy of the License at
7b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o *
8b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o *      http://www.apache.org/licenses/LICENSE-2.0
9b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o *
10b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * Unless required by applicable law or agreed to in writing, software
11b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * distributed under the License is distributed on an "AS IS" BASIS,
12b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * See the License for the specific language governing permissions and
14b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * limitations under the License.
15b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o */
16b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
17b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'opackage com.android.contacts.editor;
18b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
19b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'oimport com.android.contacts.model.DataKind;
20b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'oimport com.android.contacts.model.EntityDelta;
21b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'oimport com.android.contacts.model.EntityDelta.ValuesDelta;
22b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
23b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'oimport android.provider.ContactsContract.Data;
24b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
25b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o/**
26b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * Generic definition of something that edits a {@link Data} row through an
27b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o * {@link ValuesDelta} object.
28b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o */
29b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'opublic interface Editor {
30b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o    /**
31b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o     * Listener for an {@link Editor}, usually to handle deleted items.
32b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o     */
33b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o    public interface EditorListener {
34b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        /**
35b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o         * Called when the given {@link Editor} has been deleted.
36b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o         */
37b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        public void onDeleted(Editor editor);
38b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
39b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        /**
40b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o         * Called when the given {@link Editor} has a request, for example it
41b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o         * wants to select a photo.
42b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o         */
43b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        public void onRequest(int request);
44b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
45b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        public static final int REQUEST_PICK_PHOTO = 1;
46b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        public static final int FIELD_CHANGED = 2;
47b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
48b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        // The editor has switched between different representations of the same
49b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        // data, e.g. from full name to structured name
50b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o        public static final int EDITOR_FORM_CHANGED = 3;
51b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o    }
52b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
53b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o    /**
54b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o     * Prepare this editor for the given {@link ValuesDelta}, which
55b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o     * builds any needed views. Any changes performed by the user will be
56b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o     * written back to that same object.
57b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o     */
58b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o    public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly,
59b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o            ViewIdGenerator vig);
60b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o
61b0cacab066000b940551d59aad3e4553d4bad268Theodore Ts'o    public void setDeletable(boolean deletable);
62
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}
74