當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyCharacterMap.deviceHasKey方法代碼示例

本文整理匯總了Java中android.view.KeyCharacterMap.deviceHasKey方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyCharacterMap.deviceHasKey方法的具體用法?Java KeyCharacterMap.deviceHasKey怎麽用?Java KeyCharacterMap.deviceHasKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.KeyCharacterMap的用法示例。


在下文中一共展示了KeyCharacterMap.deviceHasKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isNavigationBarShow

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static boolean isNavigationBarShow(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        Point size = new Point();
        Point realSize = new Point();
        display.getSize(size);
        display.getRealSize(realSize);
        return realSize.y != size.y;
    } else {
        boolean menu = ViewConfiguration.get(activity).hasPermanentMenuKey();
        boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        if (menu || back) {
            return false;
        } else {
            return true;
        }
    }
}
 
開發者ID:mmjang,項目名稱:quiz_helper,代碼行數:19,代碼來源:ViewUtil.java

示例2: isNavigationBarShow

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static boolean isNavigationBarShow(Activity activity){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        Point size = new Point();
        Point realSize = new Point();
        display.getSize(size);
        display.getRealSize(realSize);
        return realSize.y!=size.y;
    }else {
        boolean menu = ViewConfiguration.get(activity).hasPermanentMenuKey();
        boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        if(menu || back) {
            return false;
        }else {
            return true;
        }
    }
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:19,代碼來源:ViewUtil.java

示例3: getNavBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
static int getNavBarHeight(Context c) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if (!hasMenuKey && !hasBackKey) {
        // The device has a navigation bar
        Resources res = c.getResources();

        int orientation = res.getConfiguration().orientation;
        int resourceId;
        if (isTablet(c)) {
            resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
        } else {
            resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
        }
        if (resourceId > 0) {
            return res.getDimensionPixelSize(resourceId);
        }
    }
    return result;
}
 
開發者ID:tylersuehr7,項目名稱:chips-input-layout,代碼行數:23,代碼來源:Utils.java

示例4: getNavBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static int getNavBarHeight(Context context) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if(!hasMenuKey && !hasBackKey) {
        //The device has a navigation bar
        Resources resources = context.getResources();

        int orientation = context.getResources().getConfiguration().orientation;
        int resourceId;
        if (isTablet(context)){
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
        }  else {
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
        }

        if (resourceId > 0) {
            return context.getResources().getDimensionPixelSize(resourceId);
        }
    }
    return result;
}
 
開發者ID:pchmn,項目名稱:MaterialChipsInput,代碼行數:24,代碼來源:ViewUtil.java

示例5: getNavigationBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static int getNavigationBarHeight(Context context) {

        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);


        if (hasBackKey && hasHomeKey) {
            return 0;
        } else {
            //
            Resources resources = context.getResources();
            int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
            if (resourceId > 0) {
                return resources.getDimensionPixelSize(resourceId);
            }
            return 0;
        }


    }
 
開發者ID:zhudongya123,項目名稱:WechatChatroomHelper,代碼行數:21,代碼來源:ScreenUtils.java

示例6: getNavigationBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
/**
 * 取得NavigationBar的高度
 *
 * @param c
 * @return
 */
public static int getNavigationBarHeight(Context c) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if (!hasMenuKey && !hasBackKey) {
        //The device has a navigation bar
        Resources resources = c.getResources();

        int orientation = resources.getConfiguration().orientation;
        int resourceId;
        if (isTablet(c)) {
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
        } else {
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
        }

        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
    }
    return result;
}
 
開發者ID:Grasea,項目名稱:Grandroid2,代碼行數:30,代碼來源:DisplayAgent.java

示例7: getNavBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
private static int getNavBarHeight(Context context) {
    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    boolean hasNavBar = !hasMenuKey && !hasBackKey;

    if (hasNavBar) {
        boolean isPortrait = context.getResources().getConfiguration().orientation
                == Configuration.ORIENTATION_PORTRAIT;

        boolean isTablet = (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >=
                Configuration.SCREENLAYOUT_SIZE_LARGE;

        String key = isPortrait ? "navigation_bar_height" :
                (isTablet ? "navigation_bar_height_landscape" : null);

        return key == null ? 0 : getDimenSize(context, key);
    } else {
        return 0;
    }
}
 
開發者ID:BubbleOctopus,項目名稱:Album,代碼行數:22,代碼來源:CommentUtils.java

示例8: isNavigationBarShow

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
/**
 * 底部虛擬導航是否顯示
 * @param activity activity
 * @return boolean
 */
public static boolean isNavigationBarShow(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        Point size = new Point();
        Point realSize = new Point();
        display.getSize(size);
        display.getRealSize(realSize);
        return realSize.y != size.y;
    } else {
        boolean menu = ViewConfiguration.get(activity).hasPermanentMenuKey();
        boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        if (menu || back) {
            return false;
        } else {
            return true;
        }
    }
}
 
