Example usage for android.view Window setStatusBarColor

List of usage examples for android.view Window setStatusBarColor

Introduction

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

Prototype

public abstract void setStatusBarColor(@ColorInt int color);

Source Link

Document

Sets the color of the status bar to color .

Usage

From source file:com.citrus.sdk.CitrusActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setActionBarBackground() {
    // Set primary color
    if (mColorPrimary != null && mActionBar != null) {
        mActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(mColorPrimary)));
    }/* w  w w .jav a2 s.co m*/

    // Set action bar color. Available only on android version Lollipop or higher.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mColorPrimaryDark != null) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.parseColor(mColorPrimaryDark));
    }
}

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

/**
 * Application of the chosen theme on the fly
 *
 * @param parent   parent/*from  w w  w. jav a  2  s  . c om*/
 * @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.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 source file:com.granita.tasks.ViewTaskFragment.java

@SuppressLint("NewApi")
private void updateColor(float percentage) {
    if (getActivity() instanceof TaskListActivity) {
        return;/*w  ww. jav  a  2s  .com*/
    }

    float[] hsv = new float[3];
    Color.colorToHSV(mListColor, hsv);

    if (VERSION.SDK_INT >= 11 && mColorBar != null) {
        percentage = Math.max(0, Math.min(Float.isNaN(percentage) ? 0 : percentage, 1));
        percentage = (float) Math.pow(percentage, 1.5);

        int newColor = darkenColor2(mListColor);

        hsv[2] *= (0.5 + 0.25 * percentage);

        ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
        actionBar.setBackgroundDrawable(
                new ColorDrawable((newColor & 0x00ffffff) | ((int) (percentage * 255) << 24)));

        // this is a workaround to ensure the new color is applied on all devices, some devices show a transparent ActionBar if we don't do that.
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);

        mColorBar.setBackgroundColor(mListColor);

        if (VERSION.SDK_INT >= 21) {
            Window window = getActivity().getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(newColor | 0xff000000);
        }
    }

    if (mActionButton != null) {
        // adjust color of action button
        if (hsv[0] > 70 && hsv[0] < 170 && hsv[2] < 0.62) {
            mActionButton.setBackgroundResource(R.drawable.bg_actionbutton_light);
        } else {
            mActionButton.setBackgroundResource(R.drawable.bg_actionbutton);
        }
    }
}

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

/** Called when the activity is first created. */
@Override/*w  ww  .  j  av a2  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.mooo.ziggypop.candconline.SettingsActivity.java

/**
 * Sets the actionbar and the status bar (if the build allows it) to the provided color id.
 * @param colorResourceId The id of the color to which the bars will be set.
 *///www. ja  v a 2  s  . co m
private void setBarColors(int colorResourceId) {
    // Set the action bar.
    mToolBar.setBackgroundResource(colorResourceId);
    //Set the status bar.
    Window window = getWindow();
    // clear FLAG_TRANSLUCENT_STATUS flag:
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    //Set the status bar color
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        window.setStatusBarColor(getResources().getColor(colorResourceId));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        window.setStatusBarColor(getResources().getColor(colorResourceId, getTheme()));
}

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

From source file:com.granita.tasks.EditTaskFragment.java

@SuppressLint("NewApi")
private void updateColor(float percentage) {
    if (VERSION.SDK_INT >= 11) {
        if (mColorBar == null) {
            percentage = 1;//ww  w.  jav  a  2  s.c om
        } else {
            percentage = Math.max(0, Math.min(Float.isNaN(percentage) ? 0 : percentage, 1));
        }

        int newColor = getBlendColor(mListColor, darkenColor(mListColor),
                (int) ((0.5 + 0.5 * percentage) * 255));
        ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(newColor));

        // this is a workaround to ensure the new color is applied on all devices, some devices show a transparent ActionBar if we don't do that.
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowTitleEnabled(true);

        if (VERSION.SDK_INT >= 21) {
            Window window = getActivity().getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(mixColors(newColor, mListColor));
            // window.setNavigationBarColor(mixColors(newColor, mListColor));
        }
    }
    mTaskListBar.setBackgroundColor(mListColor);
    if (mColorBar != null) {
        mColorBar.setBackgroundColor(mListColor);
    }
}

From source file:org.dmfs.tasks.TaskListActivity.java

