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:co.com.parsoniisolutions.custombottomsheetbehavior.lib.MergedAppBarLayoutBehavior.java

private void setStatusBarBackgroundVisible(boolean visible) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (visible) {
            Window window = ((Activity) mContext).getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.colorPrimaryDark));
        } else {//from w  w w  . j  a v  a2 s .  c o  m
            Window window = ((Activity) mContext).getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.transparent));
        }
    }
}

From source file:com.grarak.kerneladiutor.FileBrowserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    fileBrowserActivity = this;
    boolean dark = Utils.getBoolean("darktheme", false, this);
    if (dark)/*from w  w  w .j  a va2s .  c  o  m*/
        super.setTheme(R.style.AppThemeDark);
    setContentView(R.layout.activity_filebrowser);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    String fileType = getIntent().getExtras().getString(FILE_TYPE_ARG);
    String externalStorage = Utils.getExternalStorage();

    LinkedHashMap<String, Fragment> fragments = new LinkedHashMap<>();
    internalStorage = StorageFragment.newInstance(Environment.getExternalStorageDirectory().getPath(),
            fileType);
    fragments.put(getString(R.string.internal_storage), internalStorage);
    if (externalStorage != null) {
        this.externalStorage = StorageFragment.newInstance(externalStorage, fileType);
        fragments.put(getString(R.string.external_storage), this.externalStorage);
    }

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(new Adapter(getSupportFragmentManager(), fragments));
    if (dark)
        mViewPager.setBackgroundColor(getResources().getColor(R.color.card_background_dark));

    final SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    for (int i = 0; i < fragments.keySet().toArray().length; i++)
        mSlidingTabLayout.setContentDescription(i, (String) fragments.keySet().toArray()[i]);
    mSlidingTabLayout.setSelectedIndicatorColors(
            getResources().getColor(fragments.size() > 1 ? R.color.white : R.color.color_primary));
    mSlidingTabLayout.setDistributeEvenly(true);
    mSlidingTabLayout.setViewPager(mViewPager);

    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.color_primary_dark));
    }
}

From source file:com.android.gallery3d.app.AbstractGalleryActivity.java

private void toggleStatusBarByOrientation() {
    if (mDisableToggleStatusBar)
        return;/*from  ww w  .  j a  v a2  s.  com*/

    Window win = getWindow();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}

From source file:com.bilibili.magicasakurademo.MainActivity.java

@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    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(ThemeUtils.getColorById(this, R.color.theme_color_primary_dark));
        ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(null, null,
                ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary));
        setTaskDescription(description);
    }/* ww w . ja va  2  s. c om*/
}

From source file:com.amti.vela.bluetoothlegatt.bluetooth.DeviceScanActivity.java

void initGui() {
    leScanHandler = new Handler();

    //widgets//from w  ww.  j  ava2 s. co m
    deviceListView = (ListView) findViewById(R.id.listView);
    swipeContainer = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);

    mLeDevicesList = new ArrayList<BluetoothDevice>();
    devicesAdapter = new CustomListAdapter(this, R.layout.custom_listview_item);
    deviceListView.setAdapter(devicesAdapter);

    // Configure the refreshing colors
    swipeContainer.setColorSchemeResources(R.color.action_bar_light_blue, R.color.swipe_refresh_dark_green,
            android.R.color.holo_orange_light, android.R.color.holo_red_light);

    notificationEnableDialog = new AlertDialog.Builder(DeviceScanActivity.this);
    notificationEnableDialog.setMessage("This app wants to enable notification access in the settings app.")
            .setPositiveButton("OK", notificationDialogClickListener)
            .setNegativeButton("Cancel", notificationDialogClickListener).setCancelable(false);

    //action bar
    Toolbar actionBarToolBar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(actionBarToolBar);
    actionBarToolBar.setTitle("Choose a Device");
    actionBarToolBar.setTitleTextColor(ContextCompat.getColor(this, R.color.action_bar_text_gray));

    //status bar color
    Window window = getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.setStatusBarColor(ContextCompat.getColor(this, R.color.action_bar_dark_blue));
    }

    deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View v, int position, long arg3) {
            BluetoothDevice device = mLeDevicesList.get(position);
            if (device == null)
                return;
            final Intent intent = new Intent(DeviceScanActivity.this, MainActivity.class);
            String deviceName = device.getName() == null ? "Unknown Device" : device.getName();
            intent.putExtra(MainActivity.EXTRAS_DEVICE, deviceName + "\n" + device.getAddress());
            if (mScanning) {
                scanLeDevice(false);
                mScanning = false;
            }
            if (notificationListenerInit())
                ;
            startActivity(intent);
        }
    });

    swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Your code to refresh the list here.
            // Make sure you call swipeContainer.setRefreshing(false)
            // once the bt request has completed successfully
            clearDevices();
            scanLeDevice(true);
        }
    });
}

