diff options
author | Tor Norbye <tnorbye@google.com> | 2012-10-15 13:03:40 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-10-15 17:46:37 -0700 |
commit | a1e7aa7cc973adaba4f31673c897724eb8d9f399 (patch) | |
tree | a882deff58ea4fd638421369053660fbc8d21d44 /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java | |
parent | 1e6c45d826478a9621f433c28cce38786b890f52 (diff) | |
download | sdk-a1e7aa7cc973adaba4f31673c897724eb8d9f399.tar.gz |
Misc improvements to the multi-configuration editing
* Fix bug in switching to preview configurations
* Don't draw drop shadows for thumbnails in Dialog themes
* Move the preview title labels to sit above each preview
thumbnail
* Make error thumbnails include rendering error messages
(and wrap if necessary), plus tweak appearance
* Make switch animation show rectangles animating in
both directions
Change-Id: I0995617fa277b48419a88c5203abf5b1d49af711
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java index 73d08f828..432abdb8f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/NestedConfiguration.java @@ -23,6 +23,7 @@ import com.android.resources.UiMode; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.devices.Device; import com.android.sdklib.devices.State; +import com.google.common.base.Objects; /** * An {@linkplain NestedConfiguration} is a {@link Configuration} which inherits @@ -37,7 +38,7 @@ import com.android.sdklib.devices.State; * be "en", but otherwise inherit everything else. */ public class NestedConfiguration extends Configuration { - protected final Configuration mParent; + protected Configuration mParent; protected boolean mOverrideLocale; protected boolean mOverrideTarget; protected boolean mOverrideDevice; @@ -66,6 +67,61 @@ public class NestedConfiguration extends Configuration { } /** + * Creates a new {@linkplain NestedConfiguration} that has the same overriding + * attributes as the given other {@linkplain NestedConfiguration}, and gets + * its values from the given {@linkplain Configuration}. + * + * @param other the configuration to copy overrides from + * @param values the configuration to copy values from + * @param parent the parent to tie the configuration to for inheriting values + * @return a new configuration + */ + @NonNull + public static NestedConfiguration create( + @NonNull NestedConfiguration other, + @NonNull Configuration values, + @NonNull Configuration parent) { + NestedConfiguration configuration = + new NestedConfiguration(other.mConfigChooser, parent); + configuration.mOverrideLocale = other.mOverrideLocale; + if (configuration.mOverrideLocale) { + configuration.setLocale(values.getLocale(), true); + } + configuration.mOverrideTarget = other.mOverrideTarget; + if (configuration.mOverrideTarget) { + configuration.setTarget(values.getTarget(), true); + } + configuration.mOverrideDevice = other.mOverrideDevice; + configuration.mOverrideDeviceState = other.mOverrideDeviceState; + if (configuration.mOverrideDevice) { + configuration.setDevice(values.getDevice(), true); + } + if (configuration.mOverrideDeviceState) { + configuration.setDeviceState(values.getDeviceState(), true); + } + + configuration.mOverrideNightMode = other.mOverrideNightMode; + if (configuration.mOverrideNightMode) { + configuration.setNightMode(values.getNightMode(), true); + } + configuration.mOverrideUiMode = other.mOverrideUiMode; + if (configuration.mOverrideUiMode) { + configuration.setUiMode(values.getUiMode(), true); + } + + return configuration; + } + + /** + * Sets the parent configuration that this configuration is inheriting from. + * + * @param parent the parent configuration + */ + public void setParent(@NonNull Configuration parent) { + mParent = parent; + } + + /** * Creates a new {@linkplain Configuration} which inherits values from the * given parent {@linkplain Configuration}, possibly overriding some as * well. @@ -302,4 +358,28 @@ public class NestedConfiguration extends Configuration { public Configuration getParent() { return mParent; } + + @Override + @Nullable + public String getActivity() { + return mParent.getActivity(); + } + + @Override + public void setActivity(String activity) { + super.setActivity(activity); + } + + @Override + public String toString() { + return Objects.toStringHelper(this.getClass()) + .add("parent", mParent.getDisplayName()) //$NON-NLS-1$ + .add("display", getDisplayName()) //$NON-NLS-1$ + .add("overrideLocale", mOverrideLocale) //$NON-NLS-1$ + .add("overrideTarget", mOverrideTarget) //$NON-NLS-1$ + .add("overrideDevice", mOverrideDevice) //$NON-NLS-1$ + .add("overrideDeviceState", mOverrideDeviceState) //$NON-NLS-1$ + .add("persistent", toPersistentString()) //$NON-NLS-1$ + .toString(); + } }
\ No newline at end of file |