List of usage examples for android.view Window addFlags
public void addFlags(int flags)
From source file:com.phonegap.bossbolo.plugin.statusbar.StatusBar.java
private void setStatusBarBackgroundColor(final String colorPref) { if (Build.VERSION.SDK_INT >= 21) { if (colorPref != null && !colorPref.isEmpty()) { final Window window = cordova.getActivity().getWindow(); // Method and constants not available on all SDKs but we want to be able to compile this code with any SDK window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); try { // Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21 window.getClass().getDeclaredMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref)); } catch (IllegalArgumentException ignore) { Log.e(TAG, "Invalid hexString argument, use f.i. '#999999'"); } catch (Exception ignore) { // this should not happen, only in case Android removes this method in a version > 21 Log.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT); }//w ww. j av a 2 s . c o m } } }
From source file:za.co.neilson.alarm.alert.AlarmAlertActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(//from w w w .j ava2 s.co m WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); setContentView(R.layout.alarm_alert); Bundle bundle = this.getIntent().getExtras(); alarm = (Alarm) bundle.getSerializable("alarm"); sendNotification(this, alarm.getAlarmName(), alarm); this.setTitle(alarm.getAlarmName()); switch (alarm.getDifficulty()) { case SUPEREASY: mathProblem = new MathProblem(1); break; case EASY: mathProblem = new MathProblem(3); break; case MEDIUM: mathProblem = new MathProblem(4); break; case HARD: mathProblem = new MathProblem(5); break; } answerString = String.valueOf(mathProblem.getAnswer()); if (answerString.endsWith(".0")) { answerString = answerString.substring(0, answerString.length() - 2); } problemView = (TextView) findViewById(R.id.textView1); problemView.setText(mathProblem.toString()); answerView = (TextView) findViewById(R.id.textView2); answerView.setText("= ?"); ((Button) findViewById(R.id.Button0)).setOnClickListener(this); ((Button) findViewById(R.id.Button1)).setOnClickListener(this); ((Button) findViewById(R.id.Button2)).setOnClickListener(this); ((Button) findViewById(R.id.Button3)).setOnClickListener(this); ((Button) findViewById(R.id.Button4)).setOnClickListener(this); ((Button) findViewById(R.id.Button5)).setOnClickListener(this); ((Button) findViewById(R.id.Button6)).setOnClickListener(this); ((Button) findViewById(R.id.Button7)).setOnClickListener(this); ((Button) findViewById(R.id.Button8)).setOnClickListener(this); ((Button) findViewById(R.id.Button9)).setOnClickListener(this); ((Button) findViewById(R.id.Button_clear)).setOnClickListener(this); final AlarmAlertActivity foo = this; ((Button) findViewById(R.id.Button_alarm_off)).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { alarmActive = false; //Toast.makeText(getApplicationContext(),"off",Toast.LENGTH_SHORT).show(); foo.finish(); } }); ((Button) findViewById(R.id.Button_decimal)).setOnClickListener(this); ((Button) findViewById(R.id.Button_minus)).setOnClickListener(this); TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); PhoneStateListener phoneStateListener = new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_RINGING: Log.d(getClass().getSimpleName(), "Incoming call: " + incomingNumber); try { mediaPlayer.pause(); } catch (IllegalStateException e) { } break; case TelephonyManager.CALL_STATE_IDLE: Log.d(getClass().getSimpleName(), "Call State Idle"); try { mediaPlayer.start(); } catch (IllegalStateException e) { } break; } super.onCallStateChanged(state, incomingNumber); } }; telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); // Toast.makeText(this, answerString, Toast.LENGTH_LONG).show(); startAlarm(); }
From source file:com.chiemy.zxing.activity.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(getLayoutId());//from w w w . j a va 2 s .c om 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); //inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); getWindow().getDecorView().post(new Runnable() { @Override public void run() { 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); } }); redecodeHandler = new Handler(); redecodeRunnable = new RedecodeRunnable(this); }
From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setRequestedOrientation(getCurrentOrientation()); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_scan); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_general); setupToolbar(toolbar, R.string.scan_qr); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); hasSurface = false;//from w w w. ja v a 2 s . co m inactivityTimer = new InactivityTimer(this); hasFlashLight = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); }
From source file:com.xys.libzxing.zxing.activity.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) //?? != PackageManager.PERMISSION_GRANTED) { //??/*from w w w. j a va2 s . co m*/ ActivityCompat.requestPermissions(CaptureActivity.this, new String[] { Manifest.permission.CAMERA }, 1); } Window window = getWindow(); requestWindowFeature(Window.FEATURE_NO_TITLE); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); m_oCaptureActivity = this; 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); trunoff_on = (ImageView) findViewById(R.id.trunoff_on); trunoff_on.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (isOpen) { // ? cameraManager.offLight(); isOpen = false; } else { //? cameraManager.openLight(); isOpen = true; } } }); 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); }
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.qasp.diego.arsp.MainActivity.java
@SuppressWarnings("unchecked") @Override//from w w w.java 2 s.com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { // Activity was brought to front and not created, // Thus finishing this will get us to the last viewed activity finish(); return; } // Opcoes padrao para Preferencias. PreferenceManager.setDefaultValues(this, R.xml.preferences, false); setContentView(R.layout.activity_main); // Salva dados se nao for mais visivel if (savedInstanceState != null) { Global.estacoes = (ArrayList<Estacao>) savedInstanceState.getSerializable(ESTADO_ESTACOES); Global.GPS = (Coordenada) savedInstanceState.getSerializable(ESTADO_GPS); } else InicializaEstacoesValidas(Global.estacoes); // Colorizao da barra de servios. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.parseColor("#202020")); } // PERMISSOES verifyStoragePermissions(this); if (PermissaodoGPS(this)) { // Se a permisso ja foi aprovada anterioremente. Intent intent = new Intent(this, LocalizacaoGPSService.class); startService(intent); } // Action bar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // TABS. tablayout = (TabLayout) findViewById(R.id.tab_layout); tablayout.addTab(tablayout.newTab().setText("Lista Estaes")); tablayout.addTab(tablayout.newTab().setText("Indice Local")); tablayout.addTab(tablayout.newTab().setText("Feedback")); tablayout.setTabGravity(TabLayout.GRAVITY_FILL); // PAGER (Deslize) e Funcionamento das Tabs viewPager = (ViewPager) findViewById(R.id.pager); adapter = new PagerAdapter(getSupportFragmentManager(), tablayout.getTabCount()); viewPager.setAdapter(adapter); viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tablayout)); tablayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { // Notificar eventuais mudanas ao mudar de aba. Global.tabSelecionado = tab.getPosition(); viewPager.setCurrentItem(tab.getPosition()); viewPager.getAdapter().notifyDataSetChanged(); } @Override public void onTabUnselected(TabLayout.Tab tab) { // vazio de proposito } @Override public void onTabReselected(TabLayout.Tab tab) { // Vazio de proposito } }); }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static void applyWindowBackground(@NonNull Context context, @NonNull Window window, int theme, String option, int alpha) { if (isWindowFloating(context, theme)) return;/*from w w w . j av a 2 s . c om*/ final int normalTheme = getThemeResource(theme); if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) { window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER); window.setBackgroundDrawable(getWindowBackgroundFromThemeApplyAlpha(context, normalTheme, alpha)); } else if (VALUE_THEME_BACKGROUND_SOLID.equals(option)) { window.setBackgroundDrawable(new ColorDrawable(isDarkTheme(normalTheme) ? Color.BLACK : Color.WHITE)); } else { window.setBackgroundDrawable(getWindowBackgroundFromTheme(context, normalTheme)); } }
From source file:com.yanzhenjie.durban.DurbanActivity.java
private void initFrameViews() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { final Window window = getWindow(); if (window != null) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(mStatusColor); window.setNavigationBarColor(mNavigationColor); }//ww w . j ava 2 s . c o m } final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setBackgroundColor(mToolbarColor); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); assert actionBar != null; actionBar.setDefaultDisplayHomeAsUpEnabled(true); actionBar.setTitle(mTitle); }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.MainActivity.java
/** * Act on back-button pressed// w ww .jav a2s. co m */ @Override public void onBackPressed() { // if the backstack has only one item, it is the homescreen, so we hide the toolbar if (getSupportFragmentManager().getBackStackEntryCount() < 2) { if (getSupportActionBar() != null) { // set the statusbar sransparency if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } // hide the toolbar mToolbar.setVisibility(View.GONE); } } super.onBackPressed(); }