Example usage for android.view View SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

List of usage examples for android.view View SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.

Prototype

int SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

To view the source code for android.view View SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : Requests the status bar to draw in a mode that is compatible with light status bar backgrounds.

Usage

From source file:Main.java

public static void setDarkIcon(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }/*  w  ww.  j a va  2s.com*/
}

From source file:com.technologx.firebirddesigns.MainInterface.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bottom_interface);

    View main = findViewById(R.id.main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (main != null) {
            main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }/*from   w  ww.  j  ava2s .  c o  m*/
    }

    AppCompatActivity activity = this;
    activity.setSupportActionBar(toolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    activity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_toolbar);
    activity.getSupportActionBar().setTitle("Fire Bird Designs");
    activity.getSupportActionBar().setSubtitle("News, Content and More");

    UpdateChecker checker = new UpdateChecker(this);
    UpdateChecker.setStore(Store.GOOGLE_PLAY);
    UpdateChecker.setNoticeIcon(R.mipmap.ic_launcher);
    UpdateChecker.start();

    result = new DrawerBuilder(this).withToolbar(toolbar).withDisplayBelowStatusBar(false)
            .withTranslucentStatusBar(false).withActionBarDrawerToggleAnimated(true)
            .withDrawerLayout(R.layout.material_drawer_fits_not).withHeader(R.layout.settings_header)
            .addDrawerItems(new SectionDrawerItem().withName("Application"),
                    new PrimaryDrawerItem().withName("Notifications").withIdentifier(1),
                    new PrimaryDrawerItem().withName("Homepage").withIdentifier(2),
                    new ExpandableDrawerItem().withName("More").withSubItems(
                            new PrimaryDrawerItem().withName("Settings").withIdentifier(3),
                            new PrimaryDrawerItem().withName("License").withIdentifier(4),
                            new PrimaryDrawerItem().withName("Contact").withIdentifier(5)))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    long id = drawerItem.getIdentifier();
                    if (id == 1) {
                        Intent intent = new Intent(MainInterface.this, NewsfeedActivity.class);
                        startActivity(intent);
                    } else if (id == 2) {
                        Intent intent = new Intent(MainInterface.this, WebViewActivity.class);
                        startActivity(intent);
                    } else if (id == 3) {
                        Intent intent = new Intent(MainInterface.this, SettingsActivity.class);
                        startActivity(intent);
                    } else if (id == 4) {
                        new LicensesDialog.Builder(MainInterface.this).setNotices(R.raw.licenses).build()
                                .show();

                    } else if (id == 5) {
                        AlertDialog alertDialog = new AlertDialog.Builder(MainInterface.this).create();
                        alertDialog.setTitle(getResources().getString(R.string.feedback_title));
                        alertDialog.setMessage(getResources().getString(R.string.feedback_summary));
                        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                                getResources().getString(R.string.email),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        sendEmail();
                                    }
                                });
                        alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
                                getResources().getString(R.string.hangout),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        startHangout();
                                    }
                                });
                        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                                getResources().getString(android.R.string.cancel),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                });
                        alertDialog.show();
                    }

                    return false;
                }
            }).withSavedInstance(savedInstanceState).build();

    // Setup the viewPager
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    viewPager.setCurrentItem(1);
    viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
        @Override
        public void transformPage(View page, float position) {
            final float normalizedposition = Math.abs(Math.abs(position) - 1);
            page.setAlpha(normalizedposition);
        }
    });

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    if (mTabLayout != null) {
        mTabLayout.setupWithViewPager(viewPager);

        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
            TabLayout.Tab tab = mTabLayout.getTabAt(i);
            if (tab != null)
                tab.setCustomView(pagerAdapter.getTabView(i));
        }

        mTabLayout.getTabAt(0).getCustomView().setSelected(true);
    }
}

From source file:com.dm.material.dashboard.candybar.helpers.ColorHelper.java

