package org.tizen.emulator.skin;
-import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileReader;
import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;
import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
import org.tizen.emulator.skin.util.IOUtil;
import org.tizen.emulator.skin.util.JaxbUtil;
-import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.StringUtil;
import org.tizen.emulator.skin.util.SwtUtil;
*
*/
public class EmulatorSkinMain {
+ public static final String SKINS_FOLDER = "skins";
+ public static final String DEFAULT_SKIN_FOLDER = "emul-general-3btn";
+
public static final String SKIN_INFO_FILE_NAME = "info.ini";
public static final String SKIN_PROPERTIES_FILE_NAME = ".skin.properties";
public static final String CONFIG_PROPERTIES_FILE_NAME = ".skinconfig.properties";
/* startup arguments parsing */
Map<String, String> argsMap = parseArgs(args);
- /* emulator resolution */
- /*int resolutionW = Integer.parseInt(
- argsMap.get(ArgsConstants.RESOLUTION_WIDTH));
- int resolutionH = Integer.parseInt(
- argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));*/
-
/* get skin path from startup argument */
- String skinPath = ImageRegistry.getSkinPath(
- (String) argsMap.get(ArgsConstants.SKIN_PATH));
+ String argSkinPath = (String) argsMap.get(ArgsConstants.SKIN_PATH);
+ String skinPath = ".." +
+ File.separator + SKINS_FOLDER + File.separator + DEFAULT_SKIN_FOLDER;
+
+ File f = new File(argSkinPath);
+ if (f.isDirectory() == false) {
+ /* When emulator receive a invalid skin path,
+ emulator uses default skin path instead of it */
+ logger.info("Emulator uses default skin path (" + skinPath +
+ ") instead of invalid skin path (" + argSkinPath + ").");
+ } else {
+ skinPath = argSkinPath;
+ }
/* set skin information */
String skinInfoFilePath = skinPath + File.separator + SKIN_INFO_FILE_NAME;
logger.info("skin info:" + skinInfoProperties); //TODO:
}
+ /* determine the layout */
String skinInfoResolutionW =
skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH);
String skinInfoResolutionH =
isGeneralSkin = true;
}
SkinInformation skinInfo = new SkinInformation(
- skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME), isGeneralSkin);
+ skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME),
+ skinPath, isGeneralSkin);
/* set emulator window skin property */
String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
EmulatorConfig config = new EmulatorConfig(argsMap,
dbiContents, skinProperties, skinPropFilePath, configProperties);
- /* load SDK version */
- String strVersion = "Undefined";
- String versionFilePath = SkinUtil.getSdkVersionFilePath();
-
- File file = new File(versionFilePath);
- if (file.exists() && file.isFile()) {
- BufferedReader reader = new BufferedReader(
- new FileReader(versionFilePath));
-
- strVersion = reader.readLine();
-
- reader.close();
- } else {
- logger.info("cannot find version file" + versionFilePath);
- }
-
- logger.info("SDK version : " + strVersion);
- config.setSkinProperty(
- EmulatorConfig.SkinInfoConstants.SDK_VERSION_NAME, strVersion);
-
/* load image resource */
- ImageRegistry.getInstance().initialize(config);
+ ImageRegistry.getInstance().initialize(config, skinPath);
/* load Always on Top value */
String onTopVal = config.getSkinProperty(
/**
*
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
package org.tizen.emulator.skin.config;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
import org.tizen.emulator.skin.util.IOUtil;
+import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.StringUtil;
private Properties configProperties;
private String skinPropertiesFilePath;
+ /**
+ * Constructor
+ */
public EmulatorConfig(Map<String, String> args,
EmulatorUI dbiContents, Properties skinProperties,
String skinPropertiesFilePath, Properties configProperties) {
if (null == configProperties) {
this.configProperties = new Properties();
}
+
+ /* load SDK version */
+ String strVersion = "Undefined";
+ String versionFilePath = SkinUtil.getSdkVersionFilePath();
+
+ File file = new File(versionFilePath);
+
+ try {
+ if (file.exists() && file.isFile()) {
+ BufferedReader reader = new BufferedReader(
+ new FileReader(versionFilePath));
+
+ strVersion = reader.readLine();
+
+ reader.close();
+ } else {
+ logger.info("cannot find version file" + versionFilePath);
+ }
+ } catch (FileNotFoundException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+
+ logger.info("SDK version : " + strVersion);
+ setSkinProperty(
+ EmulatorConfig.SkinInfoConstants.SDK_VERSION_NAME, strVersion);
}
public static void validateArgs(Map<String, String> args) throws ConfigException {
skinProperties.setProperty(SkinPropertiesConstants.WINDOW_X, "" + xx);
}
- if( skinProperties.containsKey( SkinPropertiesConstants.WINDOW_Y ) ) {
+ if ( skinProperties.containsKey( SkinPropertiesConstants.WINDOW_Y ) ) {
String y = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_Y );
int yy = 0;
try {
yy = Integer.parseInt( y );
} catch ( NumberFormatException e ) {
- String msg = SkinPropertiesConstants.WINDOW_Y + " in .skin.properties is not numeric. : " + y;
+ String msg = SkinPropertiesConstants.WINDOW_Y +
+ " in .skin.properties is not numeric. : " + y;
throw new ConfigException( msg );
}
try {
Integer.parseInt( rotation );
} catch ( NumberFormatException e ) {
- String msg = SkinPropertiesConstants.WINDOW_ROTATION + " in .skin.properties is not numeric. : " + rotation;
+ String msg = SkinPropertiesConstants.WINDOW_ROTATION +
+ " in .skin.properties is not numeric. : " + rotation;
throw new ConfigException( msg );
}
}
try {
Integer.parseInt( scale );
} catch ( NumberFormatException e ) {
- String msg = SkinPropertiesConstants.WINDOW_SCALE + " in .skin.properties is not numeric. : " + scale;
+ String msg = SkinPropertiesConstants.WINDOW_SCALE +
+ " in .skin.properties is not numeric. : " + scale;
throw new ConfigException( msg );
}
}
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.skin.config.EmulatorConfig;
-import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.dbi.EmulatorUI;
import org.tizen.emulator.skin.dbi.ImageListType;
import org.tizen.emulator.skin.dbi.RotationType;
*
*/
public class ImageRegistry {
- private static Logger logger =
- SkinLogger.getSkinLogger(ImageRegistry.class).getLogger();
-
- public static final String SKINS_FOLDER = "skins";
public static final String GENERAL_FOLDER = "emul-general-3btn";
public static final String ICON_FOLDER = "icons";
public static final String IMAGES_FOLDER = "images";
public static final String KEYWINDOW_FOLDER = "key-window";
+ private static Logger logger =
+ SkinLogger.getSkinLogger(ImageRegistry.class).getLogger();
+
public enum ImageType {
IMG_TYPE_MAIN,
IMG_TYPE_PRESSED
private Map<String, Image> iconMap;
private Map<String, Image> keyWindowImageMap;
- private String argSkinPath;
+ private String skinPath;
private static ImageRegistry instance;
private static boolean isInitialized;
return instance;
}
- public void initialize(EmulatorConfig config) {
+ public void initialize(EmulatorConfig config, String skinPath) {
if (isInitialized) {
return;
}
this.display = Display.getDefault();
- this.argSkinPath = config.getArg(ArgsConstants.SKIN_PATH);
+ this.skinPath = skinPath;
this.dbiContents = config.getDbiContents();
this.skinImageMap = new HashMap<String, Image>();
this.iconMap = new HashMap<String, Image>();
this.keyWindowImageMap = new HashMap<String, Image>();
- init(this.argSkinPath);
-
- }
-
- public static String getSkinPath(String argSkinPath) {
- /* When emulator receive a invalid skin path,
- emulator uses default skin path instead of it */
- String defaultSkinPath = ".." + //TODO:
- File.separator + SKINS_FOLDER + File.separator + GENERAL_FOLDER;
-
- if (argSkinPath == null) {
- logger.info("Emulator uses default skin path (" + defaultSkinPath +
- ") instead of invalid skin path (null).");
-
- return defaultSkinPath;
- }
-
- File f = new File(argSkinPath);
- if (f.isDirectory() == false) {
- logger.info("Emulator uses default skin path (" + defaultSkinPath +
- ") instead of invalid skin path (" + argSkinPath + ").");
-
- return defaultSkinPath;
- }
-
- return argSkinPath;
+ init(this.skinPath);
}
private void init(String argSkinPath) {
return null;
}
- String skinPath = getSkinPath(argSkinPath);
logger.info("get image data of skin from " + skinPath);
RotationType targetRotation = SkinRotation.getRotation(id);
*/
public class SkinInformation {
private String skinName;
+ private String skinPath;
private boolean isGeneralSkin;
private int skinOption;
- public SkinInformation(String skinName, boolean isGeneralSkin) {
+ public SkinInformation(String skinName, String skinPath, boolean isGeneralSkin) {
this.skinName = skinName;
+ this.skinPath = skinPath;
this.isGeneralSkin = isGeneralSkin;
this.skinOption = 0;
}
return skinName;
}
+ public String getSkinPath() {
+ return skinPath;
+ }
+
public boolean isGeneralPurposeSkin() {
return isGeneralSkin;
}