List of usage examples for android.view Window addFlags
public void addFlags(int flags)
From source file:com.granita.tasks.ViewTaskFragment.java
@SuppressLint("NewApi") private void updateColor(float percentage) { if (getActivity() instanceof TaskListActivity) { return;/* w w w .j av a 2s .com*/ } float[] hsv = new float[3]; Color.colorToHSV(mListColor, hsv); if (VERSION.SDK_INT >= 11 && mColorBar != null) { percentage = Math.max(0, Math.min(Float.isNaN(percentage) ? 0 : percentage, 1)); percentage = (float) Math.pow(percentage, 1.5); int newColor = darkenColor2(mListColor); hsv[2] *= (0.5 + 0.25 * percentage); ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); actionBar.setBackgroundDrawable( new ColorDrawable((newColor & 0x00ffffff) | ((int) (percentage * 255) << 24))); // this is a workaround to ensure the new color is applied on all devices, some devices show a transparent ActionBar if we don't do that. actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(false); mColorBar.setBackgroundColor(mListColor); if (VERSION.SDK_INT >= 21) { Window window = getActivity().getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(newColor | 0xff000000); } } if (mActionButton != null) { // adjust color of action button if (hsv[0] > 70 && hsv[0] < 170 && hsv[2] < 0.62) { mActionButton.setBackgroundResource(R.drawable.bg_actionbutton_light); } else { mActionButton.setBackgroundResource(R.drawable.bg_actionbutton); } } }
From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.SearchBarDialogFragment.java
/** Initializes the dialogs animations and dim. */ private void initAnimationAndDim() { Window win = getDialog().getWindow(); win.setGravity(Gravity.TOP);/*from ww w.j a v a2 s. c om*/ win.setWindowAnimations(R.style.SearchBarAnimation); WindowManager.LayoutParams lp = win.getAttributes(); lp.dimAmount = 0.3f; //TODO abstract? is it necessary? win.setAttributes(lp); win.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); }
From source file:app.axe.imooc.zxing.app.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(icicle); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_qrcode_capture_layout); Util.currentActivity = this; CameraManager.init(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); mButtonBack = (Button) findViewById(R.id.button_back); mButtonBack.setOnClickListener(click); createBtn = (Button) findViewById(R.id.qrcode_btn); createBtn.setOnClickListener(click); photoBtn = (Button) findViewById(R.id.photo_btn); photoBtn.setOnClickListener(click);/*from www.j av a 2s. c o m*/ flashBtn = (Button) findViewById(R.id.flash_btn); flashBtn.setOnClickListener(click); surfaceView = (SurfaceView) findViewById(R.id.preview_view); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); hasSurface = false; inactivityTimer = new InactivityTimer(this); handler = null; lastResult = null; hasSurface = false; inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); // showHelpOnFirstLaunch(); }
From source file:com.itude.mobile.mobbl.core.controller.util.MBBasicViewController.java
/** * @see android.support.v4.app.DialogFragment#onStart() * //from ww w. ja v a 2 s. c o m * This method is used to do stuff with the AlertDialog created in onCreateDialog based * on optional parameters passed to this DialogFragment. */ @Override public void onStart() { super.onStart(); // At this point, Dialog.show is invoked; resolves the issue of first calling requestFeature // before doing view stuff. But this is only for the AlertDialog, i.e. closable dialogs if (getShowsDialog() && _isDialogClosable) { FrameLayout layout = (FrameLayout) getDialog().findViewById(android.R.id.custom); if (layout != null) layout.setPadding(0, 0, 0, 0); styleCloseButton(); } if (getShowsDialog() && _isDialogFullscreen) { Window window = getDialog().getWindow(); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }
From source file:de.kuschku.quasseldroid_ng.ui.chat.MainActivity.java
private void setStatusBar() { 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(getResources().getColor(android.R.color.transparent)); nickList.setPadding(0, CompatibilityUtils.getStatusBarHeight(this), 0, 0); View viewById = findViewById(R.id.statusBarBackground); ViewGroup.LayoutParams layoutParams = viewById.getLayoutParams(); layoutParams.height = CompatibilityUtils.getStatusBarHeight(this); viewById.setLayoutParams(layoutParams); }//from w w w. j a va 2s.c o m }
From source file:com.filemanager.free.activities.TextReader.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Sp = PreferenceManager.getDefaultSharedPreferences(this); if (theme1 == 1) { getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(c, R.color.holo_dark_background)); }//from w w w . jav a 2 s . c o m setContentView(R.layout.search); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); skin = PreferenceUtils.getPrimaryColorString(Sp); findViewById(R.id.lin).setBackgroundColor(Color.parseColor(skin)); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager", ((BitmapDrawable) ContextCompat.getDrawable(c, R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin)); ((Activity) this).setTaskDescription(taskDescription); } int skinStatusBar = PreferenceUtils.getStatusColor(skin); assert (getSupportActionBar()) != null; getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.texteditor) .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))); } mInput = (EditText) findViewById(R.id.fname); scrollView = (ScrollView) findViewById(R.id.editscroll); try { if (getIntent().getData() != null) { uri = getIntent().getData(); mFile = new File(getIntent().getData().getPath()); } else mFile = new File(getIntent().getStringExtra("path")); } catch (Exception e) { mFile = null; } String fileName = null; try { if (uri.getScheme().equals("file")) { fileName = uri.getLastPathSegment(); } else { Cursor cursor = null; try { cursor = getContentResolver().query(uri, new String[] { MediaStore.Images.ImageColumns.DISPLAY_NAME }, null, null, null); if (cursor != null && cursor.moveToFirst()) { fileName = cursor .getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME)); } } finally { if (cursor != null) { cursor.close(); } } } } catch (Exception e) { e.printStackTrace(); } if (fileName == null || fileName.trim().length() == 0) fileName = f.getName(); getSupportActionBar().setTitle(fileName); mInput.addTextChangedListener(this); try { if (theme1 == 1) mInput.setBackgroundColor(ContextCompat.getColor(c, R.color.holo_dark_background)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } catch (Exception ignored) { } if (savedInstanceState != null) { mOriginal = savedInstanceState.getString(KEY_ORIGINAL_TEXT); int index = savedInstanceState.getInt(KEY_INDEX); mInput.setText(savedInstanceState.getString(KEY_MODIFIED_TEXT)); mInput.setScrollY(index); } else { load(mFile); } }
From source file:org.protocoderrunner.apprunner.AppRunnerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_apprunner_host); if (!AndroidUtils.isWear(this)) { mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar);/*www . j av a2 s . c om*/ mActionbar = getSupportActionBar(); mActionbar.setTitle("hola"); } FrameLayout fl = (FrameLayout) findViewById(R.id.apprunner_fragment); // Read in the script given in the intent. Intent intent = getIntent(); if (null != intent) { boolean isService = intent.getBooleanExtra("isService", false); if (isService) { Intent i = new Intent(this, AppRunnerService.class); i.putExtras(intent); // potentially add data to the intent // i.putExtra("KEY1", "Value to be used by the service"); this.startService(i); finish(); } // NOTE: // if mProject == null , Protocoder is running in "standard" mode // if mProject != null , Protocoder is running in "standalone" mode boolean settingScreenAlwaysOn = false; boolean settingWakeUpScreen = false; if (mProject == null) { mProject = new Project(); // get projects intent //settings settingScreenAlwaysOn = intent.getBooleanExtra(Project.SETTINGS_SCREEN_ALWAYS_ON, false); settingWakeUpScreen = intent.getBooleanExtra(Project.SETTINGS_SCREEN_WAKEUP, false); //project info mProject.name = intent.getStringExtra(Project.NAME); mProject.folder = intent.getStringExtra(Project.FOLDER); mProject.prefix = intent.getStringExtra(Project.PREFIX); mProject.code = intent.getStringExtra(Project.CODE); mProject.postfix = intent.getStringExtra(Project.POSTFIX); } Bundle bundle = new Bundle(); bundle.putString(Project.NAME, mProject.name); bundle.putString(Project.FOLDER, mProject.folder); //bundle.putInt(Project.COLOR, intent.getIntExtra("color", 0)); bundle.putString(Project.PREFIX, mProject.prefix); bundle.putString(Project.CODE, mProject.code); bundle.putString(Project.POSTFIX, mProject.postfix); //MLog.d(TAG, "load " + projectName + " in " + projectFolder); // wake up if intent says so if (settingWakeUpScreen) { final Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); } //set screen always on if so setScreenAlwaysOn(settingScreenAlwaysOn); mAppRunnerFragment = AppRunnerFragment.newInstance(bundle); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(fl.getId(), mAppRunnerFragment, String.valueOf(fl.getId())); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); // ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); // ft.addToBackStack(null); ft.commit(); IDEcommunication.getInstance(this).ready(true); } }
From source file:com.granita.tasks.EditTaskFragment.java
@SuppressLint("NewApi") private void updateColor(float percentage) { if (VERSION.SDK_INT >= 11) { if (mColorBar == null) { percentage = 1;//from w ww. j a v a 2 s .c o m } else { percentage = Math.max(0, Math.min(Float.isNaN(percentage) ? 0 : percentage, 1)); } int newColor = getBlendColor(mListColor, darkenColor(mListColor), (int) ((0.5 + 0.5 * percentage) * 255)); ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(newColor)); // this is a workaround to ensure the new color is applied on all devices, some devices show a transparent ActionBar if we don't do that. actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); if (VERSION.SDK_INT >= 21) { Window window = getActivity().getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(mixColors(newColor, mListColor)); // window.setNavigationBarColor(mixColors(newColor, mListColor)); } } mTaskListBar.setBackgroundColor(mListColor); if (mColorBar != null) { mColorBar.setBackgroundColor(mListColor); } }
From source file:com.example.levelup.core.app.PaymentCodeFragment.java
/** * Forces the screen to be full-brightness and not dim. * /*from w w w. j a va 2 s .com*/ * @param isFullBrightness if true, sets the flags that force the screen to be fully bright and * kept on. False clears the flags. */ private void setForceFullBrightness(boolean isFullBrightness) { Window window = getActivity().getWindow(); // Bail if the window has gone away. if (window == null) { return; } if (isFullBrightness) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } LayoutParams attributes = window.getAttributes(); if (isFullBrightness) { attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL; } else { attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF; } window.setAttributes(attributes); }
From source file:com.microsoft.aad.adal.testapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Get the current window Window window = getWindow(); // Add the Flag from the window manager class window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); textViewStatus = (TextView) findViewById(R.id.textViewStatus); btnGetToken = (Button) findViewById(R.id.buttonGetToken); btnResetToken = (Button) findViewById(R.id.buttonReset); btnSetExpired = (Button) findViewById(R.id.buttonExpired); btnRefresh = (Button) findViewById(R.id.buttonRefresh); buttonVerify = (Button) findViewById(R.id.buttonVerify); buttonRemoveCookies = (Button) findViewById(R.id.buttonRemoveCookies); mAuthority = (EditText) findViewById(R.id.editAuthority); mResource = (EditText) findViewById(R.id.editResource); mClientId = (EditText) findViewById(R.id.editClientid); mUserid = (EditText) findViewById(R.id.editUserId); mPrompt = (EditText) findViewById(R.id.editPrompt); mRedirect = (EditText) findViewById(R.id.editRedirect); mValidate = (CheckBox) findViewById(R.id.checkBoxValidate); findViewById(R.id.buttonTestScriptRun).setOnClickListener(new View.OnClickListener() { @Override//w ww . ja v a 2s . co m public void onClick(View v) { TestScriptRunner runner = new TestScriptRunner(MainActivity.this); runner.runRemoteScript(); } }); buttonRemoveCookies.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { removeCookies(); } }); buttonVerify.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { useToken(); } }); btnGetToken.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getToken(); } }); btnResetToken.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { resetToken(); } }); btnSetExpired.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setTokenExpired(); } }); btnRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getTokenByRefreshToken(); } }); }