Home | History | Annotate | Download | only in editor
      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 
     17 package com.android.contacts.editor;
     18 
     19 import android.provider.ContactsContract.Data;
     20 
     21 import com.android.contacts.common.model.RawContactDelta;
     22 import com.android.contacts.common.model.ValuesDelta;
     23 import com.android.contacts.common.model.dataitem.DataKind;
     24 
     25 /**
     26  * Generic definition of something that edits a {@link Data} row through an
     27  * {@link ValuesDelta} object.
     28  */
     29 public interface Editor {
     30 
     31     public interface EditorListener {
     32         /**
     33          * Called when the given {@link Editor} is requested to be deleted by the user.
     34          */
     35         public void onDeleteRequested(Editor editor);
     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 
     43         public static final int REQUEST_PICK_PHOTO = 1;
     44         public static final int FIELD_CHANGED = 2;
     45         public static final int FIELD_TURNED_EMPTY = 3;
     46         public static final int FIELD_TURNED_NON_EMPTY = 4;
     47 
     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 = 5;
     51     }
     52 
     53     /**
     54      * Returns whether or not all the fields are empty in this {@link Editor}.
     55      */
     56     public boolean isEmpty();
     57 
     58     /**
     59      * Prepares this editor for the given {@link ValuesDelta}, which
     60      * builds any needed views. Any changes performed by the user will be
     61      * written back to that same object.
     62      */
     63     public void setValues(DataKind kind, ValuesDelta values, RawContactDelta state, boolean readOnly,
     64             ViewIdGenerator vig);
     65 
     66     public void setDeletable(boolean deletable);
     67 
     68     /**
     69      * Add a specific {@link EditorListener} to this {@link Editor}.
     70      */
     71     public void setEditorListener(EditorListener listener);
     72 
     73     /**
     74      * Called internally when the contents of a specific field have changed,
     75      * allowing advanced editors to persist data in a specific way.
     76      */
     77     public void onFieldChanged(String column, String value);
     78 
     79     /**
     80      * Performs the delete operation for this {@link Editor}.
     81      */
     82     public void deleteEditor();
     83 
     84     /**
     85      * Clears all fields in this {@link Editor}.
     86      */
     87     public void clearAllFields();
     88 
     89     /**
     90      * Called internally when the user has added a new field.  This
     91      * allows the appropriate editor UI to be presented immediately.
     92      * For example, if a new "event" is added, a date-picker will
     93      * immediately pop up.
     94      */
     95     public void editNewlyAddedField();
     96 
     97 }
     98