List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT
int SCREEN_ORIENTATION_PORTRAIT
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT.
Click Source Link
portrait
in the android.R.attr#screenOrientation attribute. From source file:net.olejon.spotcommander.AddComputerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Power manager final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "wakeLock"); // Allow landscape? if (!mTools.allowLandscape()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Layout/* w w w. java2s . c om*/ setContentView(R.layout.activity_add_computer); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.add_computer_toolbar); toolbar.setTitleTextColor(ContextCompat.getColor(mContext, R.color.white)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mAddComputerNameInputLayout = (TextInputLayout) findViewById(R.id.add_computer_text_input_name_layout); mAddComputerUriInputLayout = (TextInputLayout) findViewById(R.id.add_computer_text_input_uri_layout); mAddComputerNameInputLayout.setHintAnimationEnabled(true); mAddComputerUriInputLayout.setHintAnimationEnabled(true); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.add_computer_progressbar); // Information final TextView textView = (TextView) findViewById(R.id.add_computer_information); textView.setMovementMethod(LinkMovementMethod.getInstance()); // Scan dialog new MaterialDialog.Builder(mContext).title(R.string.add_computer_scan_dialog_title) .content(getString(R.string.add_computer_scan_dialog_message)) .positiveText(R.string.add_computer_scan_dialog_positive_button) .negativeText(R.string.add_computer_scan_dialog_negative_button) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { scanNetwork(); } }).contentColorRes(R.color.black).negativeColorRes(R.color.black).show(); }
From source file:org.runnerup.view.MainLayout.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.main);//from w w w . j a v a2 s.c o m int versionCode = 0; UpgradeState upgradeState = UpgradeState.UNKNOWN; SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = pref.edit(); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); versionCode = pInfo.versionCode; int version = pref.getInt("app-version", -1); if (version == -1) { upgradeState = UpgradeState.NEW; } else if (versionCode == version) { upgradeState = UpgradeState.SAME; } else if (versionCode > version) { upgradeState = UpgradeState.UPGRADE; } else if (versionCode < version) { upgradeState = UpgradeState.DOWNGRADE; } } catch (NameNotFoundException e) { e.printStackTrace(); } editor.putInt("app-version", versionCode); boolean km = Formatter.getUseKilometers(getResources(), pref, editor); if (upgradeState == UpgradeState.NEW) { editor.putString(getResources().getString(R.string.pref_autolap), Double.toString(km ? Formatter.km_meters : Formatter.mi_meters)); } editor.commit(); // clear basicTargetType between application startup/shutdown pref.edit().remove(getString(R.string.pref_basic_target_type)).commit(); Log.e(getClass().getName(), "app-version: " + versionCode + ", upgradeState: " + upgradeState + ", km: " + km); // convert pref_mute to pref_mute_bool Resources res = getResources(); try { if (pref.contains(res.getString(R.string.pref_mute))) { String v = pref.getString(res.getString(R.string.pref_mute), "no"); editor.putBoolean(res.getString(R.string.pref_mute_bool), v.equalsIgnoreCase("yes")); editor.remove(res.getString(R.string.pref_mute)); editor.commit(); } } catch (Exception e) { } PreferenceManager.setDefaultValues(this, R.xml.settings, false); PreferenceManager.setDefaultValues(this, R.xml.audio_cue_settings, true); TabHost tabHost = getTabHost(); // The activity TabHost tabHost.addTab(tabHost.newTabSpec("Start") .setIndicator(getString(R.string.Start), myGetDrawable(R.drawable.ic_tab_main)) .setContent(new Intent(this, StartActivity.class))); tabHost.addTab(tabHost.newTabSpec("Feed") .setIndicator(getString(R.string.feed), myGetDrawable(R.drawable.ic_tab_feed)) .setContent(new Intent(this, FeedActivity.class))); tabHost.addTab(tabHost.newTabSpec("History") .setIndicator(getString(R.string.History), myGetDrawable(R.drawable.ic_tab_history)) .setContent(new Intent(this, HistoryActivity.class))); tabHost.addTab(tabHost.newTabSpec("Settings") .setIndicator(getString(R.string.Settings), myGetDrawable(R.drawable.ic_tab_setup)) .setContent(new Intent(this, SettingsActivity.class))); tabHost.setCurrentTab(0); WidgetUtil.addLegacyOverflowButton(getWindow()); if (upgradeState == UpgradeState.UPGRADE) { whatsNew(); } //GPS is essential, always nag user if not granted requestGpsPermissions(this, tabHost.getCurrentView()); //Import workouts/schemes. No permission needed handleBundled(getApplicationContext().getAssets(), "bundled", getFilesDir().getPath() + "/.."); // if we were called from an intent-filter because user opened "runnerup.db.export", load it final Uri data = getIntent().getData(); if (data != null) { if (SettingsActivity.requestReadStoragePermissions(MainLayout.this)) { String filePath = null; if ("content".equals(data.getScheme())) { Cursor cursor = this.getContentResolver().query(data, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null); cursor.moveToFirst(); filePath = cursor.getString(0); cursor.close(); } else { filePath = data.getPath(); } Log.i(getClass().getSimpleName(), "Importing database from " + filePath); DBHelper.importDatabase(MainLayout.this, filePath); } else { Toast.makeText(this, "Storage permission not granted in Android settings, db is not imported.", Toast.LENGTH_SHORT).show(); } } }
From source file:cl.ipp.katbag.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setBehindContentView(R.layout.fragment_menu); katbagHandler = new KatbagHandlerSqlite(context); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); slidingMenu = getSlidingMenu();/*from w ww . jav a 2 s . co m*/ // tablet if (findViewById(R.id.fragment_menu_container) != null) { slidingMenu.setSlidingEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); TABLET = true;// tablet setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { // smartphone slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.shadow); slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); slidingMenu.setFadeDegree(0.35f); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.setSlidingEnabled(true); slidingMenu.setOnOpenListener(new OnOpenListener() { @Override public void onOpen() { hideSoftKeyboard(); } }); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); actionBar.setDisplayHomeAsUpEnabled(true); TABLET = false;// tablet } mFragment = new Board(); m = getSupportFragmentManager(); FragmentTransaction t = m.beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.addToBackStack(mFragment.getClass().getSimpleName()); getSupportFragmentManager(); m.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); t.commit(); setTextVersion(); }
From source file:org.vqeg.viqet.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //set orientation potrait if its phone if (getResources().getBoolean(R.bool.portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {/*from w w w.jav a 2s . c om*/ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } // Get max available VM memory, exceeding this amount will throw an // OutOfMemory exception. Stored in kilobytes as LruCache takes an // int in its constructor. final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); // Use 1/8th of the available memory for this memory cache. final int cacheSize = maxMemory / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in kilobytes rather than // number of items. return bitmap.getByteCount() / 1024; } }; this.mainPage = findViewById(R.id.drawer_layout); this.downloadScreen = findViewById(R.id.downloading_screen); this.internetRequiredScreen = findViewById(R.id.internet_required_screen); mTitle = mDrawerTitle = "VIQET"; mOptionsTitles = getResources().getStringArray(R.array.options_array); mImageResources = new int[] { R.drawable.home, R.drawable.camera_results_icon, R.drawable.photo_quality_results, R.drawable.help, R.drawable.about, R.drawable.setting }; mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new CustomDrawerListAdapter(this, mOptionsTitles, mImageResources)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { //todo check selectItem(0); lastClicked = 0; } else { int pos = savedInstanceState.getInt("FRAGMENT"); selectItem(pos); lastClicked = pos; } Button retryDownloadButton = (Button) findViewById(R.id.retryDownload); retryDownloadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (SystemInfo.isNetworkPresent(getApplicationContext())) { downloadScreen.setVisibility(View.VISIBLE); internetRequiredScreen.setVisibility(View.INVISIBLE); downloadRemoteInfo(PhotoInspectorService.FETCH_VERSION_ACTION); } else { Toast.makeText(getApplicationContext(), getString(R.string.noInternetError), Toast.LENGTH_LONG) .show(); } } }); //Check remote info RemoteInfo remoteInfo = RemoteInfoProvider.getRemoteInfo(); if (remoteInfo == null) { mainPage.setVisibility(View.INVISIBLE); if (SystemInfo.isNetworkPresent(getApplicationContext())) { downloadScreen.setVisibility(View.VISIBLE); internetRequiredScreen.setVisibility(View.INVISIBLE); downloadRemoteInfo(PhotoInspectorService.FETCH_VERSION_ACTION); } else { downloadScreen.setVisibility(View.INVISIBLE); internetRequiredScreen.setVisibility(View.VISIBLE); } } else { //downloadRemoteInfo(PhotoInspectorService.FETCH_VERSION_MODEL_CHANGED_ACTION); downloadRemoteInfo(PhotoInspectorService.INSPECT_ALL_PENDING_PHOTOS_ACTION); } checkFirstRun(); }
From source file:com.amazonaws.youruserpools.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set toolbar for this screen toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setTitle(""); TextView main_title = (TextView) findViewById(R.id.main_toolbar_title); main_title.setText("Sign in"); setSupportActionBar(toolbar);/*from w ww .j a v a 2 s . co m*/ // Set navigation drawer for this screen mDrawer = (DrawerLayout) findViewById(R.id.main_drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.nav_drawer_open, R.string.nav_drawer_close); mDrawer.addDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); nDrawer = (NavigationView) findViewById(R.id.nav_view); setNavDrawer(); // Initialize application AppHelper.init(getApplicationContext()); initApp(); findCurrent(); }
From source file:com.anykey.balala.activity.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mContext = this; if (AppBalala.isDebug) { NBSAppAgent.setLicenseKey("95a69f84178141d7852938a9c67e1509").start(this); } else {/* ww w . j a v a2 s . com*/ NBSAppAgent.setLicenseKey("8f420af1e407467b98b698cb4fee1a63").start(this); } }
From source file:com.amazonaws.youruserpools.UserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set toolbar for this screen toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setTitle(""); TextView main_title = (TextView) findViewById(R.id.main_toolbar_title); main_title.setText("Account"); setSupportActionBar(toolbar);/*from w w w. java2s . c om*/ // Set navigation drawer for this screen mDrawer = (DrawerLayout) findViewById(R.id.user_drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.nav_drawer_open, R.string.nav_drawer_close); mDrawer.addDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); nDrawer = (NavigationView) findViewById(R.id.nav_view); setNavDrawer(); init(); View navigationHeader = nDrawer.getHeaderView(0); TextView navHeaderSubTitle = (TextView) navigationHeader.findViewById(R.id.textViewNavUserSub); navHeaderSubTitle.setText(username); //Log.d("this is it",username); }
From source file:com.chess.genesis.activity.Settings.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final Pref pref = new Pref(this); // set layout mode final boolean isTablet = pref.getBool(R.array.pf_tabletMode); if (isTablet) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else//from w w w. j a v a2 s .c om setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_settings); addPreferencesFromResource(R.xml.settings); net = new NetworkClient(this, handle); progress = new ProgressMsg(this); final View button = findViewById(R.id.topbar_genesis); button.setOnLongClickListener(this); final boolean isLoggedin = pref.getBool(R.array.pf_isLoggedIn); final Preference bench = findPreference("benchmark"); bench.setOnPreferenceClickListener(this); final IntListPreference poll = (IntListPreference) findPreference(pref.key(R.array.pf_notifierPolling)); poll.setOnPreferenceChangeListener(this); CheckBoxPreference check = (CheckBoxPreference) findPreference(pref.key(R.array.pf_emailNoteEnabled)); check.setOnPreferenceChangeListener(this); check.setEnabled(isLoggedin); check = (CheckBoxPreference) findPreference(pref.key(R.array.pf_noteEnabled)); check.setOnPreferenceChangeListener(this); check.setEnabled(isLoggedin); CallBackPreference callbackPref = (CallBackPreference) findPreference("deleteLocalTable"); callbackPref.setCallBack(this); callbackPref = (CallBackPreference) findPreference("resyncOnlineTable"); callbackPref.setCallBack(this); callbackPref.setEnabled(isLoggedin); callbackPref = (CallBackPreference) findPreference("resyncArchiveTable"); callbackPref.setCallBack(this); callbackPref.setEnabled(isLoggedin); callbackPref = (CallBackPreference) findPreference("resyncMsgTable"); callbackPref.setCallBack(this); callbackPref.setEnabled(isLoggedin); callbackPref = (CallBackPreference) findPreference("bcReset"); callbackPref.setCallBack(this); // Set email note value from server if (pref.getBool(R.array.pf_isLoggedIn)) { progress.setText("Retrieving Settings"); net.get_option("emailnote"); new Thread(net).start(); } }
From source file:de.limexcomputer.cordova.plugin.rotationlock.RotationLock.java
/** * Executes the request./*w w w. j a va 2 s . c om*/ * * This method is called from the WebView thread. * To do a non-trivial amount of work, use: * cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action The action to execute. * @param args The exec() arguments in JSON form. * @param callback The callback context used when calling back into JavaScript. * @return Whether the action was valid. */ @Override public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException { if (!action.equalsIgnoreCase("setOrientation")) { return false; } String orientation = args.optString(0); Activity activity = this.cordova.getActivity(); // refer to https://github.com/their/pg-plugin-screen-orientation/blob/master/src/ScreenOrientation.java if (orientation.equals(UNSPECIFIED)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else if (orientation.equals(LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals(PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals(USER)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } else if (orientation.equals(BEHIND)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND); } else if (orientation.equals(SENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (orientation.equals(NOSENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else if (orientation.equals(SENSOR_LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (orientation.equals(SENSOR_PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (orientation.equals(REVERSE_LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else if (orientation.equals(REVERSE_PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else if (orientation.equals(FULL_SENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } callback.success(orientation); return true; }
From source file:com.example.mysteryhunt.UserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set toolbar for this screen toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setTitle(""); TextView main_title = (TextView) findViewById(R.id.main_toolbar_title); main_title.setText("Account"); setSupportActionBar(toolbar);//w ww .ja v a2 s . c o m // Set navigation drawer for this screen mDrawer = (DrawerLayout) findViewById(R.id.user_drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.nav_drawer_open, R.string.nav_drawer_close); mDrawer.addDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); nDrawer = (NavigationView) findViewById(R.id.nav_view); setNavDrawer(); init(); View navigationHeader = nDrawer.getHeaderView(0); TextView navHeaderSubTitle = (TextView) navigationHeader.findViewById(R.id.textViewNavUserSub); navHeaderSubTitle.setText(username); }