Example usage for android.content.res Configuration ORIENTATION_LANDSCAPE

List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.res Configuration ORIENTATION_LANDSCAPE.

Prototype

int ORIENTATION_LANDSCAPE

To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant for #orientation , value corresponding to the land resource qualifier.

Usage

From source file:com.leo.runningman.ui.ImageDetailActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Log.i(TAG, "onConfigurationChanged--->" + newConfig.orientation);
    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {

    } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

    }//w ww .  ja v  a 2 s.c  o  m
}

From source file:com.farmerbb.taskbar.fragment.AdvancedFragment.java

private void updateDashboardGridSize(boolean restartTaskbar) {
    SharedPreferences pref = U.getSharedPreferences(getActivity());
    int width = pref.getInt("dashboard_width",
            getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_width));
    int height = pref.getInt("dashboard_height",
            getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_height));

    boolean isPortrait = getActivity().getApplicationContext().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    boolean isLandscape = getActivity().getApplicationContext().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    int first = -1;
    int second = -1;

    if (isPortrait) {
        first = height;//from w w w .  j  av  a2  s . c om
        second = width;
    }

    if (isLandscape) {
        first = width;
        second = height;
    }

    findPreference("dashboard_grid_size")
            .setSummary(getString(R.string.dashboard_grid_description, first, second));

    if (restartTaskbar)
        U.restartTaskbar(getActivity());
}

From source file:com.gsma.rcs.ri.sharing.video.OutgoingVideoSharing.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Always on window
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

    // Set layout
    setContentView(R.layout.video_sharing_outgoing);

    // Set the contact selector
    mSpinner = (Spinner) findViewById(R.id.contact);
    ContactListAdapter adapter = ContactListAdapter.createRcsContactListAdapter(this);
    mSpinner.setAdapter(adapter);//from w ww .j  av a  2s .c o  m

    // Saved datas
    if (savedInstanceState == null) {
        mNbfCameras = getNumberOfCameras();
    } else {
        mSharingId = savedInstanceState.getString(SAVE_SHARING_ID);
        mNbfCameras = savedInstanceState.getInt(SAVE_NB_OF_CAMERAS);
        mVideoHeight = savedInstanceState.getInt(SAVE_VIDEO_HEIGHT);
        mVideoWidth = savedInstanceState.getInt(SAVE_VIDEO_WIDTH);
        mOpenedCameraId = CameraOptions.convert(savedInstanceState.getInt(SAVE_OPENED_CAMERA_ID));
        mContact = savedInstanceState.getParcelable(SAVE_REMOTE_CONTACT);
        mStarted = savedInstanceState.getBoolean(SAVE_STARTED);
    }
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "Sharing ID " + mSharingId + " Nb of cameras=" + mNbfCameras + " active camera="
                + mOpenedCameraId);
    }
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "Resolution: " + mVideoWidth + "x" + mVideoHeight);
    }

    // Set button callback
    mInviteBtn = (Button) findViewById(R.id.invite_btn);
    mInviteBtn.setOnClickListener(btnInviteListener);
    mDialBtn = (Button) findViewById(R.id.dial_btn);
    mDialBtn.setOnClickListener(btnDialListener);
    mSwitchCamBtn = (Button) findViewById(R.id.switch_cam_btn);

    // Disable button if no contact available
    if (adapter == null || adapter.getCount() == 0) {
        mDialBtn.setEnabled(false);
        mInviteBtn.setEnabled(false);
    }

    // Get camera info
    if (mNbfCameras > 1) {
        boolean backAvailable = checkCameraSize(CameraOptions.BACK);
        boolean frontAvailable = checkCameraSize(CameraOptions.FRONT);
        if (frontAvailable && backAvailable) {
            mSwitchCamBtn.setOnClickListener(btnSwitchCamListener);
        } else if (frontAvailable) {
            mOpenedCameraId = CameraOptions.FRONT;
            mSwitchCamBtn.setVisibility(View.INVISIBLE);
        } else if (backAvailable) {
            mOpenedCameraId = CameraOptions.BACK;
            mSwitchCamBtn.setVisibility(View.INVISIBLE);
        } else {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "No camera available for encoding");
            }
        }
    } else {
        if (checkCameraSize(CameraOptions.FRONT)) {
            mSwitchCamBtn.setVisibility(View.INVISIBLE);
        } else {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "No camera available for encoding");
            }
        }
    }

    // Create the live video view
    mVideoView = (VideoSurfaceView) findViewById(R.id.video_preview);
    mVideoView.setAspectRatio(mVideoWidth, mVideoHeight);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mVideoView.setAspectRatio(mVideoWidth, mVideoHeight);

    } else {
        mVideoView.setAspectRatio(mVideoHeight, mVideoWidth);
    }

    mSurface = mVideoView.getHolder();
    mSurface.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    mSurface.setKeepScreenOn(true);
    mSurface.addCallback(this);

    // Check if session in progress
    if (mSharingId != null) {
        // Sharing in progress
        mDialBtn.setVisibility(View.GONE);
        mInviteBtn.setVisibility(View.GONE);
        mSpinner.setVisibility(View.GONE);
        mSwitchCamBtn.setEnabled((mNbfCameras > 1));
        handler.post(continueOutgoingSessionRunnable);
        displayRemoteContact();
    } else {
        // Sharing not yet initiated
        mDialBtn.setVisibility(View.VISIBLE);
        mInviteBtn.setVisibility(View.VISIBLE);
        mSwitchCamBtn.setEnabled(false);

        boolean canInitiate = true;
        if (adapter == null || adapter.getCount() == 0) {
            canInitiate = false;
        }
        mDialBtn.setEnabled(canInitiate);
        mInviteBtn.setEnabled(canInitiate);
    }

    // Register to API connection manager
    if (!isServiceConnected(RcsServiceName.VIDEO_SHARING)) {
        showMessageThenExit(R.string.label_service_not_available);
        return;
    }
    startMonitorServices(RcsServiceName.VIDEO_SHARING);

    // Add service listener
    try {
        VideoSharingService vshService = getVideoSharingApi();
        if (mSharingId != null) {
            // Sharing is in progress: get sharing session
            mVideoSharing = vshService.getVideoSharing(mSharingId);
            if (mStarted) {
                displayVideoFormat();
            }
        }
        vshService.addEventListener(vshListener);
        if (LogUtils.isActive) {
            Log.d(LOGTAG, "onCreate video sharing");
        }
    } catch (RcsServiceException e) {
        showExceptionThenExit(e);
    }
}

