トラッキング コード

7/01/2012

Phone mode or Tablet mode in Android 4.1 Jelly Bean?




Android 4.1 Jelly Bean has Phone UI Mode and Tablet UI Mode, so same ICS.
How to change Phone / Tablet in Android Frameworks ?

If you have Android SDK Api 16, you can notice source code!!

Definition of UI Mode

Check in PhoneWindowManager#setInitialDisplaySize.

\sources\android-16\com\android\internal\policy\impl\PhoneWindowManager.java

        // SystemUI (status bar) layout policy
        int shortSizeDp = shortSize
                * DisplayMetrics.DENSITY_DEFAULT
                / DisplayMetrics.DENSITY_DEVICE;

        if (shortSizeDp < 600) {
            // 0-599dp: "phone" UI with a separate status & navigation bar
            mHasSystemNavBar = false;
            mNavigationBarCanMove = true;
        } else if (shortSizeDp < 720) {
            // 600-719dp: "phone" UI with modifications for larger screens
            mHasSystemNavBar = false;
            mNavigationBarCanMove = false;
        } else {
            // 720dp: "tablet" UI with a single combined status & navigation bar
            mHasSystemNavBar = true;
            mNavigationBarCanMove = false;
        }

        if (!mHasSystemNavBar) {
            mHasNavigationBar = mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_showNavigationBar);
            // Allow a system property to override this. Used by the emulator.
            // See also hasNavigationBar().
            String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
            if (! "".equals(navBarOverride)) {
                if      (navBarOverride.equals("1")) mHasNavigationBar = false;
                else if (navBarOverride.equals("0")) mHasNavigationBar = true;
            }
        } else {
            mHasNavigationBar = false;
        } 
PhoneWindowManager has been changed from ICS.
Tablet UI mode need 720dp!!

No comments:

Post a Comment