List of usage examples for android.app Activity setRequestedOrientation
public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation)
From source file:com.health.openscale.gui.OverviewFragment.java
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser) { if ((getActivity().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE && (getActivity().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE) { Activity a = getActivity(); if (a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }// w ww. j a va2 s. c o m } }
From source file:com.just.agentweb.VideoImpl.java
@Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity; if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return;/*from ww w .j ava2 s.c om*/ } 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:me.wizos.loread.view.webview.VideoImpl.java
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity; if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return;/* w w w . j a v a2 s.c om*/ } // ? 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:de.limexcomputer.cordova.plugin.rotationlock.RotationLock.java
/** * Executes the request./*w w w . j a v a2s . co m*/ * * This method is called from the WebView thread. * To do a non-trivial amount of work, use: * cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action The action to execute. * @param args The exec() arguments in JSON form. * @param callback The callback context used when calling back into JavaScript. * @return Whether the action was valid. */ @Override public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException { if (!action.equalsIgnoreCase("setOrientation")) { return false; } String orientation = args.optString(0); Activity activity = this.cordova.getActivity(); // refer to https://github.com/their/pg-plugin-screen-orientation/blob/master/src/ScreenOrientation.java if (orientation.equals(UNSPECIFIED)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else if (orientation.equals(LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals(PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals(USER)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } else if (orientation.equals(BEHIND)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND); } else if (orientation.equals(SENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (orientation.equals(NOSENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else if (orientation.equals(SENSOR_LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (orientation.equals(SENSOR_PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (orientation.equals(REVERSE_LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else if (orientation.equals(REVERSE_PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else if (orientation.equals(FULL_SENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } callback.success(orientation); return true; }
From source file:com.appnexus.opensdk.MRAIDImplementation.java
void close() { if (expanded) { AdView.LayoutParams lp = new AdView.LayoutParams(owner.getLayoutParams()); lp.height = default_height; lp.width = default_width; lp.gravity = Gravity.CENTER;//ww w .java 2s. c o m owner.setLayoutParams(lp); owner.close(); this.owner.loadUrl("javascript:window.mraid.util.stateChangeEvent('default');"); this.owner.owner.adListener.onAdCollapsed(this.owner.owner); // Allow orientation changes Activity a = ((Activity) this.owner.getContext()); if (a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); expanded = false; } else { // state must be default owner.hide(); hidden = true; } }
From source file:com.health.openscale.gui.GraphFragment.java
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser) { Activity a = getActivity(); if (a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); }//from w w w.j a v a 2 s .co m }
From source file:de.baumann.browser.helper.helper_main.java
public static void onStart(Activity from) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from); class_SecurePreferences sharedPrefSec = new class_SecurePreferences(from, "sharedPrefSec", "Ywn-YM.XK$b:/:&CsL8;=L,y4", true); String pw = sharedPrefSec.getString("protect_PW"); if (pw != null && pw.length() > 0) { if (sharedPref.getBoolean("isOpened", true)) { helper_main.switchToActivity(from, Activity_password.class, "", false); }//from w ww .j a v a2 s.c o m } if (sharedPref.getString("fullscreen", "2").equals("1") || sharedPref.getString("fullscreen", "2").equals("3")) { from.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } if (sharedPref.getString("orientation", "auto").equals("landscape")) { from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } if (sharedPref.getString("orientation", "auto").equals("portrait")) { from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }
From source file:com.mbientlab.metawear.app.LoggingFragment.java
@Override public void onAttach(Activity activity) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); super.onAttach(activity); }
From source file:kr.wdream.storyshop.AndroidUtilities.java
public static void unlockOrientation(Activity activity) { if (activity == null) { return;//from w w w . j ava2s .c o m } try { if (prevOrientation != -10) { activity.setRequestedOrientation(prevOrientation); prevOrientation = -10; } } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:it.readbeyond.minstrel.commander.Commander.java
private void orient(final String option, final CallbackContext callbackContext) { try {//from w w w .j a v a 2s . c om Activity activity = cordova.getActivity(); if (option.equals(ORIENT_OPTION_PORTRAIT)) { // portrait or reverse portrait activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (option.equals(ORIENT_OPTION_LANDSCAPE)) { // landscape or reverse portrait activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (option.equals(ORIENT_OPTION_AUTO)) { // unlock orientation activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else { // default: unlock orientation activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } callbackContext.success(""); } catch (Exception e) { // nop callbackContext.error("Exception " + e); } }