From source file:com.coact.kochzap.CaptureActivity.java

private int getCurrentOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        default://from w w  w.  java  2  s .c om
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        }
    } else {
        switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        default:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        }
    }
}

From source file:com.nextgis.maplibui.util.ControlHelper.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static void lockScreenOrientation(Activity activity) {
    WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
    Configuration configuration = activity.getResources().getConfiguration();
    int rotation = windowManager.getDefaultDisplay().getRotation();

    // Search for the natural position of the device
    if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
            || configuration.orientation == Configuration.ORIENTATION_PORTRAIT
                    && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) {
        // Natural position is Landscape
        switch (rotation) {
        case Surface.ROTATION_0:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        case Surface.ROTATION_90:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            break;
        case Surface.ROTATION_180:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            break;
        case Surface.ROTATION_270:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        }/*from  ww  w.  j  av  a  2s  .  c  om*/
    } else {
        // Natural position is Portrait
        switch (rotation) {
        case Surface.ROTATION_0:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        case Surface.ROTATION_90:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        case Surface.ROTATION_180:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            break;
        case Surface.ROTATION_270:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            break;
        }
    }
}

From source file:com.grarak.rom.switcher.MainActivity.java

private DrawerLayout.LayoutParams getDrawerParams() {
    boolean tablet = Utils.isTablet(this);

    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) mScrimInsetsFrameLayout.getLayoutParams();
    int width = getResources().getDisplayMetrics().widthPixels;

    if (Utils.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) {
        params.width = width / 2;/*from  w w  w  .  j av  a  2 s .  c  o m*/
        if (tablet)
            params.width -= Utils.getActionBarHeight(this) + 30;
    } else {
        params.width = tablet ? width / 2 : width - Utils.getActionBarHeight(this);
    }

    return params;
}

