diff options
author | Tor Norbye <tnorbye@google.com> | 2012-10-16 13:35:35 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-10-16 13:45:06 -0700 |
commit | 17f0e2e5d47f0bee3768528fe1ab50c6193e8386 (patch) | |
tree | 3c1bcfe12c861b101422f32f17502d7390a2807e /eclipse/plugins | |
parent | 8868d79309786b1fe233151d9415453d0c10b2d5 (diff) | |
download | sdk-17f0e2e5d47f0bee3768528fe1ab50c6193e8386.zip sdk-17f0e2e5d47f0bee3768528fe1ab50c6193e8386.tar.gz sdk-17f0e2e5d47f0bee3768528fe1ab50c6193e8386.tar.bz2 |
Hide tvdpi previews for now
Ideally, hook this up to render capabilities later.
Also customize the detailed message in the layout editor
when the Nexus 7 is chosen.
Change-Id: I7606dbb89d9fda643b175a51177624b564c417cf
Diffstat (limited to 'eclipse/plugins')
3 files changed, 50 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ComplementingConfiguration.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ComplementingConfiguration.java index 66a29c8..d42c3f6 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ComplementingConfiguration.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ComplementingConfiguration.java @@ -17,7 +17,9 @@ package com.android.ide.eclipse.adt.internal.editors.layout.configuration; import com.android.annotations.NonNull; import com.android.annotations.Nullable; +import com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreviewManager; import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo; +import com.android.resources.Density; import com.android.resources.NightMode; import com.android.resources.UiMode; import com.android.sdklib.IAndroidTarget; @@ -282,6 +284,11 @@ public class ComplementingConfiguration extends NestedConfiguration { for (Device d : devices) { double size = getScreenSize(d); if (size >= from && size < to) { + if (RenderPreviewManager.HIDE_TVDPI && + getDensity(d) == Density.TV) { + continue; + } + device = d; break; } @@ -294,6 +301,26 @@ public class ComplementingConfiguration extends NestedConfiguration { return device; } + + /** + * Returns the density of the given device + * + * @param device the device to check + * @return the density or null + */ + @Nullable + public static Density getDensity(@NonNull Device device) { + Hardware hardware = device.getDefaultHardware(); + if (hardware != null) { + Screen screen = hardware.getScreen(); + if (screen != null) { + return screen.getPixelDensity(); + } + } + + return null; + } + private static double getScreenSize(@NonNull Device device) { Hardware hardware = device.getDefaultHardware(); if (hardware != null) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java index 93fdb5e..9b8eeea 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java @@ -2048,6 +2048,21 @@ public class GraphicalEditorPart extends EditorPart "or fix the theme style references.\n\n"); } + List<Throwable> trace = logger.getFirstTrace(); + if (trace != null + && trace.toString().contains( + "java.lang.IndexOutOfBoundsException: Index: 2, Size: 2") //$NON-NLS-1$ + && mConfigChooser.getConfiguration().getDensity() == Density.TV) { + addBoldText(mErrorLabel, + "It looks like you are using a render target where the layout library " + + "does not support the tvdpi density.\n\n"); + addText(mErrorLabel, "Please try either updating to " + + "the latest available version (using the SDK manager), or if no updated " + + "version is available for this specific version of Android, try using " + + "a more recent render target version.\n\n"); + + } + if (hasAaptErrors && logger.seenTagPrefix(LayoutLog.TAG_RESOURCES_PREFIX)) { // Text will automatically be wrapped by the error widget so no reason // to insert linebreaks in this error message: diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderPreviewManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderPreviewManager.java index 80391cd..a7c3e88 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderPreviewManager.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderPreviewManager.java @@ -23,6 +23,7 @@ import static com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPre import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.ide.common.api.Rect; +import com.android.ide.common.rendering.api.Capability; import com.android.ide.common.resources.configuration.DensityQualifier; import com.android.ide.common.resources.configuration.DeviceConfigHelper; import com.android.ide.common.resources.configuration.FolderConfiguration; @@ -73,6 +74,9 @@ import java.util.Set; * managing the image buffer cache, etc */ public class RenderPreviewManager { + /** TODO: Tie this to a {@link Capability} instead */ + public static boolean HIDE_TVDPI = true; + private static double sScale = 1.0; private static final int RENDER_DELAY = 150; private static final int PREVIEW_VGAP = 18; @@ -938,6 +942,10 @@ public class RenderPreviewManager { if (Density.LOW.equals(d)) { interesting = false; } + + if (HIDE_TVDPI && d == Density.TV) { + interesting = false; + } } } |