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.gdgdevfest.android.apps.devfestbcn.ui.tablet.MapMultiPaneActivity.java

private void updateMapPadding() {
    // Pan the map left or up depending on the orientation.
    boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    boolean detailShown = findViewById(R.id.map_detail_spacer).getVisibility() == View.VISIBLE;

    mMapFragment.setCenterPadding(landscape ? (detailShown ? 0.25f : 0f) : 0,
            landscape ? 0 : (detailShown ? 0.25f : 0));
}

From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.profile_control, container, false);
    relativeLayout = (RelativeLayout) rootView.findViewById(R.id.gatt_service_carousel);
    pager = (ViewPager) rootView.findViewById(R.id.myviewpager);
    application = (CySmartApplication) getActivity().getApplication();
    PAGES = 0;//from  www . j  av a  2 s  . c  om
    mpdia = new ProgressDialog(getActivity());
    mpdia.setCancelable(false);
    setCarouselView();
    setHasOptionsMenu(true);
    /**
     * Getting the orientation of the device. Set margin for pages as a
     * negative number, so a part of next and previous pages will be showed
     */
    if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        pager.setPageMargin(-width / 3);
    } else if (getActivity().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        pager.setPageMargin(-width / 2);
    }
    return rootView;
}

From source file:com.example.android.wifidirect.WiFiDirectActivity.java

public void onConfigurationChanged(Configuration newConfig) {
    Configuration newConfig1 = getResources().getConfiguration();
    if (newConfig1.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        //?//w ww.j a  va2  s .c  o  m

    } else if (newConfig1.orientation == Configuration.ORIENTATION_PORTRAIT) {
        //?
        //setContentView(R.id.portrait);
    }
}

From source file:dev.ronlemire.commoncontrols.MainActivity.java

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

   // Test whether if enough display space for 2 panes. Only if tablet and
   // landscape.// ww  w  .  jav  a  2 s . c o  m
   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {
      // 2 panes - list on left - sample on right
      setContentView(R.layout.main_land);
      StartEmptyFragment(); // clear sample pane
   } else {
      // 1 pane - list and sample will overlay each other
      setContentView(R.layout.main);
   }

   // Save reference to List in order to replace later
   sampleListView = this.findViewById(R.id.sampleList_replacer);
   messagesEditText = (EditText) this.findViewById(R.id.etMessages);
   messagesEditText.setEnabled(false);
   messagesEditText.setTextColor(Color.parseColor("#000000")); // black

   // Receiver to catch message sent from List after a sample has been picked
   sampleListReceiver = new SampleListReceiver();
   sampleListFilter = new IntentFilter(
         ListOfControlsFragment.SAMPLE_LIST_FRAGMENT_BROADCAST_INTENT);

   // Messages from controls
    messageFromButtonsReceiver = new MessageFromButtonsReceiver();
   messageFromButtonsFilter = new IntentFilter(
         ButtonsFragment.MESSAGE_FROM_BUTTONS_INTENT);

   messageFromCheckBoxesReceiver = new MessageFromCheckBoxesReceiver();
   messageFromCheckBoxesFilter = new IntentFilter(
         CheckBoxesFragment.MESSAGE_FROM_CHECKBOXES_INTENT);

   messageFromDateTimeReceiver = new MessageFromDateTimeReceiver();
   messageFromDateTimeFilter = new IntentFilter(
         DateTimeFragment.MESSAGE_FROM_DATETIME_INTENT);

   messageFromGalleryReceiver = new MessageFromGalleryReceiver();
   messageFromGalleryFilter = new IntentFilter(
         GalleryFragment.MESSAGE_FROM_GALLERY_INTENT);

   messageFromGridViewReceiver = new MessageFromGridViewReceiver();
   messageFromGridViewFilter = new IntentFilter(
         GridViewFragment.MESSAGE_FROM_GRIDVIEW_INTENT);

   messageFromGridViewCustomReceiver = new MessageFromGridViewCustomReceiver();
   messageFromGridViewCustomFilter = new IntentFilter(
         GridViewCustomFragment.MESSAGE_FROM_GRIDVIEWCUSTOM_INTENT);

   messageFromImageViewReceiver = new MessageFromImageViewReceiver();
   messageFromImageViewFilter = new IntentFilter(
         ImageViewFragment.MESSAGE_FROM_IMAGEVIEW_INTENT);

   messageFromLayoutFrameReceiver = new MessageFromLayoutFrameReceiver();
   messageFromLayoutFrameFilter = new IntentFilter(
         LayoutFrameFragment.MESSAGE_FROM_LAYOUTFRAME_INTENT);

   messageFromLayoutRelativeReceiver = new MessageFromLayoutRelativeReceiver();
   messageFromLayoutRelativeFilter = new IntentFilter(
         LayoutRelativeFragment.MESSAGE_FROM_LAYOUTRELATIVE_INTENT);

   messageFromLayoutTable1Receiver = new MessageFromLayoutTable1Receiver();
   messageFromLayoutTable1Filter = new IntentFilter(
         LayoutTable1Fragment.MESSAGE_FROM_LAYOUTTABLE1_INTENT);

   messageFromLayoutTable2Receiver = new MessageFromLayoutTable2Receiver();
   messageFromLayoutTable2Filter = new IntentFilter(
         LayoutTable2Fragment.MESSAGE_FROM_LAYOUTTABLE2_INTENT);

   messageFromLayoutTable3Receiver = new MessageFromLayoutTable3Receiver();
   messageFromLayoutTable3Filter = new IntentFilter(
         LayoutTable3Fragment.MESSAGE_FROM_LAYOUTTABLE3_INTENT);

   messageFromListView1Receiver = new MessageFromListView1Receiver();
   messageFromListView1Filter = new IntentFilter(
         ListView1Fragment.MESSAGE_FROM_LISTVIEW1_INTENT);

   messageFromListView2Receiver = new MessageFromListView2Receiver();
   messageFromListView2Filter = new IntentFilter(
         ListView2Fragment.MESSAGE_FROM_LISTVIEW2_INTENT);

   messageFromListView3Receiver = new MessageFromListView3Receiver();
   messageFromListView3Filter = new IntentFilter(
         ListView3Fragment.MESSAGE_FROM_LISTVIEW3_INTENT);

   messageFromListView4Receiver = new MessageFromListView4Receiver();
   messageFromListView4Filter = new IntentFilter(
         ListView4Fragment.MESSAGE_FROM_LISTVIEW4_INTENT);

   messageFromRadioButtonReceiver = new MessageFromRadioButtonReceiver();
   messageFromRadioButtonFilter = new IntentFilter(
         RadioButtonFragment.MESSAGE_FROM_RADIOBUTTON_INTENT);

   messageFromSpinnerReceiver = new MessageFromSpinnerReceiver();
   messageFromSpinnerFilter = new IntentFilter(
         SpinnerFragment.MESSAGE_FROM_SPINNER_INTENT);

   messageFromStylesReceiver = new MessageFromStylesReceiver();
   messageFromStylesFilter = new IntentFilter(
         StylesFragment.MESSAGE_FROM_STYLES_INTENT);

   messageFromTextViewReceiver = new MessageFromTextViewReceiver();
   messageFromTextViewFilter = new IntentFilter(
         TextViewFragment.MESSAGE_FROM_TEXTVIEW_INTENT);

   messageFromWeightGravityReceiver = new MessageFromWeightGravityReceiver();
   messageFromWeightGravityFilter = new IntentFilter(
         WeightGravityFragment.MESSAGE_FROM_WEIGHTGRAVITY_INTENT);

   messageFromEditTextReceiver = new MessageFromEditTextReceiver();
   messageFromEditTextFilter = new IntentFilter(
         EditTextFragment.MESSAGE_FROM_EDITTEXT_INTENT);

      
   // Fill list pane with sample list
   StartListofControlsFragment();
}

