Java Code Examples for android.view.View#SYSTEM_UI_FLAG_LOW_PROFILE

The following examples show how to use android.view.View#SYSTEM_UI_FLAG_LOW_PROFILE . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: VIA-AI   File: Helper.java    License: MIT License 6 votes vote down vote up
@Override
public void run() {
    int flags;
    int curApiVersion = Build.VERSION.SDK_INT;
    // This work only for android 4.4+
    if(curApiVersion >= Build.VERSION_CODES.KITKAT){
        flags = View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        ;
    } else {
        // touch the screen, the navigation bar will show
        flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    // must be executed in main thread :)
    if(src instanceof Context) {
        ((Activity)src).getWindow().getDecorView().setSystemUiVisibility(flags);
    }
    else if(src instanceof Window) {
        ((Window)src).getDecorView().setSystemUiVisibility(flags);
    }
}
 
Example 2
/**
 * Constructor not intended to be called by clients. Use
 * {@link SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) {
    super(activity, anchorView, flags);

    mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
    mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if ((mFlags & FLAG_FULLSCREEN) != 0) {
        // If the client requested fullscreen, add flags relevant to hiding
        // the status bar. Note that some of these constants are new as of
        // API 16 (Jelly Bean). It is safe to use them, as they are inlined
        // at compile-time and do nothing on pre-Jelly Bean devices.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
        // If the client requested hiding navigation, add relevant flags.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
}
 
Example 3
/**
 * Constructor not intended to be called by clients. Use
 * {@link SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) {
    super(activity, anchorView, flags);

    mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
    mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if ((mFlags & FLAG_FULLSCREEN) != 0) {
        // If the client requested fullscreen, add flags relevant to hiding
        // the status bar. Note that some of these constants are new as of
        // API 16 (Jelly Bean). It is safe to use them, as they are inlined
        // at compile-time and do nothing on pre-Jelly Bean devices.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
        // If the client requested hiding navigation, add relevant flags.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
}
 
Example 4
Source Project: lantern   File: SystemUiHiderHoneycomb.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor not intended to be called by clients. Use
 * {@link com.tudorluca.lantern.utils.SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) {
    super(activity, anchorView, flags);

    mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
    mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if ((mFlags & FLAG_FULLSCREEN) != 0) {
        // If the client requested fullscreen, add flags relevant to hiding
        // the status bar. Note that some of these constants are new as of
        // API 16 (Jelly Bean). It is safe to use them, as they are inlined
        // at compile-time and do nothing on pre-Jelly Bean devices.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
        // If the client requested hiding navigation, add relevant flags.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
}
 
Example 5
Source Project: v9porn   File: ExoVideoControlsMobile.java    License: MIT License 6 votes vote down vote up
/**
 * Determines the appropriate fullscreen flags based on the
 * systems API version.
 *
 * @return The appropriate decor view flags to enter fullscreen mode when supported
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private int getFullscreenUiFlags() {
    int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        flags |= View.SYSTEM_UI_FLAG_IMMERSIVE;
    }
    return flags;
}
 
Example 6
Source Project: support   File: SystemUiHiderHoneycomb.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor not intended to be called by clients. Use
 * {@link SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) {
    super(activity, anchorView, flags);

    mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
    mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if ((mFlags & FLAG_FULLSCREEN) != 0) {
        // If the client requested fullscreen, add flags relevant to hiding
        // the status bar. Note that some of these constants are new as of
        // API 16 (Jelly Bean). It is safe to use them, as they are inlined
        // at compile-time and do nothing on pre-Jelly Bean devices.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
        // If the client requested hiding navigation, add relevant flags.
        mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
}
 
Example 7
Source Project: DMusic   File: Util.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏状态栏&&导航栏
 */
public static void hideSystemUI(Activity activity, View... views) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // 4.1 above API level 16
        int uist = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            uist |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }
        View decorView = activity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(uist);
        // Some views can setFitsSystemWindows(true), setPadding()
        setFitsPadding(0, getStatusBarHeight(activity), getNavigationBarHeight(activity), 0, views);
    } else {
        WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        activity.getWindow().setAttributes(attrs);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
}
 