public static void setStatusBarIconColor(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View view = ((AppCompatActivity) context).getWindow().getDecorView();
        if (view != null) {
            String homeImage = context.getResources().getString(R.string.home_image);
            if (homeImage.length() > 0) {
                view.setSystemUiVisibility(0);
                return;
            }//  ww  w .j a va  2 s.c o  m

            if (isLightToolbar(context)) {
                view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                return;
            }

            view.setSystemUiVisibility(0);
        }
    }
}

From source file:com.agenmate.lollipop.util.ViewUtils.java

public static void setLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }//from   w  w w .  j av a  2s . com
}

From source file:com.github.michaelins.lightstatusbar.LightStatusBar.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action//from  w  ww  . ja  v a2s  .  c om
 *            The action to execute.
 * @param args
 *            JSONArry of arguments for the plugin.
 * @param callbackContext
 *            The callback id used when calling back into JavaScript.
 * @return True if the action was valid, false otherwise.
 */
@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {

    LOG.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();

    if ("isSupported".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M || SystemBarTintManager.IsMiuiV6Plus()) {
                    callbackContext.success("true");
                } else {
                    callbackContext.success("false");
                }
            }
        });
        return true;
    }

    if ("setStatusBarColor".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    webView.getView().setFitsSystemWindows(true);
                    if (SystemBarTintManager.IsMiuiV6Plus()) {
                        // MIUI6+ light status bar
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                            setTranslucentStatus(window, true);
                        }
                        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
                        tintManager.setStatusBarTintEnabled(true);
                        tintManager.setStatusBarTintColor(Color.parseColor(args.getString(0)));
                        tintManager.setStatusBarDarkMode(true, activity);
                    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        // 6.0+ light status bar
                        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                        int uiOptions = window.getDecorView().getSystemUiVisibility()
                                | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
                        window.getDecorView().setSystemUiVisibility(uiOptions);
                        setStatusBarBackgroundColor(args.getString(0));
                    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        setStatusBarBackgroundColor(args.getString(0));
                    }
                } catch (JSONException ignore) {
                    LOG.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                }
            }
        });
        return true;
    }

    if ("enable".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
            }
        });
        return true;
    }

    if ("disable".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
            }
        });
        return true;
    }
    return false;
}

From source file:com.agenmate.lollipop.util.ViewUtils.java

public static void clearLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }/*from www  .  j  av a2s  .co m*/
}

From source file:com.danimahardhika.android.helpers.core.ColorHelper.java

public static void setupStatusBarIconColor(Context context, boolean isLightToolbar) {
    if (context == null) {
        Log.e("ColorHelper", "setupStatusBarIconColor() context is null");
        return;/*  ww w  . j  a va 2  s .  c  o  m*/
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (((AppCompatActivity) context).getWindow() == null) {
            Log.e("ColorHelper", "setupStatusBarIconColor() getWindow() returns null");
            return;
        }

        View view = ((AppCompatActivity) context).getWindow().getDecorView();
        if (view != null) {
            if (isLightToolbar) {
                view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                return;
            }

            view.setSystemUiVisibility(0);
        }
    }
}

From source file:com.irccloud.android.activity.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    boolean themeChanged = false;
    String theme = ColorScheme.getUserTheme();
    if (ColorScheme.getInstance().theme == null || !ColorScheme.getInstance().theme.equals(theme)) {
        themeChanged = true;/*from   w w  w.  j  a va  2 s .co  m*/
    }
    setTheme(ColorScheme.getTheme(theme, true));
    ColorScheme.getInstance().setThemeFromContext(this, theme);
    if (themeChanged) {
        EventsList.getInstance().clearCaches();
        AvatarsList.getInstance().clear();
    }
    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.splash_logo);
        if (cloud != null) {
            setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                    cloud, ColorScheme.getInstance().navBarColor));
        }
        getWindow().setStatusBarColor(ColorScheme.getInstance().statusBarColor);
        getWindow().setNavigationBarColor(getResources().getColor(android.R.color.black));
    }
    if (ColorScheme.getInstance().windowBackgroundDrawable != 0)
        getWindow().setBackgroundDrawableResource(ColorScheme.getInstance().windowBackgroundDrawable);
    if (Build.VERSION.SDK_INT >= 23) {
        if (theme.equals("dawn"))
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        else
            getWindow().getDecorView().setSystemUiVisibility(
                    getWindow().getDecorView().getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Auth.CREDENTIALS_API)
            .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();

    conn = NetworkConnection.getInstance();
    conn.addHandler(this);
    if (ServersList.getInstance().count() == 0)
        NetworkConnection.getInstance().load();

    try {
        mMultiWindow = new SMultiWindow();
        mMultiWindow.initialize(this);
        mMultiWindowActivity = new SMultiWindowActivity(this);
    } catch (Exception e) {
        mMultiWindow = null;
        mMultiWindowActivity = null;
    } catch (Error e) {
        mMultiWindow = null;
        mMultiWindowActivity = null;
    }
}

