Java Code Examples for android.content.pm.activityinfo#SCREEN_ORIENTATION_SENSOR_PORTRAIT
The following examples show how to use
android.content.pm.activityinfo#SCREEN_ORIENTATION_SENSOR_PORTRAIT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomChecks.java From fullscreen-video-view with Apache License 2.0 | 6 votes |
@Override public void perform(UiController uiController, View view) { uiController.loopMainThreadUntilIdle(); int orientation = getActivityOrientation(view); boolean checkOrientation = false; switch (orientationType) { case PORTRAIT: checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT; break; case LANDSCAPE: checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE; break; } if (checkOrientation) { isOrientation[0] = true; } }
Example 2
Source File: YouTubePlayerActivity.java From SkyTube with GNU General Public License v3.0 | 6 votes |
@Override protected void onStart() { super.onStart(); // set the video player's orientation as what the user wants String str = SkyTubeApp.getPreferenceManager().getString(getString(R.string.pref_key_screen_orientation), getString(R.string.pref_screen_auto_value)); int orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; if (str.equals(getString(R.string.pref_screen_landscape_value))) orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; if (str.equals(getString(R.string.pref_screen_portrait_value))) orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; if (str.equals(getString(R.string.pref_screen_sensor_value))) orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR; setRequestedOrientation(orientation); }
Example 3
Source File: EBrowserActivity.java From appcan-android with GNU Lesser General Public License v3.0 | 6 votes |
public final int intoOrientation(int flag) { int or = ActivityInfo.SCREEN_ORIENTATION_USER; if (flag == 1) {// portrait or = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (flag == 2) {// landscape or = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (flag == 4) {// reverse portrait or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else if (flag == 8) {// reverse landscape or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else if (flag == 5) {// portrait and reverse portrait, Some devices only portrait effective if (Build.VERSION.SDK_INT >= 18) { or = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT; } else { or = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; } } else if (flag == 10) {// landscape and reverse landscape if (Build.VERSION.SDK_INT >= 18) { or = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE; } else { or = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } } return or; }
Example 4
Source File: SDLActivity.java From simpleSDL with MIT License | 5 votes |
/** * This can be overridden */ public void setOrientationBis(int w, int h, boolean resizable, String hint) { int orientation = -1; if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } else if (hint.contains("LandscapeRight")) { orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (hint.contains("LandscapeLeft")) { orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; } else if (hint.contains("Portrait")) { orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (hint.contains("PortraitUpsideDown")) { orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } /* no valid hint */ if (orientation == -1) { if (resizable) { /* no fixed orientation */ } else { if (w > h) { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } else { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; } } } Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint); if (orientation != -1) { mSingleton.setRequestedOrientation(orientation); } }
Example 5
Source File: U.java From Taskbar with Apache License 2.0 | 5 votes |
@SuppressLint("SwitchIntDef") private static ApplicationType getApplicationType(Context context, AppEntry entry) { if(isGame(context, entry.getPackageName())) return ApplicationType.APP_FULLSCREEN; try { ActivityInfo info = context.getPackageManager().getActivityInfo( ComponentName.unflattenFromString(entry.getComponentName()), 0 ); switch(info.screenOrientation) { case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: return ApplicationType.APP_LANDSCAPE; case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: return ApplicationType.APP_PORTRAIT; } } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ } return context.getPackageName().equals(BuildConfig.ANDROIDX86_APPLICATION_ID) ? ApplicationType.APP_LANDSCAPE : ApplicationType.APP_PORTRAIT; }
Example 6
Source File: Utils.java From Android-Applications-Info with Apache License 2.0 | 5 votes |
public static String getOrientationString(int orientation) { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED: return "Unspecified"; case ActivityInfo.SCREEN_ORIENTATION_BEHIND: return "Behind"; case ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR: return "Full sensor"; case ActivityInfo.SCREEN_ORIENTATION_FULL_USER: return "Full user"; case ActivityInfo.SCREEN_ORIENTATION_LOCKED: return "Locked"; case ActivityInfo.SCREEN_ORIENTATION_NOSENSOR: return "No sensor"; case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: return "Landscape"; case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: return "Portrait"; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: return "Reverse portrait"; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: return "Reverse landscape"; case ActivityInfo.SCREEN_ORIENTATION_USER: return "User"; case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: return "Sensor landscape"; case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: return "Sensor portrait"; case ActivityInfo.SCREEN_ORIENTATION_SENSOR: return "Sensor"; case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: return "User landscape"; case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: return "User portrait"; default: return "null"; } }
Example 7
Source File: SDLActivity.java From android-port with GNU General Public License v3.0 | 5 votes |
/** * This can be overridden */ public void setOrientationBis(int w, int h, boolean resizable, String hint) { int orientation = -1; if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } else if (hint.contains("LandscapeRight")) { orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (hint.contains("LandscapeLeft")) { orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; } else if (hint.contains("Portrait")) { orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (hint.contains("PortraitUpsideDown")) { orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } /* no valid hint */ if (orientation == -1) { if (resizable) { /* no fixed orientation */ } else { if (w > h) { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } else { orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; } } } Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint); if (orientation != -1) { mSingleton.setRequestedOrientation(orientation); } }
Example 8
Source File: GalleryActivity.java From MHViewer with Apache License 2.0 | 4 votes |
@Override public void onClick(DialogInterface dialog, int which) { if (mGalleryView == null) { return; } int screenRotation = mScreenRotation.getSelectedItemPosition(); int layoutMode = GalleryView.sanitizeLayoutMode(mReadingDirection.getSelectedItemPosition()); int scaleMode = GalleryView.sanitizeScaleMode(mScaleMode.getSelectedItemPosition()); int startPosition = GalleryView.sanitizeStartPosition(mStartPosition.getSelectedItemPosition()); boolean keepScreenOn = mKeepScreenOn.isChecked(); boolean showClock = mShowClock.isChecked(); boolean showProgress = mShowProgress.isChecked(); boolean showBattery = mShowBattery.isChecked(); boolean showPageInterval = mShowPageInterval.isChecked(); boolean volumePage = mVolumePage.isChecked(); boolean readingFullscreen = mReadingFullscreen.isChecked(); boolean customScreenLightness = mCustomScreenLightness.isChecked(); int screenLightness = mScreenLightness.getProgress(); boolean oldReadingFullscreen = Settings.getReadingFullscreen(); Settings.putScreenRotation(screenRotation); Settings.putReadingDirection(layoutMode); Settings.putPageScaling(scaleMode); Settings.putStartPosition(startPosition); Settings.putKeepScreenOn(keepScreenOn); Settings.putShowClock(showClock); Settings.putShowProgress(showProgress); Settings.putShowBattery(showBattery); Settings.putShowPageInterval(showPageInterval); Settings.putVolumePage(volumePage); Settings.putReadingFullscreen(readingFullscreen); Settings.putCustomScreenLightness(customScreenLightness); Settings.putScreenLightness(screenLightness); int orientation; switch (screenRotation) { default: case 0: orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; break; case 1: orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; break; case 2: orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; break; } setRequestedOrientation(orientation); mGalleryView.setLayoutMode(layoutMode); mGalleryView.setScaleMode(scaleMode); mGalleryView.setStartPosition(startPosition); if (keepScreenOn) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } if (mClock != null) { mClock.setVisibility(showClock ? View.VISIBLE : View.GONE); } if (mProgress != null) { mProgress.setVisibility(showProgress ? View.VISIBLE : View.GONE); } if (mBattery != null) { mBattery.setVisibility(showBattery ? View.VISIBLE : View.GONE); } mGalleryView.setPagerInterval(showPageInterval ? getResources().getDimensionPixelOffset(R.dimen.gallery_pager_interval) : 0); mGalleryView.setScrollInterval(showPageInterval ? getResources().getDimensionPixelOffset(R.dimen.gallery_scroll_interval) : 0); setScreenLightness(customScreenLightness, screenLightness); // Update slider mLayoutMode = layoutMode; updateSlider(); if (oldReadingFullscreen != readingFullscreen) { recreate(); } }
Example 9
Source File: ScreenOrientationProvider.java From 365browser with Apache License 2.0 | 4 votes |
private static int getOrientationFromWebScreenOrientations(byte orientation, @Nullable WindowAndroid window, Context context) { switch (orientation) { case ScreenOrientationValues.DEFAULT: return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; case ScreenOrientationValues.PORTRAIT_PRIMARY: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case ScreenOrientationValues.PORTRAIT_SECONDARY: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case ScreenOrientationValues.LANDSCAPE_PRIMARY: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case ScreenOrientationValues.LANDSCAPE_SECONDARY: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; case ScreenOrientationValues.PORTRAIT: return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; case ScreenOrientationValues.LANDSCAPE: return ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; case ScreenOrientationValues.ANY: return ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; case ScreenOrientationValues.NATURAL: // If the tab is being reparented, we don't have a display strongly associated with // it, so we get the default display. DisplayAndroid displayAndroid = (window != null) ? window.getDisplay() : DisplayAndroid.getNonMultiDisplay(context); int rotation = displayAndroid.getRotation(); if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { if (displayAndroid.getDisplayHeight() >= displayAndroid.getDisplayWidth()) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else { if (displayAndroid.getDisplayHeight() < displayAndroid.getDisplayWidth()) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } default: Log.w(TAG, "Trying to lock to unsupported orientation!"); return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } }
Example 10
Source File: GalleryActivity.java From EhViewer with Apache License 2.0 | 4 votes |
@Override public void onClick(DialogInterface dialog, int which) { if (mGalleryView == null) { return; } int screenRotation = mScreenRotation.getSelectedItemPosition(); int layoutMode = GalleryView.sanitizeLayoutMode(mReadingDirection.getSelectedItemPosition()); int scaleMode = GalleryView.sanitizeScaleMode(mScaleMode.getSelectedItemPosition()); int startPosition = GalleryView.sanitizeStartPosition(mStartPosition.getSelectedItemPosition()); boolean keepScreenOn = mKeepScreenOn.isChecked(); boolean showClock = mShowClock.isChecked(); boolean showProgress = mShowProgress.isChecked(); boolean showBattery = mShowBattery.isChecked(); boolean showPageInterval = mShowPageInterval.isChecked(); boolean volumePage = mVolumePage.isChecked(); boolean readingFullscreen = mReadingFullscreen.isChecked(); boolean customScreenLightness = mCustomScreenLightness.isChecked(); int screenLightness = mScreenLightness.getProgress(); boolean oldReadingFullscreen = Settings.getReadingFullscreen(); Settings.putScreenRotation(screenRotation); Settings.putReadingDirection(layoutMode); Settings.putPageScaling(scaleMode); Settings.putStartPosition(startPosition); Settings.putKeepScreenOn(keepScreenOn); Settings.putShowClock(showClock); Settings.putShowProgress(showProgress); Settings.putShowBattery(showBattery); Settings.putShowPageInterval(showPageInterval); Settings.putVolumePage(volumePage); Settings.putReadingFullscreen(readingFullscreen); Settings.putCustomScreenLightness(customScreenLightness); Settings.putScreenLightness(screenLightness); int orientation; switch (screenRotation) { default: case 0: orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; break; case 1: orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; break; case 2: orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; break; case 3: orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR; break; } setRequestedOrientation(orientation); mGalleryView.setLayoutMode(layoutMode); mGalleryView.setScaleMode(scaleMode); mGalleryView.setStartPosition(startPosition); if (keepScreenOn) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } if (mClock != null) { mClock.setVisibility(showClock ? View.VISIBLE : View.GONE); } if (mProgress != null) { mProgress.setVisibility(showProgress ? View.VISIBLE : View.GONE); } if (mBattery != null) { mBattery.setVisibility(showBattery ? View.VISIBLE : View.GONE); } mGalleryView.setPagerInterval(showPageInterval ? getResources().getDimensionPixelOffset(R.dimen.gallery_pager_interval) : 0); mGalleryView.setScrollInterval(showPageInterval ? getResources().getDimensionPixelOffset(R.dimen.gallery_scroll_interval) : 0); setScreenLightness(customScreenLightness, screenLightness); // Update slider mLayoutMode = layoutMode; updateSlider(); if (oldReadingFullscreen != readingFullscreen) { recreate(); } }
Example 11
Source File: SDLActivity.java From android-port with GNU General Public License v3.0 | 4 votes |
@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.v("SDL", "surfaceChanged()"); int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default switch (format) { case PixelFormat.A_8: Log.v("SDL", "pixel format A_8"); break; case PixelFormat.LA_88: Log.v("SDL", "pixel format LA_88"); break; case PixelFormat.L_8: Log.v("SDL", "pixel format L_8"); break; case PixelFormat.RGBA_4444: Log.v("SDL", "pixel format RGBA_4444"); sdlFormat = 0x15421002; // SDL_PIXELFORMAT_RGBA4444 break; case PixelFormat.RGBA_5551: Log.v("SDL", "pixel format RGBA_5551"); sdlFormat = 0x15441002; // SDL_PIXELFORMAT_RGBA5551 break; case PixelFormat.RGBA_8888: Log.v("SDL", "pixel format RGBA_8888"); sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888 break; case PixelFormat.RGBX_8888: Log.v("SDL", "pixel format RGBX_8888"); sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888 break; case PixelFormat.RGB_332: Log.v("SDL", "pixel format RGB_332"); sdlFormat = 0x14110801; // SDL_PIXELFORMAT_RGB332 break; case PixelFormat.RGB_565: Log.v("SDL", "pixel format RGB_565"); sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 break; case PixelFormat.RGB_888: Log.v("SDL", "pixel format RGB_888"); // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? sdlFormat = 0x16161804; // SDL_PIXELFORMAT_RGB888 break; default: Log.v("SDL", "pixel format unknown " + format); break; } mWidth = width; mHeight = height; SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate()); Log.v("SDL", "Window size: " + width + "x" + height); boolean skip = false; int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { // Accept any } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { if (mWidth > mHeight) { skip = true; } } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { if (mWidth < mHeight) { skip = true; } } // Special Patch for Square Resolution: Black Berry Passport if (skip) { double min = Math.min(mWidth, mHeight); double max = Math.max(mWidth, mHeight); if (max / min < 1.20) { Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution."); skip = false; } } if (skip) { Log.v("SDL", "Skip .. Surface is not ready."); SDLActivity.mIsSurfaceReady = false; return; } /* Surface is ready */ SDLActivity.mIsSurfaceReady = true; /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ SDLActivity.onNativeSurfaceChanged(); SDLActivity.handleNativeState(); }