Example 8
/**
 * Constructor not intended to be called by clients. Use {@link SystemUiHider#getInstance} to
 * obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) {
    super(activity, anchorView, flags);

    mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
    mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

    if ((mFlags & FLAG_FULLSCREEN) != 0) {
        // If the client requested fullscreen, add flags relevant to hiding
        // the status bar. Note that some of these constants are new as of
        // API 16 (Jelly Bean). It is safe to use them, as they are inlined
        // at compile-time and do nothing on pre-Jelly Bean devices.
        mShowFlags |= 0x00000400;// View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        mHideFlags |= 0x00000400 //View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                      | 0x00000004; // View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
        // If the client requested hiding navigation, add relevant flags.
        mShowFlags |= 0x00000200;//View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        mHideFlags |= 0x00000200//View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                      | 0x00000002;//View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        mTestFlags |= 0x00000002;//View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
}
 
Example 9
Source Project: android_9.0.0_r45   File: BarController.java    License: Apache License 2.0 5 votes vote down vote up
public int updateVisibilityLw(boolean transientAllowed, int oldVis, int vis) {
    if (mWin == null) return vis;
    if (isTransientShowing() || isTransientShowRequested()) { // transient bar requested
        if (transientAllowed) {
            vis |= mTransientFlag;
            if ((oldVis & mTransientFlag) == 0) {
                vis |= mUnhideFlag;  // tell sysui we're ready to unhide
            }
            setTransientBarState(TRANSIENT_BAR_SHOWING);  // request accepted
        } else {
            setTransientBarState(TRANSIENT_BAR_NONE);  // request denied
        }
    }
    if (mShowTransparent) {
        vis |= mTransparentFlag;
        if (mSetUnHideFlagWhenNextTransparent) {
            vis |= mUnhideFlag;
            mSetUnHideFlagWhenNextTransparent = false;
        }
    }
    if (mTransientBarState != TRANSIENT_BAR_NONE) {
        vis |= mTransientFlag;  // ignore clear requests until transition completes
        vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;  // never show transient bars in low profile
    }
    if ((vis & mTranslucentFlag) != 0 || (oldVis & mTranslucentFlag) != 0 ||
            ((vis | oldVis) & mTransparentFlag) != 0) {
        mLastTranslucent = SystemClock.uptimeMillis();
    }
    return vis;
}
 
Example 10
@Override
protected int createTestFlags() {
    if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
        // Intentionally override test flags.
        return View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    return View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
 
Example 11
Source Project: EhViewer   File: SystemUiHelperImplICS.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected int createTestFlags() {
    if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
        // Intentionally override test flags.
        return View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    return View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
 
Example 12
Source Project: VCL-Android   File: VideoPlayerActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Dim the status bar and/or navigation icons when needed on Android 3.x.
 * Hide it on Android 4.0 and later
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private void dimStatusBar(boolean dim) {
    if (!AndroidUtil.isHoneycombOrLater() || mIsNavMenu)
        return;
    int visibility = 0;
    int navbar = 0;

    if (!AndroidDevices.hasCombBar() && AndroidUtil.isJellyBeanOrLater()) {
        visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        navbar = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
    }
    visibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    if (dim || mIsLocked) {
        navbar |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
        if (!AndroidDevices.hasCombBar()) {
            navbar |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            if (AndroidUtil.isKitKatOrLater())
                visibility |= View.SYSTEM_UI_FLAG_IMMERSIVE;
            visibility |= View.SYSTEM_UI_FLAG_FULLSCREEN;
        }
    }
    if (!dim) {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        visibility |= View.SYSTEM_UI_FLAG_VISIBLE;
    }

    if (AndroidDevices.hasNavBar())
        visibility |= navbar;
    getWindow().getDecorView().setSystemUiVisibility(visibility);
}
 
Example 13
/**
 * Set on the ImageView in the ViewPager children fragments, to enable/disable low profile mode
 * when the ImageView is touched.
 */
@Override
public void onClick(View v) {
    final int vis = mPager.getSystemUiVisibility();
    if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
    } else {
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }
}
 
