Home | History | Annotate | Download | only in configuration
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
      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 package com.android.ide.eclipse.adt.internal.editors.layout.configuration;
     17 
     18 import com.android.annotations.NonNull;
     19 import com.android.annotations.Nullable;
     20 import com.android.ide.common.rendering.api.ResourceValue;
     21 import com.android.ide.common.resources.ResourceRepository;
     22 import com.android.ide.eclipse.adt.internal.editors.layout.gle2.IncludeFinder.Reference;
     23 import com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas;
     24 import com.android.resources.ResourceType;
     25 import com.android.sdklib.IAndroidTarget;
     26 
     27 import java.util.Map;
     28 
     29 /**
     30  * Interface implemented by clients who embed a {@link ConfigurationChooser}.
     31  */
     32 public interface ConfigurationClient {
     33     /**
     34      * The configuration is about to be changed.
     35      *
     36      * @param flags details about what changed; consult the {@code CFG_} flags
     37      *            in {@link Configuration} such as
     38      *            {@link Configuration#CFG_DEVICE},
     39      *            {@link Configuration#CFG_LOCALE}, etc.
     40      */
     41     void aboutToChange(int flags);
     42 
     43     /**
     44      * The configuration has changed. If the client returns false, it means that
     45      * the change was rejected. This typically means that changing the
     46      * configuration in this particular way makes a configuration which has a
     47      * better file match than the current client's file, so it will open that
     48      * file to edit the new configuration -- and the current configuration
     49      * should go back to editing the state prior to this change.
     50      *
     51      * @param flags details about what changed; consult the {@code CFG_} flags
     52      *            such as {@link Configuration#CFG_DEVICE},
     53      *            {@link Configuration#CFG_LOCALE}, etc.
     54      * @return true if the change was accepted, false if it was rejected.
     55      */
     56     boolean changed(int flags);
     57 
     58     /**
     59      * Compute the project resources
     60      *
     61      * @return the project resources as a {@link ResourceRepository}
     62      */
     63     @Nullable
     64     ResourceRepository getProjectResources();
     65 
     66     /**
     67      * Compute the framework resources
     68      *
     69      * @return the project resources as a {@link ResourceRepository}
     70      */
     71     @Nullable
     72     ResourceRepository getFrameworkResources();
     73 
     74     /**
     75      * Compute the framework resources for the given Android API target
     76      *
     77      * @param target the target to look up framework resources for
     78      * @return the project resources as a {@link ResourceRepository}
     79      */
     80     @Nullable
     81     ResourceRepository getFrameworkResources(@Nullable IAndroidTarget target);
     82 
     83     /**
     84      * Returns the configured project resources for the current file and
     85      * configuration
     86      *
     87      * @return resource type maps to names to resource values
     88      */
     89     @NonNull
     90     Map<ResourceType, Map<String, ResourceValue>> getConfiguredProjectResources();
     91 
     92     /**
     93      * Returns the configured framework resources for the current file and
     94      * configuration
     95      *
     96      * @return resource type maps to names to resource values
     97      */
     98     @NonNull
     99     Map<ResourceType, Map<String, ResourceValue>> getConfiguredFrameworkResources();
    100 
    101     /**
    102      * If the current layout is an included layout rendered within an outer layout,
    103      * returns the outer layout.
    104      *
    105      * @return the outer including layout, or null
    106      */
    107     @Nullable
    108     Reference getIncludedWithin();
    109 
    110     /**
    111      * Called when the "Create" button is clicked.
    112      */
    113     void createConfigFile();
    114 
    115     /**
    116      * Called when an associated activity is picked
    117      *
    118      * @param fqcn the fully qualified class name for the associated activity context
    119      */
    120     void setActivity(@NonNull String fqcn);
    121 
    122     /**
    123      * Returns the associated layout canvas, if any
    124      *
    125      * @return the canvas, if any
    126      */
    127     @Nullable
    128     LayoutCanvas getCanvas();
    129 }
    130