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.custom.music.MusicBrowserActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Log.i(TAG, "<onConfigurationChanged>", Log.APP);
    TabWidget tabWidgetTemp = mTabHost.getTabWidget();
    View tabView;//from   w ww  .  jav  a2  s  .  co  m
    Activity activity;
    int viewStatusForTab = View.GONE;

    mOrientaiton = newConfig.orientation;
    if (mOrientaiton == Configuration.ORIENTATION_LANDSCAPE) {
        Log.i(TAG, "onConfigurationChanged--LandScape", Log.APP);
        viewStatusForTab = View.VISIBLE;
    }
    if (mService != null) {
        MusicUtils.updateNowPlaying(MusicBrowserActivity.this, mOrientaiton);
        updatePlaybackTab();
    }
    /// M: load tab which is alive only for Landscape;
    for (int i = PLAYBACK_INDEX; i < mTabCount; i++) {
        tabView = tabWidgetTemp.getChildTabViewAt(i);
        if (tabView != null) {
            tabView.setVisibility(viewStatusForTab);
        }
    }
    /// M: notify sub Activity for configuration changed;
    for (int i = 0; i < PLAYBACK_INDEX; i++) {
        activity = mActivityManager.getActivity(getStringId(i));
        if (activity != null) {
            activity.onConfigurationChanged(newConfig);
        }
    }

    if (!mHasMenukey) {
        boolean popupMenuShowing = mPopupMenuShowing;
        if (popupMenuShowing && mPopupMenu != null) {
            mPopupMenu.dismiss();
            Log.i(TAG, "changeFakeMenu:mPopupMenu.dismiss()", Log.APP);
        }
        Log.i(TAG, "changeFakeMenu:popupMenuShowing=" + popupMenuShowing, Log.APP);
        createFakeMenu();
        if (popupMenuShowing && mOverflowMenuButton != null) {
            mOverflowMenuButton.performClick();
            Log.i(TAG, "changeFakeMenu:performClick()", Log.APP);
        }
    }
    Log.i(TAG, "onConfigurationChanged >>>", Log.APP);
}

From source file:com.farmerbb.secondscreen.util.U.java

public static boolean runSizeCommand(Context context, String requestedRes) {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display disp = wm.getDefaultDisplay();
    disp.getRealMetrics(metrics);//  w  w w . ja v a  2  s .  co  m

    SharedPreferences prefMain = getPrefMain(context);
    String currentRes = " ";
    String nativeRes;

    if (prefMain.getBoolean("landscape", false))
        nativeRes = Integer.toString(prefMain.getInt("height", 0)) + "x"
                + Integer.toString(prefMain.getInt("width", 0));
    else
        nativeRes = Integer.toString(prefMain.getInt("width", 0)) + "x"
                + Integer.toString(prefMain.getInt("height", 0));

    if (prefMain.getBoolean("debug_mode", false)) {
        SharedPreferences prefCurrent = getPrefCurrent(context);
        currentRes = prefCurrent.getString("size", "reset");

        if ("reset".equals(currentRes))
            currentRes = nativeRes;
    } else {
        if ((context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
                && !prefMain.getBoolean("landscape", false))
                || (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
                        && prefMain.getBoolean("landscape", false))) {
            currentRes = Integer.toString(metrics.widthPixels) + "x" + Integer.toString(metrics.heightPixels);
        } else if ((context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
                && !prefMain.getBoolean("landscape", false))
                || (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
                        && prefMain.getBoolean("landscape", false))) {
            currentRes = Integer.toString(metrics.heightPixels) + "x" + Integer.toString(metrics.widthPixels);
        }
    }

    if (requestedRes.equals("reset"))
        requestedRes = nativeRes;

    return !requestedRes.equals(currentRes);
}

From source file:com.ruesga.rview.widget.TagEditTextView.java

