Example usage for android.content.res Configuration ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int ORIENTATION_PORTRAIT

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

Click Source Link

Document

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

Usage

From source file:org.wheelmap.android.activity.MainMultiPaneActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    ActionBar bar = getSupportActionBar();
    if (bar == null) {
        return true;
    }/*from w  ww  . ja va  2 s.  c o  m*/

    LayoutInflater inflater = LayoutInflater.from(this);
    View customView = inflater.inflate(R.layout.actionbar_tablet, null);
    bar.setCustomView(customView, new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.END));

    boolean isPortraitMode = getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortraitMode) {

        ImageView addItem = (ImageView) customView.findViewById(R.id.menu_new_poi);
        addItem.setVisibility(View.VISIBLE);
        OnClickListener addClickListener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                createNewPoi();
            }
        };
        addItem.setOnClickListener(addClickListener);

        LinearLayout l = (LinearLayout) findViewById(R.id.actionbar_bottom);
        for (int i = 0; i < l.getChildCount(); i++) {
            l.getChildAt(i).setOnTouchListener(new PressSelector());
        }

        bar.setDisplayShowCustomEnabled(true);
        View v = findViewById(R.id.menu_filter);
        MapActivityUtils.setAccessFilterOptionDrawable(this, null, v);

        View filterWc = findViewById(R.id.menu_wc);
        MapActivityUtils.setWcFilterOptionsDrawable(this, null, filterWc);

        UserCredentials credentials = new UserCredentials(getApplicationContext());
        ImageView image = (ImageView) findViewById(R.id.menu_login);
        image.setImageResource(
                credentials.isLoggedIn() ? R.drawable.start_icon_logged_in : R.drawable.start_icon_login);
    } else {
        MenuInflater inflaterMenu = getMenuInflater();
        inflaterMenu.inflate(R.menu.ab_multi_activity, menu);
        MenuItem item = menu.findItem(R.id.menu_filter);
        MapActivityUtils.setAccessFilterOptionDrawable(this, item, null);
        item = menu.findItem(R.id.menu_wc);
        MapActivityUtils.setWcFilterOptionsDrawable(this, item, null);

    }

    if (mapModeType == MapModeType.MAP_MODE_ENGAGE) {
        MenuItem itemFilterWheelChairs = menu.findItem(R.id.menu_filter);
        itemFilterWheelChairs.setEnabled(false);
        //TODO Disable it - doesn't work yet
    }

    ImageView listMapToggle = (ImageView) findViewById(R.id.switch_view);
    if (listMapToggle != null) {
        listMapToggle.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                toggleMovableResize();
            }
        });
    }

    return true;
}

From source file:com.wecandoit.jinju_0_0_4.jActivity_YoutubeSearchList.java

/**
 * Sets up the layout programatically for the three different states.
 * Portrait, landscape or fullscreen+landscape. This has to be done
 * programmatically because we handle the orientation changes ourselves in
 * order to get fluent fullscreen transitions, so the xml layout resources
 * do not get reloaded./*w  ww.j  a va 2  s .  c  om*/
 */
private void layout() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    mVideoListFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
    mVideoListFragment.setLabelVisibility(isPortrait);
    mCloseButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);
    //mFavoriteButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);
    //mDownloadButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);

    if (isFullscreen) {
        mVideoBox.setTranslationY(0); // Reset any translation that was
        // applied in portrait.
        setLayoutSize(mVideoFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(mVideoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT);
    } else if (isPortrait) {
        setLayoutSize(mVideoListFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(mVideoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM);
        setLayoutSize(mVideoFragment.getView(), MATCH_PARENT, WRAP_CONTENT);
    } else {
        mVideoBox.setTranslationY(0); // Reset any translation that was
        // applied in portrait.
        int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp);
        setLayoutSize(mVideoListFragment.getView(), screenWidth / 4, MATCH_PARENT);
        int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP);
        setLayoutSize(mVideoFragment.getView(), videoWidth, WRAP_CONTENT);
        setLayoutSizeAndGravity(mVideoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    }
}

