List of usage examples for android.view Window setStatusBarColor
public abstract void setStatusBarColor(@ColorInt int color);
From source file:com.gmartinsribeiro.qrcodereader.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. */// www . jav a 2s. c om @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.barcode_capture); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); 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); window.setStatusBarColor(getResources().getColor(R.color.blue700)); } mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay); // read parameters from the intent used to launch the activity. boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false); boolean useFlash = getIntent().getBooleanExtra(UseFlash, false); // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(autoFocus, useFlash); } else { requestCameraPermission(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show(); }
From source file:br.com.hotforms.StatusBarManager.java
public synchronized void setColor(final int r, final int g, final int b) { final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); this.cordova.getActivity().runOnUiThread(new Runnable() { @Override/*from ww w .j a v a 2s. c o m*/ public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(android.graphics.Color.rgb(r, g, b)); } }); }
From source file:com.jun.elephant.ui.main.MainActivity.java
/** * ???//from w ww.j ava 2s . co m * @param colorValue */ private void changeStatusColor(int colorValue) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(ContextCompat.getColor(this, colorValue)); } }
From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void applyStatusNavigationTranslucency() { if (C.API_LOLLIPOP) { Window window = getWindow(); int color = ACTION_BAR_COLOR; window.setStatusBarColor(color); window.setNavigationBarColor(color); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); }/*from w w w. j av a 2 s . c o m*/ }
From source file:org.docrj.smartcard.reader.AppViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_app_view); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w w w . j a va2s . c om toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); // persistent data in shared prefs SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE); mEditor = ss.edit(); mSelectedAppPos = ss.getInt("selected_app_pos", 0); Gson gson = new Gson(); String json = ss.getString("groups", null); if (json == null) { mUserGroups = new LinkedHashSet<>(); } else { Type collectionType = new TypeToken<LinkedHashSet<String>>() { }.getType(); mUserGroups = gson.fromJson(json, collectionType); } // alphabetize, case insensitive mSortedAllGroups = new ArrayList<>(mUserGroups); mSortedAllGroups.addAll(Arrays.asList(DEFAULT_GROUPS)); Collections.sort(mSortedAllGroups, String.CASE_INSENSITIVE_ORDER); // when deleting an app results in an empty group, we remove the group; // we may need to adjust group position indices for batch select and app // browse activities, which apply to the sorted list of groups mSelectedGrpPos = ss.getInt("selected_grp_pos", 0); mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos); mExpandedGrpPos = ss.getInt("expanded_grp_pos", -1); mExpandedGrpName = (mExpandedGrpPos == -1) ? "" : mSortedAllGroups.get(mExpandedGrpPos); Intent intent = getIntent(); mAppPos = intent.getIntExtra(EXTRA_APP_POS, 0); mName = (EditText) findViewById(R.id.app_name); mAid = (EditText) findViewById(R.id.app_aid); mType = (RadioGroup) findViewById(R.id.radio_grp_type); mNote = (TextView) findViewById(R.id.note); mGroups = (TextView) findViewById(R.id.group_list); // view only mName.setFocusable(false); mAid.setFocusable(false); for (int i = 0; i < mType.getChildCount(); i++) { mType.getChildAt(i).setClickable(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); w.setStatusBarColor(getResources().getColor(R.color.primary_dark)); } }
From source file:com.mercandalli.android.apps.files.file.audio.FileAudioActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize View, player and ChromeCast. setContentView(R.layout.activity_file_audio); mFileAudioPlayer = FileAudioPlayer.getInstance(this); mFileAudioPlayer.registerOnPlayerStatusChangeListener(this); mFileAudioCast.onCreate(this); if (savedInstanceState == null) { mFirstStart = true;//w w w.j a v a 2 s . c om } final Toolbar toolbar = (Toolbar) findViewById(R.id.activity_file_audio_toolbar); if (toolbar != null) { setSupportActionBar(toolbar); toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.actionbar_audio)); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle("FileSpace - Audio"); } } final Window window = getWindow(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ContextCompat.getColor(this, R.color.notifications_bar_audio)); } mTitleTextView = (TextView) findViewById(R.id.title); mSizeTextView = (TextView) findViewById(R.id.size); mSliderNumber = (Slider) findViewById(R.id.sliderNumber); mSliderNumber.setValueToDisplay(new Slider.ValueToDisplay() { @Override public String convert(int value) { return getTimeStr(value); } }); mSliderNumber.setOnValueChangedListener(new Slider.OnValueChangedListener() { @Override public void onValueChanged(int value) { } @Override public void onValueChangedUp(int value) { mFileAudioPlayer.seekTo(value); } }); mPlayPauseView = (PlayPauseView) findViewById(R.id.activity_file_audio_play); mPlayPauseView.setOnClickListener(this); findViewById(R.id.activity_file_audio_next).setOnClickListener(this); findViewById(R.id.activity_file_audio_previous).setOnClickListener(this); final Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey(EXTRA_IS_ONLINE) && bundle.containsKey(EXTRA_FILE_CURRENT_POSITION) && bundle.containsKey(EXTRA_FILES_PATH)) { // Get data mIsOnline = bundle.getBoolean(EXTRA_IS_ONLINE); mCurrentPosition = bundle.getInt(EXTRA_FILE_CURRENT_POSITION); final List<String> absolutePathArray = bundle.getStringArrayList(EXTRA_FILES_PATH); if (absolutePathArray != null) { for (String absolutePath : absolutePathArray) { if (mIsOnline) { mFileAudioModelList.add( ((FileAudioModel.FileAudioModelBuilder) (new FileAudioModel.FileAudioModelBuilder() .isOnline(true).url(absolutePath))).build()); } else { mFileAudioModelList.add( new FileAudioModel.FileAudioModelBuilder().file(new File(absolutePath)).build()); } } } if (mFileAudioModelList.isEmpty()) { Toast.makeText(this, "Oops, I have an empty list :(", Toast.LENGTH_SHORT).show(); finish(); return; } if (mFirstStart) { mFileAudioPlayer.startMusic(mCurrentPosition, mFileAudioModelList); mFileAudioCast.startMusic(mCurrentPosition, mFileAudioModelList); } else { syncSongs(mFileAudioPlayer.getCurrentMusicIndex(), mFileAudioPlayer.getFileAudioModelList()); } } mFirstStart = false; }
From source file:org.smssecure.smssecure.ConversationListFragment.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getActivity().getMenuInflater(); if (archive)//from ww w . jav a2 s.co m inflater.inflate(R.menu.conversation_list_batch_unarchive, menu); else inflater.inflate(R.menu.conversation_list_batch_archive, menu); inflater.inflate(R.menu.conversation_list_batch, menu); inflater.inflate(R.menu.conversation_send_drafts, menu); mode.setTitle(R.string.conversation_fragment_cab__batch_selection_mode); mode.setSubtitle(null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getActivity().getWindow(); window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar)); window.setNavigationBarColor(getResources().getColor(android.R.color.black)); } return true; }
From source file:com.smedic.tubtub.Pane.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void setStatusBarColor(int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(color); }/*from w ww . j ava2 s .co m*/ }
From source file:com.amaze.filemanager.activities.Preferences.java
@Override public void onCreate(Bundle savedInstanceState) { SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this); fabSkin = PreferenceUtils.getAccentString(Sp); int th = Integer.parseInt(Sp.getString("theme", "0")); theme = th == 2 ? PreferenceUtils.hourOfDay() : th; // setting accent theme if (Build.VERSION.SDK_INT >= 21) { switch (fabSkin) { case "#F44336": if (theme == 0) setTheme(R.style.pref_accent_light_red); else/*from w w w .j a v a2s. co m*/ setTheme(R.style.pref_accent_dark_red); break; case "#e91e63": if (theme == 0) setTheme(R.style.pref_accent_light_pink); else setTheme(R.style.pref_accent_dark_pink); break; case "#9c27b0": if (theme == 0) setTheme(R.style.pref_accent_light_purple); else setTheme(R.style.pref_accent_dark_purple); break; case "#673ab7": if (theme == 0) setTheme(R.style.pref_accent_light_deep_purple); else setTheme(R.style.pref_accent_dark_deep_purple); break; case "#3f51b5": if (theme == 0) setTheme(R.style.pref_accent_light_indigo); else setTheme(R.style.pref_accent_dark_indigo); break; case "#2196F3": if (theme == 0) setTheme(R.style.pref_accent_light_blue); else setTheme(R.style.pref_accent_dark_blue); break; case "#03A9F4": if (theme == 0) setTheme(R.style.pref_accent_light_light_blue); else setTheme(R.style.pref_accent_dark_light_blue); break; case "#00BCD4": if (theme == 0) setTheme(R.style.pref_accent_light_cyan); else setTheme(R.style.pref_accent_dark_cyan); break; case "#009688": if (theme == 0) setTheme(R.style.pref_accent_light_teal); else setTheme(R.style.pref_accent_dark_teal); break; case "#4CAF50": if (theme == 0) setTheme(R.style.pref_accent_light_green); else setTheme(R.style.pref_accent_dark_green); break; case "#8bc34a": if (theme == 0) setTheme(R.style.pref_accent_light_light_green); else setTheme(R.style.pref_accent_dark_light_green); break; case "#FFC107": if (theme == 0) setTheme(R.style.pref_accent_light_amber); else setTheme(R.style.pref_accent_dark_amber); break; case "#FF9800": if (theme == 0) setTheme(R.style.pref_accent_light_orange); else setTheme(R.style.pref_accent_dark_orange); break; case "#FF5722": if (theme == 0) setTheme(R.style.pref_accent_light_deep_orange); else setTheme(R.style.pref_accent_dark_deep_orange); break; case "#795548": if (theme == 0) setTheme(R.style.pref_accent_light_brown); else setTheme(R.style.pref_accent_dark_brown); break; case "#212121": if (theme == 0) setTheme(R.style.pref_accent_light_black); else setTheme(R.style.pref_accent_dark_black); break; case "#607d8b": if (theme == 0) setTheme(R.style.pref_accent_light_blue_grey); else setTheme(R.style.pref_accent_dark_blue_grey); break; case "#004d40": if (theme == 0) setTheme(R.style.pref_accent_light_super_su); else setTheme(R.style.pref_accent_dark_super_su); break; } } else { if (theme == 1) { setTheme(R.style.appCompatDark); } else { setTheme(R.style.appCompatLight); } } super.onCreate(savedInstanceState); setContentView(R.layout.prefsfrag); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); skin = PreferenceUtils.getPrimaryColorString(Sp); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin)); ((Activity) this).setTaskDescription(taskDescription); } skinStatusBar = PreferenceUtils.getStatusColor(skin); setSupportActionBar(toolbar); getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); int 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.preferences) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { boolean colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor((PreferenceUtils.getStatusColor(skin))); if (colourednavigation) window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin))); } selectItem(0); }
From source file:com.amti.vela.bluetoothlegatt.bluetooth.DeviceScanActivity.java
void initGui() { leScanHandler = new Handler(); //widgets/*from www . j a v a 2 s .com*/ deviceListView = (ListView) findViewById(R.id.listView); swipeContainer = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); mLeDevicesList = new ArrayList<BluetoothDevice>(); devicesAdapter = new CustomListAdapter(this, R.layout.custom_listview_item); deviceListView.setAdapter(devicesAdapter); // Configure the refreshing colors swipeContainer.setColorSchemeResources(R.color.action_bar_light_blue, R.color.swipe_refresh_dark_green, android.R.color.holo_orange_light, android.R.color.holo_red_light); notificationEnableDialog = new AlertDialog.Builder(DeviceScanActivity.this); notificationEnableDialog.setMessage("This app wants to enable notification access in the settings app.") .setPositiveButton("OK", notificationDialogClickListener) .setNegativeButton("Cancel", notificationDialogClickListener).setCancelable(false); //action bar Toolbar actionBarToolBar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(actionBarToolBar); actionBarToolBar.setTitle("Choose a Device"); actionBarToolBar.setTitleTextColor(ContextCompat.getColor(this, R.color.action_bar_text_gray)); //status bar color Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.setStatusBarColor(ContextCompat.getColor(this, R.color.action_bar_dark_blue)); } deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View v, int position, long arg3) { BluetoothDevice device = mLeDevicesList.get(position); if (device == null) return; final Intent intent = new Intent(DeviceScanActivity.this, MainActivity.class); String deviceName = device.getName() == null ? "Unknown Device" : device.getName(); intent.putExtra(MainActivity.EXTRAS_DEVICE, deviceName + "\n" + device.getAddress()); if (mScanning) { scanLeDevice(false); mScanning = false; } if (notificationListenerInit()) ; startActivity(intent); } }); swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // Your code to refresh the list here. // Make sure you call swipeContainer.setRefreshing(false) // once the bt request has completed successfully clearDevices(); scanLeDevice(true); } }); }