From source file:us.koller.todolist.Activities.InfoActivity.java

public void initTheme(Toolbar toolbar) {
    helper = new ThemeHelper(this);

    findViewById(R.id.info_activity_layout).setBackgroundColor(helper.get(ThemeHelper.CORD_COLOR));
    toolbar.setBackgroundColor(helper.get(ThemeHelper.TOOLBAR_COLOR));
    toolbar.setTitleTextColor(helper.get(ThemeHelper.TOOLBAR_TEXT_COLOR));
    if (helper.get(ThemeHelper.CORD_COLOR) != helper.get(ThemeHelper.TOOLBAR_COLOR)) {
        elevateToolbar(toolbar);//w ww .j  a v  a  2  s  .  c  o  m
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && helper.lightCoordColor()) {
        toolbar.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }

    View drawerIcon;
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        if (toolbar.getChildAt(i) instanceof ImageView) {
            drawerIcon = toolbar.getChildAt(i);
            ((ImageView) drawerIcon).setColorFilter(helper.getToolbarIconColor(), PorterDuff.Mode.SRC_IN);
        }
    }

    String title = getString(R.string.app_name);
    BitmapDrawable icon = (BitmapDrawable) ContextCompat.getDrawable(InfoActivity.this, R.mipmap.ic_launcher);

    ActivityManager.TaskDescription tDesc = new ActivityManager.TaskDescription(title, icon.getBitmap(),
            helper.get(ThemeHelper.TOOLBAR_COLOR));
    this.setTaskDescription(tDesc);
}

From source file:com.xxxifan.devbox.core.util.ViewUtils.java

/**
 * set status bar icon to light theme, which is called dark mode.
 * should be called in onCreate()/*from  w w  w. j ava2  s.  c om*/
 */
public static void setStatusBarLightMode(Activity activity, boolean lightMode) {
    if (activity == null || activity.getWindow() == null) {
        return;
    }

    Window window = activity.getWindow();
    boolean changed = false;
    // try miui
    try {
        Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
        Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
        int darkIcon = field.getInt(layoutParams);
        Method extraFlagField = window.getClass().getMethod("setExtraFlags", int.class, int.class);
        extraFlagField.invoke(window, lightMode ? darkIcon : 0, darkIcon);
        changed = true;
    } catch (Exception ignored) {
    }

    // try flyme
    try {
        WindowManager.LayoutParams lp = window.getAttributes();
        Field darkIcon = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
        Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
        darkIcon.setAccessible(true);
        meizuFlags.setAccessible(true);
        int bit = darkIcon.getInt(null);
        int value = meizuFlags.getInt(lp);
        if (lightMode) {
            value |= bit;
        } else {
            value &= ~bit;
        }
        meizuFlags.setInt(lp, value);
        window.setAttributes(lp);
        changed = true;
    } catch (Exception ignored) {
    }

    if (!changed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int visibility = window.getDecorView().getSystemUiVisibility();
        if (lightMode) {
            visibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            visibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        window.getDecorView().setSystemUiVisibility(visibility);
    }
}