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:ca.frozen.rpicameraviewer.activities.VideoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_video, container, false);

    // configure the name
    nameView = (TextView) view.findViewById(R.id.video_name);
    nameView.setText(camera.name);// w ww.ja  v a  2s. c  o  m

    // initialize the message
    messageView = (TextView) view.findViewById(R.id.video_message);
    messageView.setTextColor(App.getClr(R.color.good_text));
    messageView.setText(R.string.initializing_video);

    // set the texture listener
    textureView = (ZoomPanTextureView) view.findViewById(R.id.video_surface);
    textureView.setSurfaceTextureListener(this);
    textureView.setZoomRange(MIN_ZOOM, MAX_ZOOM);
    textureView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent e) {
            switch (e.getAction()) {
            case MotionEvent.ACTION_DOWN:
                stopFadeOutTimer();
                break;
            case MotionEvent.ACTION_UP:
                if (e.getPointerCount() == 1) {
                    startFadeOutTimer(false);
                }
                break;
            }
            return false;
        }
    });

    // create the snapshot button
    snapshotButton = (Button) view.findViewById(R.id.video_snapshot);
    snapshotButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int check = ContextCompat.checkSelfPermission(getActivity(),
                    Manifest.permission.WRITE_EXTERNAL_STORAGE);
            if (check != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(getActivity(),
                        new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                        REQUEST_WRITE_EXTERNAL_STORAGE);
            } else {
                takeSnapshot();
            }
        }
    });

    // move the snapshot button over to account for the navigation bar
    if (fullScreen) {
        float scale = getContext().getResources().getDisplayMetrics().density;
        int margin = (int) (5 * scale + 0.5f);
        int extra = Utils.getNavigationBarHeight(getContext(), Configuration.ORIENTATION_LANDSCAPE);
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) snapshotButton.getLayoutParams();
        lp.setMargins(margin, margin, margin + extra, margin);
    }

    return view;
}

From source file:aws.apps.underthehood.Main.java

private void mLockScreenRotation() {
    // Stop the screen orientation changing during an event
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;/*from  w ww. java  2  s .  com*/
    case Configuration.ORIENTATION_LANDSCAPE:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    }
}

From source file:com.flipzu.flipzu.Listings.java

private void initGATracker() {
    /* get analytics singleton */
    tracker = GoogleAnalyticsTracker.getInstance();

    /* start tracker. Dispatch every 30 seconds. */
    tracker.startNewSession("UA-20341887-1", 30, getApplicationContext());

    /* debug GA */
    tracker.setDebug(false);//from w  w  w  . ja va  2  s . c  o  m
    tracker.setDryRun(false);

    // Determine the screen orientation and set it in a custom variable.
    String orientation = "unknown";
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        orientation = "landscape";
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        orientation = "portrait";
        break;
    }
    tracker.setCustomVar(3, "Screen Orientation", orientation, 2);
}

From source file:com.thomasokken.free42.Free42Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;

    int init_mode;
    IntHolder version = new IntHolder();
    try {//w w w .  j  ava  2 s  .c  o m
        stateFileInputStream = openFileInput("state");
    } catch (FileNotFoundException e) {
        stateFileInputStream = null;
    }
    if (stateFileInputStream != null) {
        if (read_shell_state(version))
            init_mode = 1;
        else {
            init_shell_state(-1);
            init_mode = 2;
        }
    } else {
        init_shell_state(-1);
        init_mode = 0;
    }
    setAlwaysRepaintFullDisplay(alwaysRepaintFullDisplay);
    if (alwaysOn)
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    if (style == 1)
        setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
    else if (style == 2) {
        try {
            Method m = View.class.getMethod("setSystemUiVisibility", int.class);
            m.invoke(getWindow().getDecorView(), PreferencesDialog.immersiveModeFlags);
        } catch (Exception e) {
        }
    }

    Configuration conf = getResources().getConfiguration();
    orientation = conf.orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0;

    mainHandler = new Handler();
    calcView = new CalcView(this);
    setContentView(calcView);
    printView = new PrintView(this);
    printScrollView = new ScrollView(this);
    printScrollView.setBackgroundColor(PRINT_BACKGROUND_COLOR);
    printScrollView.addView(printView);

    skin = null;
    if (skinName[orientation].length() == 0 && externalSkinName[orientation].length() > 0) {
        try {
            skin = new SkinLayout(externalSkinName[orientation], skinSmoothing[orientation],
                    displaySmoothing[orientation]);
        } catch (IllegalArgumentException e) {
        }
    }
    if (skin == null) {
        try {
            skin = new SkinLayout(skinName[orientation], skinSmoothing[orientation],
                    displaySmoothing[orientation]);
        } catch (IllegalArgumentException e) {
        }
    }
    if (skin == null) {
        try {
            skin = new SkinLayout(builtinSkinNames[0], skinSmoothing[orientation],
                    displaySmoothing[orientation]);
        } catch (IllegalArgumentException e) {
            // This one should never fail; we're loading a built-in skin.
        }
    }

    nativeInit();
    core_init(init_mode, version.value);
    if (stateFileInputStream != null) {
        try {
            stateFileInputStream.close();
        } catch (IOException e) {
        }
        stateFileInputStream = null;
    }

    lowBatteryReceiver = new BroadcastReceiver() {
        public void onReceive(Context ctx, Intent intent) {
            low_battery = intent.getAction().equals(Intent.ACTION_BATTERY_LOW);
            Rect inval = skin.update_annunciators(-1, -1, -1, -1, low_battery ? 1 : 0, -1, -1);
            if (inval != null)
                calcView.postInvalidateScaled(inval.left, inval.top, inval.right, inval.bottom);
        }
    };
    IntentFilter iff = new IntentFilter();
    iff.addAction(Intent.ACTION_BATTERY_LOW);
    iff.addAction(Intent.ACTION_BATTERY_OKAY);
    registerReceiver(lowBatteryReceiver, iff);

    if (preferredOrientation != this.getRequestedOrientation())
        setRequestedOrientation(preferredOrientation);

    soundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
    int[] soundResourceIds = { R.raw.tone0, R.raw.tone1, R.raw.tone2, R.raw.tone3, R.raw.tone4, R.raw.tone5,
            R.raw.tone6, R.raw.tone7, R.raw.tone8, R.raw.tone9, R.raw.squeak, R.raw.click };
    soundIds = new int[soundResourceIds.length];
    for (int i = 0; i < soundResourceIds.length; i++)
        soundIds[i] = soundPool.load(this, soundResourceIds[i], 1);
}