From source file:com.cypress.cysmart.RDKEmulatorView.RemoteControlEmulatorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /**//from   w w w .ja  v a 2s .co  m
     * Getting the current orientation of the screen
     * Loading different view for LandScape and portrait
     */
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mParentView = inflater.inflate(R.layout.rdk_emulator_view_landscape, container, false);
    } else {
        mParentView = inflater.inflate(R.layout.rdk_emulator_view_portrait, container, false);
    }
    mProgressDialog = new ProgressDialog(getActivity());
    /**
     * Getting the ID's of all Emulator view UI elements
     */
    Button mTrackpadView = (Button) mParentView.findViewById(R.id.trackpad_btn);
    Button mMicrophoneView = (Button) mParentView.findViewById(R.id.microphone_btn);
    mVolumePlusbtn = (ImageButton) mParentView.findViewById(R.id.volume_plus_btn);
    mVolumeMinusBtn = (ImageButton) mParentView.findViewById(R.id.volume_minus_btn);
    mChannelPlusBtn = (ImageButton) mParentView.findViewById(R.id.channel_plus_btn);
    mChannelMinusBtn = (ImageButton) mParentView.findViewById(R.id.channel_minus_btn);
    mLeftBtn = (ImageButton) mParentView.findViewById(R.id.left_btn);
    mRightBtn = (ImageButton) mParentView.findViewById(R.id.right_btn);
    mBackBtn = (ImageButton) mParentView.findViewById(R.id.back_btn);
    mGesturebtn = (ImageButton) mParentView.findViewById(R.id.gesture_btn);
    mExitBtn = (ImageButton) mParentView.findViewById(R.id.exit_btn);
    mPowerBtn = (ImageButton) mParentView.findViewById(R.id.power_btn);
    mRecBtn = (ImageButton) mParentView.findViewById(R.id.record_btn);
    mRecBtn = (ImageButton) mParentView.findViewById(R.id.record_btn);
    /**
     * AudioTrack class initialisation as follows
     *  streamType- AudioManager.STREAM_MUSIC,
     *  sampleRateInHz- 16000,
     *  channelConfig- AudioFormat.CHANNEL_OUT_MONO,
     *  audioFormat-AudioFormat.ENCODING_PCM_16BIT,
     *  bufferSizeInBytes-8000,
     *  mode- AudioTrack.MODE_STREAM
     *
     */
    mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, SAMPLE_RATE, AudioFormat.CHANNEL_OUT_MONO,
            AudioFormat.ENCODING_PCM_16BIT, BUFFER_SIZE, AudioTrack.MODE_STREAM);
    /**
     * TrackPAd button click listner
     */
    mTrackpadView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TrackpadEmulatorFragment trackpadService = new TrackpadEmulatorFragment();
            try {
                displayView(trackpadService);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    });
    /**
     * Microphone Button click listner
     */
    mMicrophoneView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            MicrophoneEmulatorFragment microphoneService = new MicrophoneEmulatorFragment();
            microphoneService.create(mservice);
            displayView(microphoneService);
        }
    });
    return mParentView;
}

From source file:de.spiritcroc.modular_remote.Util.java

private static int getBlockUnits(SharedPreferences preferences, boolean y, View v) {
    boolean landscape = v.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    return getBlockUnits(preferences, y, landscape);
}

From source file:com.mooshim.mooshimeter.main.DeviceActivity.java

private void handleOrientation() {
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        // Start the trend view
        if (!trend_view_running) {
            Log.i(TAG, "Starting trend view.");
            trend_view_running = true;//ww w  .  j  a v  a2s . c om
            Util.dispatch(new Runnable() {
                @Override
                public void run() {
                    mMeter.pauseStream();
                }
            });
            startTrendActivity();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        // Do nothing, leave to external application
        break;
    }
}

From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.session_livestream, menu);
    mCaptionsMenuItem = menu.findItem(R.id.menu_captions);
    mShareMenuItem = menu.findItem(R.id.menu_share);
    if (mShareMenuDeferredSetup != null) {
        mShareMenuDeferredSetup.run();/* w  w w. ja va 2s  . c  om*/
    }
    if (!mIsTablet && Configuration.ORIENTATION_LANDSCAPE == getResources().getConfiguration().orientation) {
        mCaptionsMenuItem.setVisible(true);
    }
    return super.onCreateOptionsMenu(menu);
}