From source file:org.namelessrom.devicecontrol.modules.device.SensorActivity.java

@Override
protected void onResume() {
    super.onResume();

    // lock current orientation
    switch (getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_PORTRAIT: {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;/*  ww w  . j a  va2s .c om*/
    }
    case Configuration.ORIENTATION_LANDSCAPE: {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    }
    }

    // register all sensors
    for (final BaseSensor sensor : mSensorList) {
        sensor.onResume();
    }
}

From source file:org.namelessrom.devicecontrol.device.SensorActivity.java

@Override
protected void onResume() {
    super.onResume();
    // do not allow swiping to open menu with viewpagers
    MainActivity.setSwipeOnContent(false);

    // lock current orientation
    switch (getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_PORTRAIT: {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;//w  w  w.  j  av  a2  s.c om
    }
    case Configuration.ORIENTATION_LANDSCAPE: {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    }
    }

    // register all sensors
    for (final BaseSensor sensor : mSensorList) {
        sensor.onResume();
    }
}

From source file:no.barentswatch.fiskinfo.BaseActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    int orientation = newConfig.orientation;

    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        actionBar.setSelectedNavigationItem(adapter.getCount());
        // do what you want when user is in LANDSCAPE
        break;//from   w  w w . j  a  va2  s  . c om

    case Configuration.ORIENTATION_PORTRAIT:
        actionBar.setSelectedNavigationItem(adapter.getCount());
        // do what you want when user is in PORTRAIT
        break;
    }
}

From source file:ca.frozen.curlingtv.classes.Utils.java

public static int getNavigationBarHeight(Context context, int orientation) {
    Resources resources = context.getResources();
    String name = orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height"
            : "navigation_bar_height_landscape";
    int id = resources.getIdentifier(name, "dimen", "android");
    return (id > 0) ? resources.getDimensionPixelSize(id) : 0;
}

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;/*from  www.j a  v  a 2s  .  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:cz.metaverse.android.bilingualreader.helper.BookPanelOnTouchListener.java

/**
 * The entry method for any touch-related event.
 * @param view The WebView where the swipe took place
 * @param event The MotionEvent of the swipe
 *//*from  ww  w .jav  a2s.  c  o m*/
