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.common.resources.configuration.FolderConfiguration; 23 import com.android.ide.eclipse.adt.internal.editors.layout.gle2.IncludeFinder.Reference; 24 import com.android.resources.NightMode; 25 import com.android.resources.ResourceType; 26 import com.android.resources.UiMode; 27 import com.android.sdklib.IAndroidTarget; 28 import com.android.sdklib.devices.Device; 29 import com.android.sdklib.devices.State; 30 31 import java.util.Map; 32 33 /** 34 * Interface implemented by clients who embed a {@link ConfigurationChooser}. 35 */ 36 public interface ConfigurationClient { 37 /** The {@link FolderConfiguration} in the configuration has changed */ 38 public static final int CHANGED_FOLDER = 1 << 0; 39 /** The {@link Device} in the configuration has changed */ 40 public static final int CHANGED_DEVICE = 1 << 1; 41 /** The {@link State} in the configuration has changed */ 42 public static final int CHANGED_DEVICE_CONFIG = 1 << 2; 43 /** The theme in the configuration has changed */ 44 public static final int CHANGED_THEME = 1 << 3; 45 /** The locale in the configuration has changed */ 46 public static final int CHANGED_LOCALE = 1 << 4; 47 /** The rendering {@link IAndroidTarget} in the configuration has changed */ 48 public static final int CHANGED_RENDER_TARGET = 1 << 5; 49 /** The {@link NightMode} in the configuration has changed */ 50 public static final int CHANGED_NIGHT_MODE = 1 << 6; 51 /** The {@link UiMode} in the configuration has changed */ 52 public static final int CHANGED_UI_MODE = 1 << 7; 53 54 /** Everything has changed */ 55 public static final int CHANGED_ALL = 0xFFFF; 56 57 /** 58 * The configuration is about to be changed. 59 * 60 * @param flags details about what changed; consult the {@code CHANGED_} flags 61 * such as {@link #CHANGED_DEVICE}, {@link #CHANGED_LOCALE}, etc. 62 */ 63 void aboutToChange(int flags); 64 65 /** 66 * The configuration has changed. If the client returns false, it means that 67 * the change was rejected. This typically means that changing the 68 * configuration in this particular way makes a configuration which has a 69 * better file match than the current client's file, so it will open that 70 * file to edit the new configuration -- and the current configuration 71 * should go back to editing the state prior to this change. 72 * 73 * @param flags details about what changed; consult the {@code CHANGED_} flags 74 * such as {@link #CHANGED_DEVICE}, {@link #CHANGED_LOCALE}, etc. 75 * @return true if the change was accepted, false if it was rejected. 76 */ 77 boolean changed(int flags); 78 79 /** 80 * Compute the project resources 81 * 82 * @return the project resources as a {@link ResourceRepository} 83 */ 84 @Nullable 85 ResourceRepository getProjectResources(); 86 87 /** 88 * Compute the framework resources 89 * 90 * @return the project resources as a {@link ResourceRepository} 91 */ 92 @Nullable 93 ResourceRepository getFrameworkResources(); 94 95 /** 96 * Compute the framework resources for the given Android API target 97 * 98 * @param target the target to look up framework resources for 99 * @return the project resources as a {@link ResourceRepository} 100 */ 101 @Nullable 102 ResourceRepository getFrameworkResources(@Nullable IAndroidTarget target); 103 104 /** 105 * Returns the configured project resources for the current file and 106 * configuration 107 * 108 * @return resource type maps to names to resource values 109 */ 110 @NonNull 111 Map<ResourceType, Map<String, ResourceValue>> getConfiguredProjectResources(); 112 113 /** 114 * Returns the configured framework resources for the current file and 115 * configuration 116 * 117 * @return resource type maps to names to resource values 118 */ 119 @NonNull 120 Map<ResourceType, Map<String, ResourceValue>> getConfiguredFrameworkResources(); 121 122 /** 123 * If the current layout is an included layout rendered within an outer layout, 124 * returns the outer layout. 125 * 126 * @return the outer including layout, or null 127 */ 128 @Nullable 129 Reference getIncludedWithin(); 130 131 /** 132 * Called when the "Create" button is clicked. 133 */ 134 void createConfigFile(); 135 136 /** 137 * Called when an associated activity is picked 138 * 139 * @param fqcn the fully qualified class name for the associated activity context 140 */ 141 void setActivity(@NonNull String fqcn); 142 } 143