package com.backfire.doudizhu.common;

import android.app.Activity;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;

import com.backfire.utils.Log;

public class DeviceUtil {

	public static final int baseScreenWidth = 480;
	public static final int baseScreenHeight = 320;
	
	
	public static int getCurrentScreenWidth(Activity activity) {
		DisplayMetrics dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
		return dm.widthPixels;
	}
	public static int getCurrentScreenHeight(Activity activity) {
		DisplayMetrics dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
		return dm.heightPixels;
	}

	public static int AdaptScreenWidth(Activity activity, int x)
	{
		DisplayMetrics dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
		int result = x*dm.widthPixels/baseScreenWidth;
		if(result == 0)
		{
			result = 1;
		}
		return result;
	}
	
	public static int AdaptScreenHeight(Activity activity, int y)
	{
		DisplayMetrics dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
		int result = y*dm.heightPixels/baseScreenHeight;
		if(result == 0)
		{
			result = 1;
		}
		return result;
	}
	
	public static String getDeviceID()
	{
		String result = null;
		TelephonyManager telephoneMgr = (TelephonyManager)DdzApplication.getApplication().getSystemService(Context.TELEPHONY_SERVICE);
		String imei = telephoneMgr.getDeviceId();
		if (imei == null || imei.length()<=0) {
			result = "-1";
		}
		else
		{
			result = imei;
		}
		//result = "this's julin's simulator";
		Log.i("Device ID "+result);
		return result;
	}
}
