List of usage examples for android.view Window setStatusBarColor
public abstract void setStatusBarColor(@ColorInt int color);
From source file:com.bottomsheetbehavior.MergedAppBarLayoutBehavior.java
public void setStatusBarBackgroundVisible(boolean visible) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mStatusBarColor != 0) { if (visible) { Window window = ((ThemedReactContext) mContext).getCurrentActivity().getWindow(); window.getDecorView().setSystemUiVisibility(mBarStyle); window.setStatusBarColor(mStatusBarColor); } else {/* ww w . j av a 2 s . c om*/ Window window = ((ThemedReactContext) mContext).getCurrentActivity().getWindow(); window.getDecorView().setSystemUiVisibility(mBarStyleTransparent); window.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.transparent)); } } }
From source file:no.digipost.android.gui.metadata.ExternalLinkWebview.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((DigipostApplication) getApplication()).getTracker(DigipostApplication.TrackerName.APP_TRACKER); setContentView(R.layout.activity_externallink_webview); Bundle bundle = getIntent().getExtras(); fileUrl = bundle.getString("url", "https://www.digipost.no"); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww. j av a 2 s. c o m actionBar = getSupportActionBar(); if (actionBar != null) { setActionBarTitle(fileUrl); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setBackgroundDrawable(new ColorDrawable(0xff2E2E2E)); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = this.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor( ContextCompat.getColor(this, R.color.metadata_externalbrowser_top_background)); } } progressSpinner = (ProgressBar) findViewById(R.id.externallink_spinner); webView = (WebView) findViewById(R.id.externallink_webview); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setDomStorageEnabled(true); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(true); enableCookies(webView); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (firstLoad) { progressSpinner.setVisibility(View.GONE); webView.setVisibility(View.VISIBLE); firstLoad = false; } setActionBarTitle(view.getUrl()); } }); webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(final String url, final String userAgent, final String content, final String mimeType, final long contentLength) { fileName = URLUtil.guessFileName(url, content, mimeType); fileUrl = url; onComplete = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { showDownloadSuccessDialog(context); } } }; registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); if (!mimeType.equals("text/html")) { if (FileUtilities.isStorageWriteAllowed(getApplicationContext())) { showDownloadDialog(userAgent, content, mimeType, contentLength); } else { showMissingPermissionsDialog(); } } } }); if (FileUtilities.isStorageWriteAllowed(this)) { webView.loadUrl(fileUrl); } else { showPermissionsDialog(); } }
From source file:com.nerderylabs.android.nerdalert.ui.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set the navigation bar color on Lollipop+ devices 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.color_primary_dark)); }/*from w w w .j ava 2s.c o m*/ setContentView(R.layout.activity_main); // setup the Google API Client, requesting access to the Nearby Messages API // DO NOT use the application context here, otherwise the Nearby API will fail with the // following error when publishing/subscribing: // Attempting to perform a high-power operation from a non-Activity Context googleApiClient = new GoogleApiClient.Builder(this).addApi(Nearby.MESSAGES_API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); initializeMessageListener(); FragmentManager fm = getSupportFragmentManager(); MainFragment mainFragment = (MainFragment) fm.findFragmentByTag(MAIN_FRAGMENT_TAG); if (mainFragment == null) { mainFragment = new MainFragment(); fm.beginTransaction().add(R.id.container, mainFragment, MAIN_FRAGMENT_TAG).commit(); } }
From source file:io.karim.materialtabs.sample.TabsActivity.java
private void applyParametersFromIntentExtras() { Intent intent = getIntent();/* ww w .j a v a 2s.co m*/ if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { Resources resources = getResources(); int showToolbar = extras.getBoolean(TabsSettingsFragment.SHOW_TOOLBAR) ? View.VISIBLE : View.GONE; int indicatorColor = resources.getColor(extras.getInt(TabsSettingsFragment.INDICATOR_COLOR)); int underlineColor = resources.getColor(extras.getInt(TabsSettingsFragment.UNDERLINE_COLOR)); int indicatorHeightDp = extras.getInt(TabsSettingsFragment.INDICATOR_HEIGHT); int underlineHeightDp = extras.getInt(TabsSettingsFragment.UNDERLINE_HEIGHT); int tabPaddingDp = extras.getInt(TabsSettingsFragment.TAB_PADDING); mToolbar.setVisibility(showToolbar); mMaterialTabs.setIndicatorColor(indicatorColor); mMaterialTabs.setUnderlineColor(underlineColor); mMaterialTabs.setIndicatorHeight(Utils.dpToPx(resources, indicatorHeightDp)); mMaterialTabs.setUnderlineHeight(Utils.dpToPx(resources, underlineHeightDp)); mMaterialTabs.setTabPaddingLeftRight(Utils.dpToPx(resources, tabPaddingDp)); boolean paddingMiddle = extras.getBoolean(TabsSettingsFragment.PADDING_MIDDLE); boolean sameWeightTabs = extras.getBoolean(TabsSettingsFragment.SAME_WEIGHT_TABS); boolean textAllCaps = extras.getBoolean(TabsSettingsFragment.TEXT_ALL_CAPS); mMaterialTabs.setPaddingMiddle(paddingMiddle); mMaterialTabs.setSameWeightTabs(sameWeightTabs); mMaterialTabs.setAllCaps(textAllCaps); int toolbarColor = resources.getColor(extras.getInt(TabsSettingsFragment.TOOLBAR_BACKGROUND)); int tabBackgroundColor = resources.getColor(extras.getInt(TabsSettingsFragment.TAB_BACKGROUND)); mToolbar.setBackgroundColor(toolbarColor); mMaterialTabs.setBackgroundColor(tabBackgroundColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(Color.argb(Color.alpha(toolbarColor), Color.red(toolbarColor) / 2, Color.green(toolbarColor) / 2, Color.blue(toolbarColor) / 2)); } int textColorSelected = resources.getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_SELECTED)); int textColorUnselected = resources .getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_UNSELECTED)); int tabStyleSelected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_SELECTED); int tabStyleUnselected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_UNSELECTED); mMaterialTabs.setTextColorSelected(textColorSelected); mMaterialTabs.setTextColorUnselected(textColorUnselected); mMaterialTabs.setTabTypefaceSelectedStyle(tabStyleSelected); mMaterialTabs.setTabTypefaceUnselectedStyle(tabStyleUnselected); int rippleDuration = extras.getInt(RippleSettingsFragment.RIPPLE_DURATION); float rippleAlphaFloat = extras.getFloat(RippleSettingsFragment.RIPPLE_ALPHA_FLOAT); int rippleColor = resources.getColor(extras.getInt(RippleSettingsFragment.RIPPLE_COLOR)); boolean rippleDelayClick = extras.getBoolean(RippleSettingsFragment.RIPPLE_DELAY_CLICK); float rippleDiameterDp = extras.getFloat(RippleSettingsFragment.RIPPLE_DIAMETER); int rippleFadeDuration = extras.getInt(RippleSettingsFragment.RIPPLE_FADE_DURATION); int rippleHighlightColor = resources .getColor(extras.getInt(RippleSettingsFragment.RIPPLE_HIGHLIGHT_COLOR)); boolean rippleOverlay = extras.getBoolean(RippleSettingsFragment.RIPPLE_OVERLAY); boolean ripplePersistent = extras.getBoolean(RippleSettingsFragment.RIPPLE_PERSISTENT); int rippleRoundedCornusRadiusDp = extras .getInt(RippleSettingsFragment.RIPPLE_ROUNDED_CORNERS_RADIUS); mMaterialTabs.setRippleDuration(rippleDuration); mMaterialTabs.setRippleAlphaFloat(rippleAlphaFloat); mMaterialTabs.setRippleColor(rippleColor); mMaterialTabs.setRippleDelayClick(rippleDelayClick); mMaterialTabs.setRippleDiameterDp(rippleDiameterDp); mMaterialTabs.setRippleFadeDuration(rippleFadeDuration); mMaterialTabs.setRippleHighlightColor(rippleHighlightColor); mMaterialTabs.setRippleInAdapter(false); mMaterialTabs.setRippleOverlay(rippleOverlay); mMaterialTabs.setRipplePersistent(ripplePersistent); mMaterialTabs.setRippleRoundedCornersDp(rippleRoundedCornusRadiusDp); mExportableString = createExportableText(showToolbar, indicatorColor, underlineColor, indicatorHeightDp, underlineHeightDp, tabPaddingDp, paddingMiddle, sameWeightTabs, textAllCaps, toolbarColor, tabBackgroundColor, textColorSelected, textColorUnselected, tabStyleSelected, tabStyleUnselected, rippleDuration, rippleAlphaFloat, rippleColor, rippleDelayClick, rippleDiameterDp, rippleFadeDuration, rippleHighlightColor, rippleOverlay, ripplePersistent, rippleRoundedCornusRadiusDp); } } }
From source file:de.gebatzens.sia.SIAApp.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(ContextCompat.getColor(this, R.color.transparent)); }
From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_search_add_item_fatsecret, container, false); // Change the notification bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = getActivity().getWindow(); w.setStatusBarColor(getResources().getColor(R.color.light_grey)); }// w w w . j av a 2 s . c o m // Get MealType (snack, breakfast, lunch, dinner) Bundle extras = getActivity().getIntent().getExtras(); if (extras != null) { mealType = extras.getString(Globals.MEAL_TYPE); } // Initialize FatSecretSearchMethod mFatSecretSearch = new FatSecretSearchMethod(); mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swiperefresh); mSwipeRefreshLayout.setColorSchemeResources(R.color.primary, R.color.red, R.color.primary_dark); mSwipeRefreshLayout.setProgressViewOffset(true, Equations.dpToPx(getActivity(), 0), Equations.dpToPx(getActivity(), 112)); mSwipeRefreshLayout.setEnabled(false); mEtSearch = (EditText) v.findViewById(R.id.etSearch); // LogQuickSearch adapter to add items that have not been saved already mRecentLogAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all()); // List for adding items to the mItem = new ArrayList<>(); // Set to prevent duplicates being saved in LogQuickSearch set = new HashSet<>(); /** * set mListViewSearchResults adapter to SearchAdapterItemResult */ llSearch = (LinearLayout) v.findViewById(R.id.llSearch); listSearch = (ListView) v.findViewById(R.id.listSearch); searchLine = v.findViewById(R.id.searchLine); logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all()); mEtSearchAdapter = new SearchAdapterItemResult(getActivity(), mItem); mListViewSearchResults = (ListView) v.findViewById(R.id.listView); ViewGroup header = (ViewGroup) inflater.inflate(R.layout.list_search_header, mListViewSearchResults, false); mListViewSearchResults.addHeaderView(header, null, false); mListViewSearchResults.setAdapter(mEtSearchAdapter); mListViewSearchResults.setOnScrollListener(this); mListViewSearchResults.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = new Intent(getActivity(), SaveSearchAddItemActivityMain.class); i.putExtra(Globals.MEAL_TYPE, mealType); i.putExtra(Globals.MEAL_ID, mItem.get(position - 1).getID()); i.putExtra(Globals.MEAL_BRAND, mItem.get(position - 1).getBrand()); i.putExtra(Globals.MEAL_FAVORITE, "false"); startActivity(i); } }); // Toolbar mToolbarSearch = (Toolbar) v.findViewById(R.id.toolbar_search); mToolbarSearch.inflateMenu(R.menu.menu_search); mToolbarSearch.setNavigationIcon(R.mipmap.ic_arrow_back_grey); mToolbarSearch.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().getSupportFragmentManager().popBackStack(); } }); mToolbarSearch.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.action_clear) { mEtSearch.setText(""); } if (menuItem.getItemId() == R.id.action_voice) { promptSpeechInput(); } return false; } }); mEtSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mEtSearch.getText().toString().length() >= 1) { mToolbarSearch.getMenu().clear(); mToolbarSearch.inflateMenu(R.menu.menu_search_clear); logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.FilterByName(mEtSearch.getText().toString())); listSearch.setAdapter(logQuickSearchAdapter); } else { mToolbarSearch.getMenu().clear(); mToolbarSearch.inflateMenu(R.menu.menu_search); logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all()); listSearch.setAdapter(logQuickSearchAdapter); } mItem.clear(); updateListView(); } @Override public void afterTextChanged(Editable s) { } }); // Quick Search Clicked, start search based on list Item clicked from last fragment Bundle extrasFromRecentCliced = this.getArguments(); if (extrasFromRecentCliced != null) { String mealName = extrasFromRecentCliced.getString("MealName"); if (mealName != null) { mEtSearch.setText(mealName); mToolbarSearch.getMenu().clear(); mToolbarSearch.inflateMenu(R.menu.menu_search_clear); searchFood(mealName, 0); } } else { mEtSearch.requestFocus(); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); } /** * Handles softKeyboard search icon being clicked */ mEtSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mEtSearch.getWindowToken(), 0); listSearch.setVisibility(View.GONE); searchLine.setVisibility(View.GONE); searchFood(mEtSearch.getText().toString(), 0); mItem.clear(); mEtSearchAdapter.notifyDataSetChanged(); mEtSearch.clearFocus(); return true; } return false; } }); listSearch.setAdapter(logQuickSearchAdapter); listSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogQuickSearch logQuickSearch = logQuickSearchAdapter.getItem(position); mEtSearch.setText(logQuickSearch.getName()); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mEtSearch.getWindowToken(), 0); listSearch.setVisibility(View.GONE); searchLine.setVisibility(View.GONE); searchFood(logQuickSearch.getName(), 0); mItem.clear(); mEtSearchAdapter.notifyDataSetChanged(); mEtSearch.clearFocus(); } }); updateListView(); return v; }
From source file:io.flutter.embedding.android.FlutterActivity.java
private void configureStatusBarForFullscreenFlutterExperience() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); }// w w w .java2s . c o m }
From source file:org.arshad.nimbleme.WritingActivity.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override/*from w w w.j a v a2 s . c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_writing); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); Window window = this.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(this.getResources().getColor(R.color.status_bar_color)); mdToolbar = (ExpandableLinearLayout) findViewById(R.id.action_other_operate); mdEditor = (ExpandableLinearLayout) findViewById(R.id.md_editor_container); mdEditor.setVisibility(View.VISIBLE); mdEditor.expand(); mdPreview = (ExpandableLinearLayout) findViewById(R.id.md_preview_container); mdPreview.setVisibility(View.GONE); mMdEditText = (EditText) findViewById(R.id.post_description_editText); mMarkdownView = (MarkdownPreviewView) findViewById(R.id.markdownView); mTabIconView = (TabIconView) findViewById(R.id.tabIconView); mPerformEdit = new PerformEdit(mMdEditText); mPerformEditable = new PerformEditable(mMdEditText); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); MarkdownUtils.newInstance().initTab(mTabIconView, this); }
From source file:co.com.parsoniisolutions.custombottomsheetbehavior.lib.MergedAppBarLayoutBehavior.java
private void setStatusBarBackgroundVisible(boolean visible) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (visible) { Window window = ((Activity) mContext).getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.colorPrimaryDark)); } else {/*from w ww. j a v a2s. co m*/ Window window = ((Activity) mContext).getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.transparent)); } } }
From source file:jp.co.tweetmap.MainActivity.java
/** * Set status bar color as tool bar.//from w w w . j a v a 2 s . c om */ protected void setStatusBar() { // Set status bar color if the SDK version Lollipop more if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(getResources().getColor(R.color.statusbar_background)); } }