private void init(Context ctx, AttributeSet attrs, int defStyleAttr) {
    mHandler = new Handler(mTagMessenger);
    mTriggerTagCreationThreshold = CREATE_CHIP_DEFAULT_DELAYED_TIMEOUT;

    Resources.Theme theme = ctx.getTheme();
    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TagEditTextView, defStyleAttr, 0);

    mReadOnly = a.getBoolean(R.styleable.TagEditTextView_readonly, false);
    mDefaultTagMode = TAG_MODE.HASH;/*w  w w  .  j a v  a2 s.c o  m*/

    // Create the internal EditText that holds the tag logic
    mTagEdit = mReadOnly ? new TagEditText(ctx, attrs, defStyleAttr) : new TagEditText(ctx, attrs);
    mTagEdit.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0));
    mTagEdit.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mTagEdit.addTextChangedListener(mEditListener);
    mTagEdit.setTextIsSelectable(false);
    mTagEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mTagEdit.setOnFocusChangeListener((v, hasFocus) -> {
        // Remove any pending message
        mHandler.removeMessages(MESSAGE_CREATE_CHIP);
    });
    mTagEdit.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {

        }
    });
    addView(mTagEdit);

    // Configure the window mode for landscape orientation, to disallow hide the
    // EditText control, and show characters instead of chips
    int orientation = ctx.getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (ctx instanceof Activity) {
            Window window = ((Activity) ctx).getWindow();
            if (window != null) {
                window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
                mTagEdit.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            }
        }
    }

    // Save the keyListener for later restore
    mEditModeKeyListener = mTagEdit.getKeyListener();

    // Initialize resources for chips
    mChipBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mChipFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mChipFgPaint.setTextSize(mTagEdit.getTextSize() * (mReadOnly ? 1 : 0.8f));
    if (CHIP_TYPEFACE != null) {
        mChipFgPaint.setTypeface(CHIP_TYPEFACE);
    }
    mChipFgPaint.setTextAlign(Paint.Align.LEFT);

    // Calculate the width area used to remove the tag in the chip
    mChipRemoveAreaWidth = (int) (mChipFgPaint.measureText(CHIP_REMOVE_TEXT) + 0.5f);

    if (ONE_PIXEL <= 0) {
        Resources res = getResources();
        ONE_PIXEL = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics());
    }

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
        case R.styleable.TagEditTextView_supportUserTags:
            setSupportsUserTags(a.getBoolean(attr, false));
            break;

        case R.styleable.TagEditTextView_chipBackgroundColor:
            mChipBackgroundColor = a.getColor(attr, mChipBackgroundColor);
            break;

        case R.styleable.TagEditTextView_chipTextColor:
            mChipFgPaint.setColor(a.getColor(attr, Color.WHITE));
            break;
        }
    }
    a.recycle();
}

From source file:co.taqat.call.ChatFragment.java

public void showKeyboardVisibleMode() {
    boolean isOrientationLandscape = getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    if (isOrientationLandscape && topBar != null) {
        //topBar.setVisibility(View.GONE);
    }//from w  w  w. jav a 2 s  .  c  om
    LinphoneActivity.instance().hideTabBar(true);
    //contactPicture.setVisibility(View.GONE);
}

From source file:com.koushikdutta.superuser.FragmentMain.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem mode = menu.add(Menu.NONE, Menu.NONE, 100, R.string.list_mode);
    mode.setTitle(pref.getBoolean("grid_mode", true) ? R.string.list_mode : R.string.grid_mode);
    mode.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    mode.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override// w ww .j  a va  2  s .  com
        public boolean onMenuItemClick(MenuItem menuItem) {

            if (pref.edit().putBoolean("grid_mode", !pref.getBoolean("grid_mode", true)).commit())
                getActivity().recreate();
            return true;
        }
    });

    if (!gridMode)
        return;

    MenuItem gridSize = menu.add(Menu.NONE, Menu.NONE, 101, R.string.grid_size);
    gridSize.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    gridSize.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {

            int sizePort = pref.getInt("grid_size_port", 3);
            int sizeLand = pref.getInt("grid_size_land", 4);

            final AlertDialog.Builder builder = new AlertDialog.Builder(context);

            View parent = LayoutInflater.from(context).inflate(R.layout.dialog_settings_grid_size, null);

            final AppCompatSeekBar seekPort = (AppCompatSeekBar) parent.findViewById(R.id.seek_port);
            seekPort.setProgress(sizePort - 3);

            final AppCompatSeekBar seekLand = (AppCompatSeekBar) parent.findViewById(R.id.seek_land);
            seekLand.setProgress(sizeLand - 3);

            builder.setView(parent);
            builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    SharedPreferences.Editor editor = pref.edit();

                    editor.putInt("grid_size_port", seekPort.getProgress() + 3);
                    editor.putInt("grid_size_land", seekLand.getProgress() + 3).apply();

                    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                        int val = seekPort.getProgress() + 3;
                        layoutManager.setSpanCount(val);
                        callback.onGridSpanChanged(type, val);

                    } else if (getResources()
                            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                        int val = seekLand.getProgress() + 3;
                        layoutManager.setSpanCount(val);
                        callback.onGridSpanChanged(type, val);
                    }
                }
            });

            builder.show();
            return true;
        }
    });
}

