List of usage examples for android.view Window addFlags
public void addFlags(int flags)
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 w w w . j a va2s . co 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.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 ww w.j av a2s. 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:com.kuaichumen.whistle.admin.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); getSupportActionBar().hide();/* w w w . j a v a2 s .c o m*/ CameraManager.init(getApplication()); scanPreview = (SurfaceView) findViewById(R.id.capture_preview); scanContainer = (RelativeLayout) findViewById(R.id.capture_container); scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); scanLine = (ImageView) findViewById(R.id.capture_scan_line); title = (TextView) findViewById(R.id.title); flashLight = (LinearLayout) findViewById(R.id.flash_light); ll_back = (LinearLayout) findViewById(R.id.ll_back); flash = (ImageView) findViewById(R.id.flash); flashLight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { light(); } }); ll_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); EventBus.getDefault().register(this); InitData(); }
From source file:org.arshad.nimbleme.WritingActivity.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override/*from ww w. j a v a2s. c o m*/ 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:com.imagine.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); super.onCreate(savedInstanceState); win.setBackgroundDrawable(null);//from w ww . j a v a 2 s . c om win.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); if (android.os.Build.VERSION.SDK_INT >= 11) { // NativeActivity explicitly sets the window format to RGB_565, this is fine in Android 2.3 since we default to that // and call setFormat ourselves, but in >= 3.0 we only use ANativeWindow_setBuffersGeometry so set the format back to // the default value to avoid a spurious surface destroy & create the next time the window flags are set since it may // cause the screen to flash win.setFormat(PixelFormat.UNKNOWN); } // get rid of NativeActivity's view and layout listener, then add our custom view View nativeActivityView = findViewById(android.R.id.content); nativeActivityView.getViewTreeObserver().removeGlobalOnLayoutListener(this); View contentView; if (android.os.Build.VERSION.SDK_INT >= 24) contentView = new ContentViewV24(this); else if (android.os.Build.VERSION.SDK_INT >= 16) contentView = new ContentViewV16(this); else contentView = new ContentViewV9(this); setContentView(contentView); contentView.requestFocus(); }
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); }//from w w w . j a va 2 s . co m }
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;/*from w ww .j a va 2 s . c o m*/ } 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.getlantern.firetweet.activity.support.LinkHandlerActivity.java
private void requestWindowFeatures(Window window, int linkId, Uri uri) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS); }/* w ww. j ava 2s .c o m*/ supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY); final int transitionRes; switch (linkId) { case LINK_ID_USER: { transitionRes = R.transition.transition_user; break; } // case LINK_ID_STATUS: { // transitionRes = R.transition.transition_status; // break; // } default: { transitionRes = 0; break; } } if (transitionRes != 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !ThemeUtils.isTransparentBackground(this)) { Utils.setSharedElementTransition(this, window, transitionRes); } }
From source file:org.madmatrix.zxing.android.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // ?????/*from w ww .j ava2s .c om*/ Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.capture); // ????onResume hasSurface = false; inactivityTimer = new InactivityTimer(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); }
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 ava2 s . c om 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); }