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:org.smssecure.smssecure.ConversationActivity.java

private void setActionBarColor(MaterialColor color) {
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color.toActionBarColor(this)));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.setStatusBarColor(color.toStatusBarColor(this));
        window.setNavigationBarColor(getResources().getColor(android.R.color.black));
    }/*from   www  .  j  av  a 2s. c  o m*/
}

From source file:com.saphion.stencilweather.activities.MainActivity.java

public void setToolBarColor(int color) {
    try {//www  .  java  2 s  .co  m
        //            findViewById(R.id.appbar).setBackgroundColor(color);
        toolbar.setBackgroundColor(Color.TRANSPARENT);

        Integer colorFrom = Color.TRANSPARENT;
        Drawable background = findViewById(R.id.appbar).getBackground();
        if (background instanceof ColorDrawable)
            colorFrom = ((ColorDrawable) background).getColor();
        Integer colorTo = color;
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                findViewById(R.id.appbar).setBackgroundColor((Integer) animator.getAnimatedValue());
                findViewById(R.id.appbarGraph).setBackgroundColor((Integer) animator.getAnimatedValue());
            }

        });
        colorAnimation.setDuration(350);
        colorAnimation.start();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

            color = (color & 0xfefefefe) >> 1;

            window.setStatusBarColor(color);
        }

    } catch (Exception ignored) {
    }
}

From source file:com.hangulo.powercontact.MainActivity.java

public void launchSearchFragment(boolean onoff) {

    if (mTwoPane)
        return; // twopane ? ? .
    ActionBar actionBar = getSupportActionBar();

    if (onoff == mIsExpandedFragment)
        return; //  ? ? ? ? ? .

    FrameLayout view = (FrameLayout) findViewById(R.id.contact_list_view_container);
    PercentFrameLayout.LayoutParams params = (PercentFrameLayout.LayoutParams) view.getLayoutParams();
    // This will currently return null, if it was not constructed from XML.
    PercentLayoutHelper.PercentLayoutInfo info = params.getPercentLayoutInfo();

    if (onoff) { // expand
        info.heightPercent = 1.0f;//from  w  ww.j  ava 2s  .  com
        mIsExpandedFragment = true;

        //  ? 

        if (actionBar != null)
            actionBar.hide();

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

        if (mListFragment != null && mListFragment.mBtnHomeUp != null)
            mListFragment.mBtnHomeUp.setVisibility(View.VISIBLE); //  ? ? ? .

    } else { // collapse

        info.heightPercent = 0.4f;
        mIsExpandedFragment = false;

        //  ? .
        if (actionBar != null)
            actionBar.show();

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

        if (mListFragment != null && mListFragment.mBtnHomeUp != null) {
            mListFragment.mBtnHomeUp.setVisibility(View.GONE); //   ? .

            //  ?... ?  ?...
            //                mListFragment.mSearchView.setIconified(false);
        }

    }
    view.requestLayout();
    //
    //        LinearLayout layoutListView = (LinearLayout) findViewById(R.id.testtest);
    //        lpListView = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,0);
    //        if(onoff)
    //            lpListView.weight=20;
    //        else
    //            lpListView.weight=2;
    //        layoutListView.setLayoutParams(lpListView);

}

From source file:org.totschnig.myexpenses.activity.MyExpenses.java

/**
 * set the Current account to the one in the requested position of mAccountsCursor
 *
 * @param position//from  www  . j ava2s. c o  m
 */
private void setCurrentAccount(int position) {
    mAccountsCursor.moveToPosition(position);
    long newAccountId = mAccountsCursor.getLong(columnIndexRowId);
    if (mAccountId != newAccountId) {
        PrefKey.CURRENT_ACCOUNT.putLong(newAccountId);
    }
    int color = newAccountId < 0 ? colorAggregate : mAccountsCursor.getInt(columnIndexColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        //noinspection InlinedApi
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //noinspection InlinedApi
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        int color700 = Utils.get700Tint(color);
        window.setStatusBarColor(color700);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            //noinspection InlinedApi
            getWindow().getDecorView().setSystemUiVisibility(
                    Utils.isBrightColor(color700) ? View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR : 0);
        }
    }
    Utils.setBackgroundTintListOnFab(floatingActionButton, color);
    mAccountId = newAccountId;
    setBalance();
    mDrawerList.setItemChecked(position, true);
    supportInvalidateOptionsMenu();
}

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

@SuppressLint("InflateParams")
private void initialiseViews() {
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame);
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);
    if (!ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }//from   w  ww .j  a  v a 2  s .com
    if (displayImageOptions != null) {
        displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
                .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
                .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
    }

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else {
        assert mDrawerLinear != null;
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    }
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1) {
        assert v != null;
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    }

    assert v != null;
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            utils.revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0) {
        assert divider != null;
        divider.setImageResource(R.color.divider);
    } else {
        assert divider != null;
        divider.setImageResource(R.color.divider_dark);
    }

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        assert settingsbutton != null;
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert settingsbutton != null;
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        assert appbutton != null;
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert appbutton != null;
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    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.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
    //admob
    mAdView = (View) findViewById(R.id.ads);
}

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

void initialiseViews() {
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);

    if (!ImageLoader.getInstance().isInited()) {

        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }// w ww. j a  v a2s. com
    displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
            .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
            .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1)
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0)
        divider.setImageResource(R.color.divider);
    else
        divider.setImageResource(R.color.divider_dark);

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    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.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
}

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