From source file:com.dm.material.dashboard.candybar.fragments.RequestFragment.java

private void resetRecyclerViewPadding(int orientation) {
    if (mRecyclerView == null)
        return;/*from w  ww .  ja v  a  2  s  .  c  o m*/

    int padding = 0;
    boolean tabletMode = getActivity().getResources().getBoolean(R.bool.tablet_mode);
    if (tabletMode || orientation == Configuration.ORIENTATION_LANDSCAPE) {
        padding = getActivity().getResources().getDimensionPixelSize(R.dimen.content_padding);
    }

    int size = getActivity().getResources().getDimensionPixelSize(R.dimen.fab_size);
    int marginGlobal = getActivity().getResources().getDimensionPixelSize(R.dimen.fab_margin_global);

    mRecyclerView.setPadding(padding, padding, 0, size + (marginGlobal * 2));
}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Get orientation of device/*from   w ww .j a v a 2  s  . c o  m*/
 */
public int getOrientation() {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);

    if (metrics.widthPixels < metrics.heightPixels) {
        return Configuration.ORIENTATION_PORTRAIT;
    } else {
        return Configuration.ORIENTATION_LANDSCAPE;
    }
}

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        for (int i = 0, count = fm.getBackStackEntryCount(); i < count; i++) {
            fm.popBackStackImmediate();/*from   w  w w .j  ava2 s  .  c o m*/
        }
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

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

public void StartRegexFragment() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {
        Fragment regexFragment = (Fragment) fm.findFragmentById(R.id.detail_replacer);
        regexFragment = RegexFragment.newInstance("Regex");

        FragmentTransaction transaction = fm.beginTransaction().replace(R.id.detail_replacer, regexFragment);
        transaction.addToBackStack(null);
        transaction.commit();//  ww w.ja  v a  2 s. c  o m
    } else {
        RegexFragment regexFragment = RegexFragment.newInstance("Regex");
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction()
                .replace(MainActivity.validationListView.getId(), regexFragment);
        transaction.addToBackStack(null);
        transaction.commit();
    }
}

From source file:com.near.chimerarevo.activities.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if ((newConfig.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
            isLandscapeLarge = true;//from   ww w  . j  a v  a  2 s  . com
        else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
            isLandscapeLarge = false;
    }
    if (mDrawerLayout != null)
        mDrawerToggle.onConfigurationChanged(newConfig);
}

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

 public void StartRegexFragment() {
   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {// w w w .j a  va2s.c o  m
      Fragment regexFragment = (Fragment) fm
            .findFragmentById(R.id.detail_replacer);
      regexFragment = RegexFragment.newInstance("Regex");

      FragmentTransaction transaction = fm.beginTransaction()
         .replace(R.id.detail_replacer, regexFragment);
      transaction.addToBackStack(null);
      transaction.commit();
   } else {
      RegexFragment regexFragment = RegexFragment
            .newInstance("Regex");
      FragmentTransaction transaction = getSupportFragmentManager()
         .beginTransaction()
         .replace(MainActivity.validationListView.getId(), regexFragment);
      transaction.addToBackStack(null);
      transaction.commit();
   }
}