Example usage for android.view Window setFlags

List of usage examples for android.view Window setFlags

Introduction

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

Prototype

public void setFlags(int flags, int mask) 

Source Link

Document

Set the flags of the window, as per the WindowManager.LayoutParams WindowManager.LayoutParams flags.

Usage

From source file:Main.java

public static void turnScreenOnFlags(Window window) {
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}

From source file:Main.java

public static void openImmerseStatasBarMode(Activity activity) {
    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);
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }//ww  w .  ja va  2  s . co m
}

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 w  ww .j  a  v  a2  s .c o  m*/
}

From source file:Main.java

public static void showAsPopup(Activity activity) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        return;//from  www  .  ja v a2s  .  c  o m
    }
    activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);

    //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
    Window window = activity.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    Display display = activity.getWindowManager().getDefaultDisplay();
    WindowManager.LayoutParams params = window.getAttributes();
    params.height = (int) (display.getHeight() * 0.95);
    params.width = Math.min((int) (display.getWidth() * 0.9), (int) (params.height * 0.85));
    params.gravity = Gravity.BOTTOM;
    params.alpha = 1.0f;
    params.dimAmount = 0.5f;
    window.setAttributes(params);
}

From source file:Main.java

public static void setFullScreen(Activity activity) {
    Window window = activity.getWindow();
    if (window != null) {
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }//  ww  w.  ja  v  a 2s .co m
}

From source file:Main.java

public static void hide(Context context, Window window, int smartBarHeight) {
    if (!hasSmartBar()) {
        return;/*from   w ww.j  a  v  a  2 s.  c o 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

public static void makeVisible(Activity activity) {
    Window w = activity.getWindow(); // in Activity's onCreate() for
    // instance/*w w w .  j a v  a2s .  c  o m*/
    int flags = /*
                 * WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
                 */WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
    w.setFlags(flags, flags);
}

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  w w . j  a  va2  s.  c  o m
}

From source file:com.miz.utils.ViewUtils.java

public static void setupWindowFlagsForStatusbarOverlay(Window window, boolean setBackgroundResource) {

    if (MizLib.isKitKat()) {
        // If we're running on KitKat, we want to enable
        // the translucent status bar
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }/* w  w  w  . j a  v  a2 s .  com*/

    if (MizLib.hasKitKat()) {
        // If we're running on KitKat or above, we want to show
        // the background image beneath the status bar as well.
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }

    // Make the status bar color transparent to begin with
    if (MizLib.hasLollipop())
        window.setStatusBarColor(Color.TRANSPARENT);

    // If requested, set a background resource on the Window object
    if (setBackgroundResource)
        window.setBackgroundDrawableResource(R.drawable.bg);
}

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 va 2 s  .  c o  m
}