From source file:com.klinker.android.twitter.activities.profile_viewer.ProfilePager.java

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

    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);

    mCache = App.getInstance(this).getBitmapCache();
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);

    try {/*from w w w  . j  a  va 2  s .  c  om*/
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    if (getIntent().getBooleanExtra("from_widget", false)
            || ((settings.advanceWindowed && !getIntent().getBooleanExtra("long_click", false))
                    || !settings.advanceWindowed && getIntent().getBooleanExtra("long_click", false))) {
        setUpWindow();
    }

    setUpTheme();

    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    getFromIntent();

    setContentView(R.layout.tweet_pager);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter(getFragmentManager(), context, name, screenName,
            proPic, tweetId, isRetweet, isMyProfile);
    pager.setAdapter(mPagerAdapter);
    pager.setOffscreenPageLimit(3);

    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);

        if (!settings.showTitleStrip) {
            strip.setVisibility(View.GONE);
        }
    }

    Utils.setActionBar(context, !settings.advanceWindowed);

    // set it to the profile
    pager.setCurrentItem(1);
}

From source file:ca.appvelopers.mcgillmobile.ui.ScheduleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_schedule);
    ButterKnife.bind(this);
    App.component(this).inject(this);
    courses = new ArrayList<>();

    //TODO Use the SavedInstanceState to get the term and courses
    term = App.getDefaultTerm();//from   www  . ja  v  a 2 s  .co m

    //Title
    setTitle(term.getString(this));

    //Update the list of courses for this term
    courses = scheduleManager.getTermCourses(term);

    //Date is by default set to today
    date = LocalDate.now();

    //Check if we are in the current semester
    if (!term.equals(Term.currentTerm())) {
        //If not, find the starting date of this semester instead of using today
        for (Course course : courses) {
            if (course.getStartDate().isBefore(date)) {
                date = course.getStartDate();
            }
        }
    }

    //Render the right view based on the orientation
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        renderLandscapeView();
    } else {
        renderPortraitView();
    }

    //Check if this is the first time the user is using the app
    if (firstOpenPref.get()) {
        //Show them the walkthrough if it is
        Intent intent = new Intent(this, WalkthroughActivity.class).putExtra(Constants.FIRST_OPEN, true);
        startActivity(intent);
        //Save the fact that the walkthrough has been seen at least once
        firstOpenPref.set(false);
    }
}

