Device hardware profile for config selector in GLE
- Built-in device list for now - Config selector in GLE is changed to only have - MCC/MNC - Locale - Device List - Device config.
This commit is contained in:
@@ -54,6 +54,7 @@ Export-Package: com.android.ide.eclipse.adt;x-friends:="com.android.ide.eclipse.
|
|||||||
com.android.ide.eclipse.adt.internal.editors;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.internal.editors;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.internal.editors.descriptors;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.internal.editors.descriptors;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.internal.editors.layout;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.internal.editors.layout;x-friends:="com.android.ide.eclipse.tests",
|
||||||
|
com.android.ide.eclipse.adt.internal.editors.layout.configuration,
|
||||||
com.android.ide.eclipse.adt.internal.editors.layout.descriptors;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.internal.editors.layout.descriptors;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.internal.editors.layout.parts;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.internal.editors.layout.parts;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.internal.editors.layout.uimodel;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.internal.editors.layout.uimodel;x-friends:="com.android.ide.eclipse.tests",
|
||||||
|
|||||||
@@ -759,9 +759,6 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor
|
|||||||
// resources need to be updated.
|
// resources need to be updated.
|
||||||
recomputeLayout();
|
recomputeLayout();
|
||||||
} else {
|
} else {
|
||||||
// update the configuration icons with the new edited config.
|
|
||||||
mConfigComposite.displayConfigError();
|
|
||||||
|
|
||||||
// enable the Create button
|
// enable the Create button
|
||||||
mConfigComposite.setEnabledCreate(true);
|
mConfigComposite.setEnabledCreate(true);
|
||||||
|
|
||||||
|
|||||||
@@ -20,24 +20,16 @@ import com.android.ide.eclipse.adt.internal.editors.IconFactory;
|
|||||||
import com.android.ide.eclipse.adt.internal.resources.ResourceType;
|
import com.android.ide.eclipse.adt.internal.resources.ResourceType;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.CountryCodeQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.CountryCodeQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.LanguageQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.LanguageQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.NetworkCodeQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.NetworkCodeQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.RegionQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.RegionQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenDimensionQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenDimensionQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.VersionQualifier;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier.KeyboardState;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier.NavigationMethod;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier.Density;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier.ScreenOrientation;
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier.ScreenOrientation;
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier.TextInputMethod;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier.TouchScreenType;
|
|
||||||
import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
|
import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
|
||||||
import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.DimensionVerifier;
|
import com.android.ide.eclipse.adt.internal.sdk.DeviceConfiguration;
|
||||||
import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.LanguageRegionVerifier;
|
import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.LanguageRegionVerifier;
|
||||||
import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.MobileCodeVerifier;
|
import com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.MobileCodeVerifier;
|
||||||
import com.android.layoutlib.api.IResourceValue;
|
import com.android.layoutlib.api.IResourceValue;
|
||||||
@@ -61,9 +53,9 @@ import org.eclipse.swt.widgets.Text;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
public class ConfigurationComposite extends Composite {
|
public class ConfigurationComposite extends Composite {
|
||||||
|
|
||||||
@@ -71,34 +63,17 @@ public class ConfigurationComposite extends Composite {
|
|||||||
|
|
||||||
private Text mCountry;
|
private Text mCountry;
|
||||||
private Text mNetwork;
|
private Text mNetwork;
|
||||||
private Combo mLanguage;
|
private Combo mLocale;
|
||||||
private Combo mRegion;
|
private Combo mDeviceList;
|
||||||
private Combo mOrientation;
|
private Combo mDeviceConfigs;
|
||||||
private Combo mDensity;
|
|
||||||
private Combo mTouch;
|
|
||||||
private Combo mKeyboard;
|
|
||||||
private Combo mTextInput;
|
|
||||||
private Combo mNavigation;
|
|
||||||
private Text mSize1;
|
|
||||||
private Text mSize2;
|
|
||||||
private Combo mThemeCombo;
|
private Combo mThemeCombo;
|
||||||
private Button mCreateButton;
|
private Button mCreateButton;
|
||||||
|
|
||||||
private Label mCountryIcon;
|
private Label mCountryIcon;
|
||||||
private Label mNetworkIcon;
|
private Label mNetworkIcon;
|
||||||
private Label mLanguageIcon;
|
|
||||||
private Label mRegionIcon;
|
|
||||||
private Label mOrientationIcon;
|
|
||||||
private Label mDensityIcon;
|
|
||||||
private Label mTouchIcon;
|
|
||||||
private Label mKeyboardIcon;
|
|
||||||
private Label mTextInputIcon;
|
|
||||||
private Label mNavigationIcon;
|
|
||||||
private Label mSizeIcon;
|
|
||||||
|
|
||||||
private Label mCurrentLayoutLabel;
|
private Label mCurrentLayoutLabel;
|
||||||
|
|
||||||
private Image mWarningImage;
|
|
||||||
private Image mMatchImage;
|
private Image mMatchImage;
|
||||||
private Image mErrorImage;
|
private Image mErrorImage;
|
||||||
|
|
||||||
@@ -107,6 +82,12 @@ public class ConfigurationComposite extends Composite {
|
|||||||
|
|
||||||
/** The {@link FolderConfiguration} representing the state of the UI controls */
|
/** The {@link FolderConfiguration} representing the state of the UI controls */
|
||||||
private final FolderConfiguration mCurrentConfig = new FolderConfiguration();
|
private final FolderConfiguration mCurrentConfig = new FolderConfiguration();
|
||||||
|
|
||||||
|
private DeviceConfiguration[] mDevices;
|
||||||
|
|
||||||
|
private final ArrayList<ResourceQualifier[] > mLocaleList =
|
||||||
|
new ArrayList<ResourceQualifier[]>();
|
||||||
|
|
||||||
private final IConfigListener mListener;
|
private final IConfigListener mListener;
|
||||||
|
|
||||||
public interface IConfigListener {
|
public interface IConfigListener {
|
||||||
@@ -123,9 +104,9 @@ public class ConfigurationComposite extends Composite {
|
|||||||
public ConfigurationComposite(IConfigListener listener, Composite parent, int style) {
|
public ConfigurationComposite(IConfigListener listener, Composite parent, int style) {
|
||||||
super(parent, style);
|
super(parent, style);
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
mDevices = DeviceConfiguration.getDevices();
|
||||||
|
|
||||||
IconFactory factory = IconFactory.getInstance();
|
IconFactory factory = IconFactory.getInstance();
|
||||||
mWarningImage = factory.getIcon("warning"); //$NON-NLS-1$
|
|
||||||
mMatchImage = factory.getIcon("match"); //$NON-NLS-1$
|
mMatchImage = factory.getIcon("match"); //$NON-NLS-1$
|
||||||
mErrorImage = factory.getIcon("error"); //$NON-NLS-1$
|
mErrorImage = factory.getIcon("error"); //$NON-NLS-1$
|
||||||
|
|
||||||
@@ -172,151 +153,54 @@ public class ConfigurationComposite extends Composite {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Lang");
|
new Label(this, SWT.NONE).setText("Locale");
|
||||||
mLanguageIcon = createControlComposite(this, true /* grab_horizontal */);
|
mLocale = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||||
mLanguage = new Combo(mLanguageIcon.getParent(), SWT.DROP_DOWN);
|
mLocale.setLayoutData(new GridData(
|
||||||
mLanguage.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
||||||
mLanguage.addVerifyListener(new LanguageRegionVerifier());
|
mLocale.addVerifyListener(new LanguageRegionVerifier());
|
||||||
mLanguage.addSelectionListener(new SelectionListener() {
|
mLocale.addSelectionListener(new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
onLanguageChange();
|
onLocaleChange();
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
onLanguageChange();
|
onLocaleChange();
|
||||||
}
|
|
||||||
});
|
|
||||||
mLanguage.addModifyListener(new ModifyListener() {
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
onLanguageChange();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Region");
|
new Label(this, SWT.NONE).setText("Devices");
|
||||||
mRegionIcon = createControlComposite(this, true /* grab_horizontal */);
|
mDeviceList = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||||
mRegion = new Combo(mRegionIcon.getParent(), SWT.DROP_DOWN);
|
// fill with the devices
|
||||||
mRegion.setLayoutData(new GridData(
|
for (DeviceConfiguration device : mDevices) {
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
mDeviceList.add(device.getName());
|
||||||
mRegion.addVerifyListener(new LanguageRegionVerifier());
|
|
||||||
mRegion.addSelectionListener(new SelectionListener() {
|
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
|
||||||
onRegionChange();
|
|
||||||
}
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onRegionChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mRegion.addModifyListener(new ModifyListener() {
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
onRegionChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Orient");
|
|
||||||
mOrientationIcon = createControlComposite(this, true /* grab_horizontal */);
|
|
||||||
mOrientation = new Combo(mOrientationIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
ScreenOrientation[] soValues = ScreenOrientation.values();
|
|
||||||
mOrientation.add("(Default)");
|
|
||||||
for (ScreenOrientation value : soValues) {
|
|
||||||
mOrientation.add(value.getDisplayValue());
|
|
||||||
}
|
}
|
||||||
mOrientation.select(0);
|
|
||||||
mOrientation.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
|
||||||
mOrientation.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onOrientationChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Density");
|
mDeviceList.select(0);
|
||||||
mDensityIcon = createControlComposite(this, true /* grab_horizontal */);
|
mDeviceList.setLayoutData(new GridData(
|
||||||
mDensity = new Combo(mDensityIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
Density[] dValues = Density.values();
|
|
||||||
mDensity.add("(Default)");
|
|
||||||
for (Density value : dValues) {
|
|
||||||
mDensity.add(value.getDisplayValue());
|
|
||||||
}
|
|
||||||
mDensity.select(0);
|
|
||||||
mDensity.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
||||||
mDensity.addSelectionListener(new SelectionAdapter() {
|
mDeviceList.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onDensityChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Touch");
|
|
||||||
mTouchIcon = createControlComposite(this, true /* grab_horizontal */);
|
|
||||||
mTouch = new Combo(mTouchIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
TouchScreenType[] tstValues = TouchScreenType.values();
|
|
||||||
mTouch.add("(Default)");
|
|
||||||
for (TouchScreenType value : tstValues) {
|
|
||||||
mTouch.add(value.getDisplayValue());
|
|
||||||
}
|
|
||||||
mTouch.select(0);
|
|
||||||
mTouch.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
|
||||||
mTouch.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
onTouchChange();
|
onDeviceChange();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Keybrd");
|
new Label(this, SWT.NONE).setText("Config");
|
||||||
mKeyboardIcon = createControlComposite(this, true /* grab_horizontal */);
|
mDeviceConfigs = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||||
mKeyboard = new Combo(mKeyboardIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
Map<String, FolderConfiguration> configs = mDevices[0].getConfigs();
|
||||||
KeyboardState[] ksValues = KeyboardState.values();
|
Set<String> configNames = configs.keySet();
|
||||||
mKeyboard.add("(Default)");
|
for (String name : configNames) {
|
||||||
for (KeyboardState value : ksValues) {
|
mDeviceConfigs.add(name);
|
||||||
mKeyboard.add(value.getDisplayValue());
|
|
||||||
}
|
}
|
||||||
mKeyboard.select(0);
|
mDeviceConfigs.select(0);
|
||||||
mKeyboard.setLayoutData(new GridData(
|
if (configNames.size() == 1) {
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
mDeviceConfigs.setEnabled(false);
|
||||||
mKeyboard.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onKeyboardChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Input");
|
|
||||||
mTextInputIcon = createControlComposite(this, true /* grab_horizontal */);
|
|
||||||
mTextInput = new Combo(mTextInputIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
TextInputMethod[] timValues = TextInputMethod.values();
|
|
||||||
mTextInput.add("(Default)");
|
|
||||||
for (TextInputMethod value : timValues) {
|
|
||||||
mTextInput.add(value.getDisplayValue());
|
|
||||||
}
|
}
|
||||||
mTextInput.select(0);
|
mDeviceConfigs.setLayoutData(new GridData(
|
||||||
mTextInput.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
||||||
mTextInput.addSelectionListener(new SelectionAdapter() {
|
mDeviceConfigs.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onTextInputChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Nav");
|
|
||||||
mNavigationIcon = createControlComposite(this, true /* grab_horizontal */);
|
|
||||||
mNavigation = new Combo(mNavigationIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
NavigationMethod[] nValues = NavigationMethod.values();
|
|
||||||
mNavigation.add("(Default)");
|
|
||||||
for (NavigationMethod value : nValues) {
|
|
||||||
mNavigation.add(value.getDisplayValue());
|
|
||||||
}
|
|
||||||
mNavigation.select(0);
|
|
||||||
mNavigation.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
|
||||||
mNavigation.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
onNavigationChange();
|
onDeviceConfigChange();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -331,46 +215,6 @@ public class ConfigurationComposite extends Composite {
|
|||||||
mCurrentLayoutLabel.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
|
mCurrentLayoutLabel.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
|
||||||
gd.widthHint = 50;
|
gd.widthHint = 50;
|
||||||
|
|
||||||
new Label(labelParent, SWT.NONE).setText("Size");
|
|
||||||
mSizeIcon = createControlComposite(labelParent, false);
|
|
||||||
Composite sizeParent = new Composite(mSizeIcon.getParent(), SWT.NONE);
|
|
||||||
sizeParent.setLayout(gl = new GridLayout(3, false));
|
|
||||||
gl.marginWidth = gl.marginHeight = 0;
|
|
||||||
gl.horizontalSpacing = 0;
|
|
||||||
|
|
||||||
mSize1 = new Text(sizeParent, SWT.BORDER);
|
|
||||||
mSize1.setLayoutData(gd = new GridData());
|
|
||||||
gd.widthHint = 30;
|
|
||||||
new Label(sizeParent, SWT.NONE).setText("x");
|
|
||||||
mSize2 = new Text(sizeParent, SWT.BORDER);
|
|
||||||
mSize2.setLayoutData(gd = new GridData());
|
|
||||||
gd.widthHint = 30;
|
|
||||||
|
|
||||||
DimensionVerifier verifier = new DimensionVerifier();
|
|
||||||
mSize1.addVerifyListener(verifier);
|
|
||||||
mSize2.addVerifyListener(verifier);
|
|
||||||
|
|
||||||
SelectionListener sl = new SelectionListener() {
|
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
|
||||||
onSizeChange();
|
|
||||||
}
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onSizeChange();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mSize1.addSelectionListener(sl);
|
|
||||||
mSize2.addSelectionListener(sl);
|
|
||||||
|
|
||||||
ModifyListener sizeModifyListener = new ModifyListener() {
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
onSizeChange();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mSize1.addModifyListener(sizeModifyListener);
|
|
||||||
mSize2.addModifyListener(sizeModifyListener);
|
|
||||||
|
|
||||||
// first separator
|
// first separator
|
||||||
Label separator = new Label(labelParent, SWT.SEPARATOR | SWT.VERTICAL);
|
Label separator = new Label(labelParent, SWT.SEPARATOR | SWT.VERTICAL);
|
||||||
separator.setLayoutData(gd = new GridData(
|
separator.setLayoutData(gd = new GridData(
|
||||||
@@ -405,10 +249,12 @@ public class ConfigurationComposite extends Composite {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDeviceConfigChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfig(FolderConfiguration config) {
|
public void setConfig(FolderConfiguration config) {
|
||||||
mCurrentConfig.set(config);
|
// mCurrentConfig.set(config);
|
||||||
|
throw new UnsupportedOperationException("setConfig");
|
||||||
}
|
}
|
||||||
|
|
||||||
public FolderConfiguration getCurrentConfig() {
|
public FolderConfiguration getCurrentConfig() {
|
||||||
@@ -420,35 +266,14 @@ public class ConfigurationComposite extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle getScreenBounds() {
|
public Rectangle getScreenBounds() {
|
||||||
ScreenOrientation orientation = null;
|
// get the orientation from the current device config
|
||||||
if (mOrientation.getSelectionIndex() == 0) {
|
ScreenOrientationQualifier qual = mCurrentConfig.getScreenOrientationQualifier();
|
||||||
orientation = ScreenOrientation.PORTRAIT;
|
ScreenOrientation orientation = qual.getValue();
|
||||||
} else {
|
|
||||||
orientation = ScreenOrientation.getByIndex(
|
|
||||||
mOrientation.getSelectionIndex() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int s1, s2;
|
// get the device screen dimension
|
||||||
|
ScreenDimensionQualifier qual2 = mCurrentConfig.getScreenDimensionQualifier();
|
||||||
// get the size from the UI controls. If it fails, revert to default values.
|
int s1 = qual2.getValue1();
|
||||||
try {
|
int s2 = qual2.getValue2();
|
||||||
s1 = Integer.parseInt(mSize1.getText().trim());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
s1 = 480;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
s2 = Integer.parseInt(mSize2.getText().trim());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
s2 = 320;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure s1 is bigger than s2
|
|
||||||
if (s1 < s2) {
|
|
||||||
int tmp = s1;
|
|
||||||
s1 = s2;
|
|
||||||
s2 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
default:
|
default:
|
||||||
@@ -478,9 +303,11 @@ public class ConfigurationComposite extends Composite {
|
|||||||
int selection = mThemeCombo.getSelectionIndex();
|
int selection = mThemeCombo.getSelectionIndex();
|
||||||
mThemeCombo.removeAll();
|
mThemeCombo.removeAll();
|
||||||
mPlatformThemeCount = 0;
|
mPlatformThemeCount = 0;
|
||||||
mLanguage.removeAll();
|
|
||||||
|
|
||||||
Set<String> languages = new HashSet<String>();
|
mLocale.removeAll();
|
||||||
|
mLocaleList.clear();
|
||||||
|
|
||||||
|
SortedSet<String> languages = null;
|
||||||
ArrayList<String> themes = new ArrayList<String>();
|
ArrayList<String> themes = new ArrayList<String>();
|
||||||
|
|
||||||
// get the themes, and languages from the Framework.
|
// get the themes, and languages from the Framework.
|
||||||
@@ -514,11 +341,6 @@ public class ConfigurationComposite extends Composite {
|
|||||||
mPlatformThemeCount = themes.size();
|
mPlatformThemeCount = themes.size();
|
||||||
themes.clear();
|
themes.clear();
|
||||||
}
|
}
|
||||||
// now get the languages from the framework.
|
|
||||||
Set<String> frameworkLanguages = frameworkProject.getLanguages();
|
|
||||||
if (frameworkLanguages != null) {
|
|
||||||
languages.addAll(frameworkLanguages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now get the themes and languages from the project.
|
// now get the themes and languages from the project.
|
||||||
@@ -557,22 +379,34 @@ public class ConfigurationComposite extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now get the languages from the project.
|
// now get the languages from the project.
|
||||||
Set<String> projectLanguages = project.getLanguages();
|
languages = project.getLanguages();
|
||||||
if (projectLanguages != null) {
|
|
||||||
languages.addAll(projectLanguages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the languages to the Combo
|
// add the languages to the Combo
|
||||||
for (String language : languages) {
|
mLocale.add("Default");
|
||||||
mLanguage.add(language);
|
mLocaleList.add(new ResourceQualifier[] { null, null });
|
||||||
|
|
||||||
|
if (languages != null && languages.size() > 0) {
|
||||||
|
for (String language : languages) {
|
||||||
|
// first the language alone
|
||||||
|
mLocale.add(language);
|
||||||
|
LanguageQualifier qual = new LanguageQualifier(language);
|
||||||
|
mLocaleList.add(new ResourceQualifier[] { qual, null });
|
||||||
|
|
||||||
|
// now find the matching regions and add them
|
||||||
|
SortedSet<String> regions = project.getRegions(language);
|
||||||
|
for (String region : regions) {
|
||||||
|
mLocale.add(String.format("%1$s_%2$s", language, region)); //$NON-NLS-1$
|
||||||
|
RegionQualifier qual2 = new RegionQualifier(region);
|
||||||
|
mLocaleList.add(new ResourceQualifier[] { qual, qual2 });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDisableUpdates = false;
|
mDisableUpdates = false;
|
||||||
|
|
||||||
// and update the Region UI based on the current language
|
|
||||||
updateRegionUi();
|
|
||||||
|
|
||||||
// handle default selection of themes
|
// handle default selection of themes
|
||||||
if (mThemeCombo.getItemCount() > 0) {
|
if (mThemeCombo.getItemCount() > 0) {
|
||||||
mThemeCombo.setEnabled(true);
|
mThemeCombo.setEnabled(true);
|
||||||
@@ -630,142 +464,8 @@ public class ConfigurationComposite extends Composite {
|
|||||||
public void setConfiguration(FolderConfiguration config, boolean force) {
|
public void setConfiguration(FolderConfiguration config, boolean force) {
|
||||||
mDisableUpdates = true; // we do not want to trigger onXXXChange when setting new values in the widgets.
|
mDisableUpdates = true; // we do not want to trigger onXXXChange when setting new values in the widgets.
|
||||||
|
|
||||||
mCountryIcon.setImage(mMatchImage);
|
// TODO: find a device that can display this particular config or create a custom one if needed.
|
||||||
CountryCodeQualifier countryQualifier = config.getCountryCodeQualifier();
|
|
||||||
if (countryQualifier != null) {
|
|
||||||
mCountry.setText(String.format("%1$d", countryQualifier.getCode()));
|
|
||||||
mCurrentConfig.setCountryCodeQualifier(countryQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mCountry.setText(""); //$NON-NLS-1$
|
|
||||||
mCurrentConfig.setCountryCodeQualifier(null);
|
|
||||||
} else if (mCountry.getText().length() > 0) {
|
|
||||||
mCountryIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mNetworkIcon.setImage(mMatchImage);
|
|
||||||
NetworkCodeQualifier networkQualifier = config.getNetworkCodeQualifier();
|
|
||||||
if (networkQualifier != null) {
|
|
||||||
mNetwork.setText(String.format("%1$d", networkQualifier.getCode()));
|
|
||||||
mCurrentConfig.setNetworkCodeQualifier(networkQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mNetwork.setText(""); //$NON-NLS-1$
|
|
||||||
mCurrentConfig.setNetworkCodeQualifier(null);
|
|
||||||
} else if (mNetwork.getText().length() > 0) {
|
|
||||||
mNetworkIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mLanguageIcon.setImage(mMatchImage);
|
|
||||||
LanguageQualifier languageQualifier = config.getLanguageQualifier();
|
|
||||||
if (languageQualifier != null) {
|
|
||||||
mLanguage.setText(languageQualifier.getValue());
|
|
||||||
mCurrentConfig.setLanguageQualifier(languageQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mLanguage.setText(""); //$NON-NLS-1$
|
|
||||||
mCurrentConfig.setLanguageQualifier(null);
|
|
||||||
} else if (mLanguage.getText().length() > 0) {
|
|
||||||
mLanguageIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mRegionIcon.setImage(mMatchImage);
|
|
||||||
RegionQualifier regionQualifier = config.getRegionQualifier();
|
|
||||||
if (regionQualifier != null) {
|
|
||||||
mRegion.setText(regionQualifier.getValue());
|
|
||||||
mCurrentConfig.setRegionQualifier(regionQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mRegion.setText(""); //$NON-NLS-1$
|
|
||||||
mCurrentConfig.setRegionQualifier(null);
|
|
||||||
} else if (mRegion.getText().length() > 0) {
|
|
||||||
mRegionIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mOrientationIcon.setImage(mMatchImage);
|
|
||||||
ScreenOrientationQualifier orientationQualifier = config.getScreenOrientationQualifier();
|
|
||||||
if (orientationQualifier != null) {
|
|
||||||
mOrientation.select(
|
|
||||||
ScreenOrientation.getIndex(orientationQualifier.getValue()) + 1);
|
|
||||||
mCurrentConfig.setScreenOrientationQualifier(orientationQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mOrientation.select(0);
|
|
||||||
mCurrentConfig.setScreenOrientationQualifier(null);
|
|
||||||
} else if (mOrientation.getSelectionIndex() != 0) {
|
|
||||||
mOrientationIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mDensityIcon.setImage(mMatchImage);
|
|
||||||
PixelDensityQualifier densityQualifier = config.getPixelDensityQualifier();
|
|
||||||
if (densityQualifier != null) {
|
|
||||||
mDensity.select(
|
|
||||||
Density.getIndex(densityQualifier.getValue()) + 1);
|
|
||||||
mCurrentConfig.setPixelDensityQualifier(densityQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mDensity.select(0);
|
|
||||||
mCurrentConfig.setPixelDensityQualifier(null);
|
|
||||||
} else if (mDensity.getSelectionIndex() != 0) {
|
|
||||||
mDensityIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTouchIcon.setImage(mMatchImage);
|
|
||||||
TouchScreenQualifier touchQualifier = config.getTouchTypeQualifier();
|
|
||||||
if (touchQualifier != null) {
|
|
||||||
mTouch.select(TouchScreenType.getIndex(touchQualifier.getValue()) + 1);
|
|
||||||
mCurrentConfig.setTouchTypeQualifier(touchQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mTouch.select(0);
|
|
||||||
mCurrentConfig.setTouchTypeQualifier(null);
|
|
||||||
} else if (mTouch.getSelectionIndex() != 0) {
|
|
||||||
mTouchIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mKeyboardIcon.setImage(mMatchImage);
|
|
||||||
KeyboardStateQualifier keyboardQualifier = config.getKeyboardStateQualifier();
|
|
||||||
if (keyboardQualifier != null) {
|
|
||||||
mKeyboard.select(KeyboardState.getIndex(keyboardQualifier.getValue()) + 1);
|
|
||||||
mCurrentConfig.setKeyboardStateQualifier(keyboardQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mKeyboard.select(0);
|
|
||||||
mCurrentConfig.setKeyboardStateQualifier(null);
|
|
||||||
} else if (mKeyboard.getSelectionIndex() != 0) {
|
|
||||||
mKeyboardIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTextInputIcon.setImage(mMatchImage);
|
|
||||||
TextInputMethodQualifier inputQualifier = config.getTextInputMethodQualifier();
|
|
||||||
if (inputQualifier != null) {
|
|
||||||
mTextInput.select(TextInputMethod.getIndex(inputQualifier.getValue()) + 1);
|
|
||||||
mCurrentConfig.setTextInputMethodQualifier(inputQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mTextInput.select(0);
|
|
||||||
mCurrentConfig.setTextInputMethodQualifier(null);
|
|
||||||
} else if (mTextInput.getSelectionIndex() != 0) {
|
|
||||||
mTextInputIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mNavigationIcon.setImage(mMatchImage);
|
|
||||||
NavigationMethodQualifier navigationQualifiter = config.getNavigationMethodQualifier();
|
|
||||||
if (navigationQualifiter != null) {
|
|
||||||
mNavigation.select(
|
|
||||||
NavigationMethod.getIndex(navigationQualifiter.getValue()) + 1);
|
|
||||||
mCurrentConfig.setNavigationMethodQualifier(navigationQualifiter);
|
|
||||||
} else if (force) {
|
|
||||||
mNavigation.select(0);
|
|
||||||
mCurrentConfig.setNavigationMethodQualifier(null);
|
|
||||||
} else if (mNavigation.getSelectionIndex() != 0) {
|
|
||||||
mNavigationIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mSizeIcon.setImage(mMatchImage);
|
|
||||||
ScreenDimensionQualifier sizeQualifier = config.getScreenDimensionQualifier();
|
|
||||||
if (sizeQualifier != null) {
|
|
||||||
mSize1.setText(String.format("%1$d", sizeQualifier.getValue1()));
|
|
||||||
mSize2.setText(String.format("%1$d", sizeQualifier.getValue2()));
|
|
||||||
mCurrentConfig.setScreenDimensionQualifier(sizeQualifier);
|
|
||||||
} else if (force) {
|
|
||||||
mSize1.setText(""); //$NON-NLS-1$
|
|
||||||
mSize2.setText(""); //$NON-NLS-1$
|
|
||||||
mCurrentConfig.setScreenDimensionQualifier(null);
|
|
||||||
} else if (mSize1.getText().length() > 0 && mSize2.getText().length() > 0) {
|
|
||||||
mSizeIcon.setImage(mWarningImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the string showing the folder name
|
// update the string showing the folder name
|
||||||
String current = config.toDisplayString();
|
String current = config.toDisplayString();
|
||||||
@@ -774,85 +474,6 @@ public class ConfigurationComposite extends Composite {
|
|||||||
mDisableUpdates = false;
|
mDisableUpdates = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays an error icon in front of all the non-null qualifiers.
|
|
||||||
*/
|
|
||||||
public void displayConfigError() {
|
|
||||||
mCountryIcon.setImage(mMatchImage);
|
|
||||||
CountryCodeQualifier countryQualifier = mCurrentConfig.getCountryCodeQualifier();
|
|
||||||
if (countryQualifier != null) {
|
|
||||||
mCountryIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mNetworkIcon.setImage(mMatchImage);
|
|
||||||
NetworkCodeQualifier networkQualifier = mCurrentConfig.getNetworkCodeQualifier();
|
|
||||||
if (networkQualifier != null) {
|
|
||||||
mNetworkIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mLanguageIcon.setImage(mMatchImage);
|
|
||||||
LanguageQualifier languageQualifier = mCurrentConfig.getLanguageQualifier();
|
|
||||||
if (languageQualifier != null) {
|
|
||||||
mLanguageIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mRegionIcon.setImage(mMatchImage);
|
|
||||||
RegionQualifier regionQualifier = mCurrentConfig.getRegionQualifier();
|
|
||||||
if (regionQualifier != null) {
|
|
||||||
mRegionIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mOrientationIcon.setImage(mMatchImage);
|
|
||||||
ScreenOrientationQualifier orientationQualifier =
|
|
||||||
mCurrentConfig.getScreenOrientationQualifier();
|
|
||||||
if (orientationQualifier != null) {
|
|
||||||
mOrientationIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mDensityIcon.setImage(mMatchImage);
|
|
||||||
PixelDensityQualifier densityQualifier = mCurrentConfig.getPixelDensityQualifier();
|
|
||||||
if (densityQualifier != null) {
|
|
||||||
mDensityIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTouchIcon.setImage(mMatchImage);
|
|
||||||
TouchScreenQualifier touchQualifier = mCurrentConfig.getTouchTypeQualifier();
|
|
||||||
if (touchQualifier != null) {
|
|
||||||
mTouchIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mKeyboardIcon.setImage(mMatchImage);
|
|
||||||
KeyboardStateQualifier keyboardQualifier = mCurrentConfig.getKeyboardStateQualifier();
|
|
||||||
if (keyboardQualifier != null) {
|
|
||||||
mKeyboardIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTextInputIcon.setImage(mMatchImage);
|
|
||||||
TextInputMethodQualifier inputQualifier = mCurrentConfig.getTextInputMethodQualifier();
|
|
||||||
if (inputQualifier != null) {
|
|
||||||
mTextInputIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mNavigationIcon.setImage(mMatchImage);
|
|
||||||
NavigationMethodQualifier navigationQualifiter =
|
|
||||||
mCurrentConfig.getNavigationMethodQualifier();
|
|
||||||
if (navigationQualifiter != null) {
|
|
||||||
mNavigationIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
mSizeIcon.setImage(mMatchImage);
|
|
||||||
ScreenDimensionQualifier sizeQualifier = mCurrentConfig.getScreenDimensionQualifier();
|
|
||||||
if (sizeQualifier != null) {
|
|
||||||
mSizeIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the string showing the folder name
|
|
||||||
String current = mCurrentConfig.toDisplayString();
|
|
||||||
mCurrentLayoutLabel.setText(current != null ? current : "(Default)");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onCountryCodeChange() {
|
private void onCountryCodeChange() {
|
||||||
// because mCountry triggers onCountryCodeChange at each modification, calling setText()
|
// because mCountry triggers onCountryCodeChange at each modification, calling setText()
|
||||||
// will trigger notifications, and we don't want that.
|
// will trigger notifications, and we don't want that.
|
||||||
@@ -932,195 +553,68 @@ public class ConfigurationComposite extends Composite {
|
|||||||
/**
|
/**
|
||||||
* Call back for language combo selection
|
* Call back for language combo selection
|
||||||
*/
|
*/
|
||||||
private void onLanguageChange() {
|
private void onLocaleChange() {
|
||||||
// because mLanguage triggers onLanguageChange at each modification, the filling
|
// because mLanguage triggers onLanguageChange at each modification, the filling
|
||||||
// of the combo with data will trigger notifications, and we don't want that.
|
// of the combo with data will trigger notifications, and we don't want that.
|
||||||
if (mDisableUpdates == true) {
|
if (mDisableUpdates == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the current config
|
int localeIndex = mLocale.getSelectionIndex();
|
||||||
String value = mLanguage.getText();
|
ResourceQualifier[] localeQualifiers = mLocaleList.get(localeIndex);
|
||||||
|
|
||||||
updateRegionUi();
|
mCurrentConfig.setLanguageQualifier((LanguageQualifier)localeQualifiers[0]); // language
|
||||||
|
mCurrentConfig.setRegionQualifier((RegionQualifier)localeQualifiers[1]); // region
|
||||||
// empty string, means no qualifier.
|
|
||||||
if (value.length() == 0) {
|
|
||||||
mCurrentConfig.setLanguageQualifier(null);
|
|
||||||
} else {
|
|
||||||
LanguageQualifier qualifier = null;
|
|
||||||
String segment = LanguageQualifier.getFolderSegment(value);
|
|
||||||
if (segment != null) {
|
|
||||||
qualifier = LanguageQualifier.getQualifier(segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qualifier != null) {
|
|
||||||
mCurrentConfig.setLanguageQualifier(qualifier);
|
|
||||||
} else {
|
|
||||||
// Failure! Looks like the value is wrong (for instance a one letter string).
|
|
||||||
mCurrentConfig.setLanguageQualifier(null);
|
|
||||||
mLanguageIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onConfigurationChange();
|
mListener.onConfigurationChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRegionChange() {
|
private void onDeviceChange() {
|
||||||
// because mRegion triggers onRegionChange at each modification, the filling
|
|
||||||
// of the combo with data will trigger notifications, and we don't want that.
|
int deviceIndex = mDeviceList.getSelectionIndex();
|
||||||
if (mDisableUpdates == true) {
|
DeviceConfiguration device = mDevices[deviceIndex];
|
||||||
return;
|
|
||||||
|
mDeviceConfigs.removeAll();
|
||||||
|
|
||||||
|
Set<String> configNames = device.getConfigs().keySet();
|
||||||
|
for (String name : configNames) {
|
||||||
|
mDeviceConfigs.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the current config
|
mDeviceConfigs.select(0);
|
||||||
String value = mRegion.getText();
|
if (configNames.size() == 1) {
|
||||||
|
mDeviceConfigs.setEnabled(false);
|
||||||
// empty string, means no qualifier.
|
|
||||||
if (value.length() == 0) {
|
|
||||||
mCurrentConfig.setRegionQualifier(null);
|
|
||||||
} else {
|
|
||||||
RegionQualifier qualifier = null;
|
|
||||||
String segment = RegionQualifier.getFolderSegment(value);
|
|
||||||
if (segment != null) {
|
|
||||||
qualifier = RegionQualifier.getQualifier(segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qualifier != null) {
|
|
||||||
mCurrentConfig.setRegionQualifier(qualifier);
|
|
||||||
} else {
|
|
||||||
// Failure! Looks like the value is wrong (for instance a one letter string).
|
|
||||||
mCurrentConfig.setRegionQualifier(null);
|
|
||||||
mRegionIcon.setImage(mErrorImage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mListener != null) {
|
onDeviceConfigChange();
|
||||||
mListener.onConfigurationChange();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOrientationChange() {
|
private void onDeviceConfigChange() {
|
||||||
// update the current config
|
int deviceIndex = mDeviceList.getSelectionIndex();
|
||||||
int index = mOrientation.getSelectionIndex();
|
DeviceConfiguration device = mDevices[deviceIndex];
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setScreenOrientationQualifier(new ScreenOrientationQualifier(
|
|
||||||
ScreenOrientation.getByIndex(index-1)));
|
|
||||||
} else {
|
|
||||||
mCurrentConfig.setScreenOrientationQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
int configIndex = mDeviceConfigs.getSelectionIndex();
|
||||||
mListener.onConfigurationChange();
|
String name = mDeviceConfigs.getItem(configIndex);
|
||||||
}
|
FolderConfiguration config = device.getConfigs().get(name);
|
||||||
}
|
|
||||||
|
|
||||||
private void onDensityChange() {
|
// get the current qualifiers from the current config
|
||||||
int index = mDensity.getSelectionIndex();
|
CountryCodeQualifier mcc = mCurrentConfig.getCountryCodeQualifier();
|
||||||
if (index != 0) {
|
NetworkCodeQualifier mnc = mCurrentConfig.getNetworkCodeQualifier();
|
||||||
mCurrentConfig.setPixelDensityQualifier((new PixelDensityQualifier(
|
LanguageQualifier lang = mCurrentConfig.getLanguageQualifier();
|
||||||
Density.getByIndex(index-1))));
|
RegionQualifier region = mCurrentConfig.getRegionQualifier();
|
||||||
} else {
|
VersionQualifier version = mCurrentConfig.getVersionQualifier();
|
||||||
mCurrentConfig.setPixelDensityQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
// replace the config with the one from the device
|
||||||
mListener.onConfigurationChange();
|
mCurrentConfig.set(config);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onTouchChange() {
|
// and put back the rest of the qualifiers
|
||||||
// update the current config
|
mCurrentConfig.addQualifier(mcc);
|
||||||
int index = mTouch.getSelectionIndex();
|
mCurrentConfig.addQualifier(mnc);
|
||||||
if (index != 0) {
|
mCurrentConfig.addQualifier(lang);
|
||||||
mCurrentConfig.setTouchTypeQualifier(new TouchScreenQualifier(
|
mCurrentConfig.addQualifier(region);
|
||||||
TouchScreenType.getByIndex(index-1)));
|
mCurrentConfig.addQualifier(version);
|
||||||
} else {
|
|
||||||
mCurrentConfig.setTouchTypeQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onConfigurationChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onKeyboardChange() {
|
|
||||||
// update the current config
|
|
||||||
int index = mKeyboard.getSelectionIndex();
|
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setKeyboardStateQualifier(new KeyboardStateQualifier(
|
|
||||||
KeyboardState.getByIndex(index-1)));
|
|
||||||
} else {
|
|
||||||
mCurrentConfig.setKeyboardStateQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onConfigurationChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onTextInputChange() {
|
|
||||||
// update the current config
|
|
||||||
int index = mTextInput.getSelectionIndex();
|
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setTextInputMethodQualifier(new TextInputMethodQualifier(
|
|
||||||
TextInputMethod.getByIndex(index-1)));
|
|
||||||
} else {
|
|
||||||
mCurrentConfig.setTextInputMethodQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onConfigurationChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onNavigationChange() {
|
|
||||||
// update the current config
|
|
||||||
int index = mNavigation.getSelectionIndex();
|
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setNavigationMethodQualifier(new NavigationMethodQualifier(
|
|
||||||
NavigationMethod.getByIndex(index-1)));
|
|
||||||
} else {
|
|
||||||
mCurrentConfig.setNavigationMethodQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onConfigurationChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onSizeChange() {
|
|
||||||
// because mSize1 and mSize2 trigger onSizeChange at each modification, calling setText()
|
|
||||||
// will trigger notifications, and we don't want that.
|
|
||||||
if (mDisableUpdates == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the current config
|
|
||||||
String size1 = mSize1.getText();
|
|
||||||
String size2 = mSize2.getText();
|
|
||||||
|
|
||||||
// if only one of the strings is empty, do nothing
|
|
||||||
if ((size1.length() == 0) ^ (size2.length() == 0)) {
|
|
||||||
mSizeIcon.setImage(mErrorImage);
|
|
||||||
return;
|
|
||||||
} else if (size1.length() == 0 && size2.length() == 0) {
|
|
||||||
// both sizes are empty: remove the qualifier.
|
|
||||||
mCurrentConfig.setScreenDimensionQualifier(null);
|
|
||||||
} else {
|
|
||||||
ScreenDimensionQualifier qualifier = ScreenDimensionQualifier.getQualifier(size1,
|
|
||||||
size2);
|
|
||||||
|
|
||||||
if (qualifier != null) {
|
|
||||||
mCurrentConfig.setScreenDimensionQualifier(qualifier);
|
|
||||||
} else {
|
|
||||||
// Failure! Looks like the value is wrong.
|
|
||||||
// we do nothing in this case.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onConfigurationChange();
|
mListener.onConfigurationChange();
|
||||||
@@ -1167,49 +661,6 @@ public class ConfigurationComposite extends Composite {
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the Region UI widget based on the current language selection
|
|
||||||
* @param projectResources the project resources or {@code null}.
|
|
||||||
* @param frameworkResources the framework resource or {@code null}
|
|
||||||
*/
|
|
||||||
private void updateRegionUi() {
|
|
||||||
if (mListener == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectResources projectResources = mListener.getProjectResources();
|
|
||||||
ProjectResources frameworkResources = mListener.getFrameworkResources();
|
|
||||||
|
|
||||||
String currentLanguage = mLanguage.getText();
|
|
||||||
|
|
||||||
Set<String> set = null;
|
|
||||||
|
|
||||||
if (projectResources != null) {
|
|
||||||
set = projectResources.getRegions(currentLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frameworkResources != null) {
|
|
||||||
if (set != null) {
|
|
||||||
Set<String> set2 = frameworkResources.getRegions(currentLanguage);
|
|
||||||
set.addAll(set2);
|
|
||||||
} else {
|
|
||||||
set = frameworkResources.getRegions(currentLanguage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (set != null) {
|
|
||||||
mDisableUpdates = true;
|
|
||||||
|
|
||||||
mRegion.removeAll();
|
|
||||||
for (String region : set) {
|
|
||||||
mRegion.add(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
mDisableUpdates = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given <var>style</var> is a theme.
|
* Returns whether the given <var>style</var> is a theme.
|
||||||
* This is done by making sure the parent is a theme.
|
* This is done by making sure the parent is a theme.
|
||||||
|
|||||||
@@ -314,8 +314,11 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration
|
|||||||
|
|
||||||
for (ResourceQualifier qualifier : mQualifiers) {
|
for (ResourceQualifier qualifier : mQualifiers) {
|
||||||
if (qualifier != null) {
|
if (qualifier != null) {
|
||||||
result.append(QUALIFIER_SEP);
|
String segment = qualifier.getFolderSegment(target);
|
||||||
result.append(qualifier.getFolderSegment(target));
|
if (segment != null && segment.length() > 0) {
|
||||||
|
result.append(QUALIFIER_SEP);
|
||||||
|
result.append(segment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ public final class LanguageQualifier extends ResourceQualifier {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LanguageQualifier() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public LanguageQualifier(String value) {
|
||||||
|
mValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
if (mValue != null) {
|
if (mValue != null) {
|
||||||
return mValue;
|
return mValue;
|
||||||
|
|||||||
@@ -134,8 +134,7 @@ public final class NavigationMethodQualifier extends ResourceQualifier {
|
|||||||
public boolean checkAndSet(String value, FolderConfiguration config) {
|
public boolean checkAndSet(String value, FolderConfiguration config) {
|
||||||
NavigationMethod method = NavigationMethod.getEnum(value);
|
NavigationMethod method = NavigationMethod.getEnum(value);
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
NavigationMethodQualifier qualifier = new NavigationMethodQualifier();
|
NavigationMethodQualifier qualifier = new NavigationMethodQualifier(method);
|
||||||
qualifier.mValue = method;
|
|
||||||
config.setNavigationMethodQualifier(qualifier);
|
config.setNavigationMethodQualifier(qualifier);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,14 @@ public final class RegionQualifier extends ResourceQualifier {
|
|||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RegionQualifier() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionQualifier(String value) {
|
||||||
|
mValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
if (mValue != null) {
|
if (mValue != null) {
|
||||||
return mValue;
|
return mValue;
|
||||||
|
|||||||
@@ -48,6 +48,15 @@ public final class ScreenDimensionQualifier extends ResourceQualifier {
|
|||||||
* Default value is <code>DEFAULT_SIZE</code> */
|
* Default value is <code>DEFAULT_SIZE</code> */
|
||||||
private int mValue2 = DEFAULT_SIZE;
|
private int mValue2 = DEFAULT_SIZE;
|
||||||
|
|
||||||
|
public ScreenDimensionQualifier() {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScreenDimensionQualifier(int value1, int value2) {
|
||||||
|
mValue1 = value1;
|
||||||
|
mValue2 = value2;
|
||||||
|
}
|
||||||
|
|
||||||
public int getValue1() {
|
public int getValue1() {
|
||||||
return mValue1;
|
return mValue1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the resources of a project. This is a file view of the resources, with handling
|
* Represents the resources of a project. This is a file view of the resources, with handling
|
||||||
@@ -44,30 +45,30 @@ import java.util.Set;
|
|||||||
public class ProjectResources implements IResourceRepository {
|
public class ProjectResources implements IResourceRepository {
|
||||||
private final HashMap<ResourceFolderType, List<ResourceFolder>> mFolderMap =
|
private final HashMap<ResourceFolderType, List<ResourceFolder>> mFolderMap =
|
||||||
new HashMap<ResourceFolderType, List<ResourceFolder>>();
|
new HashMap<ResourceFolderType, List<ResourceFolder>>();
|
||||||
|
|
||||||
private final HashMap<ResourceType, List<ProjectResourceItem>> mResourceMap =
|
private final HashMap<ResourceType, List<ProjectResourceItem>> mResourceMap =
|
||||||
new HashMap<ResourceType, List<ProjectResourceItem>>();
|
new HashMap<ResourceType, List<ProjectResourceItem>>();
|
||||||
|
|
||||||
/** Map of (name, id) for resources of type {@link ResourceType#ID} coming from R.java */
|
/** Map of (name, id) for resources of type {@link ResourceType#ID} coming from R.java */
|
||||||
private Map<String, Map<String, Integer>> mResourceValueMap;
|
private Map<String, Map<String, Integer>> mResourceValueMap;
|
||||||
/** Map of (id, [name, resType]) for all resources coming from R.java */
|
/** Map of (id, [name, resType]) for all resources coming from R.java */
|
||||||
private Map<Integer, String[]> mResIdValueToNameMap;
|
private Map<Integer, String[]> mResIdValueToNameMap;
|
||||||
/** Map of (int[], name) for styleable resources coming from R.java */
|
/** Map of (int[], name) for styleable resources coming from R.java */
|
||||||
private Map<IntArrayWrapper, String> mStyleableValueToNameMap;
|
private Map<IntArrayWrapper, String> mStyleableValueToNameMap;
|
||||||
|
|
||||||
/** Cached list of {@link IdResourceItem}. This is mix of IdResourceItem created by
|
/** Cached list of {@link IdResourceItem}. This is mix of IdResourceItem created by
|
||||||
* {@link MultiResourceFile} for ids coming from XML files under res/values and
|
* {@link MultiResourceFile} for ids coming from XML files under res/values and
|
||||||
* {@link IdResourceItem} created manually, from the list coming from R.java */
|
* {@link IdResourceItem} created manually, from the list coming from R.java */
|
||||||
private final ArrayList<IdResourceItem> mIdResourceList = new ArrayList<IdResourceItem>();
|
private final ArrayList<IdResourceItem> mIdResourceList = new ArrayList<IdResourceItem>();
|
||||||
|
|
||||||
private final boolean mIsFrameworkRepository;
|
private final boolean mIsFrameworkRepository;
|
||||||
|
|
||||||
private final IntArrayWrapper mWrapper = new IntArrayWrapper(null);
|
private final IntArrayWrapper mWrapper = new IntArrayWrapper(null);
|
||||||
|
|
||||||
public ProjectResources(boolean isFrameworkRepository) {
|
public ProjectResources(boolean isFrameworkRepository) {
|
||||||
mIsFrameworkRepository = isFrameworkRepository;
|
mIsFrameworkRepository = isFrameworkRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSystemRepository() {
|
public boolean isSystemRepository() {
|
||||||
return mIsFrameworkRepository;
|
return mIsFrameworkRepository;
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
IAbstractFolder folder) {
|
IAbstractFolder folder) {
|
||||||
// get the list for the resource type
|
// get the list for the resource type
|
||||||
List<ResourceFolder> list = mFolderMap.get(type);
|
List<ResourceFolder> list = mFolderMap.get(type);
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<ResourceFolder>();
|
list = new ArrayList<ResourceFolder>();
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
list.add(cf);
|
list.add(cf);
|
||||||
|
|
||||||
mFolderMap.put(type, list);
|
mFolderMap.put(type, list);
|
||||||
|
|
||||||
return cf;
|
return cf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
// So we add one.
|
// So we add one.
|
||||||
ResourceFolder cf = new ResourceFolder(type, config, folder, mIsFrameworkRepository);
|
ResourceFolder cf = new ResourceFolder(type, config, folder, mIsFrameworkRepository);
|
||||||
list.add(cf);
|
list.add(cf);
|
||||||
|
|
||||||
return cf;
|
return cf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
protected void removeFolder(ResourceFolderType type, IFolder folder) {
|
protected void removeFolder(ResourceFolderType type, IFolder folder) {
|
||||||
// get the list of folders for the resource type.
|
// get the list of folders for the resource type.
|
||||||
List<ResourceFolder> list = mFolderMap.get(type);
|
List<ResourceFolder> list = mFolderMap.get(type);
|
||||||
|
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
int count = list.size();
|
int count = list.size();
|
||||||
for (int i = 0 ; i < count ; i++) {
|
for (int i = 0 ; i < count ; i++) {
|
||||||
@@ -129,7 +130,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
if (resFolder.getFolder().getIFolder().equals(folder)) {
|
if (resFolder.getFolder().getIFolder().equals(folder)) {
|
||||||
// we found the matching ResourceFolder. we need to remove it.
|
// we found the matching ResourceFolder. we need to remove it.
|
||||||
list.remove(i);
|
list.remove(i);
|
||||||
|
|
||||||
// we now need to invalidate this resource type.
|
// we now need to invalidate this resource type.
|
||||||
// The easiest way is to touch one of the other folders of the same type.
|
// The easiest way is to touch one of the other folders of the same type.
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
@@ -146,23 +147,23 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
// If we don't find a single folder to touch, then it's fine, as the top
|
// If we don't find a single folder to touch, then it's fine, as the top
|
||||||
// level items (the list of generated resource types) is not cached
|
// level items (the list of generated resource types) is not cached
|
||||||
// (for now)
|
// (for now)
|
||||||
|
|
||||||
// get the lists of ResourceTypes generated by this ResourceFolderType
|
// get the lists of ResourceTypes generated by this ResourceFolderType
|
||||||
ResourceType[] resTypes = FolderTypeRelationship.getRelatedResourceTypes(
|
ResourceType[] resTypes = FolderTypeRelationship.getRelatedResourceTypes(
|
||||||
type);
|
type);
|
||||||
|
|
||||||
// for each of those, make sure to find one folder to touch so that the
|
// for each of those, make sure to find one folder to touch so that the
|
||||||
// list of ResourceItem associated with the type is rebuilt.
|
// list of ResourceItem associated with the type is rebuilt.
|
||||||
for (ResourceType resType : resTypes) {
|
for (ResourceType resType : resTypes) {
|
||||||
// get the list of folder that can generate this type
|
// get the list of folder that can generate this type
|
||||||
ResourceFolderType[] folderTypes =
|
ResourceFolderType[] folderTypes =
|
||||||
FolderTypeRelationship.getRelatedFolders(resType);
|
FolderTypeRelationship.getRelatedFolders(resType);
|
||||||
|
|
||||||
// we only need to touch one folder in any of those (since it's one
|
// we only need to touch one folder in any of those (since it's one
|
||||||
// folder per type, not per folder type).
|
// folder per type, not per folder type).
|
||||||
for (ResourceFolderType folderType : folderTypes) {
|
for (ResourceFolderType folderType : folderTypes) {
|
||||||
List<ResourceFolder> resFolders = mFolderMap.get(folderType);
|
List<ResourceFolder> resFolders = mFolderMap.get(folderType);
|
||||||
|
|
||||||
if (resFolders != null && resFolders.size() > 0) {
|
if (resFolders != null && resFolders.size() > 0) {
|
||||||
resFolders.get(0).touch();
|
resFolders.get(0).touch();
|
||||||
break;
|
break;
|
||||||
@@ -170,7 +171,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're done updating/touching, we can stop
|
// we're done updating/touching, we can stop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -178,7 +179,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of {@link ResourceFolder} for a specific {@link ResourceFolderType}.
|
* Returns a list of {@link ResourceFolder} for a specific {@link ResourceFolderType}.
|
||||||
* @param type The {@link ResourceFolderType}
|
* @param type The {@link ResourceFolderType}
|
||||||
@@ -186,13 +187,13 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
public List<ResourceFolder> getFolders(ResourceFolderType type) {
|
public List<ResourceFolder> getFolders(ResourceFolderType type) {
|
||||||
return mFolderMap.get(type);
|
return mFolderMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.android.ide.eclipse.editors.resources.IResourceRepository#getAvailableResourceTypes()
|
* @see com.android.ide.eclipse.editors.resources.IResourceRepository#getAvailableResourceTypes()
|
||||||
*/
|
*/
|
||||||
public ResourceType[] getAvailableResourceTypes() {
|
public ResourceType[] getAvailableResourceTypes() {
|
||||||
ArrayList<ResourceType> list = new ArrayList<ResourceType>();
|
ArrayList<ResourceType> list = new ArrayList<ResourceType>();
|
||||||
|
|
||||||
// For each key, we check if there's a single ResourceType match.
|
// For each key, we check if there's a single ResourceType match.
|
||||||
// If not, we look for the actual content to give us the resource type.
|
// If not, we look for the actual content to give us the resource type.
|
||||||
|
|
||||||
@@ -213,7 +214,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
if (folders != null) {
|
if (folders != null) {
|
||||||
for (ResourceFolder folder : folders) {
|
for (ResourceFolder folder : folders) {
|
||||||
Collection<ResourceType> folderContent = folder.getResourceTypes();
|
Collection<ResourceType> folderContent = folder.getResourceTypes();
|
||||||
|
|
||||||
// then we add them, but only if they aren't already in the list.
|
// then we add them, but only if they aren't already in the list.
|
||||||
for (ResourceType folderResType : folderContent) {
|
for (ResourceType folderResType : folderContent) {
|
||||||
if (list.indexOf(folderResType) == -1) {
|
if (list.indexOf(folderResType) == -1) {
|
||||||
@@ -224,7 +225,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case ResourceType.ID haven't been added yet because there's no id defined
|
// in case ResourceType.ID haven't been added yet because there's no id defined
|
||||||
// in XML, we check on the list of compiled id resources.
|
// in XML, we check on the list of compiled id resources.
|
||||||
if (list.indexOf(ResourceType.ID) == -1 && mResourceValueMap != null) {
|
if (list.indexOf(ResourceType.ID) == -1 && mResourceValueMap != null) {
|
||||||
@@ -237,7 +238,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
// at this point the list is full of ResourceType defined in the files.
|
// at this point the list is full of ResourceType defined in the files.
|
||||||
// We need to sort it.
|
// We need to sort it.
|
||||||
Collections.sort(list);
|
Collections.sort(list);
|
||||||
|
|
||||||
return list.toArray(new ResourceType[list.size()]);
|
return list.toArray(new ResourceType[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,15 +247,15 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
*/
|
*/
|
||||||
public ProjectResourceItem[] getResources(ResourceType type) {
|
public ProjectResourceItem[] getResources(ResourceType type) {
|
||||||
checkAndUpdate(type);
|
checkAndUpdate(type);
|
||||||
|
|
||||||
if (type == ResourceType.ID) {
|
if (type == ResourceType.ID) {
|
||||||
synchronized (mIdResourceList) {
|
synchronized (mIdResourceList) {
|
||||||
return mIdResourceList.toArray(new ProjectResourceItem[mIdResourceList.size()]);
|
return mIdResourceList.toArray(new ProjectResourceItem[mIdResourceList.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ProjectResourceItem> items = mResourceMap.get(type);
|
List<ProjectResourceItem> items = mResourceMap.get(type);
|
||||||
|
|
||||||
return items.toArray(new ProjectResourceItem[items.size()]);
|
return items.toArray(new ProjectResourceItem[items.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,10 +288,10 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link ResourceFile} matching the given name, {@link ResourceFolderType} and
|
* Returns the {@link ResourceFile} matching the given name, {@link ResourceFolderType} and
|
||||||
* configuration.
|
* configuration.
|
||||||
@@ -305,29 +306,29 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
|
|
||||||
// look for folders containing a file with the given name.
|
// look for folders containing a file with the given name.
|
||||||
ArrayList<ResourceFolder> matchingFolders = new ArrayList<ResourceFolder>();
|
ArrayList<ResourceFolder> matchingFolders = new ArrayList<ResourceFolder>();
|
||||||
|
|
||||||
// remove the folders that do not have a file with the given name, or if their config
|
// remove the folders that do not have a file with the given name, or if their config
|
||||||
// is incompatible.
|
// is incompatible.
|
||||||
for (int i = 0 ; i < folders.size(); i++) {
|
for (int i = 0 ; i < folders.size(); i++) {
|
||||||
ResourceFolder folder = folders.get(i);
|
ResourceFolder folder = folders.get(i);
|
||||||
|
|
||||||
if (folder.hasFile(name) == true) {
|
if (folder.hasFile(name) == true) {
|
||||||
matchingFolders.add(folder);
|
matchingFolders.add(folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// from those, get the folder with a config matching the given reference configuration.
|
// from those, get the folder with a config matching the given reference configuration.
|
||||||
Resource match = findMatchingConfiguredResource(matchingFolders, config);
|
Resource match = findMatchingConfiguredResource(matchingFolders, config);
|
||||||
|
|
||||||
// do we have a matching folder?
|
// do we have a matching folder?
|
||||||
if (match instanceof ResourceFolder) {
|
if (match instanceof ResourceFolder) {
|
||||||
// get the ResourceFile from the filename
|
// get the ResourceFile from the filename
|
||||||
return ((ResourceFolder)match).getFile(name);
|
return ((ResourceFolder)match).getFile(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the resources values matching a given {@link FolderConfiguration}.
|
* Returns the resources values matching a given {@link FolderConfiguration}.
|
||||||
* @param referenceConfig the configuration that each value must match.
|
* @param referenceConfig the configuration that each value must match.
|
||||||
@@ -337,7 +338,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
|
|
||||||
Map<String, Map<String, IResourceValue>> map =
|
Map<String, Map<String, IResourceValue>> map =
|
||||||
new HashMap<String, Map<String, IResourceValue>>();
|
new HashMap<String, Map<String, IResourceValue>>();
|
||||||
|
|
||||||
// special case for Id since there's a mix of compiled id (declared inline) and id declared
|
// special case for Id since there's a mix of compiled id (declared inline) and id declared
|
||||||
// in the XML files.
|
// in the XML files.
|
||||||
if (mIdResourceList.size() > 0) {
|
if (mIdResourceList.size() > 0) {
|
||||||
@@ -348,10 +349,10 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
idMap.put(id.getName(), new ResourceValue(idType, id.getName(),
|
idMap.put(id.getName(), new ResourceValue(idType, id.getName(),
|
||||||
mIsFrameworkRepository));
|
mIsFrameworkRepository));
|
||||||
}
|
}
|
||||||
|
|
||||||
map.put(ResourceType.ID.getName(), idMap);
|
map.put(ResourceType.ID.getName(), idMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<ResourceType> keys = mResourceMap.keySet();
|
Set<ResourceType> keys = mResourceMap.keySet();
|
||||||
for (ResourceType key : keys) {
|
for (ResourceType key : keys) {
|
||||||
// we don't process ID resources since we already did it above.
|
// we don't process ID resources since we already did it above.
|
||||||
@@ -359,10 +360,10 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
map.put(key.getName(), getConfiguredResource(key, referenceConfig));
|
map.put(key.getName(), getConfiguredResource(key, referenceConfig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all the resources. Essentially this forces to load the values from the
|
* Loads all the resources. Essentially this forces to load the values from the
|
||||||
* {@link ResourceFile} objects to make sure they are up to date and loaded
|
* {@link ResourceFile} objects to make sure they are up to date and loaded
|
||||||
@@ -371,13 +372,13 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
public void loadAll() {
|
public void loadAll() {
|
||||||
// gets all the resource types available.
|
// gets all the resource types available.
|
||||||
ResourceType[] types = getAvailableResourceTypes();
|
ResourceType[] types = getAvailableResourceTypes();
|
||||||
|
|
||||||
// loop on them and load them
|
// loop on them and load them
|
||||||
for (ResourceType type: types) {
|
for (ResourceType type: types) {
|
||||||
checkAndUpdate(type);
|
checkAndUpdate(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves a compiled resource id into the resource name and type
|
* Resolves a compiled resource id into the resource name and type
|
||||||
* @param id
|
* @param id
|
||||||
@@ -387,7 +388,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
if (mResIdValueToNameMap != null) {
|
if (mResIdValueToNameMap != null) {
|
||||||
return mResIdValueToNameMap.get(id);
|
return mResIdValueToNameMap.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +400,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
mWrapper.set(id);
|
mWrapper.set(id);
|
||||||
return mStyleableValueToNameMap.get(mWrapper);
|
return mStyleableValueToNameMap.get(mWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,12 +417,12 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of languages used in the resources.
|
* Returns the sorted list of languages used in the resources.
|
||||||
*/
|
*/
|
||||||
public Set<String> getLanguages() {
|
public SortedSet<String> getLanguages() {
|
||||||
Set<String> set = new HashSet<String>();
|
SortedSet<String> set = new TreeSet<String>();
|
||||||
|
|
||||||
Collection<List<ResourceFolder>> folderList = mFolderMap.values();
|
Collection<List<ResourceFolder>> folderList = mFolderMap.values();
|
||||||
for (List<ResourceFolder> folderSubList : folderList) {
|
for (List<ResourceFolder> folderSubList : folderList) {
|
||||||
@@ -433,22 +434,22 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of regions used in the resources with the given language.
|
* Returns the sorted list of regions used in the resources with the given language.
|
||||||
* @param currentLanguage the current language the region must be associated with.
|
* @param currentLanguage the current language the region must be associated with.
|
||||||
*/
|
*/
|
||||||
public Set<String> getRegions(String currentLanguage) {
|
public SortedSet<String> getRegions(String currentLanguage) {
|
||||||
Set<String> set = new HashSet<String>();
|
SortedSet<String> set = new TreeSet<String>();
|
||||||
|
|
||||||
Collection<List<ResourceFolder>> folderList = mFolderMap.values();
|
Collection<List<ResourceFolder>> folderList = mFolderMap.values();
|
||||||
for (List<ResourceFolder> folderSubList : folderList) {
|
for (List<ResourceFolder> folderSubList : folderList) {
|
||||||
for (ResourceFolder folder : folderSubList) {
|
for (ResourceFolder folder : folderSubList) {
|
||||||
FolderConfiguration config = folder.getConfiguration();
|
FolderConfiguration config = folder.getConfiguration();
|
||||||
|
|
||||||
// get the language
|
// get the language
|
||||||
LanguageQualifier lang = config.getLanguageQualifier();
|
LanguageQualifier lang = config.getLanguageQualifier();
|
||||||
if (lang != null && lang.getStringValue().equals(currentLanguage)) {
|
if (lang != null && lang.getStringValue().equals(currentLanguage)) {
|
||||||
@@ -459,7 +460,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,23 +475,23 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
FolderConfiguration referenceConfig) {
|
FolderConfiguration referenceConfig) {
|
||||||
// get the resource item for the given type
|
// get the resource item for the given type
|
||||||
List<ProjectResourceItem> items = mResourceMap.get(type);
|
List<ProjectResourceItem> items = mResourceMap.get(type);
|
||||||
|
|
||||||
// create the map
|
// create the map
|
||||||
HashMap<String, IResourceValue> map = new HashMap<String, IResourceValue>();
|
HashMap<String, IResourceValue> map = new HashMap<String, IResourceValue>();
|
||||||
|
|
||||||
for (ProjectResourceItem item : items) {
|
for (ProjectResourceItem item : items) {
|
||||||
// get the source files generating this resource
|
// get the source files generating this resource
|
||||||
List<ResourceFile> list = item.getSourceFileList();
|
List<ResourceFile> list = item.getSourceFileList();
|
||||||
|
|
||||||
// look for the best match for the given configuration
|
// look for the best match for the given configuration
|
||||||
Resource match = findMatchingConfiguredResource(list, referenceConfig);
|
Resource match = findMatchingConfiguredResource(list, referenceConfig);
|
||||||
|
|
||||||
if (match instanceof ResourceFile) {
|
if (match instanceof ResourceFile) {
|
||||||
ResourceFile matchResFile = (ResourceFile)match;
|
ResourceFile matchResFile = (ResourceFile)match;
|
||||||
|
|
||||||
// get the value of this configured resource.
|
// get the value of this configured resource.
|
||||||
IResourceValue value = matchResFile.getValue(type, item.getName());
|
IResourceValue value = matchResFile.getValue(type, item.getName());
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
map.put(item.getName(), value);
|
map.put(item.getName(), value);
|
||||||
}
|
}
|
||||||
@@ -501,7 +502,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the best matching {@link Resource}.
|
* Returns the best matching {@link Resource}.
|
||||||
* @param resources the list of {@link Resource} to choose from.
|
* @param resources the list of {@link Resource} to choose from.
|
||||||
* @param referenceConfig the {@link FolderConfiguration} to match.
|
* @param referenceConfig the {@link FolderConfiguration} to match.
|
||||||
*/
|
*/
|
||||||
@@ -512,7 +513,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
ArrayList<Resource> matchingResources = new ArrayList<Resource>();
|
ArrayList<Resource> matchingResources = new ArrayList<Resource>();
|
||||||
for (int i = 0 ; i < resources.size(); i++) {
|
for (int i = 0 ; i < resources.size(); i++) {
|
||||||
Resource res = resources.get(i);
|
Resource res = resources.get(i);
|
||||||
|
|
||||||
int count = res.getConfiguration().match(referenceConfig);
|
int count = res.getConfiguration().match(referenceConfig);
|
||||||
if (count > currentMax) {
|
if (count > currentMax) {
|
||||||
matchingResources.clear();
|
matchingResources.clear();
|
||||||
@@ -522,7 +523,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
matchingResources.add(res);
|
matchingResources.add(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have more than one match, we look for the match with the qualifiers with the
|
// if we have more than one match, we look for the match with the qualifiers with the
|
||||||
// highest priority.
|
// highest priority.
|
||||||
Resource resMatch = null;
|
Resource resMatch = null;
|
||||||
@@ -537,7 +538,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
int highest = -1;
|
int highest = -1;
|
||||||
for (int i = 0 ; i < matchingResources.size() ; i++) {
|
for (int i = 0 ; i < matchingResources.size() ; i++) {
|
||||||
Resource folder = matchingResources.get(i);
|
Resource folder = matchingResources.get(i);
|
||||||
|
|
||||||
// get highest priority qualifiers.
|
// get highest priority qualifiers.
|
||||||
int m = folder.getConfiguration().getHighestPriorityQualifier(startIndex);
|
int m = folder.getConfiguration().getHighestPriorityQualifier(startIndex);
|
||||||
|
|
||||||
@@ -552,12 +553,12 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// at this point, we have a list with 1+ resources that all have the same highest
|
// at this point, we have a list with 1+ resources that all have the same highest
|
||||||
// priority qualifiers. Go through the list again looking for the next highest
|
// priority qualifiers. Go through the list again looking for the next highest
|
||||||
// priority qualifier.
|
// priority qualifier.
|
||||||
startIndex = highest + 1;
|
startIndex = highest + 1;
|
||||||
|
|
||||||
// this should not happen, but it's better to check.
|
// this should not happen, but it's better to check.
|
||||||
if (matchingResources.size() == tmpResources.size() && highest == -1) {
|
if (matchingResources.size() == tmpResources.size() && highest == -1) {
|
||||||
// this means all the resources match with the same qualifiers
|
// this means all the resources match with the same qualifiers
|
||||||
@@ -571,7 +572,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
tmpResources.clear();
|
tmpResources.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we should have only one match here.
|
// we should have only one match here.
|
||||||
resMatch = matchingResources.get(0);
|
resMatch = matchingResources.get(0);
|
||||||
}
|
}
|
||||||
@@ -581,7 +582,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the list of {@link ResourceItem}s for the specified {@link ResourceType} needs
|
* Checks if the list of {@link ResourceItem}s for the specified {@link ResourceType} needs
|
||||||
* to be updated.
|
* to be updated.
|
||||||
* @param type the Resource Type.
|
* @param type the Resource Type.
|
||||||
*/
|
*/
|
||||||
private void checkAndUpdate(ResourceType type) {
|
private void checkAndUpdate(ResourceType type) {
|
||||||
@@ -590,7 +591,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
|
|
||||||
for (ResourceFolderType folderType : folderTypes) {
|
for (ResourceFolderType folderType : folderTypes) {
|
||||||
List<ResourceFolder> folders = mFolderMap.get(folderType);
|
List<ResourceFolder> folders = mFolderMap.get(folderType);
|
||||||
|
|
||||||
if (folders != null) {
|
if (folders != null) {
|
||||||
for (ResourceFolder folder : folders) {
|
for (ResourceFolder folder : folders) {
|
||||||
if (folder.isTouched()) {
|
if (folder.isTouched()) {
|
||||||
@@ -618,7 +619,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
// get the cache list, and lets make a backup
|
// get the cache list, and lets make a backup
|
||||||
List<ProjectResourceItem> items = mResourceMap.get(type);
|
List<ProjectResourceItem> items = mResourceMap.get(type);
|
||||||
List<ProjectResourceItem> backup = new ArrayList<ProjectResourceItem>();
|
List<ProjectResourceItem> backup = new ArrayList<ProjectResourceItem>();
|
||||||
|
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
items = new ArrayList<ProjectResourceItem>();
|
items = new ArrayList<ProjectResourceItem>();
|
||||||
mResourceMap.put(type, items);
|
mResourceMap.put(type, items);
|
||||||
@@ -629,7 +630,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
// we reset the list itself.
|
// we reset the list itself.
|
||||||
items.clear();
|
items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the list of folder that can output this type
|
// get the list of folder that can output this type
|
||||||
ResourceFolderType[] folderTypes = FolderTypeRelationship.getRelatedFolders(type);
|
ResourceFolderType[] folderTypes = FolderTypeRelationship.getRelatedFolders(type);
|
||||||
|
|
||||||
@@ -656,7 +657,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
for (int i = 0 ; i < count;) {
|
for (int i = 0 ; i < count;) {
|
||||||
// get the "new" item
|
// get the "new" item
|
||||||
ProjectResourceItem item = items.get(i);
|
ProjectResourceItem item = items.get(i);
|
||||||
|
|
||||||
// look for a similar item in the old list.
|
// look for a similar item in the old list.
|
||||||
ProjectResourceItem foundOldItem = null;
|
ProjectResourceItem foundOldItem = null;
|
||||||
for (ProjectResourceItem oldItem : backup) {
|
for (ProjectResourceItem oldItem : backup) {
|
||||||
@@ -665,15 +666,15 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundOldItem != null) {
|
if (foundOldItem != null) {
|
||||||
// erase the data of the old item with the data from the new one.
|
// erase the data of the old item with the data from the new one.
|
||||||
foundOldItem.replaceWith(item);
|
foundOldItem.replaceWith(item);
|
||||||
|
|
||||||
// remove the old and new item from their respective lists
|
// remove the old and new item from their respective lists
|
||||||
items.remove(i);
|
items.remove(i);
|
||||||
backup.remove(foundOldItem);
|
backup.remove(foundOldItem);
|
||||||
|
|
||||||
// add the old item to the new list
|
// add the old item to the new list
|
||||||
items.add(foundOldItem);
|
items.add(foundOldItem);
|
||||||
} else {
|
} else {
|
||||||
@@ -682,7 +683,7 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this is the ResourceType.ID, we create the actual list, from this list and
|
// if this is the ResourceType.ID, we create the actual list, from this list and
|
||||||
// the compiled resource list.
|
// the compiled resource list.
|
||||||
if (type == ResourceType.ID) {
|
if (type == ResourceType.ID) {
|
||||||
@@ -694,20 +695,20 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up an existing {@link ProjectResourceItem} by {@link ResourceType} and name.
|
* Looks up an existing {@link ProjectResourceItem} by {@link ResourceType} and name.
|
||||||
* @param type the Resource Type.
|
* @param type the Resource Type.
|
||||||
* @param name the Resource name.
|
* @param name the Resource name.
|
||||||
* @return the existing ResourceItem or null if no match was found.
|
* @return the existing ResourceItem or null if no match was found.
|
||||||
*/
|
*/
|
||||||
protected ProjectResourceItem findResourceItem(ResourceType type, String name) {
|
protected ProjectResourceItem findResourceItem(ResourceType type, String name) {
|
||||||
List<ProjectResourceItem> list = mResourceMap.get(type);
|
List<ProjectResourceItem> list = mResourceMap.get(type);
|
||||||
|
|
||||||
for (ProjectResourceItem item : list) {
|
for (ProjectResourceItem item : list) {
|
||||||
if (name.equals(item.getName())) {
|
if (name.equals(item.getName())) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,13 +746,13 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
|
|
||||||
// empty the current list
|
// empty the current list
|
||||||
mIdResourceList.clear();
|
mIdResourceList.clear();
|
||||||
|
|
||||||
// get the list of compile id resources.
|
// get the list of compile id resources.
|
||||||
Map<String, Integer> idMap = null;
|
Map<String, Integer> idMap = null;
|
||||||
if (mResourceValueMap != null) {
|
if (mResourceValueMap != null) {
|
||||||
idMap = mResourceValueMap.get(ResourceType.ID.getName());
|
idMap = mResourceValueMap.get(ResourceType.ID.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idMap == null) {
|
if (idMap == null) {
|
||||||
if (xmlIdResources != null) {
|
if (xmlIdResources != null) {
|
||||||
for (ProjectResourceItem resourceItem : xmlIdResources) {
|
for (ProjectResourceItem resourceItem : xmlIdResources) {
|
||||||
@@ -764,21 +765,21 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
} else {
|
} else {
|
||||||
// loop on the full list of id, and look for a match in the old list,
|
// loop on the full list of id, and look for a match in the old list,
|
||||||
// in the list coming from XML (in case a new XML item was created.)
|
// in the list coming from XML (in case a new XML item was created.)
|
||||||
|
|
||||||
Set<String> idSet = idMap.keySet();
|
Set<String> idSet = idMap.keySet();
|
||||||
|
|
||||||
idLoop: for (String idResource : idSet) {
|
idLoop: for (String idResource : idSet) {
|
||||||
// first look in the XML list in case an id went from inline to XML declared.
|
// first look in the XML list in case an id went from inline to XML declared.
|
||||||
if (xmlIdResources != null) {
|
if (xmlIdResources != null) {
|
||||||
for (ProjectResourceItem resourceItem : xmlIdResources) {
|
for (ProjectResourceItem resourceItem : xmlIdResources) {
|
||||||
if (resourceItem instanceof IdResourceItem &&
|
if (resourceItem instanceof IdResourceItem &&
|
||||||
resourceItem.getName().equals(idResource)) {
|
resourceItem.getName().equals(idResource)) {
|
||||||
mIdResourceList.add((IdResourceItem)resourceItem);
|
mIdResourceList.add((IdResourceItem)resourceItem);
|
||||||
continue idLoop;
|
continue idLoop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't found it, look in the old items.
|
// if we haven't found it, look in the old items.
|
||||||
int count = oldItems.size();
|
int count = oldItems.size();
|
||||||
for (int i = 0 ; i < count ; i++) {
|
for (int i = 0 ; i < count ; i++) {
|
||||||
@@ -789,14 +790,14 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
continue idLoop;
|
continue idLoop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't found it, it looks like it's a new id that was
|
// if we haven't found it, it looks like it's a new id that was
|
||||||
// declared inline.
|
// declared inline.
|
||||||
mIdResourceList.add(new IdResourceItem(idResource,
|
mIdResourceList.add(new IdResourceItem(idResource,
|
||||||
true /* isDeclaredInline */));
|
true /* isDeclaredInline */));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we sort the list
|
// now we sort the list
|
||||||
Collections.sort(mIdResourceList);
|
Collections.sort(mIdResourceList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.util.Map;
|
|||||||
* This class contains the data of an Android Target as loaded from the SDK.
|
* This class contains the data of an Android Target as loaded from the SDK.
|
||||||
*/
|
*/
|
||||||
public class AndroidTargetData {
|
public class AndroidTargetData {
|
||||||
|
|
||||||
public final static int DESCRIPTOR_MANIFEST = 1;
|
public final static int DESCRIPTOR_MANIFEST = 1;
|
||||||
public final static int DESCRIPTOR_LAYOUT = 2;
|
public final static int DESCRIPTOR_LAYOUT = 2;
|
||||||
public final static int DESCRIPTOR_MENU = 3;
|
public final static int DESCRIPTOR_MENU = 3;
|
||||||
@@ -45,15 +45,15 @@ public class AndroidTargetData {
|
|||||||
public final static int DESCRIPTOR_SEARCHABLE = 6;
|
public final static int DESCRIPTOR_SEARCHABLE = 6;
|
||||||
public final static int DESCRIPTOR_PREFERENCES = 7;
|
public final static int DESCRIPTOR_PREFERENCES = 7;
|
||||||
public final static int DESCRIPTOR_APPWIDGET_PROVIDER = 8;
|
public final static int DESCRIPTOR_APPWIDGET_PROVIDER = 8;
|
||||||
|
|
||||||
public final static class LayoutBridge {
|
public final static class LayoutBridge {
|
||||||
/** Link to the layout bridge */
|
/** Link to the layout bridge */
|
||||||
public ILayoutBridge bridge;
|
public ILayoutBridge bridge;
|
||||||
|
|
||||||
public LoadStatus status = LoadStatus.LOADING;
|
public LoadStatus status = LoadStatus.LOADING;
|
||||||
|
|
||||||
public ClassLoader classLoader;
|
public ClassLoader classLoader;
|
||||||
|
|
||||||
public int apiLevel;
|
public int apiLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +67,12 @@ public class AndroidTargetData {
|
|||||||
* The attribute namespace prefix must be:
|
* The attribute namespace prefix must be:
|
||||||
* - "android" for AndroidConstants.NS_RESOURCES
|
* - "android" for AndroidConstants.NS_RESOURCES
|
||||||
* - "xmlns" for the XMLNS URI.
|
* - "xmlns" for the XMLNS URI.
|
||||||
*
|
*
|
||||||
* This is used for attributes that do not have a unique name, but still need to be populated
|
* This is used for attributes that do not have a unique name, but still need to be populated
|
||||||
* with values in the UI. Uniquely named attributes have their values in {@link #mEnumValueMap}.
|
* with values in the UI. Uniquely named attributes have their values in {@link #mEnumValueMap}.
|
||||||
*/
|
*/
|
||||||
private Hashtable<String, String[]> mAttributeValues = new Hashtable<String, String[]>();
|
private Hashtable<String, String[]> mAttributeValues = new Hashtable<String, String[]>();
|
||||||
|
|
||||||
private IResourceRepository mSystemResourceRepository;
|
private IResourceRepository mSystemResourceRepository;
|
||||||
|
|
||||||
private AndroidManifestDescriptors mManifestDescriptors;
|
private AndroidManifestDescriptors mManifestDescriptors;
|
||||||
@@ -86,19 +86,20 @@ public class AndroidTargetData {
|
|||||||
private LayoutBridge mLayoutBridge;
|
private LayoutBridge mLayoutBridge;
|
||||||
|
|
||||||
private boolean mLayoutBridgeInit = false;
|
private boolean mLayoutBridgeInit = false;
|
||||||
|
private DeviceConfiguration[] mDevices;
|
||||||
|
|
||||||
AndroidTargetData(IAndroidTarget androidTarget) {
|
AndroidTargetData(IAndroidTarget androidTarget) {
|
||||||
mTarget = androidTarget;
|
mTarget = androidTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDexWrapper(DexWrapper wrapper) {
|
void setDexWrapper(DexWrapper wrapper) {
|
||||||
mDexWrapper = wrapper;
|
mDexWrapper = wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AndroidTargetData object.
|
* Creates an AndroidTargetData object.
|
||||||
* @param platformLibraries
|
* @param platformLibraries
|
||||||
* @param optionalLibraries
|
* @param optionalLibraries
|
||||||
*/
|
*/
|
||||||
void setExtraData(IResourceRepository systemResourceRepository,
|
void setExtraData(IResourceRepository systemResourceRepository,
|
||||||
AndroidManifestDescriptors manifestDescriptors,
|
AndroidManifestDescriptors manifestDescriptors,
|
||||||
@@ -113,15 +114,17 @@ public class AndroidTargetData {
|
|||||||
String[] intentCategoryValues,
|
String[] intentCategoryValues,
|
||||||
String[] platformLibraries,
|
String[] platformLibraries,
|
||||||
IOptionalLibrary[] optionalLibraries,
|
IOptionalLibrary[] optionalLibraries,
|
||||||
|
DeviceConfiguration[] devices,
|
||||||
ProjectResources resources,
|
ProjectResources resources,
|
||||||
LayoutBridge layoutBridge) {
|
LayoutBridge layoutBridge) {
|
||||||
|
|
||||||
mSystemResourceRepository = systemResourceRepository;
|
mSystemResourceRepository = systemResourceRepository;
|
||||||
mManifestDescriptors = manifestDescriptors;
|
mManifestDescriptors = manifestDescriptors;
|
||||||
mLayoutDescriptors = layoutDescriptors;
|
mLayoutDescriptors = layoutDescriptors;
|
||||||
mMenuDescriptors = menuDescriptors;
|
mMenuDescriptors = menuDescriptors;
|
||||||
mXmlDescriptors = xmlDescriptors;
|
mXmlDescriptors = xmlDescriptors;
|
||||||
mEnumValueMap = enumValueMap;
|
mEnumValueMap = enumValueMap;
|
||||||
|
mDevices = devices;
|
||||||
mFrameworkResources = resources;
|
mFrameworkResources = resources;
|
||||||
mLayoutBridge = layoutBridge;
|
mLayoutBridge = layoutBridge;
|
||||||
|
|
||||||
@@ -134,11 +137,11 @@ public class AndroidTargetData {
|
|||||||
public DexWrapper getDexWrapper() {
|
public DexWrapper getDexWrapper() {
|
||||||
return mDexWrapper;
|
return mDexWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResourceRepository getSystemResources() {
|
public IResourceRepository getSystemResources() {
|
||||||
return mSystemResourceRepository;
|
return mSystemResourceRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link IDescriptorProvider} from a given Id.
|
* Returns an {@link IDescriptorProvider} from a given Id.
|
||||||
* The Id can be one of {@link #DESCRIPTOR_MANIFEST}, {@link #DESCRIPTOR_LAYOUT},
|
* The Id can be one of {@link #DESCRIPTOR_MANIFEST}, {@link #DESCRIPTOR_LAYOUT},
|
||||||
@@ -168,21 +171,21 @@ public class AndroidTargetData {
|
|||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the manifest descriptors.
|
* Returns the manifest descriptors.
|
||||||
*/
|
*/
|
||||||
public AndroidManifestDescriptors getManifestDescriptors() {
|
public AndroidManifestDescriptors getManifestDescriptors() {
|
||||||
return mManifestDescriptors;
|
return mManifestDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the layout Descriptors.
|
* Returns the layout Descriptors.
|
||||||
*/
|
*/
|
||||||
public LayoutDescriptors getLayoutDescriptors() {
|
public LayoutDescriptors getLayoutDescriptors() {
|
||||||
return mLayoutDescriptors;
|
return mLayoutDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the menu descriptors.
|
* Returns the menu descriptors.
|
||||||
*/
|
*/
|
||||||
@@ -202,7 +205,7 @@ public class AndroidTargetData {
|
|||||||
* <p/>This should only be called for attributes for which possible values depend on the
|
* <p/>This should only be called for attributes for which possible values depend on the
|
||||||
* parent element node.
|
* parent element node.
|
||||||
* <p/>For attributes that have the same values no matter the parent node, use
|
* <p/>For attributes that have the same values no matter the parent node, use
|
||||||
* {@link #getEnumValueMap()}.
|
* {@link #getEnumValueMap()}.
|
||||||
* @param elementName the name of the element containing the attribute.
|
* @param elementName the name of the element containing the attribute.
|
||||||
* @param attributeName the name of the attribute
|
* @param attributeName the name of the attribute
|
||||||
* @return an array of String with the possible values, or <code>null</code> if no values were
|
* @return an array of String with the possible values, or <code>null</code> if no values were
|
||||||
@@ -220,7 +223,7 @@ public class AndroidTargetData {
|
|||||||
* <p/>The typical example of this is for the 'name' attribute under
|
* <p/>The typical example of this is for the 'name' attribute under
|
||||||
* activity/intent-filter/action
|
* activity/intent-filter/action
|
||||||
* <p/>For attributes that have the same values no matter the parent node, use
|
* <p/>For attributes that have the same values no matter the parent node, use
|
||||||
* {@link #getEnumValueMap()}.
|
* {@link #getEnumValueMap()}.
|
||||||
* @param elementName the name of the element containing the attribute.
|
* @param elementName the name of the element containing the attribute.
|
||||||
* @param attributeName the name of the attribute
|
* @param attributeName the name of the attribute
|
||||||
* @param greatGrandParentElementName the great-grand-parent node.
|
* @param greatGrandParentElementName the great-grand-parent node.
|
||||||
@@ -231,13 +234,13 @@ public class AndroidTargetData {
|
|||||||
String greatGrandParentElementName) {
|
String greatGrandParentElementName) {
|
||||||
if (greatGrandParentElementName != null) {
|
if (greatGrandParentElementName != null) {
|
||||||
String key = String.format("(%1$s,%2$s,%3$s)", //$NON-NLS-1$
|
String key = String.format("(%1$s,%2$s,%3$s)", //$NON-NLS-1$
|
||||||
greatGrandParentElementName, elementName, attributeName);
|
greatGrandParentElementName, elementName, attributeName);
|
||||||
String[] values = mAttributeValues.get(key);
|
String[] values = mAttributeValues.get(key);
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAttributeValues(elementName, attributeName);
|
return getAttributeValues(elementName, attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,14 +253,14 @@ public class AndroidTargetData {
|
|||||||
public Map<String, Map<String, Integer>> getEnumValueMap() {
|
public Map<String, Map<String, Integer>> getEnumValueMap() {
|
||||||
return mEnumValueMap;
|
return mEnumValueMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link ProjectResources} containing the Framework Resources.
|
* Returns the {@link ProjectResources} containing the Framework Resources.
|
||||||
*/
|
*/
|
||||||
public ProjectResources getFrameworkResources() {
|
public ProjectResources getFrameworkResources() {
|
||||||
return mFrameworkResources;
|
return mFrameworkResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link LayoutBridge} object possibly containing a {@link ILayoutBridge} object.
|
* Returns a {@link LayoutBridge} object possibly containing a {@link ILayoutBridge} object.
|
||||||
* <p/>If {@link LayoutBridge#bridge} is <code>null</code>, {@link LayoutBridge#status} will
|
* <p/>If {@link LayoutBridge#bridge} is <code>null</code>, {@link LayoutBridge#status} will
|
||||||
@@ -272,7 +275,11 @@ public class AndroidTargetData {
|
|||||||
}
|
}
|
||||||
return mLayoutBridge;
|
return mLayoutBridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeviceConfiguration[] getDevices() {
|
||||||
|
return mDevices;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the permission values
|
* Sets the permission values
|
||||||
* @param permissionValues the list of permissions
|
* @param permissionValues the list of permissions
|
||||||
@@ -285,7 +292,7 @@ public class AndroidTargetData {
|
|||||||
setValues("(service,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(service,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
setValues("(provider,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(provider,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIntentFilterActionsAndCategories(String[] activityIntentActions,
|
private void setIntentFilterActionsAndCategories(String[] activityIntentActions,
|
||||||
String[] broadcastIntentActions, String[] serviceIntentActions,
|
String[] broadcastIntentActions, String[] serviceIntentActions,
|
||||||
String[] intentCategoryValues) {
|
String[] intentCategoryValues) {
|
||||||
@@ -294,18 +301,18 @@ public class AndroidTargetData {
|
|||||||
setValues("(service,action,android:name)", serviceIntentActions); //$NON-NLS-1$
|
setValues("(service,action,android:name)", serviceIntentActions); //$NON-NLS-1$
|
||||||
setValues("(category,android:name)", intentCategoryValues); //$NON-NLS-1$
|
setValues("(category,android:name)", intentCategoryValues); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOptionalLibraries(String[] platformLibraries,
|
private void setOptionalLibraries(String[] platformLibraries,
|
||||||
IOptionalLibrary[] optionalLibraries) {
|
IOptionalLibrary[] optionalLibraries) {
|
||||||
|
|
||||||
ArrayList<String> libs = new ArrayList<String>();
|
ArrayList<String> libs = new ArrayList<String>();
|
||||||
|
|
||||||
if (platformLibraries != null) {
|
if (platformLibraries != null) {
|
||||||
for (String name : platformLibraries) {
|
for (String name : platformLibraries) {
|
||||||
libs.add(name);
|
libs.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionalLibraries != null) {
|
if (optionalLibraries != null) {
|
||||||
for (int i = 0; i < optionalLibraries.length; i++) {
|
for (int i = 0; i < optionalLibraries.length; i++) {
|
||||||
libs.add(optionalLibraries[i].getName());
|
libs.add(optionalLibraries[i].getName());
|
||||||
|
|||||||
@@ -254,6 +254,9 @@ public final class AndroidTargetParser {
|
|||||||
LayoutBridge layoutBridge = loadLayoutBridge();
|
LayoutBridge layoutBridge = loadLayoutBridge();
|
||||||
progress.worked(1);
|
progress.worked(1);
|
||||||
|
|
||||||
|
// get the devices
|
||||||
|
DeviceConfiguration[] devices = getDevices();
|
||||||
|
|
||||||
// and finally create the PlatformData with all that we loaded.
|
// and finally create the PlatformData with all that we loaded.
|
||||||
targetData.setExtraData(frameworkRepository,
|
targetData.setExtraData(frameworkRepository,
|
||||||
manifestDescriptors,
|
manifestDescriptors,
|
||||||
@@ -268,6 +271,7 @@ public final class AndroidTargetParser {
|
|||||||
categories.toArray(new String[categories.size()]),
|
categories.toArray(new String[categories.size()]),
|
||||||
mAndroidTarget.getPlatformLibraries(),
|
mAndroidTarget.getPlatformLibraries(),
|
||||||
mAndroidTarget.getOptionalLibraries(),
|
mAndroidTarget.getOptionalLibraries(),
|
||||||
|
devices,
|
||||||
resources,
|
resources,
|
||||||
layoutBridge);
|
layoutBridge);
|
||||||
|
|
||||||
@@ -701,4 +705,10 @@ public final class AndroidTargetParser {
|
|||||||
|
|
||||||
return layoutBridge;
|
return layoutBridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DeviceConfiguration[] getDevices() {
|
||||||
|
// TODO: load this from the target.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 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.ide.eclipse.adt.internal.sdk;
|
||||||
|
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenDimensionQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenRatioQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier.KeyboardState;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier.NavigationMethod;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier.Density;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier.ScreenOrientation;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenRatioQualifier.ScreenRatio;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier.ScreenSize;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier.TextInputMethod;
|
||||||
|
import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier.TouchScreenType;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DeviceConfiguration {
|
||||||
|
|
||||||
|
private final String mName;
|
||||||
|
private Map<String, FolderConfiguration> mMap =
|
||||||
|
new HashMap<String, FolderConfiguration>();
|
||||||
|
|
||||||
|
DeviceConfiguration(String name) {
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addConfig(String name, FolderConfiguration config) {
|
||||||
|
mMap.put(name, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void seal() {
|
||||||
|
mMap = Collections.unmodifiableMap(mMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, FolderConfiguration> getConfigs() {
|
||||||
|
return mMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* temp method returning some hard-coded devices.
|
||||||
|
* TODO: load devices from the SDK and add-ons and remove this method.
|
||||||
|
*/
|
||||||
|
public static DeviceConfiguration[] getDevices() {
|
||||||
|
DeviceConfiguration adp1 = new DeviceConfiguration("ADP1");
|
||||||
|
// default config
|
||||||
|
FolderConfiguration defConfig = new FolderConfiguration();
|
||||||
|
defConfig.addQualifier(new ScreenSizeQualifier(ScreenSize.NORMAL));
|
||||||
|
defConfig.addQualifier(new ScreenRatioQualifier(ScreenRatio.NOTLONG));
|
||||||
|
defConfig.addQualifier(new PixelDensityQualifier(Density.MEDIUM));
|
||||||
|
defConfig.addQualifier(new TouchScreenQualifier(TouchScreenType.FINGER));
|
||||||
|
defConfig.addQualifier(new TextInputMethodQualifier(TextInputMethod.QWERTY));
|
||||||
|
defConfig.addQualifier(new NavigationMethodQualifier(NavigationMethod.TRACKBALL));
|
||||||
|
defConfig.addQualifier(new ScreenDimensionQualifier(480, 320));
|
||||||
|
|
||||||
|
// specific configs
|
||||||
|
FolderConfiguration closedLand = new FolderConfiguration();
|
||||||
|
closedLand.set(defConfig);
|
||||||
|
closedLand.addQualifier(new ScreenOrientationQualifier(ScreenOrientation.LANDSCAPE));
|
||||||
|
closedLand.addQualifier(new KeyboardStateQualifier(KeyboardState.HIDDEN));
|
||||||
|
adp1.addConfig("Closed, landscape", closedLand);
|
||||||
|
|
||||||
|
FolderConfiguration closedPort = new FolderConfiguration();
|
||||||
|
closedPort.set(defConfig);
|
||||||
|
closedPort.addQualifier(new ScreenOrientationQualifier(ScreenOrientation.PORTRAIT));
|
||||||
|
closedPort.addQualifier(new KeyboardStateQualifier(KeyboardState.HIDDEN));
|
||||||
|
adp1.addConfig("Closed, portrait", closedPort);
|
||||||
|
|
||||||
|
FolderConfiguration opened = new FolderConfiguration();
|
||||||
|
opened.set(defConfig);
|
||||||
|
opened.addQualifier(new ScreenOrientationQualifier(ScreenOrientation.LANDSCAPE));
|
||||||
|
opened.addQualifier(new KeyboardStateQualifier(KeyboardState.EXPOSED));
|
||||||
|
adp1.addConfig("Opened", opened);
|
||||||
|
|
||||||
|
DeviceConfiguration ion = new DeviceConfiguration("Ion");
|
||||||
|
// default config
|
||||||
|
defConfig = new FolderConfiguration();
|
||||||
|
defConfig.addQualifier(new ScreenSizeQualifier(ScreenSize.NORMAL));
|
||||||
|
defConfig.addQualifier(new ScreenRatioQualifier(ScreenRatio.NOTLONG));
|
||||||
|
defConfig.addQualifier(new PixelDensityQualifier(Density.MEDIUM));
|
||||||
|
defConfig.addQualifier(new TouchScreenQualifier(TouchScreenType.FINGER));
|
||||||
|
defConfig.addQualifier(new KeyboardStateQualifier(KeyboardState.EXPOSED));
|
||||||
|
defConfig.addQualifier(new TextInputMethodQualifier(TextInputMethod.NOKEY));
|
||||||
|
defConfig.addQualifier(new NavigationMethodQualifier(NavigationMethod.TRACKBALL));
|
||||||
|
defConfig.addQualifier(new ScreenDimensionQualifier(480, 320));
|
||||||
|
|
||||||
|
// specific configs
|
||||||
|
FolderConfiguration landscape = new FolderConfiguration();
|
||||||
|
landscape.set(defConfig);
|
||||||
|
landscape.addQualifier(new ScreenOrientationQualifier(ScreenOrientation.LANDSCAPE));
|
||||||
|
ion.addConfig("Landscape", landscape);
|
||||||
|
|
||||||
|
FolderConfiguration portrait = new FolderConfiguration();
|
||||||
|
portrait.set(defConfig);
|
||||||
|
portrait.addQualifier(new ScreenOrientationQualifier(ScreenOrientation.PORTRAIT));
|
||||||
|
ion.addConfig("Portrait", portrait);
|
||||||
|
|
||||||
|
return new DeviceConfiguration[] { adp1, ion };
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user