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.jaspersoft.android.jaspermobile.activities.share.AnnotationActivity.java

private void lockScreenOrientation() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else/*from  w w  w . j a v a2s.c  o  m*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

From source file:com.klinker.android.twitter.activities.compose.Compose.java

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

    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

    countHandler = new Handler();

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

    try {//from   w  w  w  .  jav a2  s . c  o  m
        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
    }

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

    currentAccount = sharedPrefs.getInt("current_account", 1);

    buildGoogleApiClient();

    Utils.setUpPopupTheme(context, settings);
    setUpWindow();
    setUpLayout();
    setUpActionBar();
    setUpReplyText();

    if (reply.getText().toString().contains(" RT @") || reply.getText().toString().contains("/status/")) {
        reply.setSelection(0);
    }

    if (getIntent().getBooleanExtra("start_attach", false)) {
        attachButton.performClick();
        //overflow.performClick();
    }

    if (notiId != 0) {
        HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to);
        replyTo.setText(replyText);
        TextUtils.linkifyText(context, replyTo, null, true, "", true);
        replyTo.setVisibility(View.VISIBLE);
    }

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            String text = reply.getText().toString();

            try {
                if (!android.text.TextUtils.isEmpty(text)
                        && !(text.startsWith(" RT @") || text.contains("/status/"))) {
                    //text = text.replaceAll("  ", " ");

                    reply.setText(text);
                    reply.setSelection(text.length());

                    if (!text.endsWith(" ")) {
                        reply.append(" ");
                    }
                }
            } catch (Exception e) {

            }
        }
    }, 250);
}

From source file:com.liato.bankdroid.Helpers.java

public static String getAppUserAgentString(Context context) {
    if (USER_AGENT != null)
        return USER_AGENT;
    String appName = context.getResources().getString(R.string.app_name);
    String appVersion = "";
    int height = 0;
    int width = 0;
    DisplayMetrics display = context.getResources().getDisplayMetrics();
    Configuration config = context.getResources().getConfiguration();

    // Always send screen dimension for portrait mode
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        height = display.widthPixels;//  www  .j a  v  a2 s  .c o  m
        width = display.heightPixels;
    } else {
        width = display.widthPixels;
        height = display.heightPixels;
    }

    try {
        PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        appVersion = packageInfo.versionName;
    } catch (PackageManager.NameNotFoundException ignore) {
        // this should never happen, we are looking up ourself
    }

    // Tries to conform to default android UA string without the Safari / webkit noise, plus adds the screen dimensions
    USER_AGENT = String.format(
            "%1$s/%2$s (%3$s; U; Android %4$s; %5$s-%6$s; %12$s Build/%7$s; %8$s) %9$dX%10$d %11$s %12$s",
            appName, appVersion, System.getProperty("os.name", "Linux"), Build.VERSION.RELEASE,
            config.locale.getLanguage().toLowerCase(), config.locale.getCountry().toLowerCase(), Build.ID,
            Build.BRAND, width, height, Build.MANUFACTURER, Build.MODEL);
    return USER_AGENT;
}

From source file:com.klinker.android.twitter.ui.compose.Compose.java

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

    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

    countHandler = new Handler();

    settings = AppSettings.getInstance(this);
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);

    try {/*  ww  w  .  j a va 2s  . c o m*/
        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
    }

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

    currentAccount = sharedPrefs.getInt("current_account", 1);

    mLocationClient = new LocationClient(context, this, this);
    mLocationClient.connect();

    Utils.setUpPopupTheme(context, settings);
    setUpWindow();
    setUpLayout();
    setUpActionBar();
    setUpReplyText();

    if (reply.getText().toString().contains(" RT @")) {
        reply.setSelection(0);
    }

    //Utils.setActionBar(context, false);

    if (getIntent().getBooleanExtra("start_attach", false)) {
        attachButton.performClick();
        //overflow.performClick();
    }

    if (notiId != 0) {
        HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to);
        replyTo.setText(replyText);
        TextUtils.linkifyText(context, replyTo, null, true, "", true);
        replyTo.setVisibility(View.VISIBLE);
    }

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            String text = reply.getText().toString();

            try {
                if (!android.text.TextUtils.isEmpty(text) && !text.startsWith(" RT @")) {
                    //text = text.replaceAll("  ", " ");

                    reply.setText(text);
                    reply.setSelection(text.length());

                    if (!text.endsWith(" ")) {
                        reply.append(" ");
                    }
                }
            } catch (Exception e) {

            }
        }
    }, 250);
}

From source file:com.gelakinetic.mtgfam.fragments.LifeCounterFragment.java