From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = this;

    isTablet = Utils.isTablet(this);

    // Setting the default network
    sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE);
    Editor editor = sharedPreferences.edit();
    editor.putString(Constants.NETWORK, Constants.DEFAULT_NETWORK);
    editor.commit();/*from  w  w w  .ja v  a  2s.  c om*/

    // Starting the resources monitoring service
    startService(new Intent(this, DeviceMonitorService.class));

    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    // Settings menu elements
    ArrayList<MenuListElement> listElements = new ArrayList<MenuListElement>();

    listElements.add(new MenuListElement(getResources().getString(R.string.connectMenuTitle),
            getResources().getString(R.string.connectMenuSubTitle)));
    listElements.add(new MenuListElement(getResources().getString(R.string.settingsMenuTitle),
            getResources().getString(R.string.settingsMenuSubTitle)));
    listElements.add(new MenuListElement(getResources().getString(R.string.exitMenuTitle),
            getResources().getString(R.string.exitMenuSubTitle)));

    listView = (ListView) findViewById(R.id.ListViewContent);

    MenuListAdapter adapter = new MenuListAdapter(this, R.layout.menu_list_view_row, listElements);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new ListItemClickListener());

    mainRL = (RelativeLayout) findViewById(R.id.rlContainer);
    listRL = (RelativeLayout) findViewById(R.id.listContainer);

    cpuBar = (LinearLayout) findViewById(R.id.CpuBar);
    memoryBar = (LinearLayout) findViewById(R.id.MemoryBar);

    titleBarRL = (RelativeLayout) findViewById(R.id.titleLl);

    // Adding swipe gesture listener to the top bar
    titleBarRL.setOnTouchListener(new SwipeAndClickListener());

    menuButton = (Button) findViewById(R.id.menuButton);
    menuButton.setOnTouchListener(new SwipeAndClickListener());

    infoButton = (Button) findViewById(R.id.infoButton);
    infoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlertDialog dialog = new AlertDialog(NAM4JAndroidActivity.this) {

                @Override
                public boolean dispatchTouchEvent(MotionEvent event) {
                    dismiss();
                    return false;
                }

            };

            String text = getResources().getString(R.string.aboutApp);
            String title = getResources().getString(R.string.nam4j);

            dialog.setMessage(text);
            dialog.setTitle(title);
            dialog.setCanceledOnTouchOutside(true);
            dialog.show();
        }
    });

    centerButton = (Button) findViewById(R.id.centerButton);
    centerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            centerMap();
        }
    });

    isTablet = Utils.isTablet(context);

    int[] screenSize = Utils.getScreenSize(context, getWindow());
    screenWidth = screenSize[0];
    screenHeight = screenSize[1];

    // Updates the display orientation each time the device is rotated
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        screenOrientation = Orientation.LANDSCAPE;
    } else {
        screenOrientation = Orientation.PORTRAIT;
    }

    // If the device is portrait, the menu button is displayed, the menu is
    // hidden and the swipe listener is added to the menu bar
    if (screenOrientation == Orientation.PORTRAIT) {

        menuButton.setVisibility(View.VISIBLE);

        // Adding swipe gesture listener to the top bar
        titleBarRL.setOnTouchListener(new SwipeAndClickListener());

        if (isTablet) {
            menuWidth = 0.35;
        } else {
            menuWidth = 0.6;
        }
    } else {
        // If the device is a tablet in landscape, the menu button is
        // hidden, the menu is displayed, the swipe listener is not added to
        // the menu bar and the mainRL width is set to the window's width
        // minus the menu's width
        if (isTablet) {
            menuWidth = 0.2;
            menuButton.setVisibility(View.INVISIBLE);

            RelativeLayout.LayoutParams menuListLP = (LayoutParams) mainRL.getLayoutParams();

            // Setting the main view width as the container width without
            // the menu
            menuListLP.width = (int) (screenWidth * (1 - menuWidth));
            mainRL.setLayoutParams(menuListLP);

            displaySideMenu();
        } else {
            menuWidth = 0.4;
            menuButton.setVisibility(View.VISIBLE);

            // Adding swipe gesture listener to the top bar
            titleBarRL.setOnTouchListener(new SwipeAndClickListener());
        }
    }

    // Check if the device has the Google Play Services installed and
    // updated. They are necessary to use Google Maps
    int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);

    if (code != ConnectionResult.SUCCESS) {

        showErrorDialog(code);

        System.out.println("Google Play Services error");

        FrameLayout fl = (FrameLayout) findViewById(R.id.frameId);
        fl.removeAllViews();
    } else {
        // Create a new global location parameters object
        mLocationRequest = new LocationRequest();

        // Set the update interval
        mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);

        // Use high accuracy
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        // Set the interval ceiling to one minute
        mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);

        bitmapDescriptorBlue = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);

        blueCircle = BitmapDescriptorFactory
                .fromBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.blue_circle));

        bitmapDescriptorRed = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED);

        // Create a new location client, using the enclosing class to handle
        // callbacks
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(LocationServices.API).build();

        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapview)).getMap();

        if (map != null) {

            // Set default map center and zoom on Parma
            double lat = 44.7950156;
            double lgt = 10.32547;
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lgt), 12.0f));

            // Adding listeners to the map respectively for zoom level
            // change and onTap event
            map.setOnCameraChangeListener(getCameraChangeListener());
            map.setOnMapClickListener(getOnMapClickListener());

            // Set map type as normal (i.e. not the satellite view)
            map.setMapType(com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL);

            // Hide traffic layer
            map.setTrafficEnabled(false);

            // Enable the 'my-location' layer, which continuously draws an
            // indication of a user's current location and bearing, and
            // displays UI controls that allow the interaction with the
            // location itself
            // map.setMyLocationEnabled(true);

            ml = new HashMap<String, Marker>();

            // Get file manager for config files
            fileManager = FileManager.getFileManager();
            fileManager.createFiles();

            map.setOnMarkerClickListener(this);

        } else {
            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.setMessage("The map cannot be initialized.");
            dialog.setCancelable(true);
            dialog.setPositiveButton(getResources().getString(R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    });
            dialog.show();
        }
    }
}

