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");
|
mDeviceList.select(0);
|
||||||
mOrientationIcon = createControlComposite(this, true /* grab_horizontal */);
|
mDeviceList.setLayoutData(new GridData(
|
||||||
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));
|
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
||||||
mOrientation.addSelectionListener(new SelectionAdapter() {
|
mDeviceList.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
onOrientationChange();
|
onDeviceChange();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Density");
|
new Label(this, SWT.NONE).setText("Config");
|
||||||
mDensityIcon = createControlComposite(this, true /* grab_horizontal */);
|
mDeviceConfigs = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||||
mDensity = new Combo(mDensityIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
Map<String, FolderConfiguration> configs = mDevices[0].getConfigs();
|
||||||
Density[] dValues = Density.values();
|
Set<String> configNames = configs.keySet();
|
||||||
mDensity.add("(Default)");
|
for (String name : configNames) {
|
||||||
for (Density value : dValues) {
|
mDeviceConfigs.add(name);
|
||||||
mDensity.add(value.getDisplayValue());
|
|
||||||
}
|
}
|
||||||
mDensity.select(0);
|
mDeviceConfigs.select(0);
|
||||||
mDensity.setLayoutData(new GridData(
|
if (configNames.size() == 1) {
|
||||||
|
mDeviceConfigs.setEnabled(false);
|
||||||
|
}
|
||||||
|
mDeviceConfigs.setLayoutData(new GridData(
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
||||||
mDensity.addSelectionListener(new SelectionAdapter() {
|
mDeviceConfigs.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
onDensityChange();
|
onDeviceConfigChange();
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onTouchChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new Label(this, SWT.NONE).setText("Keybrd");
|
|
||||||
mKeyboardIcon = createControlComposite(this, true /* grab_horizontal */);
|
|
||||||
mKeyboard = new Combo(mKeyboardIcon.getParent(), SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
KeyboardState[] ksValues = KeyboardState.values();
|
|
||||||
mKeyboard.add("(Default)");
|
|
||||||
for (KeyboardState value : ksValues) {
|
|
||||||
mKeyboard.add(value.getDisplayValue());
|
|
||||||
}
|
|
||||||
mKeyboard.select(0);
|
|
||||||
mKeyboard.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
|
||||||
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);
|
|
||||||
mTextInput.setLayoutData(new GridData(
|
|
||||||
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
|
||||||
mTextInput.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
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
onNavigationChange();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -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
|
||||||
|
mLocale.add("Default");
|
||||||
|
mLocaleList.add(new ResourceQualifier[] { null, null });
|
||||||
|
|
||||||
|
if (languages != null && languages.size() > 0) {
|
||||||
for (String language : languages) {
|
for (String language : languages) {
|
||||||
mLanguage.add(language);
|
// 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) {
|
onDeviceConfigChange();
|
||||||
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) {
|
private void onDeviceConfigChange() {
|
||||||
mListener.onConfigurationChange();
|
int deviceIndex = mDeviceList.getSelectionIndex();
|
||||||
}
|
DeviceConfiguration device = mDevices[deviceIndex];
|
||||||
}
|
|
||||||
|
|
||||||
private void onOrientationChange() {
|
int configIndex = mDeviceConfigs.getSelectionIndex();
|
||||||
// update the current config
|
String name = mDeviceConfigs.getItem(configIndex);
|
||||||
int index = mOrientation.getSelectionIndex();
|
FolderConfiguration config = device.getConfigs().get(name);
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setScreenOrientationQualifier(new ScreenOrientationQualifier(
|
|
||||||
ScreenOrientation.getByIndex(index-1)));
|
|
||||||
} else {
|
|
||||||
mCurrentConfig.setScreenOrientationQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
// get the current qualifiers from the current config
|
||||||
mListener.onConfigurationChange();
|
CountryCodeQualifier mcc = mCurrentConfig.getCountryCodeQualifier();
|
||||||
}
|
NetworkCodeQualifier mnc = mCurrentConfig.getNetworkCodeQualifier();
|
||||||
}
|
LanguageQualifier lang = mCurrentConfig.getLanguageQualifier();
|
||||||
|
RegionQualifier region = mCurrentConfig.getRegionQualifier();
|
||||||
|
VersionQualifier version = mCurrentConfig.getVersionQualifier();
|
||||||
|
|
||||||
private void onDensityChange() {
|
// replace the config with the one from the device
|
||||||
int index = mDensity.getSelectionIndex();
|
mCurrentConfig.set(config);
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setPixelDensityQualifier((new PixelDensityQualifier(
|
|
||||||
Density.getByIndex(index-1))));
|
|
||||||
} else {
|
|
||||||
mCurrentConfig.setPixelDensityQualifier(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) {
|
// and put back the rest of the qualifiers
|
||||||
mListener.onConfigurationChange();
|
mCurrentConfig.addQualifier(mcc);
|
||||||
}
|
mCurrentConfig.addQualifier(mnc);
|
||||||
}
|
mCurrentConfig.addQualifier(lang);
|
||||||
|
mCurrentConfig.addQualifier(region);
|
||||||
private void onTouchChange() {
|
mCurrentConfig.addQualifier(version);
|
||||||
// update the current config
|
|
||||||
int index = mTouch.getSelectionIndex();
|
|
||||||
if (index != 0) {
|
|
||||||
mCurrentConfig.setTouchTypeQualifier(new TouchScreenQualifier(
|
|
||||||
TouchScreenType.getByIndex(index-1)));
|
|
||||||
} 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) {
|
||||||
|
String segment = qualifier.getFolderSegment(target);
|
||||||
|
if (segment != null && segment.length() > 0) {
|
||||||
result.append(QUALIFIER_SEP);
|
result.append(QUALIFIER_SEP);
|
||||||
result.append(qualifier.getFolderSegment(target));
|
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
|
||||||
@@ -418,10 +419,10 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
||||||
@@ -438,11 +439,11 @@ public class ProjectResources implements IResourceRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ 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;
|
||||||
@@ -113,6 +114,7 @@ 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) {
|
||||||
|
|
||||||
@@ -122,6 +124,7 @@ public class AndroidTargetData {
|
|||||||
mMenuDescriptors = menuDescriptors;
|
mMenuDescriptors = menuDescriptors;
|
||||||
mXmlDescriptors = xmlDescriptors;
|
mXmlDescriptors = xmlDescriptors;
|
||||||
mEnumValueMap = enumValueMap;
|
mEnumValueMap = enumValueMap;
|
||||||
|
mDevices = devices;
|
||||||
mFrameworkResources = resources;
|
mFrameworkResources = resources;
|
||||||
mLayoutBridge = layoutBridge;
|
mLayoutBridge = layoutBridge;
|
||||||
|
|
||||||
@@ -273,6 +276,10 @@ 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
|
||||||
|
|||||||
@@ -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