aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs
diff options
context:
space:
mode:
Diffstat (limited to 'sdkmanager/libs')
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java33
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategorySource.java13
2 files changed, 46 insertions, 0 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
index e72c128..fde9b90 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
@@ -268,6 +268,8 @@ class PackagesDiffLogic {
/** Creates the category for the given key and returns it. */
public abstract PkgCategory createCategory(Object catKey);
+ /** Adjust attributes of an existing category. */
+ public abstract void adjustCategory(PkgCategory cat, Object catKey);
/** Sorts the category list (but not the items within the categories.) */
public abstract void sortCategoryList();
@@ -565,6 +567,9 @@ class PackagesDiffLogic {
cats.add(cat);
}
op.sortCategoryList();
+ } else {
+ // Not a new category. Give op a chance to adjust the category attributes
+ op.adjustCategory(cat, catKey);
}
PkgItem item = new PkgItem(pkg, state);
@@ -677,6 +682,11 @@ class PackagesDiffLogic {
}
@Override
+ public void adjustCategory(PkgCategory cat, Object catKey) {
+ // Pass. Nothing to do for API-sorted categories
+ }
+
+ @Override
public void sortCategoryList() {
// Sort the categories list.
// We always want categories in order tools..platforms..extras.
@@ -767,12 +777,35 @@ class PackagesDiffLogic {
}
}
+ /**
+ * Create a new source category.
+ * <p/>
+ * One issue is that local archives are processed first and we don't have the
+ * full source information on them (e.g. we know the referral URL but not
+ * the referral name of the site).
+ * In this case this will just create {@link PkgCategorySource} where the label isn't
+ * known yet.
+ */
@Override
public PkgCategory createCategory(Object catKey) {
assert catKey instanceof SdkSource;
PkgCategory cat = new PkgCategorySource((SdkSource) catKey, mUpdaterData);
return cat;
+ }
+ /**
+ * Checks whether the category needs to be adjust.
+ * As mentioned in {@link #createCategory(Object)}, local archives are processed
+ * first and result in a {@link PkgCategorySource} where the label isn't known.
+ * Once we process the external source with the actual name, we'll update it.
+ */
+ @Override
+ public void adjustCategory(PkgCategory cat, Object catKey) {
+ assert cat instanceof PkgCategorySource;
+ assert catKey instanceof SdkSource;
+ if (cat instanceof PkgCategorySource) {
+ ((PkgCategorySource) cat).adjustLabel((SdkSource) catKey);
+ }
}
@Override
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategorySource.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategorySource.java
index bc37ff7..5b589d0 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategorySource.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategorySource.java
@@ -31,6 +31,11 @@ class PkgCategorySource extends PkgCategory {
new SdkRepoSource("http://no.source", "Local Packages");
private final SdkSource mSource;
+ /**
+ * Creates a new {@link PkgCategorySource}.
+ * This uses {@link SdkSource#toString()} to get the source's description.
+ * Note that if the name of the source isn't known, the description will use its URL.
+ */
public PkgCategorySource(SdkSource source, UpdaterData updaterData) {
super(
source, // the source is the key and it can be null
@@ -52,4 +57,12 @@ class PkgCategorySource extends PkgCategory {
public SdkSource getSource() {
return mSource;
}
+
+ /** Sets the label to match the source's UI name if the label wasn't already set. */
+ public void adjustLabel(SdkSource source) {
+ if (getLabel() == null || getLabel().startsWith("http")) { //$NON-NLS-1$
+ setLabel(source == UNKNOWN_SOURCE ? "Local Packages" : source.toString());
+ }
+ }
+
}