Java Code Examples for android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE

The following examples show how to use android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE . 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: MainActivity.java    From MoeGallery with GNU General Public License v3.0 6 votes vote down vote up
public void updateOrientation(int width, int height) {
    if (width == height) {
        return;
    }

    if (mPagerAdapter.getCount() == 1) {
        return;
    }

    int orientation = getRequestedOrientation();
    if (width <= height && orientation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (width > height && orientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}
 
Example 2
Source File: EyepetizerDetailActivity.java    From Ency with Apache License 2.0 6 votes vote down vote up
private void initVideoPlayer() {
    LinkedHashMap map = new LinkedHashMap();
    if (videoBean.getContent().getData().getPlayInfo().size() == 3) {
        map.put("流畅", videoBean.getContent().getData().getPlayInfo().get(0).getUrl());
        map.put("标清", videoBean.getContent().getData().getPlayInfo().get(1).getUrl());
        map.put("高清", videoBean.getContent().getData().getPlayInfo().get(2).getUrl());
    } else if (videoBean.getContent().getData().getPlayInfo().size() == 2) {
        map.put("标清", videoBean.getContent().getData().getPlayInfo().get(0).getUrl());
        map.put("高清", videoBean.getContent().getData().getPlayInfo().get(1).getUrl());
    } else if (videoBean.getContent().getData().getPlayInfo().size() == 1) {
        map.put("高清", videoBean.getContent().getData().getPlayInfo().get(0).getUrl());
    }
    Object[] objects = new Object[3];
    objects[0] = map;
    objects[1] = false;//looping
    objects[2] = new HashMap<>();
    videoPlayerStandard.backButton.setVisibility(View.VISIBLE);
    videoPlayerStandard.titleTextView.setTextSize(16);
    videoPlayerStandard.setUp(objects, 0,
            JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, videoBean.getContent().getData().getTitle());
    ImageLoader.loadAllNoPlaceHolder(mContext, videoBean.getContent().getData().getCover().getFeed()
            ,videoPlayerStandard.thumbImageView);
    JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    JZVideoPlayer.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
 
Example 3
Source File: OrientationUtils.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
private void initGravity(Activity activity) {
    if (mIsLand == LAND_TYPE_NULL) {
        int defaultRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        if (defaultRotation == Surface.ROTATION_0) {
            // 竖向为正方向。 如:手机、小米平板
            mIsLand = LAND_TYPE_NULL;
            mScreenType = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        } else if (defaultRotation == Surface.ROTATION_270) {
            // 横向为正方向。 如:三星、sony平板
            mIsLand = LAND_TYPE_REVERSE;
            mScreenType = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        } else {
            // 未知方向
            mIsLand = LAND_TYPE_NORMAL;
            mScreenType = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        }
    }
}
 
Example 4
Source File: HomeActivity.java    From ZZShow with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_BACK){
        if(mFullScreenLayout != null && mFullScreenLayout.getVisibility() == View.VISIBLE  && getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            return true;
        }else{
            if( System.currentTimeMillis() - oldOutTime > 1200l){
                oldOutTime = System.currentTimeMillis();
                Toast.makeText(HomeActivity.this,"再次点击,退出应用",Toast.LENGTH_SHORT).show();
                return true;
            }
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 5
Source File: OrientationUtils.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 点击切换的逻辑,比如竖屏的时候点击了就是切换到横屏不会受屏幕的影响
 */
@SuppressLint("SourceLockedOrientationActivity")
public void resolveByClick() {
    if (mIsLand == LAND_TYPE_NULL && mVideoPlayer != null && mVideoPlayer.isVerticalFullByVideoSize()) {
        return;
    }
    mClick = true;
    if (mIsLand == LAND_TYPE_NULL) {
        int request = mActivity.getRequestedOrientation();
        if (request == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
            mScreenType = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        } else {
            mScreenType = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        }
        setRequestedOrientation(mScreenType);
        if (mVideoPlayer.getFullscreenButton() != null) {
            mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getShrinkImageRes());
        }
        mIsLand = LAND_TYPE_NORMAL;
        mClickLand = false;
    } else {
        mScreenType = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        if (mVideoPlayer.getFullscreenButton() != null) {
            if (mVideoPlayer.isIfCurrentIsFullscreen()) {
                mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getShrinkImageRes());
            } else {
                mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getEnlargeImageRes());
            }
        }
        mIsLand = LAND_TYPE_NULL;
        mClickPort = false;
    }

}
 
Example 6
Source File: LiveActivity.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
public void fullChangeScreen() {
    if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)// 切换为竖屏
    {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        tvRelierMsg.setText("免责声明");
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        tvRelierMsg.setText("");
    }
}
 
Example 7
Source File: SDLActivity.java    From android-port with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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: SimplePlayer.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onBackPressed() {
    //先返回正常状态
    if (orientationUtils.getScreenType() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        videoPlayer.getFullscreenButton().performClick();
        return;
    }
    //释放所有
    videoPlayer.setVideoAllCallBack(null);
    super.onBackPressed();
}
 
Example 9
Source File: AxglePlayActivity.java    From v9porn with MIT License 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_USER) {
        //这里没必要,因为我们使用的是setColorForSwipeBack,并不会有这个虚拟的view,而是设置的padding
        StatusBarUtil.hideFakeStatusBarView(this);
    } else if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimary));
    }
}
 