From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomTabLayout.java

private boolean isLandscape() {
    return getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}

From source file:com.android.calendar.selectcalendars.SelectCalendarsSimpleAdapter.java

/**
 * @param position position of the calendar item
 * @param selected whether it is selected or not
 * @return the drawable to use for this view
 *//* w  w  w  .  j a  va2  s.  co m*/
protected Drawable getBackground(int position, boolean selected) {
    int bg;
    bg = selected ? IS_SELECTED : 0;
    bg |= (position == 0 && mOrientation == Configuration.ORIENTATION_LANDSCAPE) ? IS_TOP : 0;
    bg |= position == mData.length - 1 ? IS_BOTTOM : 0;
    bg |= (position > 0 && mData[position - 1].selected) ? IS_BELOW_SELECTED : 0;
    return mRes.getDrawable(TabletCalendarItemBackgrounds.getBackgrounds()[bg]);
}

From source file:de.vanita5.twittnuker.view.ColorPickerView.java

@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {

    int width = 0;
    int height = 0;

    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);

    int widthAllowed = MeasureSpec.getSize(widthMeasureSpec);
    int heightAllowed = MeasureSpec.getSize(heightMeasureSpec);

    widthAllowed = chooseWidth(widthMode, widthAllowed);
    heightAllowed = chooseHeight(heightMode, heightAllowed);

    if (!mShowAlphaPanel) {

        height = (int) (widthAllowed - PANEL_SPACING - HUE_PANEL_WIDTH);

        // If calculated height (based on the width) is more than the
        // allowed height.
        if (height > heightAllowed
                || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            height = heightAllowed;//from  ww w  .  j  a v a  2 s .  c om
            width = (int) (height + PANEL_SPACING + HUE_PANEL_WIDTH);
        } else {
            width = widthAllowed;
        }
    } else {

        width = (int) (heightAllowed - ALPHA_PANEL_HEIGHT + HUE_PANEL_WIDTH);

        if (width > widthAllowed) {
            width = widthAllowed;
            height = (int) (widthAllowed - HUE_PANEL_WIDTH + ALPHA_PANEL_HEIGHT);
        } else {
            height = heightAllowed;
        }

    }

    setMeasuredDimension(width, height);
}

From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java

private void updateDrawerWidth() {
    Log.d(TAG, "updateDrawerWidth()");

    int viewportWidth = getContext().getResources().getDisplayMetrics().widthPixels;
    int viewportHeight = getContext().getResources().getDisplayMetrics().heightPixels;

    //Minus the width of the vertical nav bar
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        int navigationBarWidthResId = getResources().getIdentifier("navigation_bar_width", "dimen", "android");
        if (navigationBarWidthResId > 0) {
            viewportWidth -= getResources().getDimensionPixelSize(navigationBarWidthResId);
        }//  www.j a va2 s .c  o  m
    }

    int viewportMin = Math.min(viewportWidth, viewportHeight);

    //App bar size
    TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true);
    int actionBarSize = TypedValue.complexToDimensionPixelSize(typedValue.data,
            getResources().getDisplayMetrics());

    int width = viewportMin - actionBarSize;

    getLayoutParams().width = Math.min(width, drawerMaxWidth);

    updateProfileSpacing();
}