/* Copyright © 2013-2014, Silent Circle, LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Any redistribution, use, or modification is done solely for personal benefit and not for any commercial purpose or for monetary gain * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name Silent Circle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SILENT CIRCLE, LLC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * This implementation is edited version of original Android sources. */ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.silentcircle.contacts.editor; import com.silentcircle.contacts.model.RawContactDelta; import com.silentcircle.contacts.model.dataitem.DataKind; /** * Generic definition of something that edits a {@link Data} row through an * {@link com.silentcircle.contacts.model.RawContactDelta.ValuesDelta} object. */ public interface Editor { public interface EditorListener { /** * Called when the given {@link Editor} is requested to be deleted by the user. */ public void onDeleteRequested(Editor editor); /** * Called when the given {@link Editor} has a request, for example it * wants to select a photo. */ public void onRequest(int request); public static final int REQUEST_PICK_PHOTO = 1; public static final int FIELD_CHANGED = 2; public static final int FIELD_TURNED_EMPTY = 3; public static final int FIELD_TURNED_NON_EMPTY = 4; // The editor has switched between different representations of the same // data, e.g. from full name to structured name public static final int EDITOR_FORM_CHANGED = 5; } /** * Returns whether or not all the fields are empty in this {@link Editor}. */ public boolean isEmpty(); /** * Prepares this editor for the given {@link com.silentcircle.contacts.model.RawContactDelta.ValuesDelta}, which * builds any needed views. Any changes performed by the user will be * written back to that same object. */ public void setValues(DataKind kind, RawContactDelta.ValuesDelta values, RawContactDelta state, boolean readOnly, ViewIdGenerator vig); public void setDeletable(boolean deletable); /** * Add a specific {@link EditorListener} to this {@link Editor}. */ public void setEditorListener(EditorListener listener); /** * Called internally when the contents of a specific field have changed, * allowing advanced editors to persist data in a specific way. */ public void onFieldChanged(String column, String value); /** * Performs the delete operation for this {@link Editor}. */ public void deleteEditor(); /** * Clears all fields in this {@link Editor}. */ public void clearAllFields(); /** * Called internally when the user has added a new field. This * allows the appropriate editor UI to be presented immediately. * For example, if a new "event" is added, a date-picker will * immediately pop up. */ public void editNewlyAddedField(); }