Example 14
private WindowManager.LayoutParams getLayoutParams()
{
    //DisplayMetrics metrics = new DisplayMetrics();
    //windowManager.getDefaultDisplay().getRealMetrics(metrics);
    Point displaySize = new Point();
    windowManager.getDefaultDisplay().getRealSize(displaySize);
    Point windowSize = new Point();
    windowManager.getDefaultDisplay().getSize(windowSize);
    displaySize.x += displaySize.x - windowSize.x;
    displaySize.y += displaySize.y - windowSize.y;

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            displaySize.x, //metrics.widthPixels, // + getNavigationBarWidth(), //WindowManager.LayoutParams.MATCH_PARENT,
            displaySize.y, //metrics.heightPixels, // + getNavigationBarHeight(), //WindowManager.LayoutParams.MATCH_PARENT,
            0,
            0,
            //Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
            //WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
                    //WindowManager.LayoutParams.FLAG_FULLSCREEN |
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
                    (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ?
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN : 0) |
                    WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
                    //WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR |
                    //WindowManager.LayoutParams.FLAG_DIM_BEHIND |
                    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
            PixelFormat.TRANSPARENT
    );

    params.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
    params.dimAmount = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
    params.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE; // View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
    //params.gravity = Gravity.DISPLAY_CLIP_HORIZONTAL | Gravity.DISPLAY_CLIP_VERTICAL;
    return params;
}
 
Example 15
/**
 * Set on the ImageView in the ViewPager children fragments, to enable/disable low profile mode
 * when the ImageView is touched.
 */
@TargetApi(VERSION_CODES.HONEYCOMB)
@Override
public void onClick(View v) {
    final int vis = mPager.getSystemUiVisibility();
    if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
    } else {
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }
}
 
Example 16
/**
 * Constructor not intended to be called by clients. Use
 * {@link SystemUiHider#getInstance} to obtain an instance.
 */
protected SystemUiHiderHoneycomb(Activity activity, View anchorView,
		int flags) {
	super(activity, anchorView, flags);

	mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
	mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
	mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

	if ((mFlags & FLAG_FULLSCREEN) != 0) {
		// If the client requested fullscreen, add flags relevant to hiding
		// the status bar. Note that some of these constants are new as of
		// API 16 (Jelly Bean). It is safe to use them, as they are inlined
		// at compile-time and do nothing on pre-Jelly Bean devices.
		mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
		mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
				| View.SYSTEM_UI_FLAG_FULLSCREEN;
	}

	if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
		// If the client requested hiding navigation, add relevant flags.
		mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
		mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
				| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
		mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
	}
}
 
Example 17
/**
 * 画面がフルスクリーンになった場合はViewを非表示にします。
 */
