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:org.videolan.vlc.gui.video.VideoPlayerActivity.java
private void changeSurfaceSize() { // get screen size int dw = getWindow().getDecorView().getWidth(); int dh = getWindow().getDecorView().getHeight(); // getWindow().getDecorView() doesn't always take orientation into account, we have to correct the values boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; if (dw > dh && isPortrait || dw < dh && !isPortrait) { int d = dw; dw = dh;/*from w w w. ja v a 2 s. co m*/ dh = d; } // sanity check if (dw * dh == 0 || mVideoWidth * mVideoHeight == 0) { Log.e(TAG, "Invalid surface size"); return; } // compute the aspect ratio double ar, vw; double density = (double) mSarNum / (double) mSarDen; if (density == 1.0) { /* No indication about the density, assuming 1:1 */ vw = mVideoWidth; ar = (double) mVideoWidth / (double) mVideoHeight; } else { /* Use the specified aspect ratio */ vw = mVideoWidth * density; ar = vw / mVideoHeight; } // compute the display aspect ratio double dar = (double) dw / (double) dh; switch (mCurrentSize) { case SURFACE_BEST_FIT: if (dar < ar) dh = (int) (dw / ar); else dw = (int) (dh * ar); break; case SURFACE_FIT_HORIZONTAL: dh = (int) (dw / ar); break; case SURFACE_FIT_VERTICAL: dw = (int) (dh * ar); break; case SURFACE_FILL: break; case SURFACE_16_9: ar = 16.0 / 9.0; if (dar < ar) dh = (int) (dw / ar); else dw = (int) (dh * ar); break; case SURFACE_4_3: ar = 4.0 / 3.0; if (dar < ar) dh = (int) (dw / ar); else dw = (int) (dh * ar); break; case SURFACE_ORIGINAL: ar = 16.0 / 9.0; if (dar < ar) dh = (int) (dw / ar); else dw = (int) (dh * ar); break; } // align width on 16bytes int alignedWidth = (mVideoWidth + mSurfaceAlign) & ~mSurfaceAlign; // force surface buffer size mSurfaceHolder.setFixedSize(alignedWidth, mVideoHeight); // set display size LayoutParams lp = mSurface.getLayoutParams(); lp.width = dw * alignedWidth / mVideoWidth; lp.height = dh; mSurface.setLayoutParams(lp); // set frame size (crop if necessary) // lp = mSurfaceFrame.getLayoutParams(); // lp.width = dw; // lp.height = dh; // mSurfaceFrame.setLayoutParams(lp); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurfaceFrame.getLayoutParams(); params.width = dw; params.height = dh; if (mCurrentSize == SURFACE_ORIGINAL) { params.topMargin = 0; params.gravity = Gravity.CENTER; } else { params.topMargin = (int) getResources().getDimension(R.dimen.video_padding_top); params.gravity = Gravity.CENTER_HORIZONTAL; } ; mSurfaceFrame.setLayoutParams(params); mSurface.invalidate(); }
From source file:com.if3games.chessonline.DroidFish.java
private final void readPrefs() { if (isSinglePlayer) { int modeNr = getIntSetting("gameMode", 1); gameMode = new GameMode(modeNr); String oldPlayerName = playerName; playerName = settings.getString("playerName", "Player"); boardFlipped = settings.getBoolean("boardFlipped", false); autoSwapSides = settings.getBoolean("autoSwapSides", false); playerNameFlip = settings.getBoolean("playerNameFlip", true); setBoardFlip(!playerName.equals(oldPlayerName)); boolean drawSquareLabels = settings.getBoolean("drawSquareLabels", false); cb.setDrawSquareLabels(drawSquareLabels); cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", false); cb.toggleSelection = getIntSetting("squareSelectType", 0) == 1; cb.highlightLastMove = settings.getBoolean("highlightLastMove", true); cb.setBlindMode(settings.getBoolean("blindMode", false)); mShowThinking = settings.getBoolean("showThinking", false); mShowStats = settings.getBoolean("showStats", true); mWhiteBasedScores = settings.getBoolean("whiteBasedScores", false); maxNumArrows = getIntSetting("thinkingArrows", 2); mShowBookHints = settings.getBoolean("bookHints", false); mEngineThreads = getIntSetting("threads", 1); String engine = settings.getString("engine", "stockfish"); int strength = settings.getInt("strength", 1000); setEngineStrength(engine, strength); mPonderMode = settings.getBoolean("ponderMode", false); if (!mPonderMode) ctrl.stopPonder();//from w w w . j a v a 2 s . c om timeControl = getIntSetting("timeControl", 120000); movesPerSession = getIntSetting("movesPerSession", 60); timeIncrement = getIntSetting("timeIncrement", 0); boardGestures = settings.getBoolean("boardGestures", true); scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2")); invertScrollDirection = settings.getBoolean("invertScrollDirection", false); discardVariations = settings.getBoolean("discardVariations", false); Util.setFullScreenMode(this, settings); useWakeLock = settings.getBoolean("wakeLock", false); setWakeLock(useWakeLock); // Visible Options int fontSize = getIntSetting("fontSize", 12); int statusFontSize = fontSize; Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_PORTRAIT) statusFontSize = Math.min(statusFontSize, 16); status.setTextSize(statusFontSize); moveList.setTextSize(fontSize); thinking.setTextSize(fontSize); soundEnabled = settings.getBoolean("soundEnabled", false); vibrateEnabled = settings.getBoolean("vibrateEnabled", false); animateMoves = settings.getBoolean("animateMoves", true); autoScrollTitle = settings.getBoolean("autoScrollTitle", true); setTitleScrolling(); ColorTheme.instance().readColors(settings); cb.setColors(); Util.overrideFonts(findViewById(android.R.id.content)); // End Visible Options custom1ButtonActions.readPrefs(settings, actionFactory); custom2ButtonActions.readPrefs(settings, actionFactory); custom3ButtonActions.readPrefs(settings, actionFactory); updateButtons(); bookOptions.filename = settings.getString("bookFile", ""); bookOptions.maxLength = getIntSetting("bookMaxLength", 1000000); bookOptions.preferMainLines = settings.getBoolean("bookPreferMainLines", false); bookOptions.tournamentMode = settings.getBoolean("bookTournamentMode", false); bookOptions.random = (settings.getInt("bookRandom", 500) - 500) * (3.0 / 500); setBookOptions(); engineOptions.hashMB = getIntSetting("hashMB", 16); engineOptions.hints = settings.getBoolean("tbHints", false); engineOptions.hintsEdit = settings.getBoolean("tbHintsEdit", false); engineOptions.rootProbe = settings.getBoolean("tbRootProbe", true); engineOptions.engineProbe = settings.getBoolean("tbEngineProbe", true); String gtbPath = settings.getString("gtbPath", "").trim(); if (gtbPath.length() == 0) { File extDir = Environment.getExternalStorageDirectory(); String sep = File.separator; gtbPath = extDir.getAbsolutePath() + sep + gtbDefaultDir; } engineOptions.gtbPath = gtbPath; setEngineOptions(false); setEgtbHints(cb.getSelectedSquare()); updateThinkingInfo(); pgnOptions.view.variations = settings.getBoolean("viewVariations", true); pgnOptions.view.comments = settings.getBoolean("viewComments", true); pgnOptions.view.nag = settings.getBoolean("viewNAG", true); pgnOptions.view.headers = settings.getBoolean("viewHeaders", false); final int oldViewPieceType = pgnOptions.view.pieceType; pgnOptions.view.pieceType = getIntSetting("viewPieceType", PGNOptions.PT_LOCAL); showVariationLine = settings.getBoolean("showVariationLine", false); pgnOptions.imp.variations = settings.getBoolean("importVariations", true); pgnOptions.imp.comments = settings.getBoolean("importComments", true); pgnOptions.imp.nag = settings.getBoolean("importNAG", true); pgnOptions.exp.variations = settings.getBoolean("exportVariations", true); pgnOptions.exp.comments = settings.getBoolean("exportComments", true); pgnOptions.exp.nag = settings.getBoolean("exportNAG", true); pgnOptions.exp.playerAction = settings.getBoolean("exportPlayerAction", false); pgnOptions.exp.clockInfo = settings.getBoolean("exportTime", false); gameTextListener.clear(); setPieceNames(pgnOptions.view.pieceType); ctrl.prefsChanged(oldViewPieceType != pgnOptions.view.pieceType); // update the typeset in case of a change anyway, cause it could occur // as well in rotation setFigurineNotation(pgnOptions.view.pieceType == PGNOptions.PT_FIGURINE, fontSize); showMaterialDiff = settings.getBoolean("materialDiff", false); secondTitleLine.setVisibility(showMaterialDiff ? View.VISIBLE : View.GONE); } else { int modeNr = 1; gameMode = new GameMode(modeNr); String oldPlayerName = playerName; playerName = "Player"; boardFlipped = false; autoSwapSides = false; playerNameFlip = true; setBoardFlip(!playerName.equals(oldPlayerName)); boolean drawSquareLabels = false; cb.setDrawSquareLabels(drawSquareLabels); cb.oneTouchMoves = false; cb.toggleSelection = getIntSetting("squareSelectType", 0) == 1; cb.highlightLastMove = settings.getBoolean("highlightLastMove", true); cb.setBlindMode(false); mShowThinking = false; mShowStats = settings.getBoolean("showStats", true); mWhiteBasedScores = false; maxNumArrows = getIntSetting("thinkingArrows", 2); mShowBookHints = false; mEngineThreads = 1; String engine = "stockfish"; int strength = 1000; setEngineStrength(engine, strength); mPonderMode = false; if (!mPonderMode) ctrl.stopPonder(); // Toto: add time control to gms timeControl = 120000; movesPerSession = 60; timeIncrement = 0; boardGestures = false; scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2")); invertScrollDirection = settings.getBoolean("invertScrollDirection", false); discardVariations = false; Util.setFullScreenMode(this, settings); useWakeLock = false; setWakeLock(useWakeLock); // Visible Options int fontSize = getIntSetting("fontSize", 12); int statusFontSize = fontSize; Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_PORTRAIT) statusFontSize = Math.min(statusFontSize, 16); status.setTextSize(statusFontSize); moveList.setTextSize(fontSize); thinking.setTextSize(fontSize); soundEnabled = settings.getBoolean("soundEnabled", false); vibrateEnabled = settings.getBoolean("vibrateEnabled", false); animateMoves = settings.getBoolean("animateMoves", true); autoScrollTitle = settings.getBoolean("autoScrollTitle", true); setTitleScrolling(); ColorTheme.instance().readColors(settings); cb.setColors(); Util.overrideFonts(findViewById(android.R.id.content)); // End Visible Options custom1ButtonActions.readPrefs(settings, actionFactory); custom2ButtonActions.readPrefs(settings, actionFactory); custom3ButtonActions.readPrefs(settings, actionFactory); updateButtons(); bookOptions.filename = ""; bookOptions.maxLength = 1000000; bookOptions.preferMainLines = false; bookOptions.tournamentMode = false; bookOptions.random = (settings.getInt("bookRandom", 500) - 500) * (3.0 / 500); setBookOptions(); engineOptions.hashMB = 16; engineOptions.hints = false; engineOptions.hintsEdit = false; engineOptions.rootProbe = true; engineOptions.engineProbe = true; String gtbPath = settings.getString("gtbPath", "").trim(); if (gtbPath.length() == 0) { File extDir = Environment.getExternalStorageDirectory(); String sep = File.separator; gtbPath = extDir.getAbsolutePath() + sep + gtbDefaultDir; } engineOptions.gtbPath = gtbPath; setEngineOptions(false); setEgtbHints(cb.getSelectedSquare()); updateThinkingInfo(); pgnOptions.view.variations = settings.getBoolean("viewVariations", true); pgnOptions.view.comments = settings.getBoolean("viewComments", true); pgnOptions.view.nag = settings.getBoolean("viewNAG", true); pgnOptions.view.headers = settings.getBoolean("viewHeaders", false); final int oldViewPieceType = pgnOptions.view.pieceType; pgnOptions.view.pieceType = getIntSetting("viewPieceType", PGNOptions.PT_LOCAL); showVariationLine = settings.getBoolean("showVariationLine", false); pgnOptions.imp.variations = settings.getBoolean("importVariations", true); pgnOptions.imp.comments = settings.getBoolean("importComments", true); pgnOptions.imp.nag = settings.getBoolean("importNAG", true); pgnOptions.exp.variations = settings.getBoolean("exportVariations", true); pgnOptions.exp.comments = settings.getBoolean("exportComments", true); pgnOptions.exp.nag = settings.getBoolean("exportNAG", true); pgnOptions.exp.playerAction = settings.getBoolean("exportPlayerAction", false); pgnOptions.exp.clockInfo = settings.getBoolean("exportTime", false); gameTextListener.clear(); setPieceNames(pgnOptions.view.pieceType); ctrl.prefsChanged(oldViewPieceType != pgnOptions.view.pieceType); // update the typeset in case of a change anyway, cause it could occur // as well in rotation setFigurineNotation(pgnOptions.view.pieceType == PGNOptions.PT_FIGURINE, fontSize); showMaterialDiff = settings.getBoolean("materialDiff", true); secondTitleLine.setVisibility(showMaterialDiff ? View.VISIBLE : View.GONE); } }
From source file:github.daneren2005.dsub.fragments.NowPlayingFragment.java
@Override public void onSongChanged(DownloadFile currentPlaying, int currentPlayingIndex) { this.currentPlaying = currentPlaying; if (currentPlaying != null) { Entry song = currentPlaying.getSong(); songTitleTextView.setText(song.getTitle()); getImageLoader().loadImage(albumArtImageView, song, true, true); if (song.isStarred()) { starButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else {//from w w w.j a v a2 s.co m if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { starButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.star_outline)); } else { starButton.setImageResource(R.drawable.ic_toggle_star_outline_dark); } } setSubtitle(context.getResources().getString(R.string.download_playing_out_of, currentPlayingIndex + 1, currentPlayingSize)); int badRating, goodRating, bookmark; if (song.getRating() == 1) { rateBadButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_bad_selected)); } else { if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { badRating = R.drawable.ic_action_rating_bad_dark; } else { badRating = DrawableTint.getDrawableRes(context, R.attr.rating_bad); } rateBadButton.setImageResource(badRating); } if (song.getRating() == 5) { rateGoodButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_good_selected)); } else { if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { goodRating = R.drawable.ic_action_rating_good_dark; } else { goodRating = DrawableTint.getDrawableRes(context, R.attr.rating_good); } rateGoodButton.setImageResource(goodRating); } if (song.getBookmark() != null) { bookmarkButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_menu_bookmark_selected)); } else { if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { bookmark = R.drawable.ic_menu_bookmark_dark; } else { bookmark = DrawableTint.getDrawableRes(context, R.attr.bookmark); } bookmarkButton.setImageResource(bookmark); } } else { songTitleTextView.setText(null); getImageLoader().loadImage(albumArtImageView, (Entry) null, true, false); starButton.setImageResource(R.drawable.ic_toggle_star_outline_dark); setSubtitle(null); } }
From source file:com.harlan.jxust.ui.view.bottombar.BottomBar.java
private static void navBarMagic(Activity activity, final BottomBar bottomBar) { Resources res = activity.getResources(); int softMenuIdentifier = res.getIdentifier("config_showNavigationBar", "bool", "android"); int navBarIdentifier = res.getIdentifier("navigation_bar_height", "dimen", "android"); int navBarHeight = 0; if (navBarIdentifier > 0) { navBarHeight = res.getDimensionPixelSize(navBarIdentifier); }/*from w ww. ja v a2 s. co m*/ if (!bottomBar.drawBehindNavBar() || navBarHeight == 0 || (!(softMenuIdentifier > 0 && res.getBoolean(softMenuIdentifier)))) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && ViewConfiguration.get(activity).hasPermanentMenuKey()) { return; } /** * Copy-paste coding made possible by: * http://stackoverflow.com/a/14871974/940036 */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Display d = activity.getWindowManager().getDefaultDisplay(); DisplayMetrics realDisplayMetrics = new DisplayMetrics(); d.getRealMetrics(realDisplayMetrics); int realHeight = realDisplayMetrics.heightPixels; int realWidth = realDisplayMetrics.widthPixels; DisplayMetrics displayMetrics = new DisplayMetrics(); d.getMetrics(displayMetrics); int displayHeight = displayMetrics.heightPixels; int displayWidth = displayMetrics.widthPixels; boolean hasSoftwareKeys = (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0; if (!hasSoftwareKeys) { return; } } /** * End of delicious copy-paste code */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { activity.getWindow().getAttributes().flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; if (bottomBar.useTopOffset()) { int offset; int statusBarResource = res.getIdentifier("status_bar_height", "dimen", "android"); if (statusBarResource > 0) { offset = res.getDimensionPixelSize(statusBarResource); } else { offset = MiscUtils.dpToPixel(activity, 25); } if (!bottomBar.useOnlyStatusbarOffset()) { TypedValue tv = new TypedValue(); if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { offset += TypedValue.complexToDimensionPixelSize(tv.data, res.getDisplayMetrics()); } else { offset += MiscUtils.dpToPixel(activity, 56); } } bottomBar.getUserContainer().setPadding(0, offset, 0, 0); } final View outerContainer = bottomBar.getOuterContainer(); final int navBarHeightCopy = navBarHeight; bottomBar.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { bottomBar.shyHeightAlreadyCalculated(); int newHeight = outerContainer.getHeight() + navBarHeightCopy; outerContainer.getLayoutParams().height = newHeight; if (bottomBar.isShy()) { int defaultOffset = bottomBar.useExtraOffset() ? navBarHeightCopy : 0; bottomBar.setTranslationY(defaultOffset); ((CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams()) .setBehavior(new BottomNavigationBehavior(newHeight, defaultOffset, bottomBar.isShy(), bottomBar.mIsTabletMode)); } ViewTreeObserver obs = outerContainer.getViewTreeObserver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { obs.removeOnGlobalLayoutListener(this); } else { obs.removeGlobalOnLayoutListener(this); } } }); } }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { formGallery = ((EditText) findViewById(R.id.upload_target)).getText().toString(); formTitle = ((EditText) findViewById(R.id.upload_title)).getText().toString(); formBody = ((EditText) findViewById(R.id.upload_text)).getText().toString(); formLocation = ((CheckBox) findViewById(R.id.upload_enclose_position)).isChecked(); initViews();// w ww .j av a 2 s . c o m } }
From source file:com.hichinaschool.flashcards.anki.Info.java
private void lockScreenOrientation() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }// w ww .ja v a 2s. com }
From source file:com.ywesee.amiko.MainActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (mWebView != null) { // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { mWebView.getSettings().setTextZoom(125); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { mWebView.getSettings().setTextZoom(175); }//from ww w . jav a 2 s . c o m } }
From source file:github.popeen.dsub.fragments.NowPlayingFragment.java
@Override public void onMetadataUpdate(Entry song, int fieldChange) { if (song != null && song.isStarred()) { starButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else {// ww w.j a v a 2 s .c o m if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { starButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.star_outline)); } else { starButton.setImageResource(R.drawable.ic_toggle_star_outline_dark); } } int badRating, goodRating, bookmark; if (song != null && song.getRating() == 1) { rateBadButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_bad_selected)); } else { if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { badRating = R.drawable.ic_action_rating_bad_dark; } else { badRating = DrawableTint.getDrawableRes(context, R.attr.rating_bad); } rateBadButton.setImageResource(badRating); } if (song != null && song.getRating() == 5) { rateGoodButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_good_selected)); } else { if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { goodRating = R.drawable.ic_action_rating_good_dark; } else { goodRating = DrawableTint.getDrawableRes(context, R.attr.rating_good); } rateGoodButton.setImageResource(goodRating); } if (song != null && song.getBookmark() != null) { bookmarkButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_menu_bookmark_selected)); } else { if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { bookmark = R.drawable.ic_menu_bookmark_dark; } else { bookmark = DrawableTint.getDrawableRes(context, R.attr.bookmark); } bookmarkButton.setImageResource(bookmark); } if (song != null && albumArtImageView != null && fieldChange == DownloadService.METADATA_UPDATED_COVER_ART) { getImageLoader().loadImage(albumArtImageView, song, true, true); } }
From source file:edu.mit.viral.shen.DroidFish.java
private final void readPrefs() { int modeNr = getIntSetting("gameMode", 3); gameMode = new GameMode(modeNr); String oldPlayerName = playerName; playerName = settings.getString("playerName", "Player"); boardFlipped = settings.getBoolean("boardFlipped", false); autoSwapSides = settings.getBoolean("autoSwapSides", false); playerNameFlip = settings.getBoolean("playerNameFlip", true); setBoardFlip(!playerName.equals(oldPlayerName)); boolean drawSquareLabels = settings.getBoolean("drawSquareLabels", false); cb.setDrawSquareLabels(drawSquareLabels); cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", true); cb.toggleSelection = getIntSetting("squareSelectType", 0) == 1; cb.highlightLastMove = settings.getBoolean("highlightLastMove", false); cb.setBlindMode(settings.getBoolean("blindMode", false)); mShowThinking = settings.getBoolean("showThinking", true); mShowStats = settings.getBoolean("showStats", true); mWhiteBasedScores = settings.getBoolean("whiteBasedScores", false); maxNumArrows = getIntSetting("thinkingArrows", 2); mShowBookHints = settings.getBoolean("bookHints", false); mEngineThreads = getIntSetting("threads", 1); String engine = settings.getString("engine", "stockfish"); int strength = settings.getInt("strength", 1000); setEngineStrength(engine, strength); mPonderMode = settings.getBoolean("ponderMode", false); if (!mPonderMode) ctrl.stopPonder();/*w w w .j a v a2s . c o m*/ timeControl = getIntSetting("timeControl", 120000); movesPerSession = getIntSetting("movesPerSession", 60); timeIncrement = getIntSetting("timeIncrement", 0); boardGestures = settings.getBoolean("boardGestures", true); scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2")); invertScrollDirection = settings.getBoolean("invertScrollDirection", false); discardVariations = settings.getBoolean("discardVariations", false); Util.setFullScreenMode(this, settings); useWakeLock = settings.getBoolean("wakeLock", false); setWakeLock(useWakeLock); int fontSize = getIntSetting("fontSize", 16); int statusFontSize = fontSize; Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_PORTRAIT) statusFontSize = Math.min(statusFontSize, 16); status.setTextSize(statusFontSize); moveList.setTextSize(fontSize); thinking.setTextSize(fontSize); soundEnabled = settings.getBoolean("soundEnabled", false); vibrateEnabled = settings.getBoolean("vibrateEnabled", false); animateMoves = settings.getBoolean("animateMoves", true); autoScrollTitle = settings.getBoolean("autoScrollTitle", true); setTitleScrolling(); custom1ButtonActions.readPrefs(settings, actionFactory); custom2ButtonActions.readPrefs(settings, actionFactory); custom3ButtonActions.readPrefs(settings, actionFactory); updateButtons(); bookOptions.filename = settings.getString("bookFile", ""); bookOptions.maxLength = getIntSetting("bookMaxLength", 1000000); bookOptions.preferMainLines = settings.getBoolean("bookPreferMainLines", false); bookOptions.tournamentMode = settings.getBoolean("bookTournamentMode", false); bookOptions.random = (settings.getInt("bookRandom", 500) - 500) * (3.0 / 500); setBookOptions(); engineOptions.hashMB = getIntSetting("hashMB", 16); engineOptions.hints = settings.getBoolean("tbHints", false); engineOptions.hintsEdit = settings.getBoolean("tbHintsEdit", false); engineOptions.rootProbe = settings.getBoolean("tbRootProbe", true); engineOptions.engineProbe = settings.getBoolean("tbEngineProbe", true); String gtbPath = settings.getString("gtbPath", "").trim(); if (gtbPath.length() == 0) { File extDir = Environment.getExternalStorageDirectory(); String sep = File.separator; gtbPath = extDir.getAbsolutePath() + sep + gtbDefaultDir; } engineOptions.gtbPath = gtbPath; setEngineOptions(false); setEgtbHints(cb.getSelectedSquare()); updateThinkingInfo(); pgnOptions.view.variations = settings.getBoolean("viewVariations", true); pgnOptions.view.comments = settings.getBoolean("viewComments", true); pgnOptions.view.nag = settings.getBoolean("viewNAG", true); pgnOptions.view.headers = settings.getBoolean("viewHeaders", false); final int oldViewPieceType = pgnOptions.view.pieceType; pgnOptions.view.pieceType = getIntSetting("viewPieceType", PGNOptions.PT_LOCAL); showVariationLine = settings.getBoolean("showVariationLine", false); pgnOptions.imp.variations = settings.getBoolean("importVariations", true); pgnOptions.imp.comments = settings.getBoolean("importComments", true); pgnOptions.imp.nag = settings.getBoolean("importNAG", true); pgnOptions.exp.variations = settings.getBoolean("exportVariations", true); pgnOptions.exp.comments = settings.getBoolean("exportComments", true); pgnOptions.exp.nag = settings.getBoolean("exportNAG", true); pgnOptions.exp.playerAction = settings.getBoolean("exportPlayerAction", false); pgnOptions.exp.clockInfo = settings.getBoolean("exportTime", false); ColorTheme.instance().readColors(settings); cb.setColors(); Util.overrideFonts(findViewById(android.R.id.content)); gameTextListener.clear(); setPieceNames(pgnOptions.view.pieceType); ctrl.prefsChanged(oldViewPieceType != pgnOptions.view.pieceType); // update the typeset in case of a change anyway, cause it could occur // as well in rotation setFigurineNotation(pgnOptions.view.pieceType == PGNOptions.PT_FIGURINE, fontSize); showMaterialDiff = settings.getBoolean("materialDiff", false); secondTitleLine.setVisibility(showMaterialDiff ? View.VISIBLE : View.GONE); }
From source file:com.aimfire.demo.CamcorderActivity.java
/** * get the default/natural device orientation. this should be PORTRAIT * for phones and LANDSCAPE for tablets/*ww w . j a v a 2 s .c o m*/ */ public int getDeviceDefaultOrientation() { WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Configuration config = getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && config.orientation == Configuration.ORIENTATION_LANDSCAPE) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && config.orientation == Configuration.ORIENTATION_PORTRAIT)) { return Configuration.ORIENTATION_LANDSCAPE; } else { return Configuration.ORIENTATION_PORTRAIT; } }