Example usage for android.view Window clearFlags

List of usage examples for android.view Window clearFlags

Introduction

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

Prototype

public void clearFlags(int flags) 

Source Link

Document

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

Usage

From source file:de.kuschku.quasseldroid_ng.ui.chat.MainActivity.java

private void setStatusBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(android.R.color.transparent));

        nickList.setPadding(0, CompatibilityUtils.getStatusBarHeight(this), 0, 0);

        View viewById = findViewById(R.id.statusBarBackground);
        ViewGroup.LayoutParams layoutParams = viewById.getLayoutParams();
        layoutParams.height = CompatibilityUtils.getStatusBarHeight(this);
        viewById.setLayoutParams(layoutParams);
    }//  w w w .  j av  a  2  s.c om
}

From source file:ua.com.spacetv.mycookbook.fragments.FragSettings.java

/**
 * Application of the chosen theme on the fly
 *
 * @param parent   parent/*ww  w  . j a va 2 s.co m*/
 * @param view     view
 * @param position position
 * @param id       id
 */
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    //set default INDIGO theme
    int colorPrimaryDark = R.color.colorPrimaryDark; //status bar
    int colorPrimary = R.color.colorPrimary; //tool bar
    int colorPrimaryBackground = R.color.colorPrimaryBackground; //main background
    int colorTheme = R.style.IndigoTheme; //name of color theme

    switch (position) {
    case PINK:
        colorPrimaryDark = R.color.pinkColorPrimaryDark;
        colorPrimary = R.color.pinkColorPrimary;
        colorPrimaryBackground = R.color.pinkColorPrimaryBackground;
        colorTheme = R.style.PinkTheme;
        break;
    case PURPLE:
        colorPrimaryDark = R.color.purpleColorPrimaryDark;
        colorPrimary = R.color.purpleColorPrimary;
        colorPrimaryBackground = R.color.purpleColorPrimaryBackground;
        colorTheme = R.style.PurpleTheme;
        break;
    case DEEP_PURPLE:
        colorPrimaryDark = R.color.deepPurpleColorPrimaryDark;
        colorPrimary = R.color.deepPurpleColorPrimary;
        colorPrimaryBackground = R.color.deepPurpleColorPrimaryBackground;
        colorTheme = R.style.DeepPurpleTheme;
        break;
    case RED:
        colorPrimaryDark = R.color.redColorPrimaryDark;
        colorPrimary = R.color.redColorPrimary;
        colorPrimaryBackground = R.color.redColorPrimaryBackground;
        colorTheme = R.style.RedTheme;
        break;
    case BLUE:
        colorPrimaryDark = R.color.bluePrimaryDark;
        colorPrimary = R.color.bluePrimary;
        colorPrimaryBackground = R.color.bluePrimaryBackground;
        colorTheme = R.style.BlueTheme;
        break;
    case LIGHT_BLUE:
        colorPrimaryDark = R.color.lightBluePrimaryDark;
        colorPrimary = R.color.lightBluePrimary;
        colorPrimaryBackground = R.color.lightBluePrimaryBackground;
        colorTheme = R.style.LightBlueTheme;
        break;
    case CYAN:
        colorPrimaryDark = R.color.cyanPrimaryDark;
        colorPrimary = R.color.cyanPrimary;
        colorPrimaryBackground = R.color.cyanPrimaryBackground;
        colorTheme = R.style.CyanTheme;
        break;
    case TEAL:
        colorPrimaryDark = R.color.tealColorPrimaryDark;
        colorPrimary = R.color.tealColorPrimary;
        colorPrimaryBackground = R.color.tealColorPrimaryBackground;
        colorTheme = R.style.TealTheme;
        break;
    case GREEN:
        colorPrimaryDark = R.color.greenColorPrimaryDark;
        colorPrimary = R.color.greenColorPrimary;
        colorPrimaryBackground = R.color.greenColorPrimaryBackground;
        colorTheme = R.style.GreenTheme;
        break;
    case LIGHT_GREEN:
        colorPrimaryDark = R.color.lightGreenColorPrimaryDark;
        colorPrimary = R.color.lightGreenColorPrimary;
        colorPrimaryBackground = R.color.lightGreenColorPrimaryBackground;
        colorTheme = R.style.LightGreenTheme;
        break;
    case LIME:
        colorPrimaryDark = R.color.limeColorPrimaryDark;
        colorPrimary = R.color.limeColorPrimary;
        colorPrimaryBackground = R.color.limeColorPrimaryBackground;
        colorTheme = R.style.LimeTheme;
        break;
    case YELLOW:
        colorPrimaryDark = R.color.yellowColorPrimaryDark;
        colorPrimary = R.color.yellowColorPrimary;
        colorPrimaryBackground = R.color.yellowColorPrimaryBackground;
        colorTheme = R.style.YellowTheme;
        break;
    case AMBER:
        colorPrimaryDark = R.color.amberColorPrimaryDark;
        colorPrimary = R.color.amberColorPrimary;
        colorPrimaryBackground = R.color.amberColorPrimaryBackground;
        colorTheme = R.style.AmberTheme;
        break;
    case ORANGE:
        colorPrimaryDark = R.color.orangeColorPrimaryDark;
        colorPrimary = R.color.orangeColorPrimary;
        colorPrimaryBackground = R.color.orangeColorPrimaryBackground;
        colorTheme = R.style.OrangeTheme;
        break;
    case DEEP_ORANGE:
        colorPrimaryDark = R.color.deepOrangeColorPrimaryDark;
        colorPrimary = R.color.deepOrangeColorPrimary;
        colorPrimaryBackground = R.color.deepOrangeColorPrimaryBackground;
        colorTheme = R.style.DeepOrangeTheme;
        break;
    case BROWN:
        colorPrimaryDark = R.color.brownColorPrimaryDark;
        colorPrimary = R.color.brownColorPrimary;
        colorPrimaryBackground = R.color.brownColorPrimaryBackground;
        colorTheme = R.style.BrownTheme;
        break;
    case GREY:
        colorPrimaryDark = R.color.greyColorPrimaryDark;
        colorPrimary = R.color.greyColorPrimary;
        colorPrimaryBackground = R.color.greyColorPrimaryBackground;
        colorTheme = R.style.GreyTheme;
        break;
    case BLUE_GREY:
        colorPrimaryDark = R.color.blueGreyColorPrimaryDark;
        colorPrimary = R.color.blueGreyColorPrimary;
        colorPrimaryBackground = R.color.blueGreyColorPrimaryBackground;
        colorTheme = R.style.BlueGreyTheme;
        break;
    case BLACK_WHITE:
        colorPrimaryDark = R.color.blackWhiteColorPrimaryDark;
        colorPrimary = R.color.blackWhiteColorPrimary;
        colorPrimaryBackground = R.color.blackWhiteColorPrimaryBackground;
        colorTheme = R.style.BlackWhiteTheme;
        break;
    }
    int colorStatusBar = ContextCompat.getColor(mContext, colorPrimaryDark);
    int colorToolbar = ContextCompat.getColor(mContext, colorPrimary);
    mColorBackground = ContextCompat.getColor(mContext, colorPrimaryBackground);
    MainActivity.mHeaderNavigationDrawerLayout.setBackgroundColor(colorToolbar);
    getActivity().setTheme(colorTheme);

    //Getting status bar if Lolipop+
    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getActivity().getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(colorStatusBar);
    }
    MainActivity.mToolbar.setBackgroundColor(colorToolbar);
    if (MainActivity.mFrameLayout != null)
        if (isBackgroundWhite) {
            MainActivity.mFrameLayout.setBackgroundColor(Color.WHITE);
        } else
            MainActivity.mFrameLayout.setBackgroundColor(mColorBackground);
}

