Example usage for android.view Window addFlags

List of usage examples for android.view Window addFlags

Introduction

In this page you can find the example usage for android.view Window addFlags.

Prototype

public void addFlags(int flags) 

Source Link

Document

Convenience function to set the flag bits as specified in flags, as per #setFlags .

Usage

From source file:Main.java

public static void setFullScreen(Activity activity, boolean isFull) {
    Window window = activity.getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    if (isFull) {
        params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        window.setAttributes(params);/*  w  ww.ja  va2 s .c o m*/
        window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    } else {
        params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        window.setAttributes(params);
        window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
}

From source file:enterprayz.megatools.Tools.java

public static void setStatusBarColor(Activity activity, int resColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setTranslucentStatus(activity, true);
        Window window = activity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.setStatusBarColor(ContextCompat.getColor(activity, resColor));
    }//w ww  . jav a 2 s  .c om
}

From source file:com.stockita.stockitapointofsales.utilities.Utility.java

/**
 * This method to will set the color of the statusbar to
 *///  w  w  w .j  a v  a2  s. c  o  m
public static void changeTheStatusbarColor(Activity activity, int colorResource) {
    /**
     * Change the color of the status bar
     */
    Window window = activity.getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    if (Build.VERSION.SDK_INT >= 23) {
        window.setStatusBarColor(ContextCompat.getColor(activity, colorResource));
    } else {
        window.setStatusBarColor(activity.getResources().getColor(colorResource));
    }
}

From source file:Main.java

public static void hide(Context context, Window window, int smartBarHeight) {
    if (!hasSmartBar()) {
        return;//  w ww . j  a va 2s .co  m
    }
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        return;
    }

    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    int statusBarHeight = getStatusBarHeight(context);

    window.getDecorView().setPadding(0, statusBarHeight, 0, -smartBarHeight);
}

From source file:Main.java

@TargetApi(19)
public static void transparencyBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = activity.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }/* w w  w .j a v  a2  s  .  co m*/
}

From source file:org.bottiger.podcast.utils.UIUtils.java

public static void tintStatusBar(int argColor, Activity argActivity) {
    if (Build.VERSION.SDK_INT >= 22) {
        Window window = argActivity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(argColor);
    }//from  w w w.  j  a  v a  2  s. com
}

From source file:me.henrytao.mdcore.core.MdCompat.java

public static void enableTranslucentStatus(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }//  w  ww .j  ava  2 s  . c o  m
}

From source file:Main.java

/**
 * @see android.view.Window#setStatusBarColor(int color).
 *///from w  w  w .j av a 2  s . c  o m
public static void setStatusBarColor(Window window, int statusBarColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // If both system bars are black, we can remove these from our layout,
        // removing or shrinking the SurfaceFlinger overlay required for our views.
        if (statusBarColor == Color.BLACK && window.getNavigationBarColor() == Color.BLACK) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        } else {
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        }
        window.setStatusBarColor(statusBarColor);
    }
}

From source file:Main.java

public static void initSystemBar(Activity activity) {
    if (android.os.Build.VERSION.SDK_INT > 18 && android.os.Build.VERSION.SDK_INT < 21) {
        Window window = activity.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    } else if (android.os.Build.VERSION.SDK_INT >= 21) {
        Window window = activity.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }/*from www.ja v a 2  s.c o  m*/
}

From source file:util.Utils.java

/**
 * ??//  ww  w .j  av a2s  .  co  m
 *
 * @param context
 * @param color
 */
public static void modifyStatusBar(FragmentActivity context, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = context.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //            window.setStatusBarColor(color);
    }
}