From 1f72cb7cb032538b79e79d6fc7ff3905e9766ce1 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 28 Jan 2011 15:18:32 -0800 Subject: Move Pair and annoatations into resources.jar now renamed as common.jar Move all the resource query methods that returned an array of 2 Strings to return a pair of ResourceType and String. Change-Id: I6b8447aa27005de786e2defef81ad88a72363523 --- common/.classpath | 6 + common/.gitignore | 2 + common/.project | 17 +++ common/Android.mk | 27 +++++ common/README.txt | 14 +++ common/src/com/android/annotations/Nullable.java | 35 ++++++ .../com/android/annotations/VisibleForTesting.java | 50 ++++++++ common/src/com/android/resources/Density.java | 129 +++++++++++++++++++++ common/src/com/android/resources/DockMode.java | 94 +++++++++++++++ common/src/com/android/resources/Keyboard.java | 99 ++++++++++++++++ .../src/com/android/resources/KeyboardState.java | 97 ++++++++++++++++ common/src/com/android/resources/Navigation.java | 98 ++++++++++++++++ .../src/com/android/resources/NavigationState.java | 96 +++++++++++++++ common/src/com/android/resources/NightMode.java | 96 +++++++++++++++ common/src/com/android/resources/ResourceEnum.java | 60 ++++++++++ common/src/com/android/resources/ResourceType.java | 110 ++++++++++++++++++ .../com/android/resources/ScreenOrientation.java | 98 ++++++++++++++++ common/src/com/android/resources/ScreenRatio.java | 98 ++++++++++++++++ common/src/com/android/resources/ScreenSize.java | 99 ++++++++++++++++ common/src/com/android/resources/TouchScreen.java | 98 ++++++++++++++++ common/src/com/android/util/Pair.java | 107 +++++++++++++++++ .../plugins/com.android.ide.eclipse.adt/.classpath | 2 +- .../META-INF/MANIFEST.MF | 7 +- .../com.android.ide.eclipse.adt/build.properties | 3 +- .../android/ide/common/api/IClientRulesEngine.java | 2 +- .../src/com/android/ide/common/api/MenuAction.java | 2 +- .../ide/common/layout/AbsoluteLayoutRule.java | 2 +- .../android/ide/common/layout/BaseLayoutRule.java | 2 +- .../android/ide/common/layout/FrameLayoutRule.java | 2 +- .../ide/common/layout/RelativeLayoutRule.java | 2 +- .../internal/editors/layout/ProjectCallback.java | 18 +-- .../editors/layout/gle2/ExtractIncludeAction.java | 2 +- .../editors/layout/gle2/IncludeFinder.java | 3 +- .../editors/layout/gle2/IncludeOverlay.java | 2 +- .../internal/editors/layout/gle2/OutlinePage.java | 5 +- .../editors/layout/gle2/PaletteControl.java | 2 +- .../editors/layout/gle2/PlayAnimationMenu.java | 2 +- .../editors/layout/gle2/PreviewIconFactory.java | 2 +- .../editors/layout/gre/ViewMetadataRepository.java | 2 +- .../adt/internal/editors/xml/Hyperlinks.java | 4 +- .../manager/CompiledResourcesMonitor.java | 11 +- .../resources/manager/ProjectResources.java | 7 +- .../wizards/newxmlfile/NewXmlFileCreationPage.java | 2 +- .../com.android.ide.eclipse.tests/.classpath | 2 +- .../layoutRendering/ApiDemosRenderingTest.java | 31 +++-- .../ide/common/layout/BaseLayoutRuleTest.java | 2 +- .../ide/common/layout/RelativeLayoutRuleTest.java | 2 +- eclipse/scripts/create_adt_symlinks.sh | 2 +- ide_common/.classpath | 2 +- ide_common/Android.mk | 2 +- .../ide/common/rendering/LayoutLibrary.java | 4 +- .../common/rendering/legacy/ILegacyCallback.java | 31 ----- .../common/rendering/legacy/LegacyCallback.java | 52 +++++++++ layoutlib_api/.classpath | 2 +- layoutlib_api/Android.mk | 2 +- .../ide/common/rendering/api/IProjectCallback.java | 12 +- resources/.classpath | 6 - resources/.gitignore | 2 - resources/.project | 17 --- resources/Android.mk | 27 ----- resources/README.txt | 16 --- resources/src/com/android/resources/Density.java | 129 --------------------- resources/src/com/android/resources/DockMode.java | 94 --------------- resources/src/com/android/resources/Keyboard.java | 99 ---------------- .../src/com/android/resources/KeyboardState.java | 97 ---------------- .../src/com/android/resources/Navigation.java | 98 ---------------- .../src/com/android/resources/NavigationState.java | 96 --------------- resources/src/com/android/resources/NightMode.java | 96 --------------- .../src/com/android/resources/ResourceEnum.java | 60 ---------- .../src/com/android/resources/ResourceType.java | 110 ------------------ .../com/android/resources/ScreenOrientation.java | 98 ---------------- .../src/com/android/resources/ScreenRatio.java | 98 ---------------- .../src/com/android/resources/ScreenSize.java | 99 ---------------- .../src/com/android/resources/TouchScreen.java | 98 ---------------- sdkmanager/app/etc/manifest.txt | 2 +- sdkmanager/libs/sdklib/.classpath | 2 +- sdkmanager/libs/sdklib/src/Android.mk | 2 +- .../sdklib/src/com/android/sdklib/SdkManager.java | 2 +- .../com/android/sdklib/annotations/Nullable.java | 35 ------ .../sdklib/annotations/VisibleForTesting.java | 50 -------- .../sdklib/internal/repository/AddonPackage.java | 4 +- .../internal/repository/AddonsListFetcher.java | 4 +- .../sdklib/internal/repository/LocalSdkParser.java | 2 +- .../internal/repository/PlatformPackage.java | 4 +- .../internal/repository/PlatformToolPackage.java | 4 +- .../sdklib/internal/repository/SdkAddonSource.java | 2 +- .../sdklib/internal/repository/SdkRepoSource.java | 2 +- .../sdklib/internal/repository/SdkSource.java | 6 +- .../sdklib/internal/repository/ToolPackage.java | 4 +- .../sdklib/src/com/android/sdklib/util/Pair.java | 107 ----------------- 90 files changed, 1674 insertions(+), 1660 deletions(-) create mode 100644 common/.classpath create mode 100644 common/.gitignore create mode 100644 common/.project create mode 100644 common/Android.mk create mode 100644 common/README.txt create mode 100755 common/src/com/android/annotations/Nullable.java create mode 100755 common/src/com/android/annotations/VisibleForTesting.java create mode 100644 common/src/com/android/resources/Density.java create mode 100644 common/src/com/android/resources/DockMode.java create mode 100644 common/src/com/android/resources/Keyboard.java create mode 100644 common/src/com/android/resources/KeyboardState.java create mode 100644 common/src/com/android/resources/Navigation.java create mode 100644 common/src/com/android/resources/NavigationState.java create mode 100644 common/src/com/android/resources/NightMode.java create mode 100644 common/src/com/android/resources/ResourceEnum.java create mode 100644 common/src/com/android/resources/ResourceType.java create mode 100644 common/src/com/android/resources/ScreenOrientation.java create mode 100644 common/src/com/android/resources/ScreenRatio.java create mode 100644 common/src/com/android/resources/ScreenSize.java create mode 100644 common/src/com/android/resources/TouchScreen.java create mode 100644 common/src/com/android/util/Pair.java delete mode 100644 ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java create mode 100644 ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java delete mode 100644 resources/.classpath delete mode 100644 resources/.gitignore delete mode 100644 resources/.project delete mode 100644 resources/Android.mk delete mode 100644 resources/README.txt delete mode 100644 resources/src/com/android/resources/Density.java delete mode 100644 resources/src/com/android/resources/DockMode.java delete mode 100644 resources/src/com/android/resources/Keyboard.java delete mode 100644 resources/src/com/android/resources/KeyboardState.java delete mode 100644 resources/src/com/android/resources/Navigation.java delete mode 100644 resources/src/com/android/resources/NavigationState.java delete mode 100644 resources/src/com/android/resources/NightMode.java delete mode 100644 resources/src/com/android/resources/ResourceEnum.java delete mode 100644 resources/src/com/android/resources/ResourceType.java delete mode 100644 resources/src/com/android/resources/ScreenOrientation.java delete mode 100644 resources/src/com/android/resources/ScreenRatio.java delete mode 100644 resources/src/com/android/resources/ScreenSize.java delete mode 100644 resources/src/com/android/resources/TouchScreen.java delete mode 100755 sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/Nullable.java delete mode 100755 sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/VisibleForTesting.java delete mode 100644 sdkmanager/libs/sdklib/src/com/android/sdklib/util/Pair.java diff --git a/common/.classpath b/common/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/common/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 0000000..fe99505 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1,2 @@ +bin + diff --git a/common/.project b/common/.project new file mode 100644 index 0000000..3a7717d --- /dev/null +++ b/common/.project @@ -0,0 +1,17 @@ + + + common + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/common/Android.mk b/common/Android.mk new file mode 100644 index 0000000..aa2ba8e --- /dev/null +++ b/common/Android.mk @@ -0,0 +1,27 @@ +# +# Copyright (C) 2008 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. +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under,src) + +LOCAL_JAVA_LIBRARIES := \ + +LOCAL_MODULE := common + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/common/README.txt b/common/README.txt new file mode 100644 index 0000000..d4c6232 --- /dev/null +++ b/common/README.txt @@ -0,0 +1,14 @@ +common.jar contains resource configuration enums. It is used by various tools, but also +by layoutlib.jar + +Layoutlib.jar is built from frameworks/base.git and therefore is versioned with the platform. + +IMPORTANT NOTE REGARDING CHANGES IN common.jar: + +- The API must stay compatible. This is because while layoutlib.jar compiles against it, + the client provides the implementation and must be able to load earlier versions of layoutlib.jar. + +- Updated version of common should be copied to the current in-dev branch of + prebuilt/common/common/common-prebuilt.jar + The PREBUILT file in the same folder must be updated as well to reflect how to rebuild this + prebuilt jar file. \ No newline at end of file diff --git a/common/src/com/android/annotations/Nullable.java b/common/src/com/android/annotations/Nullable.java new file mode 100755 index 0000000..0de1b6f --- /dev/null +++ b/common/src/com/android/annotations/Nullable.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php + * + * 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.android.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Denotes a parameter or field can be null. + *