開發者ID:ymex,項目名稱:kits,代碼行數:24,代碼來源:ToolKit.java

示例9: getNavBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static int getNavBarHeight(Context context) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if(!hasMenuKey && !hasBackKey) {
        //The device has a navigation bar
        Resources resources = context.getResources();

        int orientation = resources.getConfiguration().orientation;
        int resourceId;
        if (isTablet(context)){
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
        }  else {
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
        }

        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
    }
    return result;
}
 
開發者ID:stanidesis,項目名稱:quotograph,代碼行數:24,代碼來源:UIUtils.java

示例10: hasNavBar

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static boolean hasNavBar(Context context) {
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);

    if (hasBackKey && hasHomeKey) {
        if (Build.MANUFACTURER.toLowerCase(Locale.ENGLISH).contains("samsung") && !Build.MODEL.toLowerCase(Locale.ENGLISH).contains("nexus")) {
            return false;
        }

        Resources resources = context.getResources();
        int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
        if (id > 0) {
            return resources.getBoolean(id);
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
開發者ID:ccrama,項目名稱:Slide,代碼行數:21,代碼來源:NavigationUtils.java

示例11: getNavBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
private int getNavBarHeight(Context context) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if(!hasMenuKey && !hasBackKey) {
        //The device has a navigation bar
        Resources resources = context.getResources();

        int orientation = resources.getConfiguration().orientation;
        int resourceId;
        if (isTablet){
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
        }  else {
            resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
        }

        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
    }
    return result;
}
 
開發者ID:krajeswaran,項目名稱:LeanLauncher,代碼行數:24,代碼來源:DeviceProfile.java

示例12: getNavBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
private static int getNavBarHeight(Context context) {
    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    boolean hasNavBar = !hasMenuKey && !hasBackKey;

    if (hasNavBar) {
        boolean isPortrait = context.getResources().getConfiguration().orientation
                == Configuration.ORIENTATION_PORTRAIT;

        boolean isTablet = (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK)
                >= Configuration.SCREENLAYOUT_SIZE_LARGE;

        String key = isPortrait ? "navigation_bar_height"
                : (isTablet ? "navigation_bar_height_landscape" : null);

        return key == null ? 0 : getDimenSize(context, key);
    } else {
        return 0;
    }
}
 
開發者ID:alexvasilkov,項目名稱:GestureViews,代碼行數:22,代碼來源:DecorUtils.java

示例13: hasSoftwareKeys

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public boolean hasSoftwareKeys(Context context) {
	int sdkVersion = Build.VERSION.SDK_INT;

	// Gingerbread and below are considered to have physical buttons.
	if (sdkVersion <= Build.VERSION_CODES.GINGERBREAD_MR1)
		return false;

	// Honeycomb is dedicated to the tablets having no physical buttons.
	if (sdkVersion >= Build.VERSION_CODES.GINGERBREAD_MR1 && sdkVersion <= Build.VERSION_CODES.HONEYCOMB_MR2)
		return true;

	// ICS and above provide convenient function able to determine if the
	// device has
	// physical buttons or not.
	// This function is not available below ICS
	
	boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
	boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
	
	return !hasMenuKey && !hasBackKey;
}
 
開發者ID:naver,項目名稱:android-utilset,代碼行數:23,代碼來源:SoftwareKeyDetector.java

示例14: hasVirtualNavigationBar

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
/**
 * 判斷手機是否含有虛擬按鍵  99%
 *
 * @return
 */
public static boolean hasVirtualNavigationBar(Context context) {
    boolean hasSoftwareKeys = true;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Display d = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

        DisplayMetrics realDisplayMetrics = new DisplayMetrics();
        d.getRealMetrics(realDisplayMetrics);

        int realHeight = realDisplayMetrics.heightPixels;
        int realWidth = realDisplayMetrics.widthPixels;

        DisplayMetrics displayMetrics = new DisplayMetrics();
        d.getMetrics(displayMetrics);

        int displayHeight = displayMetrics.heightPixels;
        int displayWidth = displayMetrics.widthPixels;

        hasSoftwareKeys = (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        hasSoftwareKeys = !hasMenuKey && !hasBackKey;
    }

    return hasSoftwareKeys;
}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:33,代碼來源:DisplayUtil.java

示例15: getNavigationBarHeight

import android.view.KeyCharacterMap; //導入方法依賴的package包/類
public static int getNavigationBarHeight(Context context) {
    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(4);
    if (!hasMenuKey && !hasBackKey) {
        int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        return context.getResources().getDimensionPixelSize(resourceId);
    } else {
        return 0;
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:11,代碼來源:TitleCompatibilityUtil.java


注:本文中的android.view.KeyCharacterMap.deviceHasKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。