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.gebatzens.sia.SIAApp.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarColorTransparent(Window w) {
    w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    w.setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
}

From source file:com.ferid.app.classroom.statistics.StatisticalListActivity.java

/**
 * Set status bar colour on graph visibility change
 *//* w  w  w.  j  a  va  2 s . com*/
private void setStatusBarColour() {
    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

        if (graphLayout.getVisibility() == View.VISIBLE) {
            Configuration configuration = getResources().getConfiguration();

            if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                window.setStatusBarColor(ContextCompat.getColor(this, R.color.materialLightGreen));
            } else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
                window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark));
            }
        } else {
            window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark));
        }
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.program.stage.StageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.containsKey(Args.EXPERIMENT_PROPS)) {
            mProps = extras.getParcelableArrayList(Args.EXPERIMENT_PROPS);
        }//w  ww. ja v  a2 s . c  o m

        mOrientation = extras.getInt(Args.STAGE_ORIENTATION,
                getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
                        ? Scene.ORIENTATION_LANDSCAPE
                        : Scene.ORIENTATION_PORTRAIT);

        mSpecifiedWidth = extras.getInt(Args.STAGE_WIDTH, -1);
        mSpecifiedHeight = extras.getInt(Args.STAGE_HEIGHT, -1);
    } else {
        mProps = new ArrayList<PropIdPair>();
    }

    refreshStage();

    mPropAdapter = new PropAdapter(this, mProps);

    View view = getLayoutInflater().inflate(R.layout.activity_stage, null);
    mStage = (StageView) view.findViewById(R.id.stage);
    mStage.setNativeWidth(mSpecifiedWidth);
    mStage.setNativeHeight(mSpecifiedHeight);
    mStage.setAdapter(mPropAdapter);
    mStage.setOnItemClickListener(mPropClickListener);
    mStage.setOnStageClickListener(2, mSelectClickListener);
    mStage.setOnStageClickListener(1, mAddClickListener);
    mStage.setOnStageClickListener(3, mAddClickListener);
    mStage.forceMultiTouchWhenEmpty(3);
    mStage.setOnStageClickListener(4, mPropertiesClickListener);
    mStage.exemptMultiTouchFromEmptyCondition(4);
    setContentView(view);
}

From source file:com.smedic.tubtub.Pane.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(color);
    }/*from w w  w .j  a  va2s  . c  o  m*/
}

From source file:jp.co.tweetmap.MainActivity.java

/**
 * Set status bar color as tool bar.//from w  w  w. ja v  a 2 s. c o  m
 */
protected void setStatusBar() {
    // Set status bar color if the SDK version Lollipop more
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.statusbar_background));
    }
}

From source file:com.gmartinsribeiro.qrcodereader.BarcodeCaptureActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *///  w ww  .  j a v  a  2  s  . co  m
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.barcode_capture);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.blue700));
    }

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay);

    // read parameters from the intent used to launch the activity.
    boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
    boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash);
    } else {
        requestCameraPermission();
    }

    gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());

    Snackbar.make(mGraphicOverlay, "Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show();
}

From source file:com.berniesanders.fieldthebern.MainActivity.java

@TargetApi(21)
void setStatusBarColor(int color) {
    Window window = getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(color);//from w w  w  .  j a  v a2 s  . c om
}

