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:com.dw.bartinter.BarTinter.java

private void navigationBar(final String colorPref) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (colorPref != null && !colorPref.isEmpty()) {
            final Window window = cordova.getActivity().getWindow();
            window.clearFlags(0x04000000);
            window.addFlags(0x80000000);
            try {
                window.getClass().getDeclaredMethod("setNavigationBarColor", int.class).invoke(window,
                        Color.parseColor(colorPref));
            } catch (IllegalArgumentException ignore) {
                Log.e(PLUGIN, "Invalid hexString argument.");
            } catch (Exception ignore) {
                Log.w(PLUGIN,// w  ww  .  j a va  2  s  .  co  m
                        "Method window.setNavigationBarColor not found for SDK level " + Build.VERSION.SDK_INT);
            }
        }
    }
}

From source file:de.gebatzens.ggvertretungsplan.GGApp.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarColor(Window w) {
    w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    w.setStatusBarColor(GGApp.GG_APP.provider.getDarkColor());
}

From source file:de.gebatzens.ggvertretungsplan.GGApp.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(getResources().getColor(R.color.transparent));
}

From source file:com.dongbang.yutian.activity.CommonScanActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_scan_code);
    ButterKnife.bind(this);
    scanMode = getIntent().getIntExtra(Constant.REQUEST_SCAN_MODE, Constant.REQUEST_SCAN_MODE_ALL_MODE);
    initView();/*from  w  w w.ja v a2  s . com*/
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);//www  .  j  a  v a2 s  . co m
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));
        setTaskDescription(taskDescription);
    }
    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(MainActivity.currentTab == 1 ? skinTwo : skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : 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(MainActivity.currentTab == 1 ? skinTwo : skin)));
        if (colourednavigation)
            window.setNavigationBarColor(
                    (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));

    }
    selectItem(0);
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);/*from   w  ww.ja  v a2s .  c  om*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(
            getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab)));

    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (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(
                getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(
                    getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));

    }
    if (savedInstanceState != null) {
        selectedItem = savedInstanceState.getInt(KEY_CURRENT_FRAG_OPEN, 0);
    }
    selectItem(selectedItem);
}

From source file:org.catrobat.paintroid.WelcomeActivity.java

private void changeStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }/*from  www  .  j av a2s  .  c om*/
}

From source file:com.amaze.carbonfilemanager.activities.DbViewer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    this.checkStorage = false;
    super.onCreate(savedInstanceState);

    if (getAppTheme().equals(AppTheme.DARK)) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background));
    }//www .  j  a  v a 2s.co  m
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        setTaskDescription(taskDescription);
    }
    getSupportActionBar().setBackgroundDrawable(
            getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        boolean colourednavigation = sharedPref.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(
                getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(
                    getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));

    }

    path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

}

From source file:org.kaaproject.kaa.demo.iotworld.climate.ClimateControlActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_climate);

    if (savedInstanceState == null) {
        showThermostat();//w  w  w .  j  a  v  a  2 s  .c  o m
    }
}

From source file:com.adkdevelopment.rssreader.ui.DetailFragment.java

@Override
public void showData(NewsObject newsItem) {

    //ImageView backdrop = ButterKnife.findById(getActivity(), R.id.backdrop);
    if (mBackdrop != null) {
        Picasso.with(getContext()).load(newsItem.getThumbnail()).into(mBackdrop, new Callback() {
            @Override/*ww w  . j  a  v a 2 s.  c om*/
            public void onSuccess() {
                // makes detail view colored according to the image palette
                if (mBackdrop != null) {
                    BitmapDrawable drawable = (BitmapDrawable) mBackdrop.getDrawable();

                    int[] palette = Utilities.getPalette(drawable);
                    mNestedScroll.setBackgroundColor(palette[0]);
                    CollapsingToolbarLayout toolbarLayout = ButterKnife.findById(getActivity(),
                            R.id.collapsing_toolbar);
                    if (toolbarLayout != null) {
                        toolbarLayout.setContentScrimColor(palette[1]);
                    }

                    Toolbar toolbar = ButterKnife.findById(getActivity(), R.id.toolbar);
                    toolbar.setBackgroundColor(palette[2]);

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        Window window = getActivity().getWindow();
                        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                        window.setStatusBarColor(palette[2]);
                    }
                }
            }

            @Override
            public void onError() {
                Log.e(TAG, "onError: no image");
            }
        });
    }

    mTextDate.setText(Utilities.getFormattedDate(newsItem.getPubDate()));
    mTextTitle.setText(newsItem.getTitle());
    mTextDescription.setText(newsItem.getDescription());
    String learMore = getString(R.string.learn_more) + " " + newsItem.getLink();
    mTextLink.setText(learMore);
}