1aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey/*
2aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * Copyright (C) 2009 The Android Open Source Project
3aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey *
4aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License");
5aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * you may not use this file except in compliance with the License.
6aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * You may obtain a copy of the License at
7aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey *
8aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey *      http://www.apache.org/licenses/LICENSE-2.0
9aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey *
10aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * Unless required by applicable law or agreed to in writing, software
11aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS,
12aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * See the License for the specific language governing permissions and
14aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * limitations under the License.
15aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey */
16aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
1718ffaa2561cc7dd2e3ef81737e6537931c0a9a11Dmitri Plotnikovpackage com.android.contacts.editor;
18aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
19405671a7b42d97ebf7ae7c0eeb4721f881139673Daisuke Miyakawaimport com.android.contacts.model.DataKind;
20afeae64e9a9bb39c918202a5775c4904e2f0d92eDaniel Lehmannimport com.android.contacts.model.EntityDelta;
21aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkeyimport com.android.contacts.model.EntityDelta.ValuesDelta;
22aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
23aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkeyimport android.provider.ContactsContract.Data;
24aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
25aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey/**
26aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * Generic definition of something that edits a {@link Data} row through an
27aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey * {@link ValuesDelta} object.
28aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey */
29aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkeypublic interface Editor {
302591436971bad3050c85929c8e0c5a8d48111f88Katherine Kuan
31aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    public interface EditorListener {
32aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey        /**
332293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan         * Called when the given {@link Editor} is requested to be deleted by the user.
34aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey         */
352293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan        public void onDeleteRequested(Editor editor);
366f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey
376f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey        /**
386f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey         * Called when the given {@link Editor} has a request, for example it
396f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey         * wants to select a photo.
406f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey         */
416f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey        public void onRequest(int request);
426f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey
436f8d46b5fb96c2bead1317aae93a73fc89b093abJeff Sharkey        public static final int REQUEST_PICK_PHOTO = 1;
4447673e82f210e3b2d38d49652726b51770e71230Neel Parekh        public static final int FIELD_CHANGED = 2;
452591436971bad3050c85929c8e0c5a8d48111f88Katherine Kuan        public static final int FIELD_TURNED_EMPTY = 3;
462591436971bad3050c85929c8e0c5a8d48111f88Katherine Kuan        public static final int FIELD_TURNED_NON_EMPTY = 4;
4741f026d52e0277e21236787b10f76129a8bc6fa4Dmitri Plotnikov
4841f026d52e0277e21236787b10f76129a8bc6fa4Dmitri Plotnikov        // The editor has switched between different representations of the same
4941f026d52e0277e21236787b10f76129a8bc6fa4Dmitri Plotnikov        // data, e.g. from full name to structured name
502591436971bad3050c85929c8e0c5a8d48111f88Katherine Kuan        public static final int EDITOR_FORM_CHANGED = 5;
51aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    }
52aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
53aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    /**
542591436971bad3050c85929c8e0c5a8d48111f88Katherine Kuan     * Returns whether or not all the fields are empty in this {@link Editor}.
551b22073590c1801c3e6c7bde2f4636632a049f6cKatherine Kuan     */
562591436971bad3050c85929c8e0c5a8d48111f88Katherine Kuan    public boolean isEmpty();
571b22073590c1801c3e6c7bde2f4636632a049f6cKatherine Kuan
581b22073590c1801c3e6c7bde2f4636632a049f6cKatherine Kuan    /**
591b22073590c1801c3e6c7bde2f4636632a049f6cKatherine Kuan     * Prepares this editor for the given {@link ValuesDelta}, which
60aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     * builds any needed views. Any changes performed by the user will be
61aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     * written back to that same object.
62aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     */
634b722a93f1ecdeb2890fb7e5db4c22794bccfdcdMakoto Onuki    public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly,
644b722a93f1ecdeb2890fb7e5db4c22794bccfdcdMakoto Onuki            ViewIdGenerator vig);
65aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
66d25f958595b190586bd838d50718b1a2a3f0d417Dmitri Plotnikov    public void setDeletable(boolean deletable);
67d25f958595b190586bd838d50718b1a2a3f0d417Dmitri Plotnikov
68aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    /**
69aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     * Add a specific {@link EditorListener} to this {@link Editor}.
70aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     */
71aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    public void setEditorListener(EditorListener listener);
72aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey
73aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    /**
74aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     * Called internally when the contents of a specific field have changed,
75aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     * allowing advanced editors to persist data in a specific way.
76aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey     */
77aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey    public void onFieldChanged(String column, String value);
782293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan
792293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan    /**
802293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan     * Performs the delete operation for this {@link Editor}.
812293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan     */
822293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan    public void deleteEditor();
832293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan
842293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan    /**
852293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan     * Clears all fields in this {@link Editor}.
862293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan     */
872293e55d550fbc9974d1185960715e59acb14a85Katherine Kuan    public void clearAllFields();
88aad8848282f51d73ad308e9ad3ebcef592fa153fJeff Sharkey}
89