From source file:com.mercandalli.android.apps.files.file.audio.FileAudioActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initialize View, player and ChromeCast.
    setContentView(R.layout.activity_file_audio);
    mFileAudioPlayer = FileAudioPlayer.getInstance(this);
    mFileAudioPlayer.registerOnPlayerStatusChangeListener(this);

    mFileAudioCast.onCreate(this);

    if (savedInstanceState == null) {
        mFirstStart = true;//from w w  w.  ja  va  2s . c o  m
    }

    final Toolbar toolbar = (Toolbar) findViewById(R.id.activity_file_audio_toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.actionbar_audio));

        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setTitle("FileSpace - Audio");
        }
    }

    final Window window = getWindow();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(ContextCompat.getColor(this, R.color.notifications_bar_audio));
    }

    mTitleTextView = (TextView) findViewById(R.id.title);
    mSizeTextView = (TextView) findViewById(R.id.size);
    mSliderNumber = (Slider) findViewById(R.id.sliderNumber);
    mSliderNumber.setValueToDisplay(new Slider.ValueToDisplay() {
        @Override
        public String convert(int value) {
            return getTimeStr(value);
        }
    });
    mSliderNumber.setOnValueChangedListener(new Slider.OnValueChangedListener() {
        @Override
        public void onValueChanged(int value) {

        }

        @Override
        public void onValueChangedUp(int value) {
            mFileAudioPlayer.seekTo(value);
        }
    });

    mPlayPauseView = (PlayPauseView) findViewById(R.id.activity_file_audio_play);
    mPlayPauseView.setOnClickListener(this);
    findViewById(R.id.activity_file_audio_next).setOnClickListener(this);
    findViewById(R.id.activity_file_audio_previous).setOnClickListener(this);

    final Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.containsKey(EXTRA_IS_ONLINE) && bundle.containsKey(EXTRA_FILE_CURRENT_POSITION)
            && bundle.containsKey(EXTRA_FILES_PATH)) {

        // Get data
        mIsOnline = bundle.getBoolean(EXTRA_IS_ONLINE);
        mCurrentPosition = bundle.getInt(EXTRA_FILE_CURRENT_POSITION);
        final List<String> absolutePathArray = bundle.getStringArrayList(EXTRA_FILES_PATH);
        if (absolutePathArray != null) {
            for (String absolutePath : absolutePathArray) {
                if (mIsOnline) {
                    mFileAudioModelList.add(
                            ((FileAudioModel.FileAudioModelBuilder) (new FileAudioModel.FileAudioModelBuilder()
                                    .isOnline(true).url(absolutePath))).build());
                } else {
                    mFileAudioModelList.add(
                            new FileAudioModel.FileAudioModelBuilder().file(new File(absolutePath)).build());
                }
            }
        }

        if (mFileAudioModelList.isEmpty()) {
            Toast.makeText(this, "Oops, I have an empty list :(", Toast.LENGTH_SHORT).show();
            finish();
            return;
        }

        if (mFirstStart) {
            mFileAudioPlayer.startMusic(mCurrentPosition, mFileAudioModelList);
            mFileAudioCast.startMusic(mCurrentPosition, mFileAudioModelList);
        } else {
            syncSongs(mFileAudioPlayer.getCurrentMusicIndex(), mFileAudioPlayer.getFileAudioModelList());
        }
    }

    mFirstStart = false;
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    fabSkin = PreferenceUtils.getAccentString(Sp);

    int th = Integer.parseInt(Sp.getString("theme", "0"));

    theme = th == 2 ? PreferenceUtils.hourOfDay() : th;

    // setting accent theme
    if (Build.VERSION.SDK_INT >= 21) {

        switch (fabSkin) {
        case "#F44336":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_red);
            else//from  ww w.  j  av a 2  s  . c  o m
                setTheme(R.style.pref_accent_dark_red);
            break;

        case "#e91e63":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_pink);
            else
                setTheme(R.style.pref_accent_dark_pink);
            break;

        case "#9c27b0":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_purple);
            else
                setTheme(R.style.pref_accent_dark_purple);
            break;

        case "#673ab7":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_purple);
            else
                setTheme(R.style.pref_accent_dark_deep_purple);
            break;

        case "#3f51b5":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_indigo);
            else
                setTheme(R.style.pref_accent_dark_indigo);
            break;

        case "#2196F3":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue);
            else
                setTheme(R.style.pref_accent_dark_blue);
            break;

        case "#03A9F4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_blue);
            else
                setTheme(R.style.pref_accent_dark_light_blue);
            break;

        case "#00BCD4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_cyan);
            else
                setTheme(R.style.pref_accent_dark_cyan);
            break;

        case "#009688":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_teal);
            else
                setTheme(R.style.pref_accent_dark_teal);
            break;

        case "#4CAF50":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_green);
            else
                setTheme(R.style.pref_accent_dark_green);
            break;

        case "#8bc34a":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_green);
            else
                setTheme(R.style.pref_accent_dark_light_green);
            break;

        case "#FFC107":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_amber);
            else
                setTheme(R.style.pref_accent_dark_amber);
            break;

        case "#FF9800":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_orange);
            else
                setTheme(R.style.pref_accent_dark_orange);
            break;

        case "#FF5722":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_orange);
            else
                setTheme(R.style.pref_accent_dark_deep_orange);
            break;

        case "#795548":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_brown);
            else
                setTheme(R.style.pref_accent_dark_brown);
            break;

        case "#212121":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_black);
            else
                setTheme(R.style.pref_accent_dark_black);
            break;

        case "#607d8b":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue_grey);
            else
                setTheme(R.style.pref_accent_dark_blue_grey);
            break;

        case "#004d40":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_super_su);
            else
                setTheme(R.style.pref_accent_dark_super_su);
            break;
        }
    } else {
        if (theme == 1) {
            setTheme(R.style.appCompatDark);
        } else {
            setTheme(R.style.appCompatLight);
        }
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .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)));

    }
    selectItem(0);
}

From source file:com.ovrhere.android.morseflash.ui.MainActivity.java

/**
 * Sets the activity to be fullscreen, removing the action bar and status
 * bar. Also sets isFullscreen to the value passed.
 * @param fullscreen <code>true</code> to set fullscreen,
 * <code>false</code> to return to normal screen.
 *///w w  w  .j a v  a  2 s  . c o  m
private void setFullscreen(boolean fullscreen) {
    Window window = getWindow();
    if (fullscreen) {
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getSupportActionBar().hide();
    } else {
        window.setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getSupportActionBar().show();
    }
    //ensure redraw
    findViewById(R.id.container).requestLayout();
    isFullscreen = fullscreen;
}