@Override
public void onScreenChanged(Rect windowRect, int visibility) {
    // detect status bar
    final boolean isFitSystemWindowTop = windowRect.top == 0;
    boolean isHideStatusBar;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && visibility != FullscreenObserverView.NO_LAST_VISIBILITY) {
        // Support for screen rotation when setSystemUiVisibility is used
        isHideStatusBar = isFitSystemWindowTop || (visibility & View.SYSTEM_UI_FLAG_LOW_PROFILE) == View.SYSTEM_UI_FLAG_LOW_PROFILE;
    } else {
        isHideStatusBar = isFitSystemWindowTop;
    }

    // detect navigation bar
    final boolean isHideNavigationBar;
    if (visibility == FullscreenObserverView.NO_LAST_VISIBILITY) {
        // At the first it can not get the correct value, so do special processing
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            mWindowManager.getDefaultDisplay().getRealMetrics(mDisplayMetrics);
            isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels == 0 && windowRect.bottom - mDisplayMetrics.heightPixels == 0;
        } else {
            mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
            isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels > 0 || windowRect.height() - mDisplayMetrics.heightPixels > 0;
        }
    } else {
        isHideNavigationBar = (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    final boolean isPortrait = mResources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    // update FloatingView layout
    mTargetFloatingView.onUpdateSystemLayout(isHideStatusBar, isHideNavigationBar, isPortrait, windowRect);

    // フルスクリーンでの非表示モードでない場合は何もしない
    if (mDisplayMode != DISPLAY_MODE_HIDE_FULLSCREEN) {
        return;
    }

    mIsMoveAccept = false;
    final int state = mTargetFloatingView.getState();
    // 重なっていない場合は全て非表示処理
    if (state == FloatingView.STATE_NORMAL) {
        final int size = mFloatingViewList.size();
        for (int i = 0; i < size; i++) {
            final FloatingView floatingView = mFloatingViewList.get(i);
            floatingView.setVisibility(isFitSystemWindowTop ? View.GONE : View.VISIBLE);
        }
        mTrashView.dismiss();
    }
    // 重なっている場合は削除
    else if (state == FloatingView.STATE_INTERSECTING) {
        mTargetFloatingView.setFinishing();
        mTrashView.dismiss();
    }
}
 
Example 18
Source Project: sketch   File: DeviceUtils.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressLint("LongLogTag")
public static int getWindowHeightSupplement(Activity activity) {
    int uiVisibility = activity.getWindow().getDecorView().getSystemUiVisibility();
    int navigationBarHeight = getNavigationBarHeight(activity.getResources());

    String uiVisibilityName = null;
    switch (uiVisibility) {
        case View.SYSTEM_UI_FLAG_FULLSCREEN:
            uiVisibilityName = "SYSTEM_UI_FLAG_FULLSCREEN";
            break;
        case View.SYSTEM_UI_FLAG_HIDE_NAVIGATION:
            uiVisibilityName = "SYSTEM_UI_FLAG_HIDE_NAVIGATION";
            break;
        case View.SYSTEM_UI_FLAG_IMMERSIVE:
            uiVisibilityName = "SYSTEM_UI_FLAG_IMMERSIVE";
            break;
        case View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY:
            uiVisibilityName = "SYSTEM_UI_FLAG_IMMERSIVE_STICKY";
            break;
        case View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN:
            uiVisibilityName = "SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN";
            break;
        case View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION:
            uiVisibilityName = "SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION";
            break;
        case View.SYSTEM_UI_FLAG_LAYOUT_STABLE:
            uiVisibilityName = "SYSTEM_UI_FLAG_LAYOUT_STABLE";
            break;
        case View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR:
            uiVisibilityName = "SYSTEM_UI_FLAG_LIGHT_STATUS_BAR";
            break;
        case View.SYSTEM_UI_FLAG_LOW_PROFILE:
            uiVisibilityName = "SYSTEM_UI_FLAG_LOW_PROFILE";
            break;
        case View.SYSTEM_UI_FLAG_VISIBLE:
            uiVisibilityName = "SYSTEM_UI_FLAG_VISIBLE";
            break;
    }

    Log.d("getWindowHeightSupplement", Build.BRAND + " " + Build.MODEL + ". uiVisibilityName: " + uiVisibilityName + ", navigationBarHeight: " + navigationBarHeight);

    if (uiVisibility == View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) {
        return navigationBarHeight;
    }
    return 0;
}
 
Example 19
/**
 * Detects and toggles immersive mode (also known as "hidey bar" mode).
 */
public void toggleUiFlags() {

    // BEGIN_INCLUDE (get_current_ui_flags)
    // The "Decor View" is the parent view of the Activity.  It's also conveniently the easiest
    // one to find from within a fragment, since there's a handy helper method to pull it, and
    // we don't have to bother with picking a view somewhere deeper in the hierarchy and calling
    // "findViewById" on it.
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    int newUiOptions = uiOptions;
    // END_INCLUDE (get_current_ui_flags)

    // BEGIN_INCLUDE (toggle_lowprofile_mode)
    // Low profile mode doesn't resize the screen at all, but it covers the nav & status bar
    // icons with black so they're less distracting.  Unlike "full screen" and "hide nav bar,"
    // this mode doesn't interact with immersive mode at all, but it's instructive when running
    // this sample to observe the differences in behavior.
    if (mLowProfileCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
    }
    // END_INCLUDE (toggle_lowprofile_mode)

    // BEGIN_INCLUDE (toggle_fullscreen_mode)
    // When enabled, this flag hides non-critical UI, such as the status bar,
    // which usually shows notification icons, battery life, etc
    // on phone-sized devices.  The bar reappears when the user swipes it down.  When immersive
    // mode is also enabled, the app-drawable area expands, and when the status bar is swiped
    // down, it appears semi-transparently and slides in over the app, instead of pushing it
    // down.
    if (mHideStatusBarCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    // END_INCLUDE (toggle_fullscreen_mode)

    // BEGIN_INCLUDE (toggle_hidenav_mode)
    // When enabled, this flag hides the black nav bar along the bottom,
    // where the home/back buttons are.  The nav bar normally instantly reappears
    // when the user touches the screen.  When immersive mode is also enabled, the nav bar
    // stays hidden until the user swipes it back.
    if (mHideNavCheckbox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    // END_INCLUDE (toggle_hidenav_mode)

    // BEGIN_INCLUDE (toggle_immersive_mode)
    // Immersive mode doesn't do anything without at least one of the previous flags
    // enabled.  When enabled, it allows the user to swipe the status and/or nav bars
    // off-screen.  When the user swipes the bars back onto the screen, the flags are cleared
    // and immersive mode is automatically disabled.
    if (mImmersiveModeCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE;
    }
    // END_INCLUDE (toggle_immersive_mode)

    // BEGIN_INCLUDE (toggle_immersive_mode_sticky)
    // There's actually two forms of immersive mode, normal and "sticky".  Sticky immersive mode
    // is different in 2 key ways:
    //
    // * Uses semi-transparent bars for the nav and status bars
    // * This UI flag will *not* be cleared when the user interacts with the UI.
    //   When the user swipes, the bars will temporarily appear for a few seconds and then
    //   disappear again.
    if (mImmersiveModeStickyCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    // END_INCLUDE (toggle_immersive_mode_sticky)

    // BEGIN_INCLUDE (set_ui_flags)
    //Set the new UI flags.
    decorView.setSystemUiVisibility(newUiOptions);
    // END_INCLUDE (set_ui_flags)

    dumpFlagStateToLog(uiOptions);
}
 
Example 20
/**
 * 画面がフルスクリーンになった場合はViewを非表示にします。
 */
@Override
public void onScreenChanged(Rect windowRect, int visibility) {
    // detect status bar
    final boolean isFitSystemWindowTop = windowRect.top == 0;
    boolean isHideStatusBar;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && visibility != FullscreenObserverView.NO_LAST_VISIBILITY) {
        // Support for screen rotation when setSystemUiVisibility is used
        isHideStatusBar = isFitSystemWindowTop || (visibility & View.SYSTEM_UI_FLAG_LOW_PROFILE) == View.SYSTEM_UI_FLAG_LOW_PROFILE;
    } else {
        isHideStatusBar = isFitSystemWindowTop;
    }

    // detect navigation bar
    final boolean isHideNavigationBar;
    if (visibility == FullscreenObserverView.NO_LAST_VISIBILITY) {
        // At the first it can not get the correct value, so do special processing
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            mWindowManager.getDefaultDisplay().getRealMetrics(mDisplayMetrics);
            isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels == 0 && windowRect.bottom - mDisplayMetrics.heightPixels == 0;
        } else {
            mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
            isHideNavigationBar = windowRect.width() - mDisplayMetrics.widthPixels > 0 || windowRect.height() - mDisplayMetrics.heightPixels > 0;
        }
    } else {
        isHideNavigationBar = (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    final boolean isPortrait = mResources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    // update FloatingView layout
    mTargetFloatingView.onUpdateSystemLayout(isHideStatusBar, isHideNavigationBar, isPortrait, windowRect);

    // フルスクリーンでの非表示モードでない場合は何もしない
    if (mDisplayMode != DISPLAY_MODE_HIDE_FULLSCREEN) {
        return;
    }

    mIsMoveAccept = false;
    final int state = mTargetFloatingView.getState();
    // 重なっていない場合は全て非表示処理
    if (state == FloatingView.STATE_NORMAL) {
        final int size = mFloatingViewList.size();
        for (int i = 0; i < size; i++) {
            final FloatingView floatingView = mFloatingViewList.get(i);
            floatingView.setVisibility(isFitSystemWindowTop ? View.GONE : View.VISIBLE);
        }
        mTrashView.dismiss();
    }
    // 重なっている場合は削除
    else if (state == FloatingView.STATE_INTERSECTING) {
        mTargetFloatingView.setFinishing();
        mTrashView.dismiss();
    }
}