Example 10
Source File: LiveActivity.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
public void setScreenRate(int rate) {
    int width = 0;
    int height = 0;
    if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)// 横屏
    {
        if (rate == SIZE_DEFAULT) {
            width = videoView.getmVideoWidth();
            height = videoView.getmVideoHeight();
        } else if (rate == SIZE_4_3) {
            width = screenWidth / 3 * 4;
            height = screenWidth;
        } else if (rate == SIZE_16_9) {
            width = screenWidth / 9 * 16;
            height = screenWidth;
        }
    } else //竖屏
    {
        if (rate == SIZE_DEFAULT) {
            width = videoView.getmVideoWidth();
            height = videoView.getmVideoHeight();
        } else if (rate == SIZE_4_3) {
            width = screenWidth;
            height = screenWidth * 3 / 4;
        } else if (rate == SIZE_16_9) {
            width = screenWidth;
            height = screenWidth * 9 / 16;
        }
    }
    if (width > 0 && height > 0) {
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) videoView.getmRenderView().getView().getLayoutParams();
        lp.width = width;
        lp.height = height;
        videoView.getmRenderView().getView().setLayoutParams(lp);
    }
}
 
Example 11
Source File: MainActivity.java    From AndroidVideoPlayer with GNU General Public License v2.0 5 votes vote down vote up
/***
 * 恢复屏幕至竖屏
 */
private void resetPageToPortrait() {
    if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        mSuperVideoPlayer.setPageType(MediaController.PageType.SHRINK);
    }
}
 
Example 12
Source File: WebActivity.java    From GankGirl with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    webView.onResume();
    webView.resumeTimers();

    /**
     * 设置为横屏
     */
    if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

}
 
Example 13
Source File: AxglePlayActivity.java    From v9porn with MIT License 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_USER) {
        //这里没必要,因为我们使用的是setColorForSwipeBack,并不会有这个虚拟的view,而是设置的padding
        StatusBarUtil.hideFakeStatusBarView(this);
    } else if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimary));
    }
}
 
Example 14
Source File: GiraffePlayer.java    From GiraffePlayer with Apache License 2.0 5 votes vote down vote up
private void updateFullScreenButton() {
    if (getScreenOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        $.id(R.id.app_video_fullscreen).image(R.drawable.ic_fullscreen_exit_white_36dp);
    } else {
        $.id(R.id.app_video_fullscreen).image(R.drawable.ic_fullscreen_white_24dp);
    }
}
 
Example 15
Source File: BaseActivity.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSessionId = UUID.randomUUID().toString();

    try {
        if (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT == HiSettingsHelper.getInstance().getScreenOrietation()) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE == HiSettingsHelper.getInstance().getScreenOrietation()) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
        }
    } catch (Exception ignored) {
        //avoid android 8.0 bug
    }

    int theme = HiUtils.getThemeValue(this,
            HiSettingsHelper.getInstance().getActiveTheme(),
            HiSettingsHelper.getInstance().getPrimaryColor());
    setTheme(theme);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && HiSettingsHelper.getInstance().isNavBarColored()) {
        getWindow().setNavigationBarColor(ColorHelper.getColorPrimary(this));
        View view = getWindow().getDecorView();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (theme == R.style.ThemeLight_White) {
                view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            } else {
                view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            }
        }
    }
}
 
Example 16
Source File: XLVideoPlayActivity.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
private int getScreenOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;
    int orientation;
    // if the device's natural orientation is portrait:
    if ((rotation == Surface.ROTATION_0
            || rotation == Surface.ROTATION_180) && height > width ||
            (rotation == Surface.ROTATION_90
                    || rotation == Surface.ROTATION_270) && width > height) {
        switch (rotation) {
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_180:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            case Surface.ROTATION_270:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
        }
    }
    // if the device's natural orientation is landscape or if the device
    // is square:
    else {
        switch (rotation) {
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_180:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            case Surface.ROTATION_270:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
        }
    }

    return orientation;
}
 
Example 17
Source File: GiraffePlayer.java    From GiraffePlayer with Apache License 2.0 4 votes vote down vote up
private int getScreenOrientation() {
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;
    int orientation;
    // if the device's natural orientation is portrait:
    if ((rotation == Surface.ROTATION_0
            || rotation == Surface.ROTATION_180) && height > width ||
            (rotation == Surface.ROTATION_90
                    || rotation == Surface.ROTATION_270) && width > height) {
        switch (rotation) {
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_180:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            case Surface.ROTATION_270:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
        }
    }
    // if the device's natural orientation is landscape or if the device
    // is square:
    else {
        switch (rotation) {
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_180:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            case Surface.ROTATION_270:
                orientation =
                        ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
        }
    }

    return orientation;
}
 
Example 18
Source File: WindowUtils.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * 获取界面方向
 */
public static int getScreenOrientation(Activity activity) {
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;
    int orientation;
    // if the device's natural orientation is portrait:
    if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width ||
            (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) {
        switch (rotation) {
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_180:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            case Surface.ROTATION_270:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
        }
    }
    // if the device's natural orientation is landscape or if the device
    // is square:
    else {
        switch (rotation) {
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_180:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            case Surface.ROTATION_270:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
        }
    }

    return orientation;
}
 
Example 19
Source File: OrientationChangeAction.java    From PhilHackerNews with MIT License 4 votes vote down vote up
public static ViewAction orientationLandscape() {
    return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
 
Example 20
Source File: CustomMediaController.java    From ZZShow with Apache License 2.0 4 votes vote down vote up
public int getScreenOrientation(Activity activity){
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;
    int orientation;
    // if the device's natural orientation is portrait:
    if((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
            && height > width
            || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
            && width > height){
        switch (rotation){
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_180:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            case Surface.ROTATION_270:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
        }
    }
    // if the device's natural orientation is landscape or if the device
    // is square:
    else{
        switch (rotation){
            case Surface.ROTATION_0:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
            case Surface.ROTATION_90:
                orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                break;
            case Surface.ROTATION_180:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
                break;
            case Surface.ROTATION_270:
                orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
                break;
            default:
                orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                break;
        }
    }
    return orientation;
}