List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:edu.mit.mobile.android.locast.casts.VideoPlayer.java
private void adjustForOrientation(Configuration newConfig) { if (Configuration.ORIENTATION_PORTRAIT == newConfig.orientation) { mDescriptionView.setVisibility(View.VISIBLE); mTitleView.setVisibility(View.VISIBLE); mHandler.removeMessages(MSG_HIDE_TITLE); } else {/*from w w w . j a va2 s. c o m*/ mDescriptionView.setVisibility(View.INVISIBLE); if (mVideoView.isPlaying()) { hideTitleNow(); } } }
From source file:org.wso2.iot.agent.activities.AuthenticationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {//from www . j a v a 2 s . co m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } setContentView(R.layout.activity_authentication); RelativeLayout relativeLayout = (RelativeLayout) this.findViewById(R.id.relavtiveLayoutAuthentication); if (Constants.DEFAULT_OWNERSHIP.equals(Constants.OWNERSHIP_COSU)) { relativeLayout.setVisibility(RelativeLayout.GONE); } deviceInfo = new DeviceInfo(context); etDomain = (EditText) findViewById(R.id.etDomain); etUsername = (EditText) findViewById(R.id.etUsername); etPassword = (EditText) findViewById(R.id.etPassword); etDomain.setFocusable(true); etDomain.requestFocus(); btnSignIn = (Button) findViewById(R.id.btnSignIn); btnSignIn.setOnClickListener(onClickAuthenticate); btnSignIn.setEnabled(false); // change button color background till user enters a valid input btnSignIn.setBackgroundResource(R.drawable.btn_grey); btnSignIn.setTextColor(ContextCompat.getColor(this, R.color.black)); TextView textViewSignIn = (TextView) findViewById(R.id.textViewSignIn); LinearLayout loginLayout = (LinearLayout) findViewById(R.id.loginLayout); if (Preference.hasPreferenceKey(context, Constants.TOKEN_EXPIRED)) { etDomain.setEnabled(false); etDomain.setTextColor(ContextCompat.getColor(this, R.color.black)); etUsername.setEnabled(false); etUsername.setTextColor(ContextCompat.getColor(this, R.color.black)); btnSignIn.setText(R.string.btn_sign_in); etPassword.setFocusable(true); etPassword.requestFocus(); String tenantedUserName = Preference.getString(context, Constants.USERNAME); int tenantSeparator = tenantedUserName.lastIndexOf('@'); etUsername.setText(tenantedUserName.substring(0, tenantSeparator)); etDomain.setText(tenantedUserName.substring(tenantSeparator + 1, tenantedUserName.length())); isReLogin = true; textViewSignIn.setText(R.string.msg_need_to_sign_in); } else if (Constants.CLOUD_MANAGER != null) { isCloudLogin = true; etDomain.setVisibility(View.GONE); textViewSignIn.setText(R.string.txt_sign_in_cloud); } if (Preference.getBoolean(context, Constants.PreferenceFlag.DEVICE_ACTIVE) && !isReLogin) { Intent intent = new Intent(AuthenticationActivity.this, AlreadyRegisteredActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); return; } TextView textViewSignUp = (TextView) findViewById(R.id.textViewSignUp); if (!isReLogin && Constants.SIGN_UP_URL != null) { Linkify.TransformFilter transformFilter = new Linkify.TransformFilter() { @Override public String transformUrl(Matcher match, String url) { return Constants.SIGN_UP_URL; } }; Pattern pattern = Pattern.compile(getResources().getString(R.string.txt_sign_up_linkify)); Linkify.addLinks(textViewSignUp, pattern, null, null, transformFilter); } else { textViewSignUp.setVisibility(View.GONE); } if (Constants.HIDE_LOGIN_UI) { loginLayout.setVisibility(View.GONE); } if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { startLockTask(); } } TextView textViewWipeData = (TextView) this.findViewById(R.id.textViewWipeData); if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP) && Constants.DISPLAY_WIPE_DEVICE_BUTTON) { textViewWipeData.setVisibility(View.VISIBLE); textViewWipeData.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { new AlertDialog.Builder(AuthenticationActivity.this).setTitle(getString(R.string.app_name)) .setMessage(R.string.wipe_confirmation) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getApplicationContext() .getSystemService(Context.DEVICE_POLICY_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE | DevicePolicyManager.WIPE_RESET_PROTECTION_DATA); } else { devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE); } } }).setNegativeButton(android.R.string.no, null).show(); } }); } ImageView logo = (ImageView) findViewById(R.id.imageViewLogo); if (Constants.COSU_SECRET_EXIT) { logo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { kioskExit++; if (kioskExit == 6) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { stopLockTask(); } finish(); } } }); } etUsername.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { enableSubmitIfReady(); } @Override public void afterTextChanged(Editable s) { enableSubmitIfReady(); } }); etPassword.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { enableSubmitIfReady(); } @Override public void afterTextChanged(Editable s) { enableSubmitIfReady(); } }); if (org.wso2.iot.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE .equals(org.wso2.iot.agent.proxy.utils.Constants.Authenticator.MUTUAL_SSL_AUTHENTICATOR)) { AuthenticatorFactory authenticatorFactory = new AuthenticatorFactory(); ClientAuthenticator authenticator = authenticatorFactory.getClient( org.wso2.iot.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE, AuthenticationActivity.this, Constants.AUTHENTICATION_REQUEST_CODE); authenticator.doAuthenticate(); } //This is an override to ownership type. if (Constants.DEFAULT_OWNERSHIP != null) { deviceType = Constants.DEFAULT_OWNERSHIP; Preference.putString(context, Constants.DEVICE_TYPE, deviceType); } else { deviceType = Constants.OWNERSHIP_BYOD; } if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP)) { Intent intent = getIntent(); if (intent.hasExtra("android.app.extra.token")) { adminAccessToken = intent.getStringExtra("android.app.extra.token"); proceedToAuthentication(); } } // This is added so that in case due to an agent customisation, if the authentication // activity is called the AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED is set, the activity // must be finished. if (Constants.AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED) { finish(); } }
From source file:com.scto.filerenamer.MainActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show(); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show(); }/*from w w w .ja va 2 s .c o m*/ }
From source file:com.waz.zclient.AppEntryActivity.java
@Override public void onCreate(Bundle savedInstanceState) { if (getActionBar() != null) { getActionBar().hide();// w w w.j a va 2s . c o m } super.onCreate(savedInstanceState); setTheme(R.style.Theme_Dark); ViewUtils.lockScreenOrientation(Configuration.ORIENTATION_PORTRAIT, this); setContentView(R.layout.activity_signup); countryController = new CountryController(this); progressView = ViewUtils.getView(this, R.id.liv__progress); // always disable progress bar at the beginning enableProgress(false); createdFromSavedInstance = savedInstanceState != null; accentColor = getResources().getColor(R.color.text__primary_dark); if (unsplashInitLoadHandle == null && unsplashInitImageAsset == null) { unsplashInitImageAsset = ImageAssetFactory.getImageAsset(Uri.parse(UNSPLASH_API_URL)); // This is just to force that SE will download the image so that it is probably ready when we are at the // set picture screen unsplashInitLoadHandle = unsplashInitImageAsset.getSingleBitmap(PREFETCH_IMAGE_WIDTH, new ImageAsset.BitmapCallback() { @Override public void onBitmapLoaded(Bitmap b, boolean isPreview) { } @Override public void onBitmapLoadingFailed() { } }); } }
From source file:com.farmerbb.taskbar.fragment.AdvancedFragment.java
@SuppressLint("SetTextI18n") @Override/*from ww w . j ava2 s .c o m*/ public boolean onPreferenceClick(final Preference p) { final SharedPreferences pref = U.getSharedPreferences(getActivity()); switch (p.getKey()) { case "clear_pinned_apps": Intent clearIntent = null; switch (pref.getString("theme", "light")) { case "light": clearIntent = new Intent(getActivity(), ClearDataActivity.class); break; case "dark": clearIntent = new Intent(getActivity(), ClearDataActivityDark.class); break; } startActivity(clearIntent); break; case "launcher": if (U.canDrawOverlays(getActivity())) { ComponentName component = new ComponentName(getActivity(), HomeActivity.class); getActivity().getPackageManager().setComponentEnabledSetting(component, ((CheckBoxPreference) p).isChecked() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } else { U.showPermissionDialog(getActivity()); ((CheckBoxPreference) p).setChecked(false); } if (!((CheckBoxPreference) p).isChecked()) LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent("com.farmerbb.taskbar.KILL_HOME_ACTIVITY")); break; case "keyboard_shortcut": ComponentName component = new ComponentName(getActivity(), KeyboardShortcutActivity.class); getActivity().getPackageManager() .setComponentEnabledSetting(component, ((CheckBoxPreference) p).isChecked() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); break; case "dashboard_grid_size": AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LinearLayout dialogLayout = (LinearLayout) View.inflate(getActivity(), R.layout.dashboard_size_dialog, null); boolean isPortrait = getActivity().getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isLandscape = getActivity().getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; int editTextId = -1; int editText2Id = -1; if (isPortrait) { editTextId = R.id.fragmentEditText2; editText2Id = R.id.fragmentEditText1; } if (isLandscape) { editTextId = R.id.fragmentEditText1; editText2Id = R.id.fragmentEditText2; } final EditText editText = (EditText) dialogLayout.findViewById(editTextId); final EditText editText2 = (EditText) dialogLayout.findViewById(editText2Id); builder.setView(dialogLayout).setTitle(R.string.dashboard_grid_size) .setPositiveButton(R.string.action_ok, (dialog, id) -> { boolean successfullyUpdated = false; String widthString = editText.getText().toString(); String heightString = editText2.getText().toString(); if (widthString.length() > 0 && heightString.length() > 0) { int width = Integer.parseInt(widthString); int height = Integer.parseInt(heightString); if (width > 0 && height > 0) { SharedPreferences.Editor editor = pref.edit(); editor.putInt("dashboard_width", width); editor.putInt("dashboard_height", height); editor.apply(); updateDashboardGridSize(true); successfullyUpdated = true; } } if (!successfullyUpdated) U.showToast(getActivity(), R.string.invalid_grid_size); }).setNegativeButton(R.string.action_cancel, null); editText.setText(Integer.toString(pref.getInt("dashboard_width", getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_width)))); editText2.setText(Integer.toString(pref.getInt("dashboard_height", getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_height)))); AlertDialog dialog = builder.create(); dialog.show(); new Handler().post(() -> { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText2, InputMethodManager.SHOW_IMPLICIT); }); break; case "navigation_bar_buttons": Intent intent = null; switch (pref.getString("theme", "light")) { case "light": intent = new Intent(getActivity(), NavigationBarButtonsActivity.class); break; case "dark": intent = new Intent(getActivity(), NavigationBarButtonsActivityDark.class); break; } startActivity(intent); break; } return true; }
From source file:com.example.igorklimov.popularmoviesdemo.fragments.MoviesGridFragment.java
/** * This method sets minimum sizes for posters and RecyclerView's * {@link android.support.v7.widget.RecyclerView.LayoutManager} *///from w ww .java2 s . c o m private void setupMinSizes() { int orientation = mMainActivity.getResources().getConfiguration().orientation; int spanCount; if (orientation == Configuration.ORIENTATION_PORTRAIT && mIsTablet) { mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, HORIZONTAL, false)); } else { if (orientation == Configuration.ORIENTATION_LANDSCAPE || mIsTablet) { spanCount = 3; } else { spanCount = 2; } mRecyclerView.setLayoutManager(new GridLayoutManager(mMainActivity, spanCount)); } }
From source file:com.example.ok.kom_argeopouchobj.camera.CameraSourcePreview.java
private boolean isPortraitMode() { int orientation = mContext.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { return false; }//from w w w . j a v a2 s. c o m if (orientation == Configuration.ORIENTATION_PORTRAIT) { return true; } Log.d(TAG, "isPortraitMode returning false by default"); return false; }
From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Getting the width on orientation changed Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w . ja va 2 s. c o m int width = size.x; /** * Getting the orientation of the device. Set margin for pages as a * negative number, so a part of next and previous pages will be showed */ if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { pager.setPageMargin(-width / 2); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { pager.setPageMargin(-width / 3); } pager.refreshDrawableState(); }
From source file:com.chute.android.photopickerplus.ui.activity.ServicesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); fragmentManager = getSupportFragmentManager(); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main_layout); dualPanes = getResources().getBoolean(R.bool.has_two_panes); signOut = (TextView) findViewById(R.id.gcTextViewSignOut); signOut.setOnClickListener(new SignOutListener()); retrieveValuesFromBundle(savedInstanceState); if (dualPanes && savedInstanceState == null && getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT) { replaceContentWithEmptyFragment(); }// w w w . j a v a2 s . com }
From source file:com.hichinaschool.flashcards.anki.StudyOptionsActivity.java
/** Handles item selections */ @Override//from w w w . ja va 2s.co m public boolean onOptionsItemSelected(MenuItem item) { Resources res = this.getResources(); switch (item.getItemId()) { case android.R.id.home: closeStudyOptions(); return true; case MENU_PREFERENCES: startActivityForResult(new Intent(this, Preferences.class), StudyOptionsFragment.PREFERENCES_UPDATE); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.FADE); } return true; case MENU_ROTATE: if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } return true; case MENU_NIGHT: SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this); if (preferences.getBoolean("invertedColors", false)) { preferences.edit().putBoolean("invertedColors", false).commit(); item.setIcon(R.drawable.ic_menu_night); } else { preferences.edit().putBoolean("invertedColors", true).commit(); item.setIcon(R.drawable.ic_menu_night_checked); } return true; case DeckPicker.MENU_CREATE_DYNAMIC_DECK: StyledDialog.Builder builder = new StyledDialog.Builder(StudyOptionsActivity.this); builder.setTitle(res.getString(R.string.new_deck)); mDialogEditText = new EditText(StudyOptionsActivity.this); ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames(); int n = 1; String cramDeckName = "Cram 1"; while (names.contains(cramDeckName)) { n++; cramDeckName = "Cram " + n; } mDialogEditText.setText(cramDeckName); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder.setView(mDialogEditText, false, false); builder.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { long id; Bundle initialConfig = new Bundle(); try { initialConfig.putString("searchSuffix", "'deck:" + AnkiDroidApp.getCol().getDecks().current().getString("name") + "'"); id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString()); AnkiDroidApp.getCol().getDecks().get(id); } catch (JSONException e) { throw new RuntimeException(e); } loadContent(false, initialConfig); } }); builder.setNegativeButton(res.getString(R.string.cancel), null); builder.create().show(); return true; default: return super.onOptionsItemSelected(item); } }