From source file:com.hellofyc.base.app.activity.BaseActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarColorTransparent() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = 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);
    }/*from   w ww .ja v a2 s  .  c o m*/
}

From source file:com.devnoobs.bmr.MainActivity.java

@Override
public void zmienReklamy(boolean stan) {

    //Toast toast = Toast.makeText(getApplicationContext(), "test",5 );
    //toast.show();

    if (stan == true) {
        adView.setVisibility(View.VISIBLE);
        adView.loadAd(new AdRequest());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow(); // in Activity's onCreate() for instance
            w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            // w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            //w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }//  w  ww  .  j  av a 2 s  .c  om
    } else {
        adView.setVisibility(View.GONE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            super.setTheme(android.R.style.Theme_Holo_Light_NoActionBar_TranslucentDecor);
            Window w = getWindow();
            w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }

    }

}

From source file:io.karim.materialtabs.sample.TabsActivity.java

private void applyParametersFromIntentExtras() {
    Intent intent = getIntent();//from  ww  w. j ava  2s  .c o  m
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            Resources resources = getResources();

            int showToolbar = extras.getBoolean(TabsSettingsFragment.SHOW_TOOLBAR) ? View.VISIBLE : View.GONE;
            int indicatorColor = resources.getColor(extras.getInt(TabsSettingsFragment.INDICATOR_COLOR));
            int underlineColor = resources.getColor(extras.getInt(TabsSettingsFragment.UNDERLINE_COLOR));
            int indicatorHeightDp = extras.getInt(TabsSettingsFragment.INDICATOR_HEIGHT);
            int underlineHeightDp = extras.getInt(TabsSettingsFragment.UNDERLINE_HEIGHT);
            int tabPaddingDp = extras.getInt(TabsSettingsFragment.TAB_PADDING);

            mToolbar.setVisibility(showToolbar);

            mMaterialTabs.setIndicatorColor(indicatorColor);
            mMaterialTabs.setUnderlineColor(underlineColor);
            mMaterialTabs.setIndicatorHeight(Utils.dpToPx(resources, indicatorHeightDp));
            mMaterialTabs.setUnderlineHeight(Utils.dpToPx(resources, underlineHeightDp));
            mMaterialTabs.setTabPaddingLeftRight(Utils.dpToPx(resources, tabPaddingDp));

            boolean paddingMiddle = extras.getBoolean(TabsSettingsFragment.PADDING_MIDDLE);
            boolean sameWeightTabs = extras.getBoolean(TabsSettingsFragment.SAME_WEIGHT_TABS);
            boolean textAllCaps = extras.getBoolean(TabsSettingsFragment.TEXT_ALL_CAPS);

            mMaterialTabs.setPaddingMiddle(paddingMiddle);
            mMaterialTabs.setSameWeightTabs(sameWeightTabs);
            mMaterialTabs.setAllCaps(textAllCaps);

            int toolbarColor = resources.getColor(extras.getInt(TabsSettingsFragment.TOOLBAR_BACKGROUND));
            int tabBackgroundColor = resources.getColor(extras.getInt(TabsSettingsFragment.TAB_BACKGROUND));
            mToolbar.setBackgroundColor(toolbarColor);
            mMaterialTabs.setBackgroundColor(tabBackgroundColor);

            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(Color.argb(Color.alpha(toolbarColor), Color.red(toolbarColor) / 2,
                        Color.green(toolbarColor) / 2, Color.blue(toolbarColor) / 2));
            }

            int textColorSelected = resources.getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_SELECTED));
            int textColorUnselected = resources
                    .getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_UNSELECTED));
            int tabStyleSelected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_SELECTED);
            int tabStyleUnselected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_UNSELECTED);

            mMaterialTabs.setTextColorSelected(textColorSelected);
            mMaterialTabs.setTextColorUnselected(textColorUnselected);

            mMaterialTabs.setTabTypefaceSelectedStyle(tabStyleSelected);
            mMaterialTabs.setTabTypefaceUnselectedStyle(tabStyleUnselected);

            int rippleDuration = extras.getInt(RippleSettingsFragment.RIPPLE_DURATION);
            float rippleAlphaFloat = extras.getFloat(RippleSettingsFragment.RIPPLE_ALPHA_FLOAT);
            int rippleColor = resources.getColor(extras.getInt(RippleSettingsFragment.RIPPLE_COLOR));
            boolean rippleDelayClick = extras.getBoolean(RippleSettingsFragment.RIPPLE_DELAY_CLICK);
            float rippleDiameterDp = extras.getFloat(RippleSettingsFragment.RIPPLE_DIAMETER);
            int rippleFadeDuration = extras.getInt(RippleSettingsFragment.RIPPLE_FADE_DURATION);
            int rippleHighlightColor = resources
                    .getColor(extras.getInt(RippleSettingsFragment.RIPPLE_HIGHLIGHT_COLOR));
            boolean rippleOverlay = extras.getBoolean(RippleSettingsFragment.RIPPLE_OVERLAY);
            boolean ripplePersistent = extras.getBoolean(RippleSettingsFragment.RIPPLE_PERSISTENT);
            int rippleRoundedCornusRadiusDp = extras
                    .getInt(RippleSettingsFragment.RIPPLE_ROUNDED_CORNERS_RADIUS);

            mMaterialTabs.setRippleDuration(rippleDuration);
            mMaterialTabs.setRippleAlphaFloat(rippleAlphaFloat);
            mMaterialTabs.setRippleColor(rippleColor);
            mMaterialTabs.setRippleDelayClick(rippleDelayClick);
            mMaterialTabs.setRippleDiameterDp(rippleDiameterDp);
            mMaterialTabs.setRippleFadeDuration(rippleFadeDuration);
            mMaterialTabs.setRippleHighlightColor(rippleHighlightColor);
            mMaterialTabs.setRippleInAdapter(false);
            mMaterialTabs.setRippleOverlay(rippleOverlay);
            mMaterialTabs.setRipplePersistent(ripplePersistent);
            mMaterialTabs.setRippleRoundedCornersDp(rippleRoundedCornusRadiusDp);

            mExportableString = createExportableText(showToolbar, indicatorColor, underlineColor,
                    indicatorHeightDp, underlineHeightDp, tabPaddingDp, paddingMiddle, sameWeightTabs,
                    textAllCaps, toolbarColor, tabBackgroundColor, textColorSelected, textColorUnselected,
                    tabStyleSelected, tabStyleUnselected, rippleDuration, rippleAlphaFloat, rippleColor,
                    rippleDelayClick, rippleDiameterDp, rippleFadeDuration, rippleHighlightColor, rippleOverlay,
                    ripplePersistent, rippleRoundedCornusRadiusDp);
        }
    }
}

