Java Code Examples for android.view.Window#getStatusBarColor()

The following examples show how to use android.view.Window#getStatusBarColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConversationFragment.java    From mollyim-android with GNU General Public License v3.0 7 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  MenuInflater inflater = mode.getMenuInflater();
  inflater.inflate(R.menu.conversation_context, menu);

  mode.setTitle("1");

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getActivity().getWindow();
    statusBarColor = window.getStatusBarColor();
    window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }

  setCorrectMenuVisibility(menu);
  AdaptiveActionsToolbar.adjustMenuActions(menu, 10, requireActivity().getWindow().getDecorView().getMeasuredWidth());
  listener.onMessageActionToolbarOpened();
  return true;
}
 
Example 2
Source File: AppUtils.java    From AndroidNavigation with MIT License 6 votes vote down vote up
public static int getStatusBarColor(final Window window) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return window.getStatusBarColor();
    } else {
        ViewGroup decorViewGroup = (ViewGroup) window.getDecorView();
        View statusBarView = decorViewGroup.findViewWithTag("custom_status_bar_tag");
        if (statusBarView != null) {
            Drawable drawable = statusBarView.getBackground();
            if (drawable instanceof ColorDrawable) {
                ColorDrawable colorDrawable = (ColorDrawable) drawable;
                return colorDrawable.getColor();
            }
        }
    }
    return Color.BLACK;
}
 
Example 3
Source File: ShapeThemingDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(
    LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
  this.wrappedContext = new ContextThemeWrapper(getContext(), getShapeTheme());
  LayoutInflater layoutInflaterWithThemedContext =
      layoutInflater.cloneInContext(wrappedContext);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getActivity().getWindow();
    statusBarColor = window.getStatusBarColor();
    final TypedValue value = new TypedValue();
    wrappedContext
        .getTheme()
        .resolveAttribute(R.attr.colorPrimaryDark, value, true);
    window.setStatusBarColor(value.data);
  }

  return super.onCreateView(layoutInflaterWithThemedContext, viewGroup, bundle);
}
 
Example 4
Source File: ConversationFragment.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.conversation_context, menu);

    mode.setTitle("1");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getActivity().getWindow();
        statusBarColor = window.getStatusBarColor();
        window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
    }

    setCorrectMenuVisibility(menu);
    return true;
}
 
Example 5
Source File: MediaOverviewPageFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  mode.getMenuInflater().inflate(R.menu.media_overview_context, menu);
  mode.setTitle(getActionModeTitle());

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = requireActivity().getWindow();
    originalStatusBarColor = window.getStatusBarColor();
    window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }
  return true;
}
 
Example 6
Source File: ActivityStatusRecord.java    From scene with Apache License 2.0 5 votes vote down vote up
public static ActivityStatusRecord newInstance(Activity activity) {
    ActivityStatusRecord record = new ActivityStatusRecord();
    Window window = activity.getWindow();
    View decorView = window.getDecorView();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        record.mStatusBarColor = window.getStatusBarColor();
        record.mNavigationBarColor = window.getNavigationBarColor();
    }
    record.mSystemUiVisibility = decorView.getSystemUiVisibility();
    record.mSoftInputMode = window.getAttributes().softInputMode;
    record.mWindowFlags = window.getAttributes().flags;
    record.mRequestedOrientation = activity.getRequestedOrientation();
    return record;
}
 
Example 7
Source File: ImageStreamUi.java    From belvedere with Apache License 2.0 5 votes vote down vote up
private void tintStatusBar(float scrollOffset) {

        int statusBarColor = toolbar.getResources().getColor(R.color.belvedere_image_stream_status_bar_color);
        int colorPrimaryDark = Utils.getThemeColor(toolbar.getContext(), R.attr.colorPrimaryDark);
        boolean fullyExpanded = scrollOffset == 1.f;
        final Window window = activity.getWindow();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if(fullyExpanded) {
                if (window.getStatusBarColor() == colorPrimaryDark) {
                    final ValueAnimator animation = ValueAnimator.ofObject(new ArgbEvaluator(), colorPrimaryDark, statusBarColor);
                    animation.setDuration(100);
                    animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
                        @Override
                        public void onAnimationUpdate(ValueAnimator animator) {
                            window.setStatusBarColor((Integer) animation.getAnimatedValue());
                        }

                    });
                    animation.start();
                }
            } else {
                window.setStatusBarColor(colorPrimaryDark);
            }
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            View decor = window.getDecorView();
            if(fullyExpanded) {
                decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            } else {
                decor.setSystemUiVisibility(0);
            }
        }
    }
 
