package com.lemonhc.mplus.framework.constant;

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

/**
 * Created by kangsh on 2017. 1. 9..
 * enum을 정의해 놓은 클래스
 */
public class FrameworkConstant {
    public enum msg_types {
        ERROR("error")
        ,COMMAND("command")
        ;

        private String typeName;

        msg_types(String typeName) {
            this.typeName = typeName;
        }

        public String getTypeName() {
            return typeName;
        }

        public static msg_types getEnum(String typeName) {
            final msg_types[] t = values();
            for (final msg_types type : t) {
                if (type.typeName.equals(typeName)) {
                    return type;
                }
            }
            return null;
        }
    }

    public enum functionType {
        exit
    }

    //asyncTask의 타입넘버를 정의한 enum
    public enum asyncTaskType {
        VERSION_CHECK(100)
        ,MOVE_TO_MAIN(200)
        ,MOVE_TO_LOCK_SCREEN(300)
        ;

        private int typeNum;

        asyncTaskType(int typeNum) {
            this.typeNum = typeNum;
        }

        public int getTypeNum() {
            return typeNum;
        }

        public static asyncTaskType getEnum(int typeNum) {
            final asyncTaskType[] t = values();
            for (final asyncTaskType type : t) {
                if (type.typeNum == typeNum) {
                    return type;
                }
            }
            return null;
        }
    }

    public enum pacsType {
        L_TYPE("L")
        ,W_TYPE("W")
        ,S_TYPE("S")
        ,V_TYPE("V")
        ;

        public String typeName;

        pacsType(String typeName) {
            this.typeName = typeName;
        }

        public String getTypeName() {
            return typeName;
        }

        public static pacsType getEnum(String typeName) {
            final pacsType[] t = values();
            for (final pacsType type : t) {
                if (type.typeName.equals(typeName)) {
                    return type;
                }
            }
            return null;
        }
    }

    //잠금화면 ENUM 정의
    public enum passwordInputType {
        FIRST_INPUT("FIRST_INPUT")
        ,CONFIRM_INPUT("CONFIRM_INPUT")
        ,UNLOCK_INPUT("UNLOCK_INPUT")
        ,UNLOCK_FAIL_RE_INPUT("UNLOCK_FAIL_RE_INPUT")
        ,CHANGE_FIRST_INPUT("CHANGE_FIRST_INPUT")
        ,CHANGE_CONFIRM_INPUT("CHANGE_CONFIRM_INPUT")
        ;

        public String typeName;

        passwordInputType(String typeName) {
            this.typeName = typeName;
        }

        public String getTypeName() {
            return typeName;
        }

        public static passwordInputType getEnum(String typeName) {
            final passwordInputType[] t = values();
            for (final  passwordInputType type : t) {
                if (type.typeName.equals(typeName)) {
                    return type;
                }
            }
            return null;
        }
    }

    public static Boolean isTablet(Activity activity){
        DisplayMetrics metrics = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        float yInches= metrics.heightPixels/metrics.ydpi;
        float xInches= metrics.widthPixels/metrics.xdpi;
        double diagonalInches = Math.sqrt(xInches*xInches + yInches*yInches);
        if (diagonalInches>=6.5){
            // 6.5inch device or bigger
            return true;
        }else{
            // smaller device
            return false;
        }
    }

}