/**
 * Get UI element references, set onClickListeners for the toolbar, clear the measurement data and attach a
 * ViewTreeObserver to measure the UI when it is drawn. Get the life/poison mode from the savedInstanceState if the
 * fragment is persisting. Save the current brightness. Players are not added here.
 *
 * @param inflater           The LayoutInflater object that can be used to inflate any views in the fragment,
 * @param container          If non-null, this is the parent view that the fragment's UI should be attached to. The
 *                           fragment should not add the view itself, but this can be used to generate the
 *                           LayoutParams of the view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous saved state as given
 *                           here.//from   ww w.  jav a  2s . c o m
 * @return The inflated view
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mListSizeWidth = -1;
    mListSizeHeight = -1;

    View myFragmentView = inflater.inflate(R.layout.life_counter_frag, container, false);
    assert myFragmentView != null;
    mGridLayout = myFragmentView.findViewById(R.id.playerList);

    mDisplayMode = Integer.parseInt(PreferenceAdapter.getDisplayMode(getContext()));

    mCommanderPlayerView = myFragmentView.findViewById(R.id.commander_player);

    if (null != myFragmentView.findViewById(R.id.playerScrollView_horz)) {
        mScrollView = myFragmentView.findViewById(R.id.playerScrollView_horz);
    } else {
        mScrollView = myFragmentView.findViewById(R.id.playerScrollView_vert);
    }
    ViewTreeObserver viewTreeObserver = mScrollView.getViewTreeObserver();
    assert viewTreeObserver != null;
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            if (isVisible()) {
                boolean changed = false;
                if (mListSizeHeight < mScrollView.getHeight()) {
                    mListSizeHeight = mScrollView.getHeight();
                    changed = true;
                }
                if (mListSizeWidth < mScrollView.getWidth()) {
                    mListSizeWidth = mScrollView.getWidth();
                    changed = true;
                }
                if (changed) {
                    if (getActivity().getResources()
                            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                        if (mDisplayMode == DISPLAY_COMMANDER) {
                            /* Conveniently takes care of re-adding the sized views in the right number of rows */
                            changeDisplayMode(false);
                        }
                    }
                    for (LcPlayer player : mPlayers) {
                        player.setSize(mListSizeWidth, mListSizeHeight, mDisplayMode,
                                getActivity().getResources()
                                        .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
                    }
                }
            }
        }
    });

    mPoisonButton = myFragmentView.findViewById(R.id.poison_button);
    mPoisonButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            setStatDisplaying(STAT_POISON);
        }
    });

    mLifeButton = myFragmentView.findViewById(R.id.life_button);
    mLifeButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            setStatDisplaying(STAT_LIFE);
        }
    });

    mCommanderButton = myFragmentView.findViewById(R.id.commander_button);
    mCommanderButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            setStatDisplaying(STAT_COMMANDER);
        }
    });

    myFragmentView.findViewById(R.id.reset_button).setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            showDialog(LifeCounterDialogFragment.DIALOG_RESET_CONFIRM);
        }
    });

    if (savedInstanceState != null) {
        mStatDisplaying = savedInstanceState.getInt(DISPLAY_MODE, STAT_LIFE);
    }

    return myFragmentView;
}

From source file:com.duckduckgo.mobile.android.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from   w w w. j  av a  2 s.  c o m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.TOP | Gravity.CENTER);
    textView.setTextAppearance(context, R.style.TabTitle);
    textView.setHeight((int) getResources().getDimension(R.dimen.actionbar_tab_height2));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    int halfPadding = (int) (padding * 0.5);
    //textView.setPadding(padding, padding, padding, padding);
    textView.setPadding(padding, halfPadding, padding, padding);

    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    int width;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
    } else {
        width = display.getWidth();
    }

    if (width > getResources().getDimension(R.dimen.tab_small)
            || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        textView.setWidth(width / mViewPager.getAdapter().getCount());
    }

    return textView;
}

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

 private void ReturnToSampleList() {
   ClearMessageBox();//from   w w  w  .  java  2  s  .c  om
   PopFragmentBackStack();

   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {
      StartSampleListFragment();
      StartEmptyFragment();
   } else {
      SampleListFragment sampleListFragment = SampleListFragment
            .newInstance("List");
      getSupportFragmentManager()
            .beginTransaction()
            .replace(MainActivity.sampleListView.getId(),
                  sampleListFragment).commit();
   }
}

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

private void ReturnToSampleList() {
    ClearMessageBox();//  ww w .j  a  v  a 2s . co m
    PopFragmentBackStack();

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {
        StartSampleListFragment();
        StartEmptyFragment();
    } else {
        SampleListFragment sampleListFragment = SampleListFragment.newInstance("List");
        getSupportFragmentManager().beginTransaction()
                .replace(MainActivity.sampleListView.getId(), sampleListFragment).commit();
    }
}

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

public void StartInputTypeFragment() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {
        Fragment inputTypeFragment = (Fragment) fm.findFragmentById(R.id.detail_replacer);
        inputTypeFragment = InputTypeFragment.newInstance("InputType");

        FragmentTransaction transaction = fm.beginTransaction().replace(R.id.detail_replacer,
                inputTypeFragment);/*from   w  w w  .  j a v a  2 s  . c o m*/
        transaction.addToBackStack(null);
        transaction.commit();
    } else {
        InputTypeFragment inputTypeFragment = InputTypeFragment.newInstance("InputType");
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction()
                .replace(MainActivity.validationListView.getId(), inputTypeFragment);
        transaction.addToBackStack(null);
        transaction.commit();
    }
}

From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java

private void initializeLegend(final TextView legend) {
    // From: http://stackoverflow.com/questions/6068197/utils-read-resource-text-file-to-string-java#answer-18897411
    String html = new Scanner(this.getClass().getResourceAsStream("/legend.html"), "UTF-8").useDelimiter("\\A")
            .next();//w  w  w .  j a va2  s  .  c  om
    legend.setText(trimTrailingWhitespace(Html.fromHtml(html)));

    // Check MainActivity.PREF_SHOW_LEGEND and set legend visibility from that
    SharedPreferences preferences = getActivity().getPreferences(Context.MODE_PRIVATE);
    boolean showLegend = preferences.getBoolean(MainActivity.PREF_SHOW_LEGEND, true);
    legend.setVisibility(showLegend ? View.VISIBLE : View.GONE);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        int width = (int) spToPixels(LEGEND_WIDTH_LANDSCAPE_SP);

        // Put an upper bound on the legend width at 40% landscape screen width
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        //noinspection deprecation
        int landscapeWidth = Math.max(display.getWidth(), display.getHeight());
        if (width > landscapeWidth * 0.4) {
            width = (int) (landscapeWidth * 0.4);
        }

        legend.getLayoutParams().width = width;
    }
}