From source file:com.phonegap.bossbolo.plugin.statusbar.StatusBar.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *///  w  w  w. j  ava2 s  .  c  o m
@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();
    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    }

    if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("backgroundColorByHexString".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    setStatusBarBackgroundColor(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                }
            }
        });
        return true;
    }

    return false;
}

From source file:org.apache.cordova.statusbar.StatusBar.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *///from w w  w.  ja va2s . c o  m
@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();
    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
        return true;
    }

    if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("backgroundColorByHexString".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    setStatusBarBackgroundColor(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                }
            }
        });
        return true;
    }

    return false;
}

From source file:br.com.hotforms.StatusBarManager.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *//*from w ww  .  j a va  2s  .  c  o  m*/
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();

    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    } else if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    } else if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

                if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                    window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
                }
            }
        });
        return true;
    } else if ("setTranslucent".equals(action)) {
        if (currentapiVersion >= android.os.Build.VERSION_CODES.KITKAT) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                        window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
                    }

                    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                }
            });
            return true;
        } else {
            return false;
        }
    } else if ("setTransparent".equals(action)) {
        if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

                    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
                }
            });
            return true;
        } else {
            return false;
        }
    } else if ("setColor".equals(action)) {
        if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            this.setColor(args.getInt(0), args.getInt(1), args.getInt(2));
            return true;
        } else {
            return false;
        }
    }

    return false;
}