@Override
public boolean onTouch(View view, MotionEvent event) {
    // Provide data to the GestureDetector.
    gestureDetector.onTouchEvent(event);

    /*
     * Handle Double Tap Swipe in real time.
     *  This handling isn't in onDoubleTapEvent() because that method has a limit how many times
     *  it gets called after which it isn't called at all until the user lifts the finger in which
     *  case it gets called one last time. That is not workable for on-the-fly resizing of panels.
     */
    if (isDoubleTapSwipe) {
        float absDiffX = Math.abs(doubleTapOriginX - event.getX());
        float absDiffY = Math.abs(doubleTapOriginY - event.getY());

        // If the swipe was over predefined threshold value high and it was higher than wider,
        // or if the swipe was over predefined threshold value wide and it was wider than higher.
        if (doubleTapSwipeEscapedBounds ||
        // Bounds for PORTRAIT orientation.
                (absDiffY > threshold_swipe_up_or_down_change_panel_size_px && absDiffY > absDiffX
                        && doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT)
                ||
                // Bounds for LANDSCAPE orientation.
                (absDiffX > threshold_swipe_left_right_change_panel_size_px && absDiffX > absDiffY
                        && doubleTapSwipe_orientation != Configuration.ORIENTATION_PORTRAIT)) {

            if (!doubleTapSwipeEscapedBounds) {
                // This is the first time doubleTapSwipe escaped it's bounds
                // - we're officially in the set-panels-size mode.
                doubleTapSwipeEscapedBounds = true;

                // Find out and save the relevant dimensions of our view/display
                Window window = activity.getWindow();

                if (doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) {
                    doubleTapSwipe_contentStartsAtHeight = window.findViewById(Window.ID_ANDROID_CONTENT)
                            .getTop();
                    doubleTapSwipe_viewHeight = window.getDecorView().getHeight();
                } else {
                    doubleTapSwipe_contentStartsAtHeight = window.findViewById(Window.ID_ANDROID_CONTENT)
                            .getLeft();
                    doubleTapSwipe_viewHeight = window.getDecorView().getWidth();
                }
            }

            // Compute the panels weight
            float useCoordinate = (doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT)
                    ? event.getRawY()
                    : event.getRawX();

            newPanelsWeight = (useCoordinate - doubleTapSwipe_contentStartsAtHeight)
                    / (doubleTapSwipe_viewHeight - doubleTapSwipe_contentStartsAtHeight);

            // If the weight is close to 0.5, let it stick to it.
            if (Math.abs(0.5 - newPanelsWeight) < PANEL_RESIZE_SNAP_WEIGHT_AROUND_HALF) {
                newPanelsWeight = 0.5f;
            }

            // Assure that the weight is between the allowed minimum and maximum.
            newPanelsWeight = Func.minMaxRange(Func.PANEL_WEIGHT_MIN, newPanelsWeight, Func.PANEL_WEIGHT_MAX);

            // Change relative panel size on the fly.
            governor.changePanelsWeight(newPanelsWeight);

            //Log.v(LOG, "[" + panelPosition + "] doubleTapSwipe " + newPanelsWeight);
            //+ " = (" + event.getRawY() + " - " + contentViewTop + ") / " + (height - contentViewTop));
        }
    }

    /*
     * Handle ACTION_UP event for scrolling, because onScroll (almost?) never gets
     * called with the last MotionEvent.ACTION_UP.
     * Don't forget to mirror any changes made here in the onScroll() method as well, to be safe.
     */
    if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) {
        Log.d(LOG, "[" + panelPosition + "] OnTouchListener --> onTouch ACTION_UP - scrollY: "
                + webView.getScrollY());

        // Only if it's not DoubleTapSwipe, that is handled separately.
        if (!isDoubleTapSwipe) {
            // Evaluate if the scroll that has just ended constitutes some gesture.
            handleScrollEnd(event);
        }
    }

    // Modify the event so that it is passed on in a state where the X coordinate hasn't changed at all.
    // This prevents the "over scroll glow effect" on pages that have some (hidden) horizontal scroll.
    //  -- Disabled because it causes the wrong scroll position to be loaded after opening a page
    //     sometimes (but not every time), for some unknown reason.
    //event.setLocation(touchOriginX, event.getY());

    view.performClick(); // Android system mandates we pass the baton to the onClick listener now.

    return view.onTouchEvent(event);
}

From source file:cc.echonet.coolmicapp.MainActivity.java

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

    setContentView(R.layout.home);//from  w w  w.  j a  v a 2s . c  om
    timerValue = (TextView) findViewById(R.id.timerValue);
    BroadcastReceiver mPowerKeyReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String strAction = intent.getAction();
            if (strAction.equals(Intent.ACTION_SCREEN_OFF) || strAction.equals(Intent.ACTION_SCREEN_ON)
                    || strAction.equals(Intent.ACTION_USER_PRESENT)) {
                if (isThreadOn) {
                    RedFlashLight();
                }
            }
        }
    };
    final IntentFilter theFilter = new IntentFilter();
    /** System Defined Broadcast */
    theFilter.addAction(Intent.ACTION_SCREEN_ON);
    theFilter.addAction(Intent.ACTION_SCREEN_OFF);
    theFilter.addAction(Intent.ACTION_USER_PRESENT);

    getApplicationContext().registerReceiver(mPowerKeyReceiver, theFilter);

    imageView1 = (ImageView) findViewById(R.id.imageView1);

    Log.v("onCreate", (imageView1 == null ? "iv null" : "iv ok"));

    android.view.ViewGroup.LayoutParams layoutParams = imageView1.getLayoutParams();

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        layoutParams.height = 400;
    } else {
        layoutParams.height = 180;
    }

    imageView1.setLayoutParams(layoutParams);

    myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    animation.setDuration(500); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE);
    start_button = (Button) findViewById(R.id.start_recording_button);
    stop_button = (Button) findViewById(R.id.stop_recording_button);
    buttonColor = start_button.getBackground();
    logArea = (TextView) findViewById(R.id.log_area);
    logArea.setMovementMethod(new ScrollingMovementMethod());

    coolmic = new CoolMic(this, "default");

    if (Wrapper.getState() == Wrapper.WrapperInitializationStatus.WRAPPER_UNINITIALIZED) {
        if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) {
            Log.d("WrapperInit", Wrapper.getInitException().toString());
            Toast.makeText(getApplicationContext(),
                    "Could not initialize native components :( Blocking controls!", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getApplicationContext(), "Native components initialized!", Toast.LENGTH_SHORT)
                    .show();
        }
    } else if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) {
        Toast.makeText(getApplicationContext(),
                "Previous problem detected with native components :( Blocking controls!", Toast.LENGTH_SHORT)
                .show();
    } else if (Wrapper.init() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) {
        Toast.makeText(getApplicationContext(), "Native components in unknown state!", Toast.LENGTH_SHORT)
                .show();
    }

    txtListeners = (TextView) findViewById(R.id.txtListeners);
    IntentFilter mStatusIntentFilter = new IntentFilter(Constants.BROADCAST_STREAM_STATS_SERVICE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mStreamStatsReceiver, mStatusIntentFilter);
}

