diff options
2 files changed, 50 insertions, 26 deletions
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 a784b34..56bf492 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 @@ -577,6 +577,17 @@ public class AddonPackage extends Package String name = displayName.toLowerCase(Locale.US);
name = name.replaceAll("[^a-z0-9_-]+", "_"); //$NON-NLS-1$ //$NON-NLS-2$
name = name.replaceAll("_+", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // NOTE: ideally we would want to trim leading and trailing _ but in fact
+ // this MUST NOT be done, otherwise it will break <vendor-id> tags that were
+ // auto converted from the old <vendor> tag when switching from the addon
+ // schema v3 to v4.
+ // if (name.length() > 1) {
+ // name = name.replaceAll("^_+", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ // }
+ // if (name.length() > 1) {
+ // name = name.replaceAll("_+$", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ // }
return name;
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java index d3dc7b6..d6eb73e 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java @@ -1560,42 +1560,55 @@ public class PackagesPage extends UpdaterPage @Override public String getToolTipText(Object element) { - if (element instanceof PkgItem) { - element = ((PkgItem) element).getMainPackage(); + PkgItem pi = element instanceof PkgItem ? (PkgItem) element : null; + if (pi != null) { + element = pi.getMainPackage(); } if (element instanceof IDescription) { - String s = ((IDescription) element).getLongDescription(); - if (element instanceof Package) { - Package p = (Package) element; + String s = getTooltipDescription((IDescription) element); - if (!p.isLocal()) { - // For non-installed item, try to find a download size - for (Archive a : p.getArchives()) { - if (!a.isLocal() && a.isCompatible()) { - s += '\n' + a.getSizeDescription(); - break; - } + if (pi != null && pi.hasUpdatePkg()) { + s += "\n-----------------" + //$NON-NLS-1$ + "\nUpdate Available:\n" + //$NON-NLS-1$ + getTooltipDescription(pi.getUpdatePkg()); + } + + return s; + } + return super.getToolTipText(element); + } + + private String getTooltipDescription(IDescription element) { + String s = element.getLongDescription(); + if (element instanceof Package) { + Package p = (Package) element; + + if (!p.isLocal()) { + // For non-installed item, try to find a download size + for (Archive a : p.getArchives()) { + if (!a.isLocal() && a.isCompatible()) { + s += '\n' + a.getSizeDescription(); + break; } } + } - // Display info about where this package comes/came from - SdkSource src = p.getParentSource(); - if (src != null) { - try { - URL url = new URL(src.getUrl()); - String host = url.getHost(); - if (p.isLocal()) { - s += String.format("\nInstalled from %1$s", host); - } else { - s += String.format("\nProvided by %1$s", host); - } - } catch (MalformedURLException ignore) { + // Display info about where this package comes/came from + SdkSource src = p.getParentSource(); + if (src != null) { + try { + URL url = new URL(src.getUrl()); + String host = url.getHost(); + if (p.isLocal()) { + s += String.format("\nInstalled from %1$s", host); + } else { + s += String.format("\nProvided by %1$s", host); } + } catch (MalformedURLException ignore) { } } - return s; } - return super.getToolTipText(element); + return s; } @Override |