+ * When decorating a method call parameter, this denotes the parameter can + * legitimately be null and the method will gracefully deal with it. Typically used + * on optional parameters. + *

+ * When decorating a method, this denotes the method might legitimately return null. + *

+ * This is a marker annotation and it has no specific attributes. + */ +@Retention(RetentionPolicy.SOURCE) +public @interface Nullable { +} diff --git a/common/src/com/android/annotations/VisibleForTesting.java b/common/src/com/android/annotations/VisibleForTesting.java new file mode 100755 index 0000000..6741d93 --- /dev/null +++ b/common/src/com/android/annotations/VisibleForTesting.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php + * + * 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.android.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Denotes that the class, method or field has its visibility relaxed so + * that unit tests can access it. + *

+ * The visibility argument can be used to specific what the original + * visibility should have been if it had not been made public or package-private for testing. + * The default is to consider the element private. + */ +@Retention(RetentionPolicy.SOURCE) +public @interface VisibleForTesting { + /** + * Intended visibility if the element had not been made public or package-private for + * testing. + */ + enum Visibility { + /** The element should be considered protected. */ + PROTECTED, + /** The element should be considered package-private. */ + PACKAGE, + /** The element should be considered private. */ + PRIVATE + } + + /** + * Intended visibility if the element had not been made public or package-private for testing. + * If not specified, one should assume the element originally intended to be private. + */ + Visibility visibility() default Visibility.PRIVATE; +} diff --git a/common/src/com/android/resources/Density.java b/common/src/com/android/resources/Density.java new file mode 100644 index 0000000..c1d7e3f --- /dev/null +++ b/common/src/com/android/resources/Density.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2010 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.android.resources; + + +/** + * Density enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names + * as well as other places needing to know the density values. + */ +public enum Density implements ResourceEnum { + XHIGH("xhdpi", "X-High Density", 320), //$NON-NLS-1$ + HIGH("hdpi", "High Density", 240), //$NON-NLS-1$ + MEDIUM("mdpi", "Medium Density", 160), //$NON-NLS-1$ + LOW("ldpi", "Low Density", 120), //$NON-NLS-1$ + NODPI("nodpi", "No Density", 0); //$NON-NLS-1$ + + public final static int DEFAULT_DENSITY = 160; + + private final String mValue; + private final String mDisplayValue; + private final int mDensity; + + private Density(String value, String displayValue, int density) { + mValue = value; + mDisplayValue = displayValue; + mDensity = density; + } + + /** + * Returns the enum matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no match was found. + */ + public static Density getEnum(String value) { + for (Density orient : values()) { + if (orient.mValue.equals(value)) { + return orient; + } + } + + return null; + } + + /** + * Returns the enum matching the given density value + * @param value The density value. + * @return the enum for the density value or null if no match was found. + */ + public static Density getEnum(int value) { + for (Density d : values()) { + if (d.mDensity == value) { + return d; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public int getDpiValue() { + return mDensity; + } + + public String getLegacyValue() { + if (this != NODPI) { + return String.format("%1$ddpi", getDpiValue()); + } + + return ""; + } + + public String getShortDisplayValue() { + return mDisplayValue; + } + + public String getLongDisplayValue() { + return mDisplayValue; + } + + public static int getIndex(Density value) { + int i = 0; + for (Density input : values()) { + if (value == input) { + return i; + } + + i++; + } + + return -1; + } + + public static Density getByIndex(int index) { + int i = 0; + for (Density value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return this != NODPI; // nodpi is not a valid config for devices. + } +} diff --git a/common/src/com/android/resources/DockMode.java b/common/src/com/android/resources/DockMode.java new file mode 100644 index 0000000..bbae6bf --- /dev/null +++ b/common/src/com/android/resources/DockMode.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Dock enum. + *

This is used in the resource folder names. + */ +public enum DockMode implements ResourceEnum { + NONE("", "No Dock"), + CAR("car", "Car Dock"), + DESK("desk", "Desk Dock"); + + private final String mValue; + private final String mDisplayValue; + + private DockMode(String value, String display) { + mValue = value; + mDisplayValue = display; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static DockMode getEnum(String value) { + for (DockMode mode : values()) { + if (mode.mValue.equals(value)) { + return mode; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mDisplayValue; + } + + public String getLongDisplayValue() { + return mDisplayValue; + } + + public static int getIndex(DockMode value) { + int i = 0; + for (DockMode mode : values()) { + if (mode == value) { + return i; + } + + i++; + } + + return -1; + } + + public static DockMode getByIndex(int index) { + int i = 0; + for (DockMode value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return this == NONE; // NONE is not a real enum. it's used for internal state only. + } + + public boolean isValidValueForDevice() { + return this != NONE; + } +} diff --git a/common/src/com/android/resources/Keyboard.java b/common/src/com/android/resources/Keyboard.java new file mode 100644 index 0000000..eb99f9b --- /dev/null +++ b/common/src/com/android/resources/Keyboard.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Keyboard enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum Keyboard implements ResourceEnum { + NOKEY("nokeys", null, "No Keys", "No keyboard"), //$NON-NLS-1$ + QWERTY("qwerty", null, "Qwerty", "Qwerty keybard"), //$NON-NLS-1$ + TWELVEKEY("12key", "twelvekey", "12 Key", "12 key keyboard"); //$NON-NLS-1$ //$NON-NLS-2$ + + private final String mValue, mValue2; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private Keyboard(String value, String value2, String shortDisplayValue, + String longDisplayValue) { + mValue = value; + mValue2 = value2; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static Keyboard getEnum(String value) { + for (Keyboard kbrd : values()) { + if (kbrd.mValue.equals(value) || + (kbrd.mValue2 != null && kbrd.mValue2.equals(value))) { + return kbrd; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(Keyboard value) { + int i = 0; + for (Keyboard input : values()) { + if (value == input) { + return i; + } + + i++; + } + + return -1; + } + + public static Keyboard getByIndex(int index) { + int i = 0; + for (Keyboard value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } +} diff --git a/common/src/com/android/resources/KeyboardState.java b/common/src/com/android/resources/KeyboardState.java new file mode 100644 index 0000000..e3333f5 --- /dev/null +++ b/common/src/com/android/resources/KeyboardState.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Keyboard state enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum KeyboardState implements ResourceEnum { + EXPOSED("keysexposed", "Exposed", "Exposed keyboard"), //$NON-NLS-1$ + HIDDEN("keyshidden", "Hidden", "Hidden keyboard"), //$NON-NLS-1$ + SOFT("keyssoft", "Soft", "Soft keyboard"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private KeyboardState(String value, String shortDisplayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static KeyboardState getEnum(String value) { + for (KeyboardState state : values()) { + if (state.mValue.equals(value)) { + return state; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(KeyboardState value) { + int i = 0; + for (KeyboardState input : values()) { + if (value == input) { + return i; + } + + i++; + } + + return -1; + } + + public static KeyboardState getByIndex(int index) { + int i = 0; + for (KeyboardState value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} diff --git a/common/src/com/android/resources/Navigation.java b/common/src/com/android/resources/Navigation.java new file mode 100644 index 0000000..d5d9541 --- /dev/null +++ b/common/src/com/android/resources/Navigation.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Navigation enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum Navigation implements ResourceEnum { + NONAV("nonav", "None", "No navigation"), //$NON-NLS-1$ + DPAD("dpad", "D-pad", "D-pad navigation"), //$NON-NLS-1$ + TRACKBALL("trackball", "Trackball", "Trackball navigation"), //$NON-NLS-1$ + WHEEL("wheel", "Wheel", "Wheel navigation"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private Navigation(String value, String shortDisplayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static Navigation getEnum(String value) { + for (Navigation nav : values()) { + if (nav.mValue.equals(value)) { + return nav; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(Navigation value) { + int i = 0; + for (Navigation nav : values()) { + if (nav == value) { + return i; + } + + i++; + } + + return -1; + } + + public static Navigation getByIndex(int index) { + int i = 0; + for (Navigation value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} \ No newline at end of file diff --git a/common/src/com/android/resources/NavigationState.java b/common/src/com/android/resources/NavigationState.java new file mode 100644 index 0000000..266d9da --- /dev/null +++ b/common/src/com/android/resources/NavigationState.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Navigation state enum. + *

This is used in the resource folder names. + */ +public enum NavigationState implements ResourceEnum { + EXPOSED("navexposed", "Exposed", "Exposed navigation"), //$NON-NLS-1$ + HIDDEN("navhidden", "Hidden", "Hidden navigation"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private NavigationState(String value, String shortDisplayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static NavigationState getEnum(String value) { + for (NavigationState state : values()) { + if (state.mValue.equals(value)) { + return state; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(NavigationState value) { + int i = 0; + for (NavigationState input : values()) { + if (value == input) { + return i; + } + + i++; + } + + return -1; + } + + public static NavigationState getByIndex(int index) { + int i = 0; + for (NavigationState value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} diff --git a/common/src/com/android/resources/NightMode.java b/common/src/com/android/resources/NightMode.java new file mode 100644 index 0000000..2d64316 --- /dev/null +++ b/common/src/com/android/resources/NightMode.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Night enum. + *

This is used in the resource folder names. + */ +public enum NightMode implements ResourceEnum { + NOTNIGHT("notnight", "Not Night", "Day time"), + NIGHT("night", "Night", "Night time"); + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private NightMode(String value, String shortDisplayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static NightMode getEnum(String value) { + for (NightMode mode : values()) { + if (mode.mValue.equals(value)) { + return mode; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(NightMode value) { + int i = 0; + for (NightMode mode : values()) { + if (mode == value) { + return i; + } + + i++; + } + + return -1; + } + + public static NightMode getByIndex(int index) { + int i = 0; + for (NightMode value : values()) { + if (i == index) { + return value; + } + i++; + } + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} diff --git a/common/src/com/android/resources/ResourceEnum.java b/common/src/com/android/resources/ResourceEnum.java new file mode 100644 index 0000000..7f4e16a --- /dev/null +++ b/common/src/com/android/resources/ResourceEnum.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * An enum representing a resource qualifier value. + */ +public interface ResourceEnum { + + /** + * Returns the resource string. This is to be used in resource folder names. + */ + String getResourceValue(); + + /** + * Whether the value actually used on device. This returns true only if a device can report + * this value, false if it's just used to qualify resources. + */ + boolean isValidValueForDevice(); + + /** + * Whether the value is neither used for device nor resources. This returns false when + * the value is only used for internal usage in the custom editors. + */ + boolean isFakeValue(); + + /** + * Returns a short string for display value. The string does not need to show the context. + *

For instance "exposed", which can be the value for the keyboard state or the navigation + * state, would be valid since something else in the UI is expected to show if this is about the + * keyboard or the navigation state. + * + * @see #getLongDisplayValue() + */ + String getShortDisplayValue(); + + /** + * Returns a long string for display value. This must not only include the enum value but + * context (qualifier) about what the value represents. + *

For instance "Exposed keyboard", and "Export navigation", as "exposed" would not be + * enough to know what qualifier the value is about. + * + * @see #getShortDisplayValue() + */ + String getLongDisplayValue(); +} diff --git a/common/src/com/android/resources/ResourceType.java b/common/src/com/android/resources/ResourceType.java new file mode 100644 index 0000000..f5f7063 --- /dev/null +++ b/common/src/com/android/resources/ResourceType.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php + * + * 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.android.resources; + + +/** + * Enum representing a type of compiled resource. + */ +public enum ResourceType { + ANIM("anim", "Animation"), //$NON-NLS-1$ + ANIMATOR("animator", "Animator"), //$NON-NLS-1$ + ARRAY("array", "Array", "string-array", "integer-array"), //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$ + ATTR("attr", "Attr"), //$NON-NLS-1$ + BOOL("bool", "Boolean"), //$NON-NLS-1$ + COLOR("color", "Color"), //$NON-NLS-1$ + DECLARE_STYLEABLE("declare-styleable", "Declare Stylable"), //$NON-NLS-1$ + DIMEN("dimen", "Dimension"), //$NON-NLS-1$ + DRAWABLE("drawable", "Drawable"), //$NON-NLS-1$ + FRACTION("fraction", "Fraction"), //$NON-NLS-1$ + ID("id", "ID"), //$NON-NLS-1$ + INTEGER("integer", "Integer"), //$NON-NLS-1$ + INTERPOLATOR("interpolator", "Interpolator"), //$NON-NLS-1$ + LAYOUT("layout", "Layout"), //$NON-NLS-1$ + MENU("menu", "Menu"), //$NON-NLS-1$ + PLURALS("plurals", "Plurals"), //$NON-NLS-1$ + RAW("raw", "Raw"), //$NON-NLS-1$ + STRING("string", "String"), //$NON-NLS-1$ + STYLE("style", "Style"), //$NON-NLS-1$ + STYLEABLE("styleable", "Styleable"), //$NON-NLS-1$ + XML("xml", "XML"), //$NON-NLS-1$ + // this is not actually used. Only there because they get parsed and since we want to + // detect new resource type, we need to have this one exist. + PUBLIC("public", "###"); //$NON-NLS-1$ //$NON-NLS-2$ + + private final String mName; + private final String mDisplayName; + private final String[] mAlternateXmlNames; + + ResourceType(String name, String displayName, String... alternateXmlNames) { + mName = name; + mDisplayName = displayName; + mAlternateXmlNames = alternateXmlNames; + } + + /** + * Returns the resource type name, as used by XML files. + */ + public String getName() { + return mName; + } + + /** + * Returns a translated display name for the resource type. + */ + public String getDisplayName() { + return mDisplayName; + } + + /** + * Returns the enum by its name as it appears in the XML or the R class. + * @param name name of the resource + * @return the matching {@link ResourceType} or null if no match was found. + */ + public static ResourceType getEnum(String name) { + for (ResourceType rType : values()) { + if (rType.mName.equals(name)) { + return rType; + } else if (rType.mAlternateXmlNames != null) { + // if there are alternate Xml Names, we test those too + for (String alternate : rType.mAlternateXmlNames) { + if (alternate.equals(name)) { + return rType; + } + } + } + } + return null; + } + + /** + * Returns an array with all the names defined by this enum. + */ + public static String[] getNames() { + ResourceType[] values = values(); + String[] names = new String[values.length]; + for (int i = values.length - 1; i >= 0; --i) { + names[i] = values[i].getName(); + } + return names; + } + + @Override + public String toString() { + return getName(); + } +} diff --git a/common/src/com/android/resources/ScreenOrientation.java b/common/src/com/android/resources/ScreenOrientation.java new file mode 100644 index 0000000..56f907b --- /dev/null +++ b/common/src/com/android/resources/ScreenOrientation.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Screen Orientation enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum ScreenOrientation implements ResourceEnum { + PORTRAIT("port", "Portrait", "Portrait Orientation"), //$NON-NLS-1$ + LANDSCAPE("land", "Landscape", "Landscape Orientation"), //$NON-NLS-1$ + SQUARE("square", "Square", "Square Orientation"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private ScreenOrientation(String value, String shortDisplayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static ScreenOrientation getEnum(String value) { + for (ScreenOrientation orient : values()) { + if (orient.mValue.equals(value)) { + return orient; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(ScreenOrientation orientation) { + int i = 0; + for (ScreenOrientation orient : values()) { + if (orient == orientation) { + return i; + } + + i++; + } + + return -1; + } + + public static ScreenOrientation getByIndex(int index) { + int i = 0; + for (ScreenOrientation orient : values()) { + if (i == index) { + return orient; + } + i++; + } + + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} diff --git a/common/src/com/android/resources/ScreenRatio.java b/common/src/com/android/resources/ScreenRatio.java new file mode 100644 index 0000000..2794b6e --- /dev/null +++ b/common/src/com/android/resources/ScreenRatio.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Screen Ratio enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum ScreenRatio implements ResourceEnum { + NOTLONG("notlong", "Not Long", "Short screen aspect ratio"), //$NON-NLS-1$ + LONG("long", "Long", "Long screen aspect ratio"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private ScreenRatio(String value, String displayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = displayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static ScreenRatio getEnum(String value) { + for (ScreenRatio orient : values()) { + if (orient.mValue.equals(value)) { + return orient; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(ScreenRatio orientation) { + int i = 0; + for (ScreenRatio orient : values()) { + if (orient == orientation) { + return i; + } + + i++; + } + + return -1; + } + + public static ScreenRatio getByIndex(int index) { + int i = 0; + for (ScreenRatio orient : values()) { + if (i == index) { + return orient; + } + i++; + } + + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} + diff --git a/common/src/com/android/resources/ScreenSize.java b/common/src/com/android/resources/ScreenSize.java new file mode 100644 index 0000000..b6ffc50 --- /dev/null +++ b/common/src/com/android/resources/ScreenSize.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Screen size enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum ScreenSize implements ResourceEnum { + SMALL("small", "Small", "Small Screen"), //$NON-NLS-1$ + NORMAL("normal", "Normal", "Normal Screen"), //$NON-NLS-1$ + LARGE("large", "Large", "Large Screen"), //$NON-NLS-1$ + XLARGE("xlarge", "X-Large", "Extra Large Screen"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private ScreenSize(String value, String shortDisplayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = shortDisplayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static ScreenSize getEnum(String value) { + for (ScreenSize orient : values()) { + if (orient.mValue.equals(value)) { + return orient; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(ScreenSize orientation) { + int i = 0; + for (ScreenSize orient : values()) { + if (orient == orientation) { + return i; + } + + i++; + } + + return -1; + } + + public static ScreenSize getByIndex(int index) { + int i = 0; + for (ScreenSize orient : values()) { + if (i == index) { + return orient; + } + i++; + } + + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} diff --git a/common/src/com/android/resources/TouchScreen.java b/common/src/com/android/resources/TouchScreen.java new file mode 100644 index 0000000..7ee1f0f --- /dev/null +++ b/common/src/com/android/resources/TouchScreen.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010 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.android.resources; + +/** + * Touch screen enum. + *

This is used in the manifest in the uses-configuration node and in the resource folder names. + */ +public enum TouchScreen implements ResourceEnum { + NOTOUCH("notouch", "No Touch", "No-touch screen"), //$NON-NLS-1$ + STYLUS("stylus", "Stylus", "Stylus-based touchscreen"), //$NON-NLS-1$ + FINGER("finger", "Finger", "Finger-based touchscreen"); //$NON-NLS-1$ + + private final String mValue; + private final String mShortDisplayValue; + private final String mLongDisplayValue; + + private TouchScreen(String value, String displayValue, String longDisplayValue) { + mValue = value; + mShortDisplayValue = displayValue; + mLongDisplayValue = longDisplayValue; + } + + /** + * Returns the enum for matching the provided qualifier value. + * @param value The qualifier value. + * @return the enum for the qualifier value or null if no matching was found. + */ + public static TouchScreen getEnum(String value) { + for (TouchScreen orient : values()) { + if (orient.mValue.equals(value)) { + return orient; + } + } + + return null; + } + + public String getResourceValue() { + return mValue; + } + + public String getShortDisplayValue() { + return mShortDisplayValue; + } + + public String getLongDisplayValue() { + return mLongDisplayValue; + } + + public static int getIndex(TouchScreen touch) { + int i = 0; + for (TouchScreen t : values()) { + if (t == touch) { + return i; + } + + i++; + } + + return -1; + } + + public static TouchScreen getByIndex(int index) { + int i = 0; + for (TouchScreen value : values()) { + if (i == index) { + return value; + } + i++; + } + + return null; + } + + public boolean isFakeValue() { + return false; + } + + public boolean isValidValueForDevice() { + return true; + } + +} diff --git a/common/src/com/android/util/Pair.java b/common/src/com/android/util/Pair.java new file mode 100644 index 0000000..8817cd7 --- /dev/null +++ b/common/src/com/android/util/Pair.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2010 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.android.util; + +/** + * A Pair class is simply a 2-tuple for use in this package. We might want to + * think about adding something like this to a more central utility place, or + * replace it by a common tuple class if one exists, or even rewrite the layout + * classes using this Pair by a more dedicated data structure (so we don't have + * to pass around generic signatures as is currently done, though at least the + * construction is helped a bit by the {@link #of} factory method. + * + * @param The type of the first value + * @param The type of the second value + */ +public class Pair { + private final S mFirst; + private final T mSecond; + + // Use {@link Pair#of} factory instead since it infers generic types + private Pair(S first, T second) { + this.mFirst = first; + this.mSecond = second; + } + + /** + * Return the first item in the pair + * + * @return the first item in the pair + */ + public S getFirst() { + return mFirst; + } + + /** + * Return the second item in the pair + * + * @return the second item in the pair + */ + public T getSecond() { + return mSecond; + } + + /** + * Constructs a new pair of the given two objects, inferring generic types. + * + * @param first the first item to store in the pair + * @param second the second item to store in the pair + * @param the type of the first item + * @param the type of the second item + * @return a new pair wrapping the two items + */ + public static Pair of(S first, T second) { + return new Pair(first,second); + } + + @Override + public String toString() { + return "Pair [first=" + mFirst + ", second=" + mSecond + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((mFirst == null) ? 0 : mFirst.hashCode()); + result = prime * result + ((mSecond == null) ? 0 : mSecond.hashCode()); + return result; + } + + @SuppressWarnings("unchecked") + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Pair other = (Pair) obj; + if (mFirst == null) { + if (other.mFirst != null) + return false; + } else if (!mFirst.equals(other.mFirst)) + return false; + if (mSecond == null) { + if (other.mSecond != null) + return false; + } else if (!mSecond.equals(other.mSecond)) + return false; + return true; + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath index 0e42f20..7a693db 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath @@ -12,7 +12,7 @@ - + diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF index 0409880..bea92fe 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF +++ b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Bundle-ClassPath: ., libs/kxml2-2.3.0.jar, libs/layoutlib_api.jar, libs/ide_common.jar, - libs/resources.jar + libs/common.jar Bundle-Activator: com.android.ide.eclipse.adt.AdtPlugin Bundle-Vendor: The Android Open Source Project Require-Bundle: com.android.ide.eclipse.ddms, @@ -47,7 +47,8 @@ Require-Bundle: com.android.ide.eclipse.ddms, org.eclipse.ltk.ui.refactoring, org.eclipse.core.expressions Eclipse-LazyStart: true -Export-Package: com.android.ide.common.api;x-friends:="com.android.ide.eclipse.tests", +Export-Package: com.android.annotations;x-friends:="com.android.ide.eclipse.tests", + com.android.ide.common.api;x-friends:="com.android.ide.eclipse.tests", com.android.ide.common.layout;x-friends:="com.android.ide.eclipse.tests", com.android.ide.common.log;x-friends:="com.android.ide.eclipse.tests", com.android.ide.common.rendering;x-friends:="com.android.ide.eclipse.tests", @@ -110,7 +111,6 @@ Export-Package: com.android.ide.common.api;x-friends:="com.android.ide.eclipse.t com.android.prefs;x-friends:="com.android.ide.eclipse.tests", com.android.resources;x-friends:="com.android.ide.eclipse.tests", com.android.sdklib;x-friends:="com.android.ide.eclipse.tests", - com.android.sdklib.annotations;x-friends:="com.android.ide.eclipse.tests", com.android.sdklib.build;x-friends:="com.android.ide.eclipse.tests", com.android.sdklib.internal.avd;x-friends:="com.android.ide.eclipse.tests", com.android.sdklib.internal.build;x-friends:="com.android.ide.eclipse.tests", @@ -128,6 +128,7 @@ Export-Package: com.android.ide.common.api;x-friends:="com.android.ide.eclipse.t com.android.sdkuilib.internal.widgets;x-friends:="com.android.ide.eclipse.tests", com.android.sdkuilib.repository;x-friends:="com.android.ide.eclipse.tests", com.android.sdkuilib.ui;x-friends:="com.android.ide.eclipse.tests", + com.android.util;x-friends:="com.android.ide.eclipse.tests", org.apache.commons.compress.archivers;x-friends:="com.android.ide.eclipse.tests", org.apache.commons.compress.archivers.ar;x-friends:="com.android.ide.eclipse.tests", org.apache.commons.compress.archivers.cpio;x-friends:="com.android.ide.eclipse.tests", diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/build.properties b/eclipse/plugins/com.android.ide.eclipse.adt/build.properties index 9eb0d29..96d191e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/build.properties +++ b/eclipse/plugins/com.android.ide.eclipse.adt/build.properties @@ -7,7 +7,8 @@ bin.includes = plugin.xml,\ libs/,\ about.properties,\ NOTICE,\ - about.html + about.html,\ + libs/common.jar source.. = src/ output.. = bin/ bin.excludes = libs/.gitignore diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java index 6a01e8a..4f91552 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java @@ -17,7 +17,7 @@ package com.android.ide.common.api; -import com.android.sdklib.annotations.Nullable; +import com.android.annotations.Nullable; /** * A Client Rules Engine is a set of methods that {@link IViewRule}s can use to diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/MenuAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/MenuAction.java index d82049d..e4d7ebf 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/MenuAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/MenuAction.java @@ -16,7 +16,7 @@ package com.android.ide.common.api; -import com.android.sdklib.annotations.Nullable; +import com.android.annotations.Nullable; import java.util.Map; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java index f0005cc..2fa20ea 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java @@ -28,7 +28,7 @@ import com.android.ide.common.api.INodeHandler; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.util.Map; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java index 69548c3..91110cb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java @@ -32,7 +32,7 @@ import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.api.IDragElement.IDragAttribute; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.util.Arrays; import java.util.HashMap; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java index ef0be13..1054c56 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java @@ -26,7 +26,7 @@ import com.android.ide.common.api.INodeHandler; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.util.Map; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java index 194ac41..b80f2ec 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java @@ -50,7 +50,7 @@ import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.api.INode.IAttribute; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.util.ArrayList; import java.util.Collections; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java index 824d0e1..976dfaf 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java @@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutLog; -import com.android.ide.common.rendering.legacy.ILegacyCallback; +import com.android.ide.common.rendering.legacy.LegacyCallback; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper; @@ -27,6 +27,7 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources; import com.android.resources.ResourceType; import com.android.sdklib.SdkConstants; import com.android.sdklib.xml.ManifestData; +import com.android.util.Pair; import org.eclipse.core.resources.IProject; @@ -41,7 +42,7 @@ import java.util.TreeSet; *

This implements {@link IProjectCallback} for the old and new API through * {@link ILegacyCallback} */ -public final class ProjectCallback implements ILegacyCallback { +public final class ProjectCallback extends LegacyCallback { private final HashMap> mLoadedClasses = new HashMap>(); private final Set mMissingClasses = new TreeSet(); @@ -205,7 +206,7 @@ public final class ProjectCallback implements ILegacyCallback { return mNamespace; } - public String[] resolveResourceValue(int id) { + public Pair resolveResourceId(int id) { if (mProjectRes != null) { return mProjectRes.resolveResourceValue(id); } @@ -213,7 +214,7 @@ public final class ProjectCallback implements ILegacyCallback { return null; } - public String resolveResourceValue(int[] id) { + public String resolveResourceId(int[] id) { if (mProjectRes != null) { return mProjectRes.resolveResourceValue(id); } @@ -221,14 +222,7 @@ public final class ProjectCallback implements ILegacyCallback { return null; } - /** - * @deprecated use {@link #getResourceValue(ResourceType, String)} instead. - */ - public Integer getResourceValue(String type, String name) { - return getResourceValue(ResourceType.getEnum(type), name); - } - - public Integer getResourceValue(ResourceType type, String name) { + public Integer getResourceId(ResourceType type, String name) { if (mProjectRes != null) { return mProjectRes.getResourceValue(type, name); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ExtractIncludeAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ExtractIncludeAction.java index 46ec8f3..8c2c956 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ExtractIncludeAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ExtractIncludeAction.java @@ -41,7 +41,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElement import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; import com.android.ide.eclipse.adt.internal.wizards.newxmlfile.ResourceNameValidator; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeFinder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeFinder.java index e7a7fdf..9ca5ae7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeFinder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeFinder.java @@ -20,11 +20,13 @@ import static com.android.ide.eclipse.adt.AndroidConstants.EXT_XML; import static com.android.ide.eclipse.adt.AndroidConstants.WS_LAYOUTS; import static com.android.ide.eclipse.adt.AndroidConstants.WS_SEP; import static com.android.sdklib.SdkConstants.FD_LAYOUT; + import static org.eclipse.core.resources.IResourceDelta.ADDED; import static org.eclipse.core.resources.IResourceDelta.CHANGED; import static org.eclipse.core.resources.IResourceDelta.CONTENT; import static org.eclipse.core.resources.IResourceDelta.REMOVED; +import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors; import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; @@ -37,7 +39,6 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager.IR import com.android.ide.eclipse.adt.io.IFileWrapper; import com.android.resources.ResourceType; import com.android.sdklib.SdkConstants; -import com.android.sdklib.annotations.VisibleForTesting; import com.android.sdklib.io.IAbstractFile; import org.eclipse.core.resources.IFile; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeOverlay.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeOverlay.java index e201c14..84f3e01 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeOverlay.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/IncludeOverlay.java @@ -16,7 +16,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; -import com.android.sdklib.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java index 4870894..d7bc412 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java @@ -21,8 +21,10 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_SRC; import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; import static com.android.ide.common.layout.LayoutConstants.DRAWABLE_PREFIX; import static com.android.ide.common.layout.LayoutConstants.LAYOUT_PREFIX; + import static org.eclipse.jface.viewers.StyledString.QUALIFIER_STYLER; +import com.android.annotations.VisibleForTesting; import com.android.ide.common.api.INode; import com.android.ide.common.api.InsertType; import com.android.ide.common.layout.BaseLayoutRule; @@ -37,8 +39,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gre.NodeProxy; import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode; import com.android.ide.eclipse.adt.internal.editors.ui.ErrorImageComposite; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java index fbf7167..fdc559d 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java @@ -50,7 +50,7 @@ import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; import com.android.ide.eclipse.adt.internal.sdk.Sdk; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java index 79c68d9..3fcae86 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java @@ -27,7 +27,7 @@ import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor; import com.android.ide.eclipse.adt.internal.wizards.newxmlfile.NewXmlFileWizard; import com.android.resources.ResourceType; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.eclipse.core.resources.IProject; import org.eclipse.jface.action.Action; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PreviewIconFactory.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PreviewIconFactory.java index a93c81e..2fb2ebe 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PreviewIconFactory.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PreviewIconFactory.java @@ -36,7 +36,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gre.ViewMetadataRepos import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.resource.ImageDescriptor; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java index 049ac64..589ad2d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java @@ -27,7 +27,7 @@ import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors; import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java index 5225911..c6ca95e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java @@ -32,6 +32,7 @@ import static com.android.sdklib.xml.AndroidManifest.ATTRIBUTE_PACKAGE; import static com.android.sdklib.xml.AndroidManifest.NODE_ACTIVITY; import static com.android.sdklib.xml.AndroidManifest.NODE_SERVICE; +import com.android.annotations.VisibleForTesting; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; @@ -51,9 +52,8 @@ import com.android.ide.eclipse.adt.io.IFileWrapper; import com.android.resources.ResourceType; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; -import com.android.sdklib.annotations.VisibleForTesting; import com.android.sdklib.io.FileWrapper; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.apache.xerces.parsers.DOMParser; import org.apache.xerces.xni.Augmentations; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/CompiledResourcesMonitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/CompiledResourcesMonitor.java index 2233cab..295fd4c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/CompiledResourcesMonitor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/CompiledResourcesMonitor.java @@ -24,6 +24,7 @@ import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonit import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IProjectListener; import com.android.resources.ResourceType; import com.android.sdklib.xml.ManifestData; +import com.android.util.Pair; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarkerDelta; @@ -150,8 +151,8 @@ public final class CompiledResourcesMonitor implements IFileListener, IProjectLi // create the maps to store the result of the parsing Map> resourceValueMap = new EnumMap>(ResourceType.class); - Map genericValueToNameMap = - new HashMap(); + Map> genericValueToNameMap = + new HashMap>(); Map styleableValueToNameMap = new HashMap(); @@ -181,7 +182,8 @@ public final class CompiledResourcesMonitor implements IFileListener, IProjectLi * @param resourceValueMap * @return True if we managed to parse the R class. */ - private boolean parseClass(Class rClass, Map genericValueToNameMap, + private boolean parseClass(Class rClass, + Map> genericValueToNameMap, Map styleableValueToNameMap, Map> resourceValueMap) { try { @@ -205,8 +207,7 @@ public final class CompiledResourcesMonitor implements IFileListener, IProjectLi f.getName()); } else if (type == int.class) { Integer value = (Integer) f.get(null); - genericValueToNameMap.put(value, - new String[] { f.getName(), resType.getName() }); + genericValueToNameMap.put(value, Pair.of(resType, f.getName())); fullMap.put(f.getName(), value); } else { assert false; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java index f0939da..64a36e1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java @@ -28,6 +28,7 @@ import com.android.ide.eclipse.adt.internal.sdk.Sdk; import com.android.ide.eclipse.adt.io.IFolderWrapper; import com.android.resources.ResourceType; import com.android.sdklib.io.IAbstractFolder; +import com.android.util.Pair; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -62,7 +63,7 @@ public class ProjectResources implements IResourceRepository { /** Map of (name, id) for resources of type {@link ResourceType#ID} coming from R.java */ private Map> mResourceValueMap; /** Map of (id, [name, resType]) for all resources coming from R.java */ - private Map mResIdValueToNameMap; + private Map> mResIdValueToNameMap; /** Map of (int[], name) for styleable resources coming from R.java */ private Map mStyleableValueToNameMap; @@ -522,7 +523,7 @@ public class ProjectResources implements IResourceRepository { * @param id * @return an array of 2 strings { name, type } or null if the id could not be resolved */ - public String[] resolveResourceValue(int id) { + public Pair resolveResourceValue(int id) { if (mResIdValueToNameMap != null) { return mResIdValueToNameMap.get(id); } @@ -922,7 +923,7 @@ public class ProjectResources implements IResourceRepository { * @param resourceValueMap a map of (name, id) for resources of type {@link ResourceType#ID}. * The list is acquired by the {@link ProjectResources} object. */ - void setCompiledResources(Map resIdValueToNameMap, + void setCompiledResources(Map> resIdValueToNameMap, Map styleableValueMap, Map> resourceValueMap) { mResourceValueMap = resourceValueMap; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java index b20da44..03aed88 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java @@ -38,7 +38,7 @@ import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.Configurati import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.SelectorMode; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath index b9a72c4..28377f7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath @@ -13,6 +13,6 @@ - + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java index 3e66649..13d9a49 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java @@ -39,12 +39,11 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; import com.android.ide.eclipse.tests.SdkTestCase; -import com.android.layoutlib.api.IXmlPullParser; -import com.android.resources.ResourceType; import com.android.resources.Density; import com.android.resources.Keyboard; import com.android.resources.KeyboardState; import com.android.resources.Navigation; +import com.android.resources.ResourceType; import com.android.resources.ScreenOrientation; import com.android.resources.ScreenRatio; import com.android.resources.ScreenSize; @@ -52,6 +51,7 @@ import com.android.resources.TouchScreen; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; import com.android.sdklib.io.FolderWrapper; +import com.android.util.Pair; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -68,7 +68,7 @@ import javax.imageio.ImageIO; public class ApiDemosRenderingTest extends SdkTestCase { /** - * Custom parser that implements {@link IXmlPullParser} (which itself extends + * Custom parser that implements {@link ILayoutPullParser} (which itself extends * {@link XmlPullParser}). */ private final static class TestParser extends KXmlParser implements ILayoutPullParser { @@ -94,7 +94,8 @@ public class ApiDemosRenderingTest extends SdkTestCase { // in some cases, the id that getResourceValue(String type, String name) returns // will be sent back to get the type/name. This map stores the id/type/name we generate // to be able to do the reverse resolution. - private Map mResourceMap = new HashMap(); + private Map> mResourceMap = + new HashMap>(); private boolean mCustomViewAttempt = false; @@ -103,18 +104,6 @@ public class ApiDemosRenderingTest extends SdkTestCase { return "com.example.android.apis"; } - public Integer getResourceValue(String type, String name) { - Integer result = ++mIdCounter; - mResourceMap.put(result, new String[] { name, type }); - return result; - } - - public Integer getResourceValue(ResourceType type, String name) { - Integer result = ++mIdCounter; - mResourceMap.put(result, new String[] { name, type.getName() }); - return result; - } - @SuppressWarnings("unchecked") public Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs) throws ClassNotFoundException, Exception { @@ -122,11 +111,17 @@ public class ApiDemosRenderingTest extends SdkTestCase { return null; } - public String[] resolveResourceValue(int id) { + public Integer getResourceId(ResourceType type, String name) { + Integer result = ++mIdCounter; + mResourceMap.put(result, Pair.of(type, name)); + return result; + } + + public Pair resolveResourceId(int id) { return mResourceMap.get(id); } - public String resolveResourceValue(int[] id) { + public String resolveResourceId(int[] id) { return null; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/BaseLayoutRuleTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/BaseLayoutRuleTest.java index 8fac515..f914e5f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/BaseLayoutRuleTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/BaseLayoutRuleTest.java @@ -23,7 +23,7 @@ import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.INode; import com.android.ide.common.api.Rect; import com.android.ide.common.layout.BaseLayoutRule.AttributeFilter; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.util.Arrays; import java.util.HashMap; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/RelativeLayoutRuleTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/RelativeLayoutRuleTest.java index 8ccbb25..c0fa548 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/RelativeLayoutRuleTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/RelativeLayoutRuleTest.java @@ -21,7 +21,7 @@ import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; import com.android.ide.common.api.INode; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.util.ArrayList; import java.util.List; diff --git a/eclipse/scripts/create_adt_symlinks.sh b/eclipse/scripts/create_adt_symlinks.sh index 6b70bf4..949362e 100755 --- a/eclipse/scripts/create_adt_symlinks.sh +++ b/eclipse/scripts/create_adt_symlinks.sh @@ -16,7 +16,7 @@ BACK=`echo $DEST | sed 's@[^/]*@..@g'` mkdir -p $DEST -LIBS="sdkstats androidprefs layoutlib_api ide_common ninepatch sdklib sdkuilib resources" +LIBS="sdkstats androidprefs common layoutlib_api ide_common ninepatch sdklib sdkuilib" echo "make java libs ..." make -j3 showcommands $LIBS || die "ADT: Fail to build one of $LIBS." diff --git a/ide_common/.classpath b/ide_common/.classpath index 9d91c20..89ce2dd 100644 --- a/ide_common/.classpath +++ b/ide_common/.classpath @@ -4,6 +4,6 @@ - + diff --git a/ide_common/Android.mk b/ide_common/Android.mk index 2cb3f84..5316703 100644 --- a/ide_common/Android.mk +++ b/ide_common/Android.mk @@ -20,7 +20,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under,src) LOCAL_JAVA_LIBRARIES := \ layoutlib_api \ - resources \ + common \ kxml2-2.3.0 LOCAL_MODULE := ide_common diff --git a/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java b/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java index 6fe7f10..e7ea32e 100644 --- a/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java +++ b/ide_common/src/com/android/ide/common/rendering/LayoutLibrary.java @@ -28,7 +28,7 @@ import com.android.ide.common.rendering.api.Result; import com.android.ide.common.rendering.api.ViewInfo; import com.android.ide.common.rendering.api.Params.RenderingMode; import com.android.ide.common.rendering.api.Result.Status; -import com.android.ide.common.rendering.legacy.ILegacyCallback; +import com.android.ide.common.rendering.legacy.LegacyCallback; import com.android.ide.common.rendering.legacy.ILegacyPullParser; import com.android.ide.common.resources.ResourceResolver; import com.android.ide.common.sdk.LoadStatus; @@ -65,7 +65,7 @@ import java.util.Map.Entry; * For client wanting to access both new and old (pre API level 5) layout libraries, it is * important that the following interfaces be used:
* {@link ILegacyPullParser} instead of {@link ILayoutPullParser}
- * {@link ILegacyCallback} instead of{@link com.android.ide.common.rendering.api.IProjectCallback}. + * {@link LegacyCallback} instead of{@link com.android.ide.common.rendering.api.IProjectCallback}. *

* These interfaces will ensure that both new and older Layout libraries can be accessed. */ diff --git a/ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java b/ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java deleted file mode 100644 index 000c7c5..0000000 --- a/ide_common/src/com/android/ide/common/rendering/legacy/ILegacyCallback.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2010 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.android.ide.common.rendering.legacy; - -import com.android.ide.common.rendering.api.IProjectCallback; - -/** - * Intermediary interface extending both old and new project call back from the layout lib API. - * - * Clients should use this instead of {@link IProjectCallback} to target both old and new - * Layout Libraries. - * - */ -@SuppressWarnings("deprecation") -public interface ILegacyCallback extends com.android.ide.common.rendering.api.IProjectCallback, - com.android.layoutlib.api.IProjectCallback { -} diff --git a/ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java b/ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java new file mode 100644 index 0000000..f4bc15a --- /dev/null +++ b/ide_common/src/com/android/ide/common/rendering/legacy/LegacyCallback.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 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.android.ide.common.rendering.legacy; + +import com.android.ide.common.rendering.api.IProjectCallback; +import com.android.resources.ResourceType; +import com.android.util.Pair; + +/** + * Intermediary class implementing parts of both the old and new project call back from the + * layout lib API. + * + * Clients should use this instead of {@link IProjectCallback} to target both old and new + * Layout Libraries. + * + */ +@SuppressWarnings("deprecation") +public abstract class LegacyCallback implements + com.android.ide.common.rendering.api.IProjectCallback, + com.android.layoutlib.api.IProjectCallback { + + // ------ implementation of the old interface using the new interface. + + public final Integer getResourceValue(String type, String name) { + return getResourceId(ResourceType.getEnum(type), name); + } + + public final String[] resolveResourceValue(int id) { + Pair info = resolveResourceId(id); + return new String[] { info.getSecond(), info.getFirst().getName() }; + } + + public final String resolveResourceValue(int[] id) { + return resolveResourceId(id); + } + + // ------ +} diff --git a/layoutlib_api/.classpath b/layoutlib_api/.classpath index bae87a9..4095535 100644 --- a/layoutlib_api/.classpath +++ b/layoutlib_api/.classpath @@ -3,6 +3,6 @@ - + diff --git a/layoutlib_api/Android.mk b/layoutlib_api/Android.mk index 4ebf1f6..30ce41b 100644 --- a/layoutlib_api/Android.mk +++ b/layoutlib_api/Android.mk @@ -19,7 +19,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-java-files-under,src) LOCAL_JAVA_LIBRARIES := \ - resources \ + common \ kxml2-2.3.0 LOCAL_MODULE := layoutlib_api diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java index aebc5a5..0ec214f 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java @@ -17,6 +17,7 @@ package com.android.ide.common.rendering.api; import com.android.resources.ResourceType; +import com.android.util.Pair; /** * Callback for project information needed by the Layout Library. @@ -49,10 +50,10 @@ public interface IProjectCallback { *

The resource id is the value of a R.<type>.<name>, and * this method will return both the type and name of the resource. * @param id the Id to resolve. - * @return an array of 2 strings containing the resource name and type, or null if the id - * does not match any resource. + * @return a Pair of {@link ResourceType} and resource name, or null if the id + * does not match any resource. */ - String[] resolveResourceValue(int id); + Pair resolveResourceId(int id); /** * Resolves the id of a resource Id of type int[] @@ -61,7 +62,7 @@ public interface IProjectCallback { * @param id the Id to resolve. * @return the name of the resource or null if not found. */ - String resolveResourceValue(int[] id); + String resolveResourceId(int[] id); /** * Returns the id of a resource. @@ -71,6 +72,5 @@ public interface IProjectCallback { * @param name the name of the resource * @return an Integer containing the resource Id, or null if not found. */ - Integer getResourceValue(ResourceType type, String name); - + Integer getResourceId(ResourceType type, String name); } diff --git a/resources/.classpath b/resources/.classpath deleted file mode 100644 index fb50116..0000000 --- a/resources/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/resources/.gitignore b/resources/.gitignore deleted file mode 100644 index fe99505..0000000 --- a/resources/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin - diff --git a/resources/.project b/resources/.project deleted file mode 100644 index 36b452a..0000000 --- a/resources/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - resources - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/resources/Android.mk b/resources/Android.mk deleted file mode 100644 index 5027a01..0000000 --- a/resources/Android.mk +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (C) 2008 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. -# -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under,src) - -LOCAL_JAVA_LIBRARIES := \ - -LOCAL_MODULE := resources - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/resources/README.txt b/resources/README.txt deleted file mode 100644 index 9b90814..0000000 --- a/resources/README.txt +++ /dev/null @@ -1,16 +0,0 @@ -resources.jar contains resource configuration enums. It is used by various tools, but also -by layoutlib.jar - -Layoutlib.jar is built from frameworks/base.git and therefore is versioned with the platform. - -IMPORTANT NOTE REGARDING CHANGES IN resources.jar: - -- The API must stay compatible. This is because while layoutlib.jar compiles against it, - the client provides the implementation and must be able to load earlier versions of layoutlib.jar. - This is true for all the classes under com.android.ide.common.rendering.api and - com.android.layoutlib.api although the latter is obsolete and should not be changed at all. - -- Updated version of layoutlib_api should be copied to the current in-dev branch of - prebuilt/common/resources/resources-prebuilt.jar - The PREBUILT file in the same folder must be updated as well to reflect how to rebuild this - prebuilt jar file. \ No newline at end of file diff --git a/resources/src/com/android/resources/Density.java b/resources/src/com/android/resources/Density.java deleted file mode 100644 index c1d7e3f..0000000 --- a/resources/src/com/android/resources/Density.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - - -/** - * Density enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names - * as well as other places needing to know the density values. - */ -public enum Density implements ResourceEnum { - XHIGH("xhdpi", "X-High Density", 320), //$NON-NLS-1$ - HIGH("hdpi", "High Density", 240), //$NON-NLS-1$ - MEDIUM("mdpi", "Medium Density", 160), //$NON-NLS-1$ - LOW("ldpi", "Low Density", 120), //$NON-NLS-1$ - NODPI("nodpi", "No Density", 0); //$NON-NLS-1$ - - public final static int DEFAULT_DENSITY = 160; - - private final String mValue; - private final String mDisplayValue; - private final int mDensity; - - private Density(String value, String displayValue, int density) { - mValue = value; - mDisplayValue = displayValue; - mDensity = density; - } - - /** - * Returns the enum matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no match was found. - */ - public static Density getEnum(String value) { - for (Density orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - /** - * Returns the enum matching the given density value - * @param value The density value. - * @return the enum for the density value or null if no match was found. - */ - public static Density getEnum(int value) { - for (Density d : values()) { - if (d.mDensity == value) { - return d; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public int getDpiValue() { - return mDensity; - } - - public String getLegacyValue() { - if (this != NODPI) { - return String.format("%1$ddpi", getDpiValue()); - } - - return ""; - } - - public String getShortDisplayValue() { - return mDisplayValue; - } - - public String getLongDisplayValue() { - return mDisplayValue; - } - - public static int getIndex(Density value) { - int i = 0; - for (Density input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static Density getByIndex(int index) { - int i = 0; - for (Density value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return this != NODPI; // nodpi is not a valid config for devices. - } -} diff --git a/resources/src/com/android/resources/DockMode.java b/resources/src/com/android/resources/DockMode.java deleted file mode 100644 index bbae6bf..0000000 --- a/resources/src/com/android/resources/DockMode.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Dock enum. - *

This is used in the resource folder names. - */ -public enum DockMode implements ResourceEnum { - NONE("", "No Dock"), - CAR("car", "Car Dock"), - DESK("desk", "Desk Dock"); - - private final String mValue; - private final String mDisplayValue; - - private DockMode(String value, String display) { - mValue = value; - mDisplayValue = display; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static DockMode getEnum(String value) { - for (DockMode mode : values()) { - if (mode.mValue.equals(value)) { - return mode; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mDisplayValue; - } - - public String getLongDisplayValue() { - return mDisplayValue; - } - - public static int getIndex(DockMode value) { - int i = 0; - for (DockMode mode : values()) { - if (mode == value) { - return i; - } - - i++; - } - - return -1; - } - - public static DockMode getByIndex(int index) { - int i = 0; - for (DockMode value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return this == NONE; // NONE is not a real enum. it's used for internal state only. - } - - public boolean isValidValueForDevice() { - return this != NONE; - } -} diff --git a/resources/src/com/android/resources/Keyboard.java b/resources/src/com/android/resources/Keyboard.java deleted file mode 100644 index eb99f9b..0000000 --- a/resources/src/com/android/resources/Keyboard.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Keyboard enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum Keyboard implements ResourceEnum { - NOKEY("nokeys", null, "No Keys", "No keyboard"), //$NON-NLS-1$ - QWERTY("qwerty", null, "Qwerty", "Qwerty keybard"), //$NON-NLS-1$ - TWELVEKEY("12key", "twelvekey", "12 Key", "12 key keyboard"); //$NON-NLS-1$ //$NON-NLS-2$ - - private final String mValue, mValue2; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private Keyboard(String value, String value2, String shortDisplayValue, - String longDisplayValue) { - mValue = value; - mValue2 = value2; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static Keyboard getEnum(String value) { - for (Keyboard kbrd : values()) { - if (kbrd.mValue.equals(value) || - (kbrd.mValue2 != null && kbrd.mValue2.equals(value))) { - return kbrd; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(Keyboard value) { - int i = 0; - for (Keyboard input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static Keyboard getByIndex(int index) { - int i = 0; - for (Keyboard value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } -} diff --git a/resources/src/com/android/resources/KeyboardState.java b/resources/src/com/android/resources/KeyboardState.java deleted file mode 100644 index e3333f5..0000000 --- a/resources/src/com/android/resources/KeyboardState.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Keyboard state enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum KeyboardState implements ResourceEnum { - EXPOSED("keysexposed", "Exposed", "Exposed keyboard"), //$NON-NLS-1$ - HIDDEN("keyshidden", "Hidden", "Hidden keyboard"), //$NON-NLS-1$ - SOFT("keyssoft", "Soft", "Soft keyboard"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private KeyboardState(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static KeyboardState getEnum(String value) { - for (KeyboardState state : values()) { - if (state.mValue.equals(value)) { - return state; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(KeyboardState value) { - int i = 0; - for (KeyboardState input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static KeyboardState getByIndex(int index) { - int i = 0; - for (KeyboardState value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/resources/src/com/android/resources/Navigation.java b/resources/src/com/android/resources/Navigation.java deleted file mode 100644 index d5d9541..0000000 --- a/resources/src/com/android/resources/Navigation.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Navigation enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum Navigation implements ResourceEnum { - NONAV("nonav", "None", "No navigation"), //$NON-NLS-1$ - DPAD("dpad", "D-pad", "D-pad navigation"), //$NON-NLS-1$ - TRACKBALL("trackball", "Trackball", "Trackball navigation"), //$NON-NLS-1$ - WHEEL("wheel", "Wheel", "Wheel navigation"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private Navigation(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static Navigation getEnum(String value) { - for (Navigation nav : values()) { - if (nav.mValue.equals(value)) { - return nav; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(Navigation value) { - int i = 0; - for (Navigation nav : values()) { - if (nav == value) { - return i; - } - - i++; - } - - return -1; - } - - public static Navigation getByIndex(int index) { - int i = 0; - for (Navigation value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} \ No newline at end of file diff --git a/resources/src/com/android/resources/NavigationState.java b/resources/src/com/android/resources/NavigationState.java deleted file mode 100644 index 266d9da..0000000 --- a/resources/src/com/android/resources/NavigationState.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Navigation state enum. - *

This is used in the resource folder names. - */ -public enum NavigationState implements ResourceEnum { - EXPOSED("navexposed", "Exposed", "Exposed navigation"), //$NON-NLS-1$ - HIDDEN("navhidden", "Hidden", "Hidden navigation"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private NavigationState(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static NavigationState getEnum(String value) { - for (NavigationState state : values()) { - if (state.mValue.equals(value)) { - return state; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(NavigationState value) { - int i = 0; - for (NavigationState input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static NavigationState getByIndex(int index) { - int i = 0; - for (NavigationState value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/resources/src/com/android/resources/NightMode.java b/resources/src/com/android/resources/NightMode.java deleted file mode 100644 index 2d64316..0000000 --- a/resources/src/com/android/resources/NightMode.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Night enum. - *

This is used in the resource folder names. - */ -public enum NightMode implements ResourceEnum { - NOTNIGHT("notnight", "Not Night", "Day time"), - NIGHT("night", "Night", "Night time"); - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private NightMode(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static NightMode getEnum(String value) { - for (NightMode mode : values()) { - if (mode.mValue.equals(value)) { - return mode; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(NightMode value) { - int i = 0; - for (NightMode mode : values()) { - if (mode == value) { - return i; - } - - i++; - } - - return -1; - } - - public static NightMode getByIndex(int index) { - int i = 0; - for (NightMode value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/resources/src/com/android/resources/ResourceEnum.java b/resources/src/com/android/resources/ResourceEnum.java deleted file mode 100644 index 7f4e16a..0000000 --- a/resources/src/com/android/resources/ResourceEnum.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * An enum representing a resource qualifier value. - */ -public interface ResourceEnum { - - /** - * Returns the resource string. This is to be used in resource folder names. - */ - String getResourceValue(); - - /** - * Whether the value actually used on device. This returns true only if a device can report - * this value, false if it's just used to qualify resources. - */ - boolean isValidValueForDevice(); - - /** - * Whether the value is neither used for device nor resources. This returns false when - * the value is only used for internal usage in the custom editors. - */ - boolean isFakeValue(); - - /** - * Returns a short string for display value. The string does not need to show the context. - *

For instance "exposed", which can be the value for the keyboard state or the navigation - * state, would be valid since something else in the UI is expected to show if this is about the - * keyboard or the navigation state. - * - * @see #getLongDisplayValue() - */ - String getShortDisplayValue(); - - /** - * Returns a long string for display value. This must not only include the enum value but - * context (qualifier) about what the value represents. - *

For instance "Exposed keyboard", and "Export navigation", as "exposed" would not be - * enough to know what qualifier the value is about. - * - * @see #getShortDisplayValue() - */ - String getLongDisplayValue(); -} diff --git a/resources/src/com/android/resources/ResourceType.java b/resources/src/com/android/resources/ResourceType.java deleted file mode 100644 index f5f7063..0000000 --- a/resources/src/com/android/resources/ResourceType.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.resources; - - -/** - * Enum representing a type of compiled resource. - */ -public enum ResourceType { - ANIM("anim", "Animation"), //$NON-NLS-1$ - ANIMATOR("animator", "Animator"), //$NON-NLS-1$ - ARRAY("array", "Array", "string-array", "integer-array"), //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$ - ATTR("attr", "Attr"), //$NON-NLS-1$ - BOOL("bool", "Boolean"), //$NON-NLS-1$ - COLOR("color", "Color"), //$NON-NLS-1$ - DECLARE_STYLEABLE("declare-styleable", "Declare Stylable"), //$NON-NLS-1$ - DIMEN("dimen", "Dimension"), //$NON-NLS-1$ - DRAWABLE("drawable", "Drawable"), //$NON-NLS-1$ - FRACTION("fraction", "Fraction"), //$NON-NLS-1$ - ID("id", "ID"), //$NON-NLS-1$ - INTEGER("integer", "Integer"), //$NON-NLS-1$ - INTERPOLATOR("interpolator", "Interpolator"), //$NON-NLS-1$ - LAYOUT("layout", "Layout"), //$NON-NLS-1$ - MENU("menu", "Menu"), //$NON-NLS-1$ - PLURALS("plurals", "Plurals"), //$NON-NLS-1$ - RAW("raw", "Raw"), //$NON-NLS-1$ - STRING("string", "String"), //$NON-NLS-1$ - STYLE("style", "Style"), //$NON-NLS-1$ - STYLEABLE("styleable", "Styleable"), //$NON-NLS-1$ - XML("xml", "XML"), //$NON-NLS-1$ - // this is not actually used. Only there because they get parsed and since we want to - // detect new resource type, we need to have this one exist. - PUBLIC("public", "###"); //$NON-NLS-1$ //$NON-NLS-2$ - - private final String mName; - private final String mDisplayName; - private final String[] mAlternateXmlNames; - - ResourceType(String name, String displayName, String... alternateXmlNames) { - mName = name; - mDisplayName = displayName; - mAlternateXmlNames = alternateXmlNames; - } - - /** - * Returns the resource type name, as used by XML files. - */ - public String getName() { - return mName; - } - - /** - * Returns a translated display name for the resource type. - */ - public String getDisplayName() { - return mDisplayName; - } - - /** - * Returns the enum by its name as it appears in the XML or the R class. - * @param name name of the resource - * @return the matching {@link ResourceType} or null if no match was found. - */ - public static ResourceType getEnum(String name) { - for (ResourceType rType : values()) { - if (rType.mName.equals(name)) { - return rType; - } else if (rType.mAlternateXmlNames != null) { - // if there are alternate Xml Names, we test those too - for (String alternate : rType.mAlternateXmlNames) { - if (alternate.equals(name)) { - return rType; - } - } - } - } - return null; - } - - /** - * Returns an array with all the names defined by this enum. - */ - public static String[] getNames() { - ResourceType[] values = values(); - String[] names = new String[values.length]; - for (int i = values.length - 1; i >= 0; --i) { - names[i] = values[i].getName(); - } - return names; - } - - @Override - public String toString() { - return getName(); - } -} diff --git a/resources/src/com/android/resources/ScreenOrientation.java b/resources/src/com/android/resources/ScreenOrientation.java deleted file mode 100644 index 56f907b..0000000 --- a/resources/src/com/android/resources/ScreenOrientation.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Screen Orientation enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum ScreenOrientation implements ResourceEnum { - PORTRAIT("port", "Portrait", "Portrait Orientation"), //$NON-NLS-1$ - LANDSCAPE("land", "Landscape", "Landscape Orientation"), //$NON-NLS-1$ - SQUARE("square", "Square", "Square Orientation"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private ScreenOrientation(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static ScreenOrientation getEnum(String value) { - for (ScreenOrientation orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(ScreenOrientation orientation) { - int i = 0; - for (ScreenOrientation orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static ScreenOrientation getByIndex(int index) { - int i = 0; - for (ScreenOrientation orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/resources/src/com/android/resources/ScreenRatio.java b/resources/src/com/android/resources/ScreenRatio.java deleted file mode 100644 index 2794b6e..0000000 --- a/resources/src/com/android/resources/ScreenRatio.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Screen Ratio enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum ScreenRatio implements ResourceEnum { - NOTLONG("notlong", "Not Long", "Short screen aspect ratio"), //$NON-NLS-1$ - LONG("long", "Long", "Long screen aspect ratio"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private ScreenRatio(String value, String displayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = displayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static ScreenRatio getEnum(String value) { - for (ScreenRatio orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(ScreenRatio orientation) { - int i = 0; - for (ScreenRatio orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static ScreenRatio getByIndex(int index) { - int i = 0; - for (ScreenRatio orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} - diff --git a/resources/src/com/android/resources/ScreenSize.java b/resources/src/com/android/resources/ScreenSize.java deleted file mode 100644 index b6ffc50..0000000 --- a/resources/src/com/android/resources/ScreenSize.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Screen size enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum ScreenSize implements ResourceEnum { - SMALL("small", "Small", "Small Screen"), //$NON-NLS-1$ - NORMAL("normal", "Normal", "Normal Screen"), //$NON-NLS-1$ - LARGE("large", "Large", "Large Screen"), //$NON-NLS-1$ - XLARGE("xlarge", "X-Large", "Extra Large Screen"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private ScreenSize(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static ScreenSize getEnum(String value) { - for (ScreenSize orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(ScreenSize orientation) { - int i = 0; - for (ScreenSize orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static ScreenSize getByIndex(int index) { - int i = 0; - for (ScreenSize orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/resources/src/com/android/resources/TouchScreen.java b/resources/src/com/android/resources/TouchScreen.java deleted file mode 100644 index 7ee1f0f..0000000 --- a/resources/src/com/android/resources/TouchScreen.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2010 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.android.resources; - -/** - * Touch screen enum. - *

This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum TouchScreen implements ResourceEnum { - NOTOUCH("notouch", "No Touch", "No-touch screen"), //$NON-NLS-1$ - STYLUS("stylus", "Stylus", "Stylus-based touchscreen"), //$NON-NLS-1$ - FINGER("finger", "Finger", "Finger-based touchscreen"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private TouchScreen(String value, String displayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = displayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static TouchScreen getEnum(String value) { - for (TouchScreen orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - public String getResourceValue() { - return mValue; - } - - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(TouchScreen touch) { - int i = 0; - for (TouchScreen t : values()) { - if (t == touch) { - return i; - } - - i++; - } - - return -1; - } - - public static TouchScreen getByIndex(int index) { - int i = 0; - for (TouchScreen value : values()) { - if (i == index) { - return value; - } - i++; - } - - return null; - } - - public boolean isFakeValue() { - return false; - } - - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/sdkmanager/app/etc/manifest.txt b/sdkmanager/app/etc/manifest.txt index 50f3e66..51845c7 100644 --- a/sdkmanager/app/etc/manifest.txt +++ b/sdkmanager/app/etc/manifest.txt @@ -1,2 +1,2 @@ Main-Class: com.android.sdkmanager.Main -Class-Path: androidprefs.jar resources.jar sdklib.jar sdkuilib.jar org.eclipse.jface_3.4.2.M20090107-0800.jar org.eclipse.equinox.common_3.4.0.v20080421-2006.jar org.eclipse.core.commands_3.4.0.I20080509-2000.jar +Class-Path: androidprefs.jar common.jar sdklib.jar sdkuilib.jar org.eclipse.jface_3.4.2.M20090107-0800.jar org.eclipse.equinox.common_3.4.0.v20080421-2006.jar org.eclipse.core.commands_3.4.0.I20080509-2000.jar diff --git a/sdkmanager/libs/sdklib/.classpath b/sdkmanager/libs/sdklib/.classpath index b3528a4..174a804 100644 --- a/sdkmanager/libs/sdklib/.classpath +++ b/sdkmanager/libs/sdklib/.classpath @@ -6,6 +6,6 @@ - + diff --git a/sdkmanager/libs/sdklib/src/Android.mk b/sdkmanager/libs/sdklib/src/Android.mk index 3c91e88..37eda21 100644 --- a/sdkmanager/libs/sdklib/src/Android.mk +++ b/sdkmanager/libs/sdklib/src/Android.mk @@ -21,7 +21,7 @@ LOCAL_JAVA_RESOURCE_DIRS := . LOCAL_JAR_MANIFEST := ../manifest.txt LOCAL_JAVA_LIBRARIES := \ androidprefs \ - resources \ + common \ commons-compress-1.0 LOCAL_MODULE := sdklib diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java index 2920674..767e582 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java @@ -21,7 +21,7 @@ import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.sdklib.AndroidVersion.AndroidVersionException; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.io.FileWrapper; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.io.File; import java.io.FileInputStream; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/Nullable.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/Nullable.java deleted file mode 100755 index 3b5e955..0000000 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/Nullable.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.sdklib.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Denotes a parameter or field can be null. - *

- * When decorating a method call parameter, this denotes the parameter can - * legitimately be null and the method will gracefully deal with it. Typically used - * on optional parameters. - *

- * When decorating a method, this denotes the method might legitimately return null. - *

- * This is a marker annotation and it has no specific attributes. - */ -@Retention(RetentionPolicy.SOURCE) -public @interface Nullable { -} diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/VisibleForTesting.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/VisibleForTesting.java deleted file mode 100755 index 86d1c99..0000000 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/annotations/VisibleForTesting.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.sdklib.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Denotes that the class, method or field has its visibility relaxed so - * that unit tests can access it. - *

- * The visibility argument can be used to specific what the original - * visibility should have been if it had not been made public or package-private for testing. - * The default is to consider the element private. - */ -@Retention(RetentionPolicy.SOURCE) -public @interface VisibleForTesting { - /** - * Intended visibility if the element had not been made public or package-private for - * testing. - */ - enum Visibility { - /** The element should be considered protected. */ - PROTECTED, - /** The element should be considered package-private. */ - PACKAGE, - /** The element should be considered private. */ - PRIVATE - } - - /** - * Intended visibility if the element had not been made public or package-private for testing. - * If not specified, one should assume the element originally intended to be private. - */ - Visibility visibility() default Visibility.PRIVATE; -} diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java index ab27561..9a90b2c 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java @@ -16,13 +16,13 @@ package com.android.sdklib.internal.repository; +import com.android.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting.Visibility; import com.android.sdklib.AndroidVersion; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; import com.android.sdklib.SdkManager; import com.android.sdklib.IAndroidTarget.IOptionalLibrary; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.annotations.VisibleForTesting.Visibility; import com.android.sdklib.internal.repository.Archive.Arch; import com.android.sdklib.internal.repository.Archive.Os; import com.android.sdklib.repository.SdkRepoConstants; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java index fcef972..9b8d808 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java @@ -16,8 +16,8 @@ package com.android.sdklib.internal.repository; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.annotations.VisibleForTesting.Visibility; +import com.android.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting.Visibility; import com.android.sdklib.repository.SdkAddonsListConstants; import org.w3c.dom.Document; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java index e0a6b21..9a2bf46 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java @@ -22,7 +22,7 @@ import com.android.sdklib.SdkConstants; import com.android.sdklib.SdkManager; import com.android.sdklib.internal.repository.Archive.Arch; import com.android.sdklib.internal.repository.Archive.Os; -import com.android.sdklib.util.Pair; +import com.android.util.Pair; import java.io.File; import java.io.FileInputStream; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java index b8a8623..8dee635 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java @@ -16,12 +16,12 @@ package com.android.sdklib.internal.repository; +import com.android.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting.Visibility; import com.android.sdklib.AndroidVersion; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; import com.android.sdklib.SdkManager; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.annotations.VisibleForTesting.Visibility; import com.android.sdklib.internal.repository.Archive.Arch; import com.android.sdklib.internal.repository.Archive.Os; import com.android.sdklib.repository.SdkRepoConstants; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformToolPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformToolPackage.java index c31325f..860d703 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformToolPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformToolPackage.java @@ -16,10 +16,10 @@ package com.android.sdklib.internal.repository; +import com.android.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting.Visibility; import com.android.sdklib.SdkConstants; import com.android.sdklib.SdkManager; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.annotations.VisibleForTesting.Visibility; import com.android.sdklib.internal.repository.Archive.Arch; import com.android.sdklib.internal.repository.Archive.Os; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkAddonSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkAddonSource.java index 049dad8..b79cc90 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkAddonSource.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkAddonSource.java @@ -16,7 +16,7 @@ package com.android.sdklib.internal.repository; -import com.android.sdklib.annotations.Nullable; +import com.android.annotations.Nullable; import com.android.sdklib.repository.SdkAddonConstants; import org.w3c.dom.Document; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkRepoSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkRepoSource.java index 9b63be3..43e49e3 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkRepoSource.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkRepoSource.java @@ -16,7 +16,7 @@ package com.android.sdklib.internal.repository; -import com.android.sdklib.annotations.Nullable; +import com.android.annotations.Nullable; import com.android.sdklib.internal.repository.Archive.Arch; import com.android.sdklib.internal.repository.Archive.Os; import com.android.sdklib.repository.RepoConstants; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java index 2a917a1..77eb981 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java @@ -16,9 +16,9 @@ package com.android.sdklib.internal.repository; -import com.android.sdklib.annotations.Nullable; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.annotations.VisibleForTesting.Visibility; +import com.android.annotations.Nullable; +import com.android.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting.Visibility; import com.android.sdklib.repository.RepoConstants; import com.android.sdklib.repository.SdkAddonConstants; import com.android.sdklib.repository.SdkRepoConstants; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ToolPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ToolPackage.java index 73ddc24..6e53dd7 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ToolPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ToolPackage.java @@ -16,10 +16,10 @@ package com.android.sdklib.internal.repository; +import com.android.annotations.VisibleForTesting; +import com.android.annotations.VisibleForTesting.Visibility; import com.android.sdklib.SdkConstants; import com.android.sdklib.SdkManager; -import com.android.sdklib.annotations.VisibleForTesting; -import com.android.sdklib.annotations.VisibleForTesting.Visibility; import com.android.sdklib.internal.repository.Archive.Arch; import com.android.sdklib.internal.repository.Archive.Os; import com.android.sdklib.repository.SdkRepoConstants; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/util/Pair.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/util/Pair.java deleted file mode 100644 index e07381c..0000000 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/util/Pair.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2010 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.android.sdklib.util; - -/** - * A Pair class is simply a 2-tuple for use in this package. We might want to - * think about adding something like this to a more central utility place, or - * replace it by a common tuple class if one exists, or even rewrite the layout - * classes using this Pair by a more dedicated data structure (so we don't have - * to pass around generic signatures as is currently done, though at least the - * construction is helped a bit by the {@link #of} factory method. - * - * @param The type of the first value - * @param The type of the second value - */ -public class Pair { - private final S mFirst; - private final T mSecond; - - // Use {@link Pair#of} factory instead since it infers generic types - private Pair(S first, T second) { - this.mFirst = first; - this.mSecond = second; - } - - /** - * Return the first item in the pair - * - * @return the first item in the pair - */ - public S getFirst() { - return mFirst; - } - - /** - * Return the second item in the pair - * - * @return the second item in the pair - */ - public T getSecond() { - return mSecond; - } - - /** - * Constructs a new pair of the given two objects, inferring generic types. - * - * @param first the first item to store in the pair - * @param second the second item to store in the pair - * @param the type of the first item - * @param the type of the second item - * @return a new pair wrapping the two items - */ - public static Pair of(S first, T second) { - return new Pair(first,second); - } - - @Override - public String toString() { - return "Pair [first=" + mFirst + ", second=" + mSecond + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((mFirst == null) ? 0 : mFirst.hashCode()); - result = prime * result + ((mSecond == null) ? 0 : mSecond.hashCode()); - return result; - } - - @SuppressWarnings("unchecked") - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Pair other = (Pair) obj; - if (mFirst == null) { - if (other.mFirst != null) - return false; - } else if (!mFirst.equals(other.mFirst)) - return false; - if (mSecond == null) { - if (other.mSecond != null) - return false; - } else if (!mSecond.equals(other.mSecond)) - return false; - return true; - } -} -- cgit v1.1