void initialiseViews() {
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);

    if (!ImageLoader.getInstance().isInited()) {

        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }/*from   ww w  . ja v a2 s .c o m*/
    displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
            .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
            .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame);
    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);

    //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    mFabBackground = findViewById(R.id.fab_bg);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    /* For SearchView, see onCreateOptionsMenu(Menu menu)*/
    TOOLBAR_START_INSET = toolbar.getContentInsetStart();
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.openDrawer(mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    } else if (findViewById(R.id.tab_frame) == null) {

        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear);
        mDrawerLayout.closeDrawer(mDrawerLinear);
        isDrawerLocked = false;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    View v = findViewById(R.id.fab_bg);
    /*if (theme1 != 1)
    v.setBackgroundColor(Color.parseColor("#a6ffffff"));*/
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            utils.revealShow(view, false);
            if (isSearchViewEnabled)
                hideSearchView();
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0)
        divider.setImageResource(R.color.divider);
    else
        divider.setImageResource(R.color.divider_dark);

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });

    View ftpButton = findViewById(R.id.ftpbutton);
    if (theme1 == 1) {
        ftpButton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark);
        ((TextView) ftpButton.findViewById(R.id.ftptext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    ftpButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new FTPServerFragment());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin))));

    // status bar0
    sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else 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);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);
    }

    searchViewLayout = (RelativeLayout) findViewById(R.id.search_view);
    searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text);
    ImageView clear = (ImageView) findViewById(R.id.search_close_btn);
    clear.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchViewEditText.setText("");
        }
    });
    findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideSearchView();
        }
    });
    searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)) {
                // Perform action on key press
                mainActivityHelper.search(searchViewEditText.getText().toString());
                hideSearchView();
                return true;
            }
            return false;
        }
    });

    //    searchViewEditText.setTextColor(getResources().getColor(android.R.color.black));
    //     searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin));
}

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

void initialiseViews() {
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);

    mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame);
    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);

    //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override/*from  w  w w  . java 2 s .  c o m*/
        public boolean onLongClick(View v) {
            Intent intent;
            if (SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    /* For SearchView, see onCreateOptionsMenu(Menu menu)*/
    TOOLBAR_START_INSET = toolbar.getContentInsetStart();
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (getAppTheme().equals(AppTheme.DARK))
        mDrawerLinear.setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background));
    else
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.openDrawer(mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    } else if (findViewById(R.id.tab_frame) == null) {

        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear);
        mDrawerLayout.closeDrawer(mDrawerLinear);
        isDrawerLocked = false;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    fabBgView = findViewById(R.id.fab_bg);
    if (getAppTheme().equals(AppTheme.DARK)) {
        fabBgView.setBackgroundResource(R.drawable.fab_shadow_dark);
    }

    fabBgView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            if (isSearchViewEnabled)
                hideSearchView();
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (getAppTheme().equals(AppTheme.LIGHT))
        divider.setImageResource(R.color.divider);
    else
        divider.setImageResource(R.color.divider_dark);

    setDrawerHeaderBackground();
    View settingsButton = findViewById(R.id.settingsbutton);
    if (getAppTheme().equals(AppTheme.DARK)) {
        settingsButton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsButton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsButton.findViewById(R.id.settingtext))
                .setTextColor(Utils.getColor(this, android.R.color.white));
    }
    settingsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, PreferencesActivity.class);
            startActivity(in);
            finish();
        }

    });
    View appButton = findViewById(R.id.appbutton);
    if (getAppTheme().equals(AppTheme.DARK)) {
        appButton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appButton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appButton.findViewById(R.id.apptext))
                .setTextColor(Utils.getColor(this, android.R.color.white));
    }
    appButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            selectedStorage = SELECT_MINUS_2;
            adapter.toggleChecked(false);
        }
    });

    View ftpButton = findViewById(R.id.ftpbutton);
    if (getAppTheme().equals(AppTheme.DARK)) {
        ftpButton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark);
        ((TextView) ftpButton.findViewById(R.id.ftptext))
                .setTextColor(Utils.getColor(this, android.R.color.white));
    }
    ftpButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new FTPServerFragment());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            selectedStorage = SELECT_MINUS_2;
            adapter.toggleChecked(false);
        }
    });
    //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin))));

    // status bar0
    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);
    }

    searchViewLayout = (RelativeLayout) findViewById(R.id.search_view);
    searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text);
    ImageView clear = (ImageView) findViewById(R.id.search_close_btn);
    clear.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchViewEditText.setText("");
        }
    });
    findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideSearchView();
        }
    });
    searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)) {
                // Perform action on key press
                mainActivityHelper.search(searchViewEditText.getText().toString());
                hideSearchView();
                return true;
            }
            return false;
        }
    });

    //    searchViewEditText.setTextColor(Utils.getColor(this, android.R.color.black));
    //     searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin));
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

/**
 * Sets up transparent navigation and status bars in LMP.
 * This method is a no-op for other platform versions.
 *//*  w  ww .j a  v a 2  s .c om*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupTransparentSystemBarsForLmp() {
    if (Utilities.isLmpOrAbove()) {
        Window window = getWindow();
        window.getAttributes().systemUiVisibility |= (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }
}

From source file:com.tct.mail.compose.ComposeActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void changeStatusBarColor() {
    Window window = ComposeActivity.this.getWindow();
    if (window != null) {
        window.setStatusBarColor(getResources().getColor(R.color.change_status_bar));
    }// w  w  w .j ava  2s. co m
}