List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE
int ORIENTATION_LANDSCAPE
To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.
Click Source Link
From source file:dev.ronlemire.validation.MainActivity.java
public void StartInputTypeFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {/* w ww . j a v a2s .c o m*/ Fragment inputTypeFragment = (Fragment) fm .findFragmentById(R.id.detail_replacer); inputTypeFragment = InputTypeFragment.newInstance("InputType"); FragmentTransaction transaction = fm.beginTransaction() .replace(R.id.detail_replacer, inputTypeFragment); 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:cc.echonet.coolmicapp.MainActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { imageView1.getLayoutParams().height = 180; } else {/*from w ww. j av a 2s. c o m*/ imageView1.getLayoutParams().height = 400; } }
From source file:com.daiv.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.daiv.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); try {// w ww . 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); 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.koushikdutta.superuser.FragmentMain.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); context = getActivity();//from www .j av a 2s . c o m pref = PreferenceManager.getDefaultSharedPreferences(context); callback = (MainCallback) getActivity(); LocalBroadcastManager.getInstance(context).registerReceiver(receiver, new IntentFilter(Common.INTENT_FILTER_MAIN)); gridMode = pref.getBoolean("grid_mode", true); coordinatorLayout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content); //tabLayout = (TabLayout) getActivity().findViewById(R.id.tabs); //viewPager = (ViewPager) getActivity().findViewById(R.id.container); int span = 0; if (gridMode) { layoutManager = new RecyclerViewSwipeable.LayoutManagerSwipeable(context, 1); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { span = pref.getInt("grid_size_port", 3); layoutManager.setSpanCount(span); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { span = pref.getInt("grid_size_land", 4); layoutManager.setSpanCount(span); } Drawable divider = ContextCompat.getDrawable(context, R.drawable.divider_grid); divider.setColorFilter(new PorterDuffColorFilter(ATHUtil.resolveColor(context, R.attr.dividerGrid), PorterDuff.Mode.SRC_ATOP)); recycler.setLayoutManager(layoutManager); recycler.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(context, R.anim.grid_layout_animation)); recycler.addItemDecoration(new GridDividerItemDecoration(divider, divider, span)); recycler.addItemDecoration(new GridTopOffsetItemDecoration(Util.toPx(context, 5), span)); } else { recycler.setLayoutManager(new LinearLayoutManager(context)); recycler.addItemDecoration(new StartOffsetItemDecoration(Util.toPx(context, 10))); } //recycler.setListener(clickListener); //recycler.setViewPager(viewPager); //recycler.setFragment(this); setData(); }
From source file:com.andrasta.dashi.MainActivity.java
@SuppressWarnings("MissingPermission") private void openCamera(int width, int height) { try {/* ww w .j a v a 2s . c om*/ configBuilder = CameraUtils.initCameraConfig(this, display, width, height); onCameraOrientationSet(configBuilder.getCameraOrientation()); int cameraWidth = configBuilder.getSize().getWidth(); int cameraHeight = configBuilder.getSize().getHeight(); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = this.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { textureView.setAspectRatio(cameraWidth, cameraHeight); laneView.setAspectRatio(cameraWidth, cameraHeight); } else { textureView.setAspectRatio(cameraHeight, cameraWidth); laneView.setAspectRatio(cameraHeight, cameraWidth); } Matrix matrix = CameraUtils.configureTransform(display.getRotation(), width, height, cameraWidth, cameraHeight); textureView.setTransform(matrix); SurfaceTexture texture = textureView.getSurfaceTexture(); if (texture == null) { Log.d(TAG, "No SurfaceTexture"); return; } // We configure the size of default buffer to be the size of camera preview we want. texture.setDefaultBufferSize(cameraWidth, cameraHeight); CameraConfig.Request request = new CameraConfig.Request(CameraDevice.TEMPLATE_PREVIEW, new Surface(texture)); request.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); configBuilder.addRequest(request); Log.d(TAG, "Display camera resolution " + cameraWidth + 'x' + cameraHeight); imageReader = ImageReader.newInstance(cameraRecSize.getWidth(), cameraRecSize.getHeight(), ImageFormat.YUV_420_888, alprHandler.getThreadsNum() + 1); imageReader.setOnImageAvailableListener(this, null); request = new CameraConfig.Request(CameraDevice.TEMPLATE_PREVIEW, imageReader.getSurface()); configBuilder.addRequest(request); Log.d(TAG, "Recognition camera resolution " + cameraRecSize.getWidth() + 'x' + cameraRecSize.getHeight()); camera.open(configBuilder.build()); Log.d(TAG, "Camera opened: " + configBuilder.getCameraId()); } catch (CameraAccessException e) { onError(false, e); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the device onError(true, e); } }
From source file:ch.jeda.platform.android.Main.java
private int getScreenOrientation(final ViewRequest request) { if (request.getFeatures().contains(WindowFeature.ORIENTATION_LANDSCAPE)) { return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (request.getFeatures().contains(WindowFeature.ORIENTATION_PORTRAIT)) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else {/* ww w .j ava 2 s . c o m*/ final int rotation = this.getWindowManager().getDefaultDisplay().getRotation(); if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else { return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } else { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else { return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } } } }
From source file:app.umitems.greenclock.DeskClock.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // We only want to show it as a menu in landscape, and only for clock/alarm fragment. mMenu = menu;/* www . j a v a 2 s. c om*/ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (mActionBar.getSelectedNavigationIndex() == ALARM_TAB_INDEX || mActionBar.getSelectedNavigationIndex() == CLOCK_TAB_INDEX) { // Clear the menu so that it doesn't get duplicate items in case onCreateOptionsMenu // was called multiple times. menu.clear(); getMenuInflater().inflate(R.menu.desk_clock_menu, menu); } // Always return true for landscape, regardless of whether we've inflated the menu, so // that when we switch tabs this method will get called and we can inflate the menu. return true; } return false; }
From source file:com.staggeredgrid.library.StaggeredGridView.java
private boolean isLandscape() { return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }
From source file:com.appnexus.opensdk.AdRequest.java
private AdRequest(AdRequester adRequester, int httpRetriesLeft, int blankRetriesLeft) { owner = adRequester.getOwner();// www . j av a 2 s.c o m this.requester = adRequester; this.httpRetriesLeft = httpRetriesLeft; this.blankRetriesLeft = blankRetriesLeft; this.placementId = owner.getPlacementID(); context = owner.getContext(); String aid = android.provider.Settings.Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); // Do we have access to location? if (context.checkCallingOrSelfPermission( "android.permission.ACCESS_FINE_LOCATION") == PackageManager.PERMISSION_GRANTED || context.checkCallingOrSelfPermission( "android.permission.ACCESS_COARSE_LOCATION") == PackageManager.PERMISSION_GRANTED) { // Get lat, long from any GPS information that might be currently // available LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location lastLocation = lm.getLastKnownLocation(lm.getBestProvider(new Criteria(), false)); if (lastLocation != null) { lat = "" + lastLocation.getLatitude(); lon = "" + lastLocation.getLongitude(); locDataAge = "" + (System.currentTimeMillis() - lastLocation.getTime()); locDataPrecision = "" + lastLocation.getAccuracy(); } } else { Clog.w(Clog.baseLogTag, Clog.getString(R.string.permissions_missing_location)); } // Do we have permission ACCESS_NETWORK_STATE? if (context.checkCallingOrSelfPermission( "android.permission.ACCESS_NETWORK_STATE") != PackageManager.PERMISSION_GRANTED) { Clog.e(Clog.baseLogTag, Clog.getString(R.string.permissions_missing_network_state)); fail(); this.cancel(true); return; } // Get orientation, the current rotation of the device orientation = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? "h" : "v"; // Get hidmd5, hidsha1, the device ID hashed if (Settings.getSettings().hidmd5 == null) { Settings.getSettings().hidmd5 = HashingFunctions.md5(aid); } hidmd5 = Settings.getSettings().hidmd5; if (Settings.getSettings().hidsha1 == null) { Settings.getSettings().hidsha1 = HashingFunctions.sha1(aid); } hidsha1 = Settings.getSettings().hidsha1; // Get devMake, devModel, the Make and Model of the current device devMake = Settings.getSettings().deviceMake; devModel = Settings.getSettings().deviceModel; // Get carrier if (Settings.getSettings().carrierName == null) { Settings.getSettings().carrierName = ((TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE)).getNetworkOperatorName(); } carrier = Settings.getSettings().carrierName; // Get firstlaunch and convert it to a string firstlaunch = Settings.getSettings().first_launch; // Get ua, the user agent... ua = Settings.getSettings().ua; // Get wxh if (owner.isBanner()) { this.width = ((BannerAdView) owner).getAdWidth(); this.height = ((BannerAdView) owner).getAdHeight(); } maxHeight = owner.getContainerHeight(); maxWidth = owner.getContainerWidth(); if (Settings.getSettings().mcc == null || Settings.getSettings().mnc == null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String networkOperator = tm.getNetworkOperator(); if (networkOperator != null && networkOperator.length() >= 6) { Settings.getSettings().mcc = networkOperator.substring(0, 3); Settings.getSettings().mnc = networkOperator.substring(3); } } mcc = Settings.getSettings().mcc; mnc = Settings.getSettings().mnc; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); connection_type = wifi.isConnected() ? "wifi" : "wan"; dev_time = "" + System.currentTimeMillis(); if (owner instanceof InterstitialAdView) { // Make string for allowed_sizes allowedSizes = ""; ArrayList<Size> sizes = ((InterstitialAdView) owner).getAllowedSizes(); for (Size s : sizes) { allowedSizes += "" + s.width() + "x" + s.height(); // If not last size, add a comma if (sizes.indexOf(s) != sizes.size() - 1) allowedSizes += ","; } } nativeBrowser = owner.getOpensNativeBrowser() ? "1" : "0"; //Reserve price reserve = owner.getReserve(); if (reserve <= 0) { this.psa = owner.shouldServePSAs ? "1" : "0"; } else { this.psa = "0"; } age = owner.getAge(); if (owner.getGender() != null) { if (owner.getGender() == AdView.GENDER.MALE) { gender = "m"; } else if (owner.getGender() == AdView.GENDER.FEMALE) { gender = "f"; } else { gender = null; } } customKeywords = owner.getCustomKeywords(); mcc = Settings.getSettings().mcc; mnc = Settings.getSettings().mnc; language = Settings.getSettings().language; }
From source file:dev.ronlemire.data.MainActivity.java
private boolean isMultiPane() { return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }