List of usage examples for android.view Window getAttributes
public final WindowManager.LayoutParams getAttributes()
From source file:com.github.piasy.chatrecyclerview.example.InputDialog.java
@Override public void onStart() { super.onStart(); // without title and title divider // Less dimmed background; see http://stackoverflow.com/q/13822842/56285 Window window = getDialog().getWindow(); WindowManager.LayoutParams params = window.getAttributes(); //CHECKSTYLE:OFF params.dimAmount = 0;/*from w w w. j a v a 2 s.c o m*/ //CHECKSTYLE:ON window.setAttributes(params); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.BOTTOM); // Transparent background; see http://stackoverflow.com/q/15007272/56285 // (Needed to make dialog's alpha shadow look good) window.setBackgroundDrawableResource(android.R.color.transparent); final Resources res = getResources(); final int titleDividerId = res.getIdentifier("titleDivider", "id", "android"); if (titleDividerId > 0) { final View titleDivider = getDialog().findViewById(titleDividerId); if (titleDivider != null) { titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent)); } } }
From source file:com.xiangqin.app.dialog.AbSampleDialogFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { Window window = getDialog().getWindow(); WindowManager.LayoutParams attributes = window.getAttributes(); attributes.gravity = mGravity;/* w ww.ja va 2s .c o m*/ window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); window.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#88818181"))); super.onActivityCreated(savedInstanceState); }
From source file:com.seongil.simpleavatarpicker.demo.PictureChooserDialog.java
@Override public void onResume() { Window window = getDialog().getWindow(); if (window != null) { ViewGroup.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; params.height = ViewGroup.LayoutParams.WRAP_CONTENT; window.setAttributes((android.view.WindowManager.LayoutParams) params); }/*from ww w .j av a2s . co m*/ super.onResume(); }
From source file:com.dw.bartinter.BarTinter.java
@Override public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(PLUGIN, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); return true; }//w ww. ja va2s.c om if ("statusBar".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { statusBar(args.getString(0)); } catch (JSONException ignore) { Log.e(PLUGIN, "Invalid hexString argument."); } } }); return true; } if ("navigationBar".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { navigationBar(args.getString(0)); } catch (JSONException ignore) { Log.e(PLUGIN, "Invalid hexString argument."); } } }); return true; } return false; }
From source file:com.phonegap.bossbolo.plugin.statusbar.StatusBar.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return True if the action was valid, false otherwise. *//* www. j av a 2s . c o m*/ @Override public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(TAG, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); } if ("show".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } if ("hide".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } if ("backgroundColorByHexString".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { setStatusBarBackgroundColor(args.getString(0)); } catch (JSONException ignore) { Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'"); } } }); return true; } return false; }
From source file:org.apache.cordova.statusbar.StatusBar.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return True if the action was valid, false otherwise. *//*from ww w . j a v a 2 s . c om*/ @Override public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(TAG, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); return true; } if ("show".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } if ("hide".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } if ("backgroundColorByHexString".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { setStatusBarBackgroundColor(args.getString(0)); } catch (JSONException ignore) { Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'"); } } }); return true; } return false; }
From source file:com.nbplus.vbroadlauncher.BaseActivity.java
public void acquireCpuWakeLock() { Log.e(TAG, "Acquiring cpu wake lock"); if (mCpuWakeLock != null) { return;/*from ww w .jav a2 s . c om*/ } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mCpuWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "I'm your father"); mCpuWakeLock.acquire(); Window window = this.getWindow(); mDefaultWindowFlags = window.getAttributes().flags; window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); }
From source file:me.wizos.loread.view.webview.VideoImpl.java
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity;/*from w ww.j a v a 2 s.com*/ if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return; } // ? mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (videoView != null) { callback.onCustomViewHidden(); return; } // KLog.e("" + mWebView + " " + videoParentView); if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (videoParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); videoParentView = new FrameLayout(mActivity); videoParentView.setBackgroundColor(Color.BLACK); videoParentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // ? mDecorView.addView(videoParentView); } // KLog.e("" + mWebView.getVisibility() + " " + videoParentView); this.mCallback = callback; this.videoView = view; videoParentView.addView(videoView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); videoParentView.setVisibility(View.VISIBLE); isPlaying = true; }
From source file:com.just.agentweb.VideoImpl.java
@Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity;//from w ww . j ava 2s .c o m if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return; } mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair = null; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (mMoiveView != null) { callback.onCustomViewHidden(); return; } if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (mMoiveParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); mMoiveParentView = new FrameLayout(mActivity); mMoiveParentView.setBackgroundColor(Color.BLACK); mDecorView.addView(mMoiveParentView); } this.mCallback = callback; mMoiveParentView.addView(this.mMoiveView = view); mMoiveParentView.setVisibility(View.VISIBLE); }
From source file:br.com.hotforms.StatusBarManager.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return True if the action was valid, false otherwise. *///from w w w. j a v a2 s. c om @Override public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(TAG, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); } else if ("show".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } else if ("hide".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); } } }); return true; } else if ("setTranslucent".equals(action)) { if (currentapiVersion >= android.os.Build.VERSION_CODES.KITKAT) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); } window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }); return true; } else { return false; } } else if ("setTransparent".equals(action)) { if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); } }); return true; } else { return false; } } else if ("setColor".equals(action)) { if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { this.setColor(args.getInt(0), args.getInt(1), args.getInt(2)); return true; } else { return false; } } return false; }