From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java

@Override
public void setScreenOnFixed(boolean fixed) {
    Window window = getWindow();
    if (fixed) {//from  w  w w.  j  a  v a2s .  c o  m
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}

From source file:com.breadwallet.presenter.activities.MainActivity.java

private void setStatusBarColor() {
    Window window = getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(getColor(R.color.status_bar));
}

From source file:com.example.haizhu.myvoiceassistant.ui.RobotChatActivity.java

private void setStatusBarTranslate() {
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = 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);
    }/*  w  w  w.ja v a  2s .  c  om*/
}

From source file:com.filemanager.free.activities.TextReader.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Sp = PreferenceManager.getDefaultSharedPreferences(this);

    if (theme1 == 1) {
        getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(c, R.color.holo_dark_background));
    }/*w ww  . j av a 2 s .co  m*/
    setContentView(R.layout.search);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    findViewById(R.id.lin).setBackgroundColor(Color.parseColor(skin));
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(c, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    int skinStatusBar = PreferenceUtils.getStatusColor(skin);
    assert (getSupportActionBar()) != null;
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.texteditor)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }
    mInput = (EditText) findViewById(R.id.fname);
    scrollView = (ScrollView) findViewById(R.id.editscroll);

    try {
        if (getIntent().getData() != null) {
            uri = getIntent().getData();

            mFile = new File(getIntent().getData().getPath());
        } else
            mFile = new File(getIntent().getStringExtra("path"));
    } catch (Exception e) {
        mFile = null;
    }
    String fileName = null;
    try {
        if (uri.getScheme().equals("file")) {
            fileName = uri.getLastPathSegment();
        } else {
            Cursor cursor = null;
            try {
                cursor = getContentResolver().query(uri,
                        new String[] { MediaStore.Images.ImageColumns.DISPLAY_NAME }, null, null, null);

                if (cursor != null && cursor.moveToFirst()) {
                    fileName = cursor
                            .getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
                }
            } finally {

                if (cursor != null) {
                    cursor.close();
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (fileName == null || fileName.trim().length() == 0)
        fileName = f.getName();
    getSupportActionBar().setTitle(fileName);
    mInput.addTextChangedListener(this);
    try {
        if (theme1 == 1)
            mInput.setBackgroundColor(ContextCompat.getColor(c, R.color.holo_dark_background));
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (Exception ignored) {

    }
    if (savedInstanceState != null) {
        mOriginal = savedInstanceState.getString(KEY_ORIGINAL_TEXT);
        int index = savedInstanceState.getInt(KEY_INDEX);
        mInput.setText(savedInstanceState.getString(KEY_MODIFIED_TEXT));
        mInput.setScrollY(index);
    } else {
        load(mFile);
    }
}

From source file:com.example.levelup.core.app.PaymentCodeFragment.java

/**
 * Forces the screen to be full-brightness and not dim.
 * /*from  www  .  j  a  v  a2 s .co m*/
 * @param isFullBrightness if true, sets the flags that force the screen to be fully bright and
 *        kept on. False clears the flags.
 */
private void setForceFullBrightness(boolean isFullBrightness) {
    Window window = getActivity().getWindow();

    // Bail if the window has gone away.
    if (window == null) {
        return;
    }

    if (isFullBrightness) {
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    LayoutParams attributes = window.getAttributes();

    if (isFullBrightness) {
        attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
    } else {
        attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
    }

    window.setAttributes(attributes);
}