Move from arbitrary resource filters to fix ones
Resource filters are used when generating additional APK containing only specific resources. The previous UI allowed for any type of filters, but we are moving to a simpler way with fixed filters. The first one is the density. Selecting the filter will generate 4 APKs per application: default (all resources), hdpi (only hdpi/nodpi and default resources), mdpi, ldpi.
This commit is contained in:
@@ -34,6 +34,7 @@ import com.android.jarutils.SignedJarBuilder.IZipEntryFilter;
|
||||
import com.android.prefs.AndroidLocation.AndroidLocationException;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.internal.project.ApkSettings;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
@@ -303,11 +304,15 @@ public class ApkBuilder extends BaseBuilder {
|
||||
return referencedProjects;
|
||||
}
|
||||
|
||||
// get the extra configs for the project.
|
||||
// The map contains (name, filter) where 'name' is a name to be used in the apk filename,
|
||||
// and filter is the resource filter to be used in the aapt -c parameters to restrict
|
||||
// which resource configurations to package in the apk.
|
||||
Map<String, String> configs = Sdk.getCurrent().getProjectApkConfigs(project);
|
||||
// get the APK configs for the project.
|
||||
ApkSettings apkSettings = Sdk.getCurrent().getApkSettings(project);
|
||||
Set<Entry<String, String>> apkfilters = null;
|
||||
if (apkSettings != null) {
|
||||
Map<String, String> filterMap = apkSettings.getResourceFilters();
|
||||
if (filterMap != null && filterMap.size() > 0) {
|
||||
apkfilters = filterMap.entrySet();
|
||||
}
|
||||
}
|
||||
|
||||
// do some extra check, in case the output files are not present. This
|
||||
// will force to recreate them.
|
||||
@@ -320,19 +325,20 @@ public class ApkBuilder extends BaseBuilder {
|
||||
mPackageResources = true;
|
||||
mBuildFinalPackage = true;
|
||||
} else {
|
||||
// if the full package is present, we check the filtered resource packages as well
|
||||
if (configs != null) {
|
||||
Set<Entry<String, String>> entrySet = configs.entrySet();
|
||||
|
||||
for (Entry<String, String> entry : entrySet) {
|
||||
// if the full package is present, we check the filtered resource packages
|
||||
// as well
|
||||
if (apkfilters != null) {
|
||||
for (Entry<String, String> entry : apkfilters) {
|
||||
String filename = String.format(AndroidConstants.FN_RESOURCES_S_AP_,
|
||||
entry.getKey());
|
||||
|
||||
tmp = outputFolder.findMember(filename);
|
||||
if (tmp == null || (tmp instanceof IFile &&
|
||||
tmp.exists() == false)) {
|
||||
String msg = String.format(Messages.s_Missing_Repackaging, filename);
|
||||
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE, project, msg);
|
||||
String msg = String.format(Messages.s_Missing_Repackaging,
|
||||
filename);
|
||||
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE,
|
||||
project, msg);
|
||||
mPackageResources = true;
|
||||
mBuildFinalPackage = true;
|
||||
break;
|
||||
@@ -360,11 +366,9 @@ public class ApkBuilder extends BaseBuilder {
|
||||
String msg = String.format(Messages.s_Missing_Repackaging, finalPackageName);
|
||||
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE, project, msg);
|
||||
mBuildFinalPackage = true;
|
||||
} else if (configs != null) {
|
||||
} else if (apkfilters != null) {
|
||||
// if the full apk is present, we check the filtered apk as well
|
||||
Set<Entry<String, String>> entrySet = configs.entrySet();
|
||||
|
||||
for (Entry<String, String> entry : entrySet) {
|
||||
for (Entry<String, String> entry : apkfilters) {
|
||||
String filename = ProjectHelper.getApkFilename(project, entry.getKey());
|
||||
|
||||
tmp = outputFolder.findMember(filename);
|
||||
@@ -411,9 +415,8 @@ public class ApkBuilder extends BaseBuilder {
|
||||
// notified.
|
||||
finalPackage.delete();
|
||||
|
||||
if (configs != null) {
|
||||
Set<Entry<String, String>> entrySet = configs.entrySet();
|
||||
for (Entry<String, String> entry : entrySet) {
|
||||
if (apkfilters != null) {
|
||||
for (Entry<String, String> entry : apkfilters) {
|
||||
String packageFilepath = osBinPath + File.separator +
|
||||
ProjectHelper.getApkFilename(project, entry.getKey());
|
||||
|
||||
@@ -477,9 +480,8 @@ public class ApkBuilder extends BaseBuilder {
|
||||
}
|
||||
|
||||
// now do the same thing for all the configured resource packages.
|
||||
if (configs != null) {
|
||||
Set<Entry<String, String>> entrySet = configs.entrySet();
|
||||
for (Entry<String, String> entry : entrySet) {
|
||||
if (apkfilters != null) {
|
||||
for (Entry<String, String> entry : apkfilters) {
|
||||
String outPathFormat = osBinPath + File.separator +
|
||||
AndroidConstants.FN_RESOURCES_S_AP_;
|
||||
String outPath = String.format(outPathFormat, entry.getKey());
|
||||
@@ -527,12 +529,11 @@ public class ApkBuilder extends BaseBuilder {
|
||||
}
|
||||
|
||||
// now do the same thing for all the configured resource packages.
|
||||
if (configs != null) {
|
||||
if (apkfilters != null) {
|
||||
String resPathFormat = osBinPath + File.separator +
|
||||
AndroidConstants.FN_RESOURCES_S_AP_;
|
||||
|
||||
Set<Entry<String, String>> entrySet = configs.entrySet();
|
||||
for (Entry<String, String> entry : entrySet) {
|
||||
for (Entry<String, String> entry : apkfilters) {
|
||||
// make the filename for the resource package.
|
||||
String resPath = String.format(resPathFormat, entry.getKey());
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.properties;
|
||||
|
||||
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdkuilib.internal.widgets.ApkConfigWidget;
|
||||
import com.android.sdklib.internal.project.ApkSettings;
|
||||
import com.android.sdkuilib.internal.widgets.SdkTargetSelector;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -27,14 +27,14 @@ import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||
import org.eclipse.ui.dialogs.PropertyPage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Property page for "Android" project.
|
||||
* This is accessible from the Package Explorer when right clicking a project and choosing
|
||||
@@ -45,7 +45,7 @@ public class AndroidPropertyPage extends PropertyPage implements IWorkbenchPrope
|
||||
|
||||
private IProject mProject;
|
||||
private SdkTargetSelector mSelector;
|
||||
private ApkConfigWidget mApkConfigWidget;
|
||||
private Button mSplitByDensity;
|
||||
|
||||
public AndroidPropertyPage() {
|
||||
// pass
|
||||
@@ -72,13 +72,13 @@ public class AndroidPropertyPage extends PropertyPage implements IWorkbenchPrope
|
||||
|
||||
mSelector = new SdkTargetSelector(top, targets);
|
||||
|
||||
l = new Label(top, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Group g = new Group(top, SWT.NONE);
|
||||
g.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
g.setLayout(new GridLayout(1, false));
|
||||
g.setText("APK Generation");
|
||||
|
||||
l = new Label(top, SWT.NONE);
|
||||
l.setText("Project APK Configurations");
|
||||
|
||||
mApkConfigWidget = new ApkConfigWidget(top);
|
||||
mSplitByDensity = new Button(g, SWT.CHECK);
|
||||
mSplitByDensity.setText("One APK per density");
|
||||
|
||||
// fill the ui
|
||||
Sdk currentSdk = Sdk.getCurrent();
|
||||
@@ -89,9 +89,9 @@ public class AndroidPropertyPage extends PropertyPage implements IWorkbenchPrope
|
||||
mSelector.setSelection(target);
|
||||
}
|
||||
|
||||
// get the apk configurations
|
||||
Map<String, String> configs = currentSdk.getProjectApkConfigs(mProject);
|
||||
mApkConfigWidget.fillTable(configs);
|
||||
// get the project settings
|
||||
ApkSettings settings = currentSdk.getApkSettings(mProject);
|
||||
mSplitByDensity.setSelection(settings.isSplitByDpi());
|
||||
}
|
||||
|
||||
mSelector.setSelectionListener(new SelectionAdapter() {
|
||||
@@ -114,8 +114,10 @@ public class AndroidPropertyPage extends PropertyPage implements IWorkbenchPrope
|
||||
public boolean performOk() {
|
||||
Sdk currentSdk = Sdk.getCurrent();
|
||||
if (currentSdk != null) {
|
||||
currentSdk.setProject(mProject, mSelector.getSelected(),
|
||||
mApkConfigWidget.getApkConfigs());
|
||||
ApkSettings apkSettings = new ApkSettings();
|
||||
apkSettings.setSplitByDensity(mSplitByDensity.getSelection());
|
||||
|
||||
currentSdk.setProject(mProject, mSelector.getSelected(), apkSettings);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.SdkManager;
|
||||
import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.android.sdklib.internal.project.ApkConfigurationHelper;
|
||||
import com.android.sdklib.internal.project.ApkSettings;
|
||||
import com.android.sdklib.internal.project.ProjectProperties;
|
||||
import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
|
||||
|
||||
@@ -68,8 +69,8 @@ public class Sdk implements IProjectListener {
|
||||
new HashMap<IProject, IAndroidTarget>();
|
||||
private final HashMap<IAndroidTarget, AndroidTargetData> mTargetDataMap =
|
||||
new HashMap<IAndroidTarget, AndroidTargetData>();
|
||||
private final HashMap<IProject, Map<String, String>> mProjectApkConfigMap =
|
||||
new HashMap<IProject, Map<String, String>>();
|
||||
private final HashMap<IProject, ApkSettings> mApkSettingsMap =
|
||||
new HashMap<IProject, ApkSettings>();
|
||||
private final String mDocBaseUrl;
|
||||
|
||||
/**
|
||||
@@ -193,11 +194,9 @@ public class Sdk implements IProjectListener {
|
||||
* apk configurations should not be updated.
|
||||
*/
|
||||
public void setProject(IProject project, IAndroidTarget target,
|
||||
Map<String, String> apkConfigMap) {
|
||||
ApkSettings settings) {
|
||||
synchronized (AdtPlugin.getDefault().getSdkLockObject()) {
|
||||
boolean resolveProject = false;
|
||||
boolean compileProject = false;
|
||||
boolean cleanProject = false;
|
||||
|
||||
ProjectProperties properties = ProjectProperties.load(
|
||||
project.getLocation().toOSString(), PropertyType.DEFAULT);
|
||||
@@ -222,16 +221,18 @@ public class Sdk implements IProjectListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (apkConfigMap != null) {
|
||||
// save the apk configs in the project persistent property
|
||||
cleanProject = ApkConfigurationHelper.setConfigs(properties, apkConfigMap);
|
||||
|
||||
// put it in a local map for easy access.
|
||||
mProjectApkConfigMap.put(project, apkConfigMap);
|
||||
|
||||
compileProject = true;
|
||||
// if there's no settings, force default values (to reset possibly changed
|
||||
// values in a previous call.
|
||||
if (settings == null) {
|
||||
settings = new ApkSettings();
|
||||
}
|
||||
|
||||
// save the project settings into the project persistent property
|
||||
ApkConfigurationHelper.setProperties(properties, settings);
|
||||
|
||||
// put it in a local map for easy access.
|
||||
mApkSettingsMap.put(project, settings);
|
||||
|
||||
// we are done with the modification. Save the property file.
|
||||
try {
|
||||
properties.save();
|
||||
@@ -242,17 +243,14 @@ public class Sdk implements IProjectListener {
|
||||
|
||||
if (resolveProject) {
|
||||
// force a resolve of the project by updating the classpath container.
|
||||
// This will also force a recompile.
|
||||
IJavaProject javaProject = JavaCore.create(project);
|
||||
AndroidClasspathContainerInitializer.updateProjects(
|
||||
new IJavaProject[] { javaProject });
|
||||
} else if (compileProject) {
|
||||
// If there was removed configs, we clean instead of build
|
||||
// (to remove the obsolete ap_ and apk file from removed configs).
|
||||
} else {
|
||||
// always do a full clean/build.
|
||||
try {
|
||||
project.build(cleanProject ?
|
||||
IncrementalProjectBuilder.CLEAN_BUILD :
|
||||
IncrementalProjectBuilder.FULL_BUILD,
|
||||
null);
|
||||
project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
|
||||
} catch (CoreException e) {
|
||||
// failed to build? force resolve instead.
|
||||
IJavaProject javaProject = JavaCore.create(project);
|
||||
@@ -316,10 +314,10 @@ public class Sdk implements IProjectListener {
|
||||
|
||||
if (sdkStorage != null) {
|
||||
synchronized (AdtPlugin.getDefault().getSdkLockObject()) {
|
||||
Map<String, String> configMap = ApkConfigurationHelper.getConfigs(properties);
|
||||
ApkSettings settings = ApkConfigurationHelper.getSettings(properties);
|
||||
|
||||
if (configMap != null) {
|
||||
sdkStorage.mProjectApkConfigMap.put(project, configMap);
|
||||
if (settings != null) {
|
||||
sdkStorage.mApkSettingsMap.put(project, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,13 +390,11 @@ public class Sdk implements IProjectListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration map for a given project.
|
||||
* <p/>The Map key are name to be used in the apk filename, while the values are comma separated
|
||||
* config values. The config value can be passed directly to aapt through the -c option.
|
||||
* Returns the APK settings for a given project.
|
||||
*/
|
||||
public Map<String, String> getProjectApkConfigs(IProject project) {
|
||||
public ApkSettings getApkSettings(IProject project) {
|
||||
synchronized (AdtPlugin.getDefault().getSdkLockObject()) {
|
||||
return mProjectApkConfigMap.get(project);
|
||||
return mApkSettingsMap.get(project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +501,7 @@ public class Sdk implements IProjectListener {
|
||||
|
||||
// now remove the project for the maps.
|
||||
mProjectTargetMap.remove(project);
|
||||
mProjectApkConfigMap.remove(project);
|
||||
mApkSettingsMap.remove(project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.ide.eclipse.adt.internal.wizards.export;
|
||||
import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
|
||||
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
|
||||
import com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.ExportWizardPage;
|
||||
import com.android.sdklib.internal.project.ApkSettings;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.swt.SWT;
|
||||
@@ -68,17 +69,17 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
private Text mDestination;
|
||||
private boolean mFatalSigningError;
|
||||
private FormText mDetailText;
|
||||
/** The Apk Config map for the current project */
|
||||
private Map<String, String> mApkConfig;
|
||||
private ScrolledComposite mScrolledComposite;
|
||||
|
||||
|
||||
private ApkSettings mApkSettings;
|
||||
|
||||
private String mKeyDetails;
|
||||
private String mDestinationDetails;
|
||||
|
||||
protected KeyCheckPage(ExportWizard wizard, String pageName) {
|
||||
super(pageName);
|
||||
mWizard = wizard;
|
||||
|
||||
|
||||
setTitle("Destination and key/certificate checks");
|
||||
setDescription(""); // TODO
|
||||
}
|
||||
@@ -93,7 +94,7 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
GridLayout gl = new GridLayout(3, false);
|
||||
gl.verticalSpacing *= 3;
|
||||
composite.setLayout(gl);
|
||||
|
||||
|
||||
GridData gd;
|
||||
|
||||
new Label(composite, SWT.NONE).setText("Destination APK file:");
|
||||
@@ -110,26 +111,26 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
FileDialog fileDialog = new FileDialog(browseButton.getShell(), SWT.SAVE);
|
||||
|
||||
|
||||
fileDialog.setText("Destination file name");
|
||||
// get a default apk name based on the project
|
||||
String filename = ProjectHelper.getApkFilename(mWizard.getProject(),
|
||||
null /*config*/);
|
||||
fileDialog.setFileName(filename);
|
||||
|
||||
|
||||
String saveLocation = fileDialog.open();
|
||||
if (saveLocation != null) {
|
||||
mDestination.setText(saveLocation);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mScrolledComposite = new ScrolledComposite(composite, SWT.V_SCROLL);
|
||||
mScrolledComposite.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
|
||||
gd.horizontalSpan = 3;
|
||||
mScrolledComposite.setExpandHorizontal(true);
|
||||
mScrolledComposite.setExpandVertical(true);
|
||||
|
||||
|
||||
mDetailText = new FormText(mScrolledComposite, SWT.NONE);
|
||||
mScrolledComposite.setContent(mDetailText);
|
||||
|
||||
@@ -139,18 +140,18 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
updateScrolling();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setControl(composite);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
void onShow() {
|
||||
// fill the texts with information loaded from the project.
|
||||
if ((mProjectDataChanged & DATA_PROJECT) != 0) {
|
||||
// reset the destination from the content of the project
|
||||
IProject project = mWizard.getProject();
|
||||
mApkConfig = Sdk.getCurrent().getProjectApkConfigs(project);
|
||||
|
||||
mApkSettings = Sdk.getCurrent().getApkSettings(project);
|
||||
|
||||
String destination = ProjectHelper.loadStringProperty(project,
|
||||
ExportWizard.PROPERTY_DESTINATION);
|
||||
String filename = ProjectHelper.loadStringProperty(project,
|
||||
@@ -159,7 +160,7 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
mDestination.setText(destination + File.separator + filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if anything change we basically reload the data.
|
||||
if (mProjectDataChanged != 0) {
|
||||
mFatalSigningError = false;
|
||||
@@ -170,7 +171,7 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
mPrivateKey = null;
|
||||
mCertificate = null;
|
||||
mKeyDetails = null;
|
||||
|
||||
|
||||
if (mWizard.getKeystoreCreationMode() || mWizard.getKeyCreationMode()) {
|
||||
int validity = mWizard.getValidity();
|
||||
StringBuilder sb = new StringBuilder(
|
||||
@@ -196,13 +197,13 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
mWizard.getKeyAlias(),
|
||||
new KeyStore.PasswordProtection(
|
||||
mWizard.getKeyPassword().toCharArray()));
|
||||
|
||||
|
||||
if (entry != null) {
|
||||
mPrivateKey = entry.getPrivateKey();
|
||||
mCertificate = (X509Certificate)entry.getCertificate();
|
||||
} else {
|
||||
setErrorMessage("Unable to find key.");
|
||||
|
||||
|
||||
setPageComplete(false);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
@@ -220,33 +221,33 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
} catch (IOException e) {
|
||||
onException(e);
|
||||
}
|
||||
|
||||
|
||||
if (mPrivateKey != null && mCertificate != null) {
|
||||
Calendar expirationCalendar = Calendar.getInstance();
|
||||
expirationCalendar.setTime(mCertificate.getNotAfter());
|
||||
Calendar today = Calendar.getInstance();
|
||||
|
||||
|
||||
if (expirationCalendar.before(today)) {
|
||||
mKeyDetails = String.format(
|
||||
"<p>Certificate expired on %s</p>",
|
||||
mCertificate.getNotAfter().toString());
|
||||
|
||||
|
||||
// fatal error = nothing can make the page complete.
|
||||
mFatalSigningError = true;
|
||||
|
||||
|
||||
setErrorMessage("Certificate is expired.");
|
||||
setPageComplete(false);
|
||||
} else {
|
||||
// valid, key/cert: put it in the wizard so that it can be finished
|
||||
mWizard.setSigningInfo(mPrivateKey, mCertificate);
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder(String.format(
|
||||
"<p>Certificate expires on %s.</p>",
|
||||
mCertificate.getNotAfter().toString()));
|
||||
|
||||
|
||||
int expirationYear = expirationCalendar.get(Calendar.YEAR);
|
||||
int thisYear = today.get(Calendar.YEAR);
|
||||
|
||||
|
||||
if (thisYear + 25 < expirationYear) {
|
||||
// do nothing
|
||||
} else {
|
||||
@@ -258,14 +259,14 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
"<p>The Certificate expires in %1$s %2$s.</p>",
|
||||
count, count == 1 ? "year" : "years"));
|
||||
}
|
||||
|
||||
|
||||
sb.append("<p>Make sure the certificate is valid for the planned lifetime of the product.</p>");
|
||||
sb.append("<p>If the certificate expires, you will be forced to sign your application with a different one.</p>");
|
||||
sb.append("<p>Applications cannot be upgraded if their certificate changes from one version to another, ");
|
||||
sb.append("forcing a full uninstall/install, which will make the user lose his/her data.</p>");
|
||||
sb.append("<p>Android Market currently requires certificates to be valid until 2033.</p>");
|
||||
}
|
||||
|
||||
|
||||
mKeyDetails = sb.toString();
|
||||
}
|
||||
} else {
|
||||
@@ -277,7 +278,7 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
|
||||
onDestinationChange(true /*forceDetailUpdate*/);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback for destination field edition
|
||||
* @param forceDetailUpdate if true, the detail {@link FormText} is updated even if a fatal
|
||||
@@ -319,12 +320,12 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
|
||||
// display the list of files that will actually be created
|
||||
Map<String, String[]> apkFileMap = getApkFileMap(file);
|
||||
|
||||
|
||||
// display them
|
||||
boolean fileExists = false;
|
||||
StringBuilder sb = new StringBuilder(String.format(
|
||||
"<p>This will create the following files:</p>"));
|
||||
|
||||
|
||||
Set<Entry<String, String[]>> set = apkFileMap.entrySet();
|
||||
for (Entry<String, String[]> entry : set) {
|
||||
String[] apkArray = entry.getValue();
|
||||
@@ -360,7 +361,7 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
updateDetailText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the scrollbar to match the content of the {@link FormText} or the new size
|
||||
* of the {@link ScrolledComposite}.
|
||||
@@ -372,41 +373,40 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
mScrolledComposite.layout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateDetailText() {
|
||||
StringBuilder sb = new StringBuilder("<form>");
|
||||
if (mKeyDetails != null) {
|
||||
sb.append(mKeyDetails);
|
||||
}
|
||||
|
||||
|
||||
if (mDestinationDetails != null && mFatalSigningError == false) {
|
||||
sb.append(mDestinationDetails);
|
||||
}
|
||||
|
||||
|
||||
sb.append("</form>");
|
||||
|
||||
|
||||
mDetailText.setText(sb.toString(), true /* parseTags */,
|
||||
true /* expandURLs */);
|
||||
|
||||
mDetailText.getParent().layout();
|
||||
|
||||
updateScrolling();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the list of destination filenames based on the content of the destination field
|
||||
* and the list of APK configurations for the project.
|
||||
*
|
||||
*
|
||||
* @param file File name from the destination field
|
||||
* @return A list of destination filenames based <code>file</code> and the list of APK
|
||||
* configurations for the project.
|
||||
*/
|
||||
private Map<String, String[]> getApkFileMap(File file) {
|
||||
String filename = file.getName();
|
||||
|
||||
|
||||
HashMap<String, String[]> map = new HashMap<String, String[]>();
|
||||
|
||||
|
||||
// add the default APK filename
|
||||
String[] apkArray = new String[ExportWizard.APK_COUNT];
|
||||
apkArray[ExportWizard.APK_FILE_SOURCE] = ProjectHelper.getApkFilename(
|
||||
@@ -415,29 +415,32 @@ final class KeyCheckPage extends ExportWizardPage {
|
||||
map.put(null, apkArray);
|
||||
|
||||
// add the APKs for each APK configuration.
|
||||
if (mApkConfig != null && mApkConfig.size() > 0) {
|
||||
// remove the extension.
|
||||
int index = filename.lastIndexOf('.');
|
||||
String base = filename.substring(0, index);
|
||||
String extension = filename.substring(index);
|
||||
|
||||
Set<Entry<String, String>> set = mApkConfig.entrySet();
|
||||
for (Entry<String, String> entry : set) {
|
||||
apkArray = new String[ExportWizard.APK_COUNT];
|
||||
apkArray[ExportWizard.APK_FILE_SOURCE] = ProjectHelper.getApkFilename(
|
||||
mWizard.getProject(), entry.getKey());
|
||||
apkArray[ExportWizard.APK_FILE_DEST] = base + "-" + entry.getKey() + extension;
|
||||
map.put(entry.getKey(), apkArray);
|
||||
if (mApkSettings != null) {
|
||||
Map<String, String> apkFilters = mApkSettings.getResourceFilters();
|
||||
if (apkFilters.size() > 0) {
|
||||
// remove the extension from the user-chosen filename
|
||||
int index = filename.lastIndexOf('.');
|
||||
String base = filename.substring(0, index);
|
||||
String extension = filename.substring(index);
|
||||
|
||||
for (Entry<String, String> entry : apkFilters.entrySet()) {
|
||||
apkArray = new String[ExportWizard.APK_COUNT];
|
||||
apkArray[ExportWizard.APK_FILE_SOURCE] = ProjectHelper.getApkFilename(
|
||||
mWizard.getProject(), entry.getKey());
|
||||
apkArray[ExportWizard.APK_FILE_DEST] = base + "-" + //$NON-NLS-1$
|
||||
entry.getKey() + extension;
|
||||
map.put(entry.getKey(), apkArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onException(Throwable t) {
|
||||
super.onException(t);
|
||||
|
||||
|
||||
mKeyDetails = String.format("ERROR: %1$s", ExportWizard.getExceptionMessage(t));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user