Example 8
Source File: ProfileSettingsFragment.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  mode.getMenuInflater().inflate(R.menu.profile_context, menu);
  mode.setTitle("1");

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getActivity().getWindow();
    originalStatusBarColor = window.getStatusBarColor();
    window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }
  return true;
}
 
Example 9
Source File: ProfileGalleryFragment.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  mode.getMenuInflater().inflate(R.menu.profile_context, menu);
  mode.setTitle("1");

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getActivity().getWindow();
    originalStatusBarColor = window.getStatusBarColor();
    window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }
  return true;
}
 
Example 10
Source File: ConversationFragment.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  MenuInflater inflater = mode.getMenuInflater();
  inflater.inflate(R.menu.conversation_context, menu);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getActivity().getWindow();
    statusBarColor = window.getStatusBarColor();
    window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
    window.setNavigationBarColor(getResources().getColor(android.R.color.black));
  }

  setCorrectMenuVisibility(menu);
  return true;
}
 
Example 11
Source File: MainActivity.java    From AndroidApp with Mozilla Public License 2.0 4 votes vote down vote up
private void getStatusBatColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        statusBatColor = window.getStatusBarColor();
    }
}
 
Example 12
Source File: ProfileDocumentsFragment.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  mode.getMenuInflater().inflate(R.menu.profile_context, menu);
  mode.setTitle("1");

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getActivity().getWindow();
    originalStatusBarColor = window.getStatusBarColor();
    window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }
  return true;
}
 
Example 13
Source File: StatusBarObserver.java    From NightOwl with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public StatusBarObserver(Activity activity, TypedArray a, int attr) {
    Window window = activity.getWindow();
    mStatusBarColor = window.getStatusBarColor();
    mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
}
 
Example 14
Source File: ExpandedScreen.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ExpandedScreen(Activity activity, boolean enabled) {
	this.activity = activity;
	statusBar = new StatusBarController(activity);
	navigationBar = new NavigationBarController();
	Resources resources = activity.getResources();
	Window window = activity.getWindow();
	boolean fullScreenLayoutEnabled;
	if (C.API_LOLLIPOP) {
		fullScreenLayoutEnabled = true;
	} else if (C.API_KITKAT) {
		int resId = resources.getIdentifier("config_enableTranslucentDecor", "bool", "android");
		fullScreenLayoutEnabled = resId != 0 && resources.getBoolean(resId);
	} else {
		fullScreenLayoutEnabled = false;
	}
	expandingEnabled = enabled;
	this.fullScreenLayoutEnabled = fullScreenLayoutEnabled;
	float density = ResourceUtils.obtainDensity(resources);
	slopShiftSize = (int) (6f * density);
	lastItemLimit = (int) (72f * density);
	if (fullScreenLayoutEnabled) {
		if (C.API_LOLLIPOP) {
			int statusBarColor = window.getStatusBarColor() | Color.BLACK;
			int navigationBarColor = window.getNavigationBarColor() | Color.BLACK;
			window.setStatusBarColor(Color.TRANSPARENT);
			window.setNavigationBarColor(Color.TRANSPARENT);
			contentForeground = new LollipopContentForeground(statusBarColor, navigationBarColor);
			statusBarContentForeground = new LollipopStatusBarForeground(statusBarColor);
			statusBarDrawerForeground = new LollipopDrawerForeground();
		} else {
			contentForeground = new KitKatContentForeground();
			statusBarContentForeground = null;
			statusBarDrawerForeground = null;
		}
		window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
				View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
	} else {
		contentForeground = null;
		statusBarContentForeground = null;
		statusBarDrawerForeground = null;
		if (enabled) {
			window.requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
		}
	}
	readConfiguration(resources.getConfiguration());
}