From source file:uk.ac.horizon.artcodes.scanner.ScannerActivity.java

private void startScanning() {
    if (experience != null) {
        Log.i("a", "Start Scanning");
        detector = this.getNewDetector(experience);
        detector.setCallback(new DetectorCallback() {
            @Override/*  www . ja  v  a2s .  c om*/
            public void detectionStart(final int margin) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Log.i("cameraErrorView", "Getting camera error view...");
                        View errorView = findViewById(R.id.cameraError);
                        if (errorView != null) {
                            Log.i("cameraErrorView", "Setting camera error view to GONE");
                            errorView.setVisibility(View.GONE);
                        }
                        progressBar.setVisibility(View.VISIBLE);
                        if (getResources()
                                .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                            View topView = findViewById(R.id.topView);
                            if (topView != null) {
                                topView.setLayoutParams(new LinearLayout.LayoutParams(
                                        ViewGroup.LayoutParams.MATCH_PARENT, margin));
                            }
                            View bottomView = findViewById(R.id.bottomView);
                            if (bottomView != null) {
                                bottomView.setLayoutParams(new LinearLayout.LayoutParams(
                                        ViewGroup.LayoutParams.MATCH_PARENT, margin));
                            }
                        } else {
                            View topView = findViewById(R.id.topView);
                            if (topView != null) {
                                topView.setLayoutParams(new LinearLayout.LayoutParams(margin,
                                        ViewGroup.LayoutParams.MATCH_PARENT));
                            }
                            View bottomView = findViewById(R.id.bottomView);
                            if (bottomView != null) {
                                bottomView.setLayoutParams(new LinearLayout.LayoutParams(margin,
                                        ViewGroup.LayoutParams.MATCH_PARENT));
                            }
                        }
                    }
                });
            }
        });
        detector.setOverlay((ImageView) findViewById(R.id.overlay));
        if (getSupportActionBar() != null && experience.getScanScreenTextTitle() == null) {
            getSupportActionBar().setDisplayShowTitleEnabled(true);
            getSupportActionBar().setTitle(experience.getName());
        }
        cameraView.setDetector(detector, experience);

        if (cameraView.deviceNeedsTapToFocus()) {
            // tap to focus
            View v = findViewById(R.id.thumbnailImageLayout);
            if (v != null) {
                v.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        setFocusTextVisible(false);
                        cameraView.focus(new Runnable() {
                            @Override
                            public void run() {
                                setFocusTextVisible(true);
                            }
                        });

                    }
                });
            }
            setFocusTextVisible(true);
        }
    } else {
        cameraView.setDetector(null, null);
    }
}