@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override/*from  ww w  .  j a va2  s  .  co m*/
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate called again");
    super.onCreate(savedInstanceState);

    // check for single pane activity change
    mTwoPane = getResources().getBoolean(R.bool.has_two_panes);

    resolveIntentAction(getIntent());

    if (mSelectedTaskUri != null) {
        if (mShouldShowDetails && mShouldSwitchToDetail) {
            Intent viewTaskIntent = new Intent(Intent.ACTION_VIEW);
            viewTaskIntent.setData(mSelectedTaskUri);
            startActivity(viewTaskIntent);
            mSwitchedToDetail = true;
            mShouldSwitchToDetail = false;
            mTransientState = true;
        }
    } else {
        mShouldShowDetails = false;
    }

    setContentView(R.layout.activity_task_list);

    mAuthority = getString(R.string.org_dmfs_tasks_authority);
    mSearchHistoryHelper = new SearchHistoryHelper(this);

    if (findViewById(R.id.task_detail_container) != null) {
        // In two-pane mode, list items should be given the
        // 'activated' state when touched.

        // get list fragment
        // mTaskListFrag = (TaskListFragment) getSupportFragmentManager().findFragmentById(R.id.task_list);
        // mTaskListFrag.setListViewScrollbarPositionLeft(true);

        // mTaskListFrag.setActivateOnItemClick(true);

        /*
         * Create a detail fragment, but don't load any URL yet, we do that later when the fragment gets attached
         */
        mTaskDetailFrag = ViewTaskFragment.newInstance(mSelectedTaskUri);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.task_detail_container, mTaskDetailFrag, DETAIL_FRAGMENT_TAG).commit();
    } else {
        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment detailFragment = fragmentManager.findFragmentByTag(DETAIL_FRAGMENT_TAG);
        if (detailFragment != null) {
            fragmentManager.beginTransaction().remove(detailFragment).commit();
        }
    }

    mGroupingFactories = new AbstractGroupingFactory[] { new ByList(mAuthority), new ByDueDate(mAuthority),
            new ByStartDate(mAuthority), new ByPriority(mAuthority), new ByProgress(mAuthority),
            new BySearch(mAuthority, mSearchHistoryHelper) };

    // set up pager adapter
    try {
        mPagerAdapter = new TaskGroupPagerAdapter(getSupportFragmentManager(), mGroupingFactories, this,
                R.xml.listview_tabs);
    } catch (XmlPullParserException e) {
        // TODO Automatisch generierter Erfassungsblock
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Automatisch generierter Erfassungsblock
        e.printStackTrace();
    } catch (XmlObjectPullParserException e) {
        // TODO Automatisch generierter Erfassungsblock
        e.printStackTrace();
    }

    // Setup ViewPager
    mPagerAdapter.setTwoPaneLayout(mTwoPane);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);

    int currentPageIndex = mPagerAdapter.getPagePosition(mCurrentPageId);

    if (currentPageIndex >= 0) {
        mCurrentPagePosition = currentPageIndex;
        mViewPager.setCurrentItem(currentPageIndex);
        if (VERSION.SDK_INT >= 14 && mCurrentPageId == R.id.task_group_search) {
            if (mSearchItem != null) {
                // that's actually quite impossible to happen
                MenuItemCompat.expandActionView(mSearchItem);
            } else {
                mAutoExpandSearchView = true;
            }
        }
    }
    updateTitle(currentPageIndex);

    // Bind the tabs to the ViewPager
    mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    mTabs.setViewPager(mViewPager);

    mTabs.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            mSelectedTaskUri = null;
            mCurrentPagePosition = position;

            int newPageId = mPagerAdapter.getPageId(position);

            if (newPageId == R.id.task_group_search) {
                int oldPageId = mCurrentPageId;
                mCurrentPageId = newPageId;

                // store the page position we're coming from
                mPreviousPagePosition = mPagerAdapter.getPagePosition(oldPageId);
            } else if (mCurrentPageId == R.id.task_group_search) {
                // we've been on the search page before, so commit the search and close the search view
                mSearchHistoryHelper.commitSearch();
                mHandler.post(mSearchUpdater);
                mCurrentPageId = newPageId;
                hideSearchActionView();
            }
            mCurrentPageId = newPageId;

            updateTitle(mCurrentPageId);
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            if (state == ViewPager.SCROLL_STATE_IDLE && mCurrentPageId == R.id.task_group_search) {
                // the search page is selected now, expand the search view
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        MenuItemCompat.expandActionView(mSearchItem);
                    }
                });
            }
        }
    });

    // make sure the status bar color is set properly on Android 5+ devices
    if (VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarker));
    }
}

From source file:org.smssecure.smssecure.ConversationListFragment.java

@Override
public void onDestroyActionMode(ActionMode mode) {
    getListAdapter().initializeBatchMode(false);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getActivity().getWindow();
        TypedArray color = getActivity().getTheme()
                .obtainStyledAttributes(new int[] { android.R.attr.statusBarColor });
        window.setStatusBarColor(color.getColor(0, Color.BLACK));
        window.setNavigationBarColor(getResources().getColor(android.R.color.black));
        color.recycle();//from  ww  w. j  a  v a2  s. c  o  m
    }

    actionMode = null;
}