From source file:com.undatech.opaque.RemoteCanvasActivity.java

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

    // TODO: Implement left-icon
    //requestWindowFeature(Window.FEATURE_LEFT_ICON);
    //setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon); 

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    handler = new Handler();
    setContentView(R.layout.canvas);//  w w  w.  j  ava  2  s .  c  o m
    canvas = (RemoteCanvas) findViewById(R.id.canvas);

    Intent i = getIntent();
    String vvFileName = startSessionFromVvFile(i);
    if (vvFileName == null) {
        android.util.Log.d(TAG, "Initializing session from connection settings.");
        connection = (ConnectionSettings) i.getSerializableExtra("com.undatech.opaque.ConnectionSettings");
        canvas.initialize(connection);
    } else {
        canvas.initialize(vvFileName, connection);
    }

    canvas.setOnKeyListener(this);
    canvas.setFocusableInTouchMode(true);
    canvas.setDrawingCacheEnabled(false);

    // If rotation is disabled, fix the orientation to the current one.
    if (!connection.isRotationEnabled()) {
        int orientation = getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    // This code detects when the soft keyboard is up and sets an appropriate visibleHeight in the canvas.
    // When the keyboard is gone, it resets visibleHeight and pans zero distance to prevent us from being
    // below the desktop image (if we scrolled all the way down when the keyboard was up).
    // TODO: Move this into a separate thread, and post the visibility changes to the handler.
    //       to avoid occupying the UI thread with this.
    final View rootView = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
    rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            Rect r = new Rect();

            rootView.getWindowVisibleDisplayFrame(r);

            // To avoid setting the visible height to a wrong value after an screen unlock event
            // (when r.bottom holds the width of the screen rather than the height due to a rotation)
            // we make sure r.top is zero (i.e. there is no notification bar and we are in full-screen mode)
            // It's a bit of a hack.
            if (r.top == 0) {
                if (canvas.myDrawable != null) {
                    canvas.setVisibleDesktopHeight(r.bottom);
                    canvas.relativePan(0, 0);
                }
            }

            // Enable/show the zoomer if the keyboard is gone, and disable/hide otherwise.
            // We detect the keyboard if more than 19% of the screen is covered.
            int offset = 0;
            int rootViewHeight = rootView.getHeight();
            if (r.bottom > rootViewHeight * 0.81) {
                offset = rootViewHeight - r.bottom;
                // Soft Kbd gone, shift the meta keys and arrows down.
                if (layoutKeys != null) {
                    layoutKeys.offsetTopAndBottom(offset);
                    keyStow.offsetTopAndBottom(offset);
                    if (prevBottomOffset != offset) {
                        setExtraKeysVisibility(View.GONE, false);
                        canvas.invalidate();
                        kbdIcon.enable();
                    }
                }
            } else {
                offset = r.bottom - rootViewHeight;
                //  Soft Kbd up, shift the meta keys and arrows up.
                if (layoutKeys != null) {
                    layoutKeys.offsetTopAndBottom(offset);
                    keyStow.offsetTopAndBottom(offset);
                    if (prevBottomOffset != offset) {
                        setExtraKeysVisibility(View.VISIBLE, true);
                        canvas.invalidate();
                        kbdIcon.hide();
                        kbdIcon.disable();
                    }
                }
            }
            setKeyStowDrawableAndVisibility();
            prevBottomOffset = offset;
        }
    });

    kbdIcon = (ZoomControls) findViewById(R.id.zoomer);
    kbdIcon.hide();
    kbdIcon.setOnZoomKeyboardClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMgr.toggleSoftInput(0, 0);
        }
    });

    // Initialize and define actions for on-screen keys.
    initializeOnScreenKeys();

    myVibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

    // Initialize map from XML IDs to input handlers.
    inputHandlerIdMap = new HashMap<Integer, InputHandler>();
    inputHandlerIdMap.put(R.id.inputMethodDirectSwipePan,
            new InputHandlerDirectSwipePan(this, canvas, myVibrator));
    inputHandlerIdMap.put(R.id.inputMethodDirectDragPan,
            new InputHandlerDirectDragPan(this, canvas, myVibrator));
    inputHandlerIdMap.put(R.id.inputMethodTouchpad, new InputHandlerTouchpad(this, canvas, myVibrator));
    inputHandlerIdMap.put(R.id.inputMethodSingleHanded, new InputHandlerSingleHanded(this, canvas, myVibrator));

    android.util.Log.e(TAG, "connection.getInputMethod(): " + connection.getInputMethod());
    inputHandler = idToInputHandler(connection.getInputMethod());
}

From source file:com.scto.filerenamer.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
    }/* w  w w .j av a 2  s  .c  o m*/
}

From source file:com.android.leanlauncher.LauncherAppState.java

public static boolean isScreenLandscape(Context context) {
    return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}

From source file:com.hplasplas.cam_capture.activitys.CamCapture.java

private void hideStatusPanelIfNeed() {

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
    }//from ww w  .ja va2 s .  c  o  m
}