use of com.android.ide.common.resources.configuration.LocaleQualifier in project android_frameworks_base by ResurrectionRemix.
the class ConfigGenerator method getFolderConfig.
public FolderConfiguration getFolderConfig() {
FolderConfiguration config = new FolderConfiguration();
config.createDefault();
config.setDensityQualifier(new DensityQualifier(mDensity));
config.setNavigationMethodQualifier(new NavigationMethodQualifier(mNavigation));
if (mScreenWidth > mScreenHeight) {
config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenWidth, mScreenHeight));
} else {
config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenHeight, mScreenWidth));
}
config.setScreenRatioQualifier(new ScreenRatioQualifier(mRatio));
config.setScreenSizeQualifier(new ScreenSizeQualifier(mSize));
config.setTextInputMethodQualifier(new TextInputMethodQualifier(mKeyboard));
config.setTouchTypeQualifier(new TouchScreenQualifier(mTouchScreen));
config.setKeyboardStateQualifier(new KeyboardStateQualifier(mKeyboardState));
config.setScreenOrientationQualifier(new ScreenOrientationQualifier(mOrientation));
config.updateScreenWidthAndHeight();
// some default qualifiers.
config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL));
config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT));
config.setCountryCodeQualifier(new CountryCodeQualifier());
config.setLayoutDirectionQualifier(new LayoutDirectionQualifier());
config.setNetworkCodeQualifier(new NetworkCodeQualifier());
config.setLocaleQualifier(new LocaleQualifier());
config.setVersionQualifier(new VersionQualifier());
return config;
}
use of com.android.ide.common.resources.configuration.LocaleQualifier in project android by JetBrains.
the class ConfigurationManager method getLocales.
@NotNull
public List<Locale> getLocales() {
// Get locales from modules, but not libraries!
LocalResourceRepository projectResources = ProjectResourceRepository.getProjectResources(myModule, true);
assert projectResources != null;
if (projectResources.getModificationCount() != myLocaleCacheStamp) {
myLocales = null;
}
if (myLocales == null) {
List<Locale> locales = new ArrayList<Locale>();
for (LocaleQualifier locale : projectResources.getLocales()) {
locales.add(Locale.create(locale));
}
myLocales = locales;
myLocaleCacheStamp = projectResources.getModificationCount();
}
return myLocales;
}
use of com.android.ide.common.resources.configuration.LocaleQualifier in project android by JetBrains.
the class ResourceResolverCache method getFrameworkResources.
/**
* Returns a {@link LocalResourceRepository} for the framework resources based on the current configuration selection.
*
* @return the framework resources or {@code null} if not found.
*/
@Nullable
public ResourceRepository getFrameworkResources(@NotNull FolderConfiguration configuration, @NotNull IAndroidTarget target) {
int apiLevel = target.getVersion().getFeatureLevel();
LocaleQualifier locale = configuration.getLocaleQualifier();
boolean needLocales = locale != null && !locale.hasFakeValue() || myManager.getLocale() != Locale.ANY;
AndroidTargetData targetData = myFrameworkResources.get(apiLevel);
if (targetData == null) {
AndroidPlatform platform = AndroidPlatform.getInstance(myManager.getModule());
if (platform == null) {
return null;
}
// uses soft ref
targetData = platform.getSdkData().getTargetData(target);
myFrameworkResources.put(apiLevel, targetData);
}
try {
return targetData.getFrameworkResources(needLocales);
} catch (IOException e) {
LOG.error(e);
}
return null;
}
use of com.android.ide.common.resources.configuration.LocaleQualifier in project android by JetBrains.
the class VariantItemListener method itemStateChanged.
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
VariantsComboItem item = (VariantsComboItem) e.getItem();
Configuration oldConfiguration = myContext.getConfiguration();
ConfigurationManager manager = oldConfiguration.getConfigurationManager();
Configuration newConfiguration = Configuration.create(manager, null, null, item.getRestrictedConfiguration());
// Target and locale are global so we need to set them in the configuration manager when updated
VersionQualifier newVersionQualifier = item.getRestrictedConfiguration().getVersionQualifier();
if (newVersionQualifier != null) {
IAndroidTarget realTarget = manager.getHighestApiTarget() != null ? manager.getHighestApiTarget() : manager.getTarget();
assert realTarget != null;
manager.setTarget(new CompatibilityRenderTarget(realTarget, newVersionQualifier.getVersion(), null));
} else {
manager.setTarget(null);
}
LocaleQualifier newLocaleQualifier = item.getRestrictedConfiguration().getLocaleQualifier();
manager.setLocale(newLocaleQualifier != null ? Locale.create(newLocaleQualifier) : Locale.ANY);
oldConfiguration.setDevice(null, false);
Configuration.copyCompatible(newConfiguration, oldConfiguration);
oldConfiguration.updated(ConfigurationListener.MASK_FOLDERCONFIG);
}
use of com.android.ide.common.resources.configuration.LocaleQualifier in project platform_frameworks_base by android.
the class ConfigGenerator method getFolderConfig.
public FolderConfiguration getFolderConfig() {
FolderConfiguration config = new FolderConfiguration();
config.createDefault();
config.setDensityQualifier(new DensityQualifier(mDensity));
config.setNavigationMethodQualifier(new NavigationMethodQualifier(mNavigation));
if (mScreenWidth > mScreenHeight) {
config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenWidth, mScreenHeight));
} else {
config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenHeight, mScreenWidth));
}
config.setScreenRatioQualifier(new ScreenRatioQualifier(mRatio));
config.setScreenSizeQualifier(new ScreenSizeQualifier(mSize));
config.setTextInputMethodQualifier(new TextInputMethodQualifier(mKeyboard));
config.setTouchTypeQualifier(new TouchScreenQualifier(mTouchScreen));
config.setKeyboardStateQualifier(new KeyboardStateQualifier(mKeyboardState));
config.setScreenOrientationQualifier(new ScreenOrientationQualifier(mOrientation));
config.updateScreenWidthAndHeight();
// some default qualifiers.
config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL));
config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT));
config.setCountryCodeQualifier(new CountryCodeQualifier());
config.setLayoutDirectionQualifier(new LayoutDirectionQualifier());
config.setNetworkCodeQualifier(new NetworkCodeQualifier());
config.setLocaleQualifier(new LocaleQualifier());
config.setVersionQualifier(new VersionQualifier());
return config;
}
Aggregations