From source file:com.example.h156252.connected_cars.CarGrid.java

/** Called when the activity is first created. */
@Override/*from  w  w w  . j a  v  a 2  s . c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.content_car_grid);
    try {
        Window window = getWindow();

        // clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

        // finally change the color
        window.setStatusBarColor(Color.rgb(0, 0, 0));
        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.rgb(0, 0, 0)));
    } catch (Exception e) {
        // Toast.makeText(getApplicationContext(),"Exception in actionbar  "+e.getLocalizedMessage(),Toast.LENGTH_SHORT).show();
    }
    session = new SessionManagement(this);
    tts = new TextToSpeech(this, this);
    //Toast.makeText(getApplicationContext(),"Entering activity",Toast.LENGTH_SHORT).show();
    Intent intent = getIntent();
    String result = intent.getStringExtra(HomeScreen.EXTRA_MESSAGE);
    //Toast.makeText(getApplicationContext(),"obtaining result: " +result,Toast.LENGTH_SHORT).show();
    ArrayList<String> listdata = new ArrayList<String>();

    try {

        JSONArray jArray = new JSONArray(result);
        if (jArray != null) {
            for (int i = 0; i < jArray.length(); i++) {

                String jstr = jArray.get(i).toString();
                JSONObject jObj = new JSONObject(jstr);
                String id = jObj.getString("id");
                //String phone = jObj.getString("phone");
                String brand = jObj.getString("text");
                String text = jObj.getString("cartext");
                String carno = jObj.getString("carnum");
                String color = jObj.getString("color");
                //String isDone = jObj.getString("isDone");
                String result_combine = "CAR " + i + ":\nCar id : #" + id + "*\n" + "License No.   : " + carno
                        + "\n" + "Color   : " + color + "\n" + "Brand   : " + brand + "\n"
                        + "Text behind car   : " + text;
                String rr = "Success " + result_combine;
                //Toast.makeText(getApplicationContext(),rr,Toast.LENGTH_SHORT).show();
                String own_id = session.getID();
                if (!(id.equals(own_id)))
                    listdata.add(result_combine);
            }
        }
    } catch (Exception e) {
        //Toast.makeText(getApplicationContext(),e.getLocalizedMessage(),Toast.LENGTH_SHORT).show();
    }

    //Toast.makeText(getApplicationContext(),"out of json",Toast.LENGTH_SHORT).show();
    final GridView gridview = (GridView) findViewById(R.id.gridview);
    // final String[] items = new String[] { "Item1", "Item2", "Item3","Item4", "Item5", "Item6", "Item7", "Item8" };

    ArrayAdapter<String> ad = new ArrayAdapter<String>(getApplicationContext(),
            android.R.layout.simple_list_item_1, listdata);
    //Toast.makeText(getApplicationContext(),"setting array adapter",Toast.LENGTH_SHORT).show();
    //gridview.setBackgroundColor(Color.GRAY);

    gridview.setNumColumns(2);
    gridview.setGravity(Gravity.CENTER);
    gridview.setAdapter(ad);
    gridview.setBackgroundColor(Color.GRAY);
    //Toast.makeText(getApplicationContext(),"setting grid view",Toast.LENGTH_SHORT).show();
    gridview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) {
            // TODO Auto-generated method stub
            // Toast.makeText(getApplicationContext(), "" + arg2,Toast.LENGTH_SHORT).show();
            //Toast.makeText(getApplicationContext(),"Prompting speech",Toast.LENGTH_SHORT).show();

            try {
                String s = ((TextView) v).getText().toString();

                int start = 0; // '(' position in string
                int end = 0; // ')' position in string
                for (int i = 0; i < s.length(); i++) {
                    if (s.charAt(i) == '#') // Looking for '(' position in string
                        start = i;
                    else if (s.charAt(i) == '*') // Looking for ')' position in  string
                        end = i;
                }
                receiver_id = s.substring(start + 1, end);

                //Toast.makeText(getApplicationContext(), "ID: " + receiver_id, Toast.LENGTH_SHORT).show();
                //promptSpeechInput();

            } catch (Exception e) {
                // Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
            }

            //receiver_id = grid_text.substring(grid_text.indexOf("#") + 1, grid_text.indexOf("#"));
            //Toast.makeText(getApplicationContext(),receiver_id,Toast.LENGTH_SHORT).show();

            try {
                promptSpeechInput();
            } catch (Exception e) {
                //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
            }

            try {
                Intent intent_rate = new Intent(getApplicationContext(), RateDriving.class);
                intent_rate.putExtra(EXTRA_MESSAGE, receiver_id);
                startActivity(intent_rate);

            } catch (Exception e) {
                //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
            }

            //new VoiceTask().execute("http://myfirst.au-syd.mybluemix.net/api/Items");
        }
    });

}

From source file:com.jun.elephant.ui.main.MainActivity.java

/**
 * ???//from  w w w  . j  av a2  s .  c  o m
 * @param colorValue 
 */
private void changeStatusColor(int colorValue) {
    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(ContextCompat.getColor(this, colorValue));
    }
}