/*Copyright 2011 indiandragon

 This file is part of j2me2AB.

 J2meAB is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 j2me2AB is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with j2me2AB.  If not, see <http://www.gnu.org/licenses/>.
 */
package javax.microedition.lcdui;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Handler;
import android.view.Display;
import android.view.WindowManager;

public class UIGlobal {

    public static Handler APP_HANDLER = new Handler();
    public static Context APP_CONTEXT = null;
    public static Activity APP_ACTIVITY = null;
    public static Typeface APP_TYPEFACE = null;
    public static boolean bStarted = false;
    public static android.view.Menu APP_MENU = null;
    //public static int APP_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    public static int BACKGROUND = Color.WHITE;
    public static int SELECTED_ITEM_BACKGROUND = Color.LTGRAY;
    public static int TEXT_NORMAL = Color.BLACK;
    public static int DEVICE_WIDTH = 0;
    public static int DEVICE_HEIGHT = 0;
   // public static int bg = 0;
    
    public static void runOnUiThread(Thread t) {

        APP_ACTIVITY.runOnUiThread(t);

    }
/*
    public static void setActivityOrientation(Activity activity, int preferenceOrientation) {

        APP_ORIENTATION = preferenceOrientation;
        System.out.println("landscape " + (preferenceOrientation == Configuration.ORIENTATION_LANDSCAPE));
        System.out.println("portrait " + (preferenceOrientation == Configuration.ORIENTATION_PORTRAIT));
        if (preferenceOrientation == Configuration.ORIENTATION_LANDSCAPE) {
            // if (activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            // You need to check if your desired orientation isn't already set because setting orientation restarts your Activity which takes long
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            //  }
        } else if (preferenceOrientation == Configuration.ORIENTATION_PORTRAIT) {
            // if (activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            //}
        } else {
            //if (activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_SENSOR) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
            //}
        }
        if (Instances.getUIInstance().getCurrent() != null) {
            Display displays = ((WindowManager) APP_CONTEXT.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();


            UIGlobal.DEVICE_WIDTH = displays.getWidth();
            UIGlobal.DEVICE_HEIGHT = displays.getHeight();

            Instances.getUIInstance().refreshCurrentScreen();
        }
    }
    */ 
}
