Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.

Prototype

int SCREEN_ORIENTATION_LANDSCAPE

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant corresponding to landscape in the android.R.attr#screenOrientation attribute.

Usage

From source file:de.cachebox_test.splash.java

private void Initial(int width, int height) {
    // Jetzt ist der workPath erstmal festgelegt.
    Log.debug(log, "Initial()");

    // lolipop ask write permission
    if (android.os.Build.VERSION.SDK_INT > 20) {
        // if (LolipopworkPath != null) workPath = LolipopworkPath + "/cachebox";
    }//ww w.  java 2  s.c  om

    // Zur Kompatibilitt mit lteren Installationen wird hier noch die redirection.txt abgefragt
    if (FileIO.FileExists(workPath + "/redirection.txt")) {
        BufferedReader Filereader;

        try {
            Filereader = new BufferedReader(new FileReader(workPath + "/redirection.txt"));
            String line;

            while ((line = Filereader.readLine()) != null) {
                // chk ob der umleitungs Ordner existiert
                if (FileIO.FileExists(line)) {
                    workPath = line;
                }
            }

            Filereader.close();
        } catch (IOException e) {
            Log.err(log, "read redirection", e);
        }

    }

    new Config(workPath);

    // Read Config
    Config.Initialize(workPath, workPath + "/cachebox.config");

    // hier muss die Config Db initialisiert werden
    Database.Settings = new AndroidDB(DatabaseType.Settings, this);

    boolean userFolderExists = FileIO.createDirectory(Config.mWorkPath + "/User");

    if (!userFolderExists)
        return;
    Database.Settings.StartUp(Config.mWorkPath + "/User/Config.db3");

    // initialisieren der PlattformSettings
    PlatformSettings.setPlatformSettings(new IPlatformSettings() {

        @Override
        public void Write(SettingBase<?> setting) {
            if (androidSetting == null)
                androidSetting = splash.this.getSharedPreferences(Global.PREFS_NAME, 0);
            if (androidSettingEditor == null)
                androidSettingEditor = androidSetting.edit();

            if (setting instanceof SettingBool) {
                androidSettingEditor.putBoolean(setting.getName(), ((SettingBool) setting).getValue());
            } else if (setting instanceof SettingString) {
                androidSettingEditor.putString(setting.getName(), ((SettingString) setting).getValue());
            } else if (setting instanceof SettingInt) {
                androidSettingEditor.putInt(setting.getName(), ((SettingInt) setting).getValue());
            }

            // Commit the edits!
            androidSettingEditor.commit();
        }

        @Override
        public SettingBase<?> Read(SettingBase<?> setting) {
            if (androidSetting == null)
                androidSetting = splash.this.getSharedPreferences(Global.PREFS_NAME, 0);

            if (setting instanceof SettingString) {
                String value = androidSetting.getString(setting.getName(), "");
                ((SettingString) setting).setValue(value);
            } else if (setting instanceof SettingBool) {
                boolean value = androidSetting.getBoolean(setting.getName(),
                        ((SettingBool) setting).getDefaultValue());
                ((SettingBool) setting).setValue(value);
            } else if (setting instanceof SettingInt) {
                int value = androidSetting.getInt(setting.getName(), ((SettingInt) setting).getDefaultValue());
                ((SettingInt) setting).setValue(value);
            }
            setting.clearDirty();
            return setting;
        }
    });

    // wenn die Settings DB neu Erstellt wurde, mssen die Default werte
    // geschrieben werden.
    if (Database.Settings.isDbNew()) {
        Config.settings.LoadAllDefaultValues();
        Config.settings.WriteToDB();
    } else {
        Config.settings.ReadFromDB();
    }

    // Add Android Only Settings
    AndroidSettings.addToSettiongsList();

    new CB_SLF4J(workPath);
    CB_SLF4J.setLogLevel((LogLevel) Config.AktLogLevel.getEnumValue());
    Config.AktLogLevel.addChangedEventListener(new IChanged() {
        @Override
        public void isChanged() {
            CB_SLF4J.setLogLevel((LogLevel) Config.AktLogLevel.getEnumValue());
        }
    });

    if (GlobalCore.isTab) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        Log.debug(log, "setRequestedOrientation SCREEN_ORIENTATION_LANDSCAPE");
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        Log.debug(log, "setRequestedOrientation SCREEN_ORIENTATION_PORTRAIT");
    }

    Database.Data = new AndroidDB(DatabaseType.CacheBox, this);

    // copy AssetFolder only if Rev-Number changed, like at new installation
    try {
        if (Config.installRev.getValue() < GlobalCore.CurrentRevision) {
            String[] exclude = new String[] { "webkit", "sound", "sounds", "images", "skins", "lang",
                    "kioskmode", "string-files", "" };
            copyAssetFolder myCopie = new copyAssetFolder();

            myCopie.copyAll(getAssets(), Config.mWorkPath, exclude);
            Config.installRev.setValue(GlobalCore.CurrentRevision);
            Config.newInstall.setValue(true);
            Config.AcceptChanges();

            File CreateFile;

            // create .nomedia Files
            try {
                CreateFile = FileFactory.createFile(workPath + "/data/.nomedia");
                CreateFile.getParentFile().mkdirs();
                CreateFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                CreateFile = FileFactory.createFile(workPath + "/skins/.nomedia");
                CreateFile.getParentFile().mkdirs();
                CreateFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                CreateFile = FileFactory.createFile(workPath + "/repository/.nomedia");
                CreateFile.getParentFile().mkdirs();
                CreateFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                CreateFile = FileFactory.createFile(workPath + "/Repositories/.nomedia");
                CreateFile.getParentFile().mkdirs();
                CreateFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                CreateFile = FileFactory.createFile(workPath + "/cache/.nomedia");
                CreateFile.getParentFile().mkdirs();
                CreateFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

        } else {
            Config.newInstall.setValue(false);
        }
    } catch (Exception e) {
        Log.err(log, "Copy Asset", e);
    }

    // save askAgain for show SandboxMsg
    Config.showSandbox.setValue(showSandbox);
    Config.AcceptChanges();

    // UiSize Structur fr die Berechnung der Gren zusammen stellen!

    Log.debug(log, GlobalCore.getVersionString());
    Log.debug(log, "Screen width/height:" + width + "/" + height);

    if (ui == null) {
        Resources res = splash.this.getResources();

        Log.debug(log, "create new devices-sizes");
        ui = new DevicesSizes();

        ui.Window = new Size(width, height);
        ui.Density = res.getDisplayMetrics().density;
        ui.isLandscape = false;

        // Log Size values
        Log.debug(log, "UI-Sizes");
        Log.debug(log, "ui.Window: " + ui.Window.toString());
        Log.debug(log, "ui.Density: " + ui.Density);
        Log.debug(log, "ui.isLandscape: " + ui.isLandscape);

    }

    new UiSizes();
    UI_Size_Base.that.initial(ui);
    GL_UISizes.defaultDPI = ui.Density;

    Global.Paints.init(this);

    {// restrict MapsforgeScaleFactor to max 1.0f (TileSize 256x256)
        ext_AndroidGraphicFactory.createInstance(this.getApplication());

        float restrictedScaleFactor = 1f;
        DisplayModel.setDeviceScaleFactor(restrictedScaleFactor);
        new de.cachebox_test.Map.AndroidManager(new DisplayModel());
    }

    Initial2();
}

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);
    }/*from  w ww  .j av a 2  s  .c o m*/
}

From source file:com.youku.player.base.YoukuBasePlayerActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Logger.d("PlayFlow", "onConfigurationChange:" + newConfig.orientation);
    if (Profile.PHONE_BROWSER == Profile.from || mediaPlayerDelegate.videoInfo != null
            && (StaticsUtil.PLAY_TYPE_LOCAL.equals(mediaPlayerDelegate.videoInfo.getPlayType())
                    || mediaPlayerDelegate.videoInfo.isHLS))
        return;//from ww w .  j a  v a2 s .c  om
    if (mediaPlayerDelegate.isFullScreen && PlayerUtil.isYoukuTablet(YoukuBasePlayerActivity.this)) {
        return;
    }
    // ????
    if (isLand()) {
        fullWidth = getWindowManager().getDefaultDisplay().getWidth();
        Logger.d("lelouch", "isLand");
        Logger.d("PlayFlow", "isTablet:" + PlayerUtil.isYoukuTablet(this));
        // ???
        if (!PlayerUtil.isYoukuTablet(this)) {
            onFullscreenListener();
            closeOptionsMenu();
            setPlayerFullScreen(false);
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    mYoukuPlayerView.onConfigrationChange();
                    if (mInvestigate != null) {
                        mInvestigate.updateLayout();
                    }
                }
            });

            if (mediaPlayerDelegate.mAdType == AdType.AD_TYPE_IMAGE) {
                updatePlugin(PLUGIN_SHOW_NOT_SET);

                if (isImageADShowing && mImageAD != null && !mImageAD.isOnclick()
                        && mImageAD.isSaveOnOrientChange()) {
                    pluginManager.addPlugin(mImageAD, player_holder);
                    mImageAD.setVisible(true);
                    mImageAD.setVisibility(View.VISIBLE);
                } else if (mImageAD != null && mImageAD.isStartToShow() && !mImageAD.isSaveOnOrientChange()) {
                    if (!mImageAD.isDomobLandingPageOpened()) {
                        mImageAD.dismissImageAD();
                        if (mediaPlayerDelegate != null) {
                            mediaPlayerDelegate.startPlayAfterImageAD();
                        }
                    }
                }
            }
            if (null != handler) {
                handler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        if (mAdDialogHint != null && mAdDialogHint.isShowing()) {
                            mAdDialogHint.cancel();
                            mAdDialogHint = null;
                        }
                    }
                }, 100);
            }
            return;
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            setPadHorizontalLayout();
            updatePlugin(!mediaPlayerDelegate.isAdvShowFinished() ? PLUGIN_SHOW_AD_PLAY : PLUGIN_SHOW_NOT_SET);
            Logger.d("PlayFlow", "???");
            layoutHandler.removeCallbacksAndMessages(null);
        }

    } else {
        // if(Profile.PLANTFORM == Plantform.TUDOU && onPause) return;
        goSmall();
        if (UIUtils.hasKitKat()) {
            showSystemUI(mPluginADPlay);
        }
        orientationHelper.fromUser = false;
        updatePlugin(!mediaPlayerDelegate.isAdvShowFinished() ? PLUGIN_SHOW_AD_PLAY : PLUGIN_SHOW_NOT_SET);
        //fitsSystemWindowstrue????padding?
        player_holder.setPadding(0, 0, 0, 0);
        Logger.d("PlayFlow", "??");
    }
    if (mInvestigate != null) {
        mInvestigate.updateLayout();
    }
    if (isImageADShowing && mImageAD != null && !mImageAD.isOnclick() && mImageAD.isSaveOnOrientChange()) {

        pluginManager.addPlugin(mImageAD, player_holder);
        mImageAD.setVisible(true);
        mImageAD.setVisibility(View.VISIBLE);
    } else if (mImageAD != null && mImageAD.isStartToShow() && !mImageAD.isSaveOnOrientChange() && !onPause) {
        if (!mImageAD.isDomobLandingPageOpened()) {
            mImageAD.dismissImageAD();
            if (mediaPlayerDelegate != null) {
                mediaPlayerDelegate.startPlayAfterImageAD();
            }
        }
    }
    if (mAdDialogHint != null && mAdDialogHint.isShowing()) {
        mAdDialogHint.cancel();
        mAdDialogHint = null;
    }
}

From source file:androidx.media.widget.VideoView2.java

private int retrieveOrientation() {
    DisplayMetrics dm = Resources.getSystem().getDisplayMetrics();
    int width = dm.widthPixels;
    int height = dm.heightPixels;

    return (height > width) ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
            : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}

From source file:com.youku.player.base.YoukuBasePlayerActivity.java

protected void changeConfiguration(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Logger.d("PlayFlow", "changeConfiguration");
    if (Profile.PHONE_BROWSER == Profile.from || mediaPlayerDelegate.videoInfo != null
            && (StaticsUtil.PLAY_TYPE_LOCAL.equals(mediaPlayerDelegate.videoInfo.getPlayType())
                    || mediaPlayerDelegate.videoInfo.isHLS))
        return;//from w  ww .jav a2s .c  om
    if (mediaPlayerDelegate.isFullScreen && PlayerUtil.isYoukuTablet(YoukuBasePlayerActivity.this)) {
        return;
    }
    // ????
    if (isLand()) {
        fullWidth = getWindowManager().getDefaultDisplay().getWidth();
        Logger.d("lelouch", "isLand");
        Logger.d("PlayFlow", "isTablet:" + PlayerUtil.isYoukuTablet(this));
        // ???
        if (!PlayerUtil.isYoukuTablet(this)) {
            onFullscreenListener();
            closeOptionsMenu();
            setPlayerFullScreen(false);
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    mYoukuPlayerView.onConfigrationChange();
                }
            });
            // detectPlugin();
            return;
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            setPadHorizontalLayout();
            updatePlugin(!mediaPlayerDelegate.isAdvShowFinished() ? PLUGIN_SHOW_AD_PLAY : PLUGIN_SHOW_NOT_SET);
            Logger.d("PlayFlow", "???");
            layoutHandler.removeCallbacksAndMessages(null);
            if (isImageADShowing && mImageAD != null && !mImageAD.isOnclick()
                    && mImageAD.isSaveOnOrientChange()) {
                pluginManager.addPlugin(mImageAD, player_holder);
                mImageAD.setVisible(true);
                mImageAD.setVisibility(View.VISIBLE);
            }
        }

    } else {
        // if(Profile.PLANTFORM == Plantform.TUDOU && onPause) return;
        goSmall();
        updatePlugin(!mediaPlayerDelegate.isAdvShowFinished() ? PLUGIN_SHOW_AD_PLAY : PLUGIN_SHOW_NOT_SET);
        Logger.d("PlayFlow", "??");
    }

}

From source file:com.youku.player.base.YoukuBasePlayerActivity.java

public void setPlayerFullScreen(final boolean lockSensor) {
    if (mediaPlayerDelegate == null)
        return;//from  w w w. j a v a2s .c  o  m
    if (lockSensor) {
        if (UIUtils.hasGingerbread() && !PreferenceUtil.getPreferenceBoolean(this, "video_lock", false)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
    }

    mediaPlayerDelegate.onChangeOrient = true;
    mediaPlayerDelegate.isFullScreen = true;
    updatePlugin(!mediaPlayerDelegate.isAdvShowFinished() ? PLUGIN_SHOW_AD_PLAY : PLUGIN_SHOW_NOT_SET);

    mYoukuPlayerView.setFullscreenBack();
    // ?fillpearent
    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    });
}

From source file:com.youku.player.base.YoukuBasePlayerActivity.java

@Override
public void port2Land() {//?
    if (null != orientationHelper)
        orientationHelper.disableListener();
    if (PreferenceUtil.getPreferenceBoolean(this, "video_lock", false)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {// w  w w . j a va  2s .  c  o m
        layoutHandler.removeCallbacksAndMessages(null);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }
}

From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private int getScreenOrientation() {
    switch (getScreenRotation()) {
    case Surface.ROTATION_0:
        return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    case Surface.ROTATION_90:
        return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    case Surface.ROTATION_180:
        // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API Level 9+
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
                ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
                : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    case Surface.ROTATION_270:
        // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API Level 9+
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
                ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
                : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    default:/*w  w  w.java  2 s  . c  om*/
        return 0;
    }
}

From source file:com.ichi2.anki2.Reviewer.java

private SharedPreferences restorePreferences() {
    SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
    mPrefHideDueCount = preferences.getBoolean("hideDueCount", false);
    mPrefWhiteboard = preferences.getBoolean("whiteboard", false);
    mPrefRecord = preferences.getBoolean("record", false);
    mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true);
    mPrefTextSelection = preferences.getBoolean("textSelection", true);
    mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false);
    // mDeckFilename = preferences.getString("deckFilename", "");
    mNightMode = preferences.getBoolean("invertedColors", false);
    mInvertedColors = mNightMode;//from  ww w .j  av a2  s.  co m
    mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true);
    mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false);
    mshowNextReviewTime = preferences.getBoolean("showNextReviewTime", true);
    mZoomEnabled = preferences.getBoolean("zoom", false);
    mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO);
    mRelativeButtonSize = preferences.getInt("answerButtonSize", 100);
    mInputWorkaround = preferences.getBoolean("inputWorkaround", false);
    mPrefFixArabic = preferences.getBoolean("fixArabicText", false);
    mSpeakText = preferences.getBoolean("tts", false);
    mShowProgressBars = preferences.getBoolean("progressBars", true);
    mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false);
    mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false);
    mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20);
    mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60);
    mScrollingButtons = preferences.getBoolean("scrolling_buttons", false);
    mDoubleScrolling = preferences.getBoolean("double_scrolling", false);

    mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences);
    if (mGesturesEnabled) {
        mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0"));
        if (mGestureShake != 0) {
            mShakeEnabled = true;
        }
        mShakeIntensity = preferences.getInt("minShakeIntensity", 70);

        mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9"));
        mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0"));
        mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8"));
        mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17"));
        mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7"));
        mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3"));
        mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6"));
        mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12"));
        mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2"));
        mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11"));
    }
    if (mPrefTextSelection && mLongClickWorkaround) {
        mGestureLongclick = GESTURE_LOOKUP;
    }
    mShowAnimations = preferences.getBoolean("themeAnimations", false);
    if (mShowAnimations) {
        int animationDuration = preferences.getInt("animationDuration", 500);
        mAnimationDurationTurn = animationDuration;
        mAnimationDurationMove = animationDuration;
    }

    // allow screen orientation in reviewer only when fix preference is not set
    if (preferences.getBoolean("fixOrientation", false)) {
        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);
        }
    }

    if (preferences.getBoolean("keepScreenOn", false)) {
        this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    mSimpleInterface = preferences.getBoolean("simpleInterface", false);
    if (mSimpleInterface) {
        String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " ");
        mSimpleInterfaceExcludeTags = new ArrayList<String>();
        for (String t : tags.split(" ")) {
            if (t.length() > 0) {
                mSimpleInterfaceExcludeTags.add(t);
            }
        }
    }

    return preferences;
}

From source file:com.nit.vicky.Reviewer.java

private SharedPreferences restorePreferences() {
    SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
    mPrefHideDueCount = preferences.getBoolean("hideDueCount", false);
    mPrefWhiteboard = preferences.getBoolean("whiteboard", false);
    mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true);
    mPrefTextSelection = preferences.getBoolean("textSelection", true);
    mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false);
    // mDeckFilename = preferences.getString("deckFilename", "");
    mNightMode = preferences.getBoolean("invertedColors", false);
    mInvertedColors = mNightMode;//from  ww  w  .  j  av a  2s .co m
    mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true);
    mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false);
    mZoomEnabled = preferences.getBoolean("zoom", false);
    mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO);
    mRelativeImageSize = preferences.getInt("relativeImageSize", 100);
    mRelativeButtonSize = preferences.getInt("answerButtonSize", 100);
    mInputWorkaround = preferences.getBoolean("inputWorkaround", false);
    mPrefFixArabic = preferences.getBoolean("fixArabicText", false);
    mPrefForceQuickUpdate = preferences.getBoolean("forceQuickUpdate", true);
    mSpeakText = preferences.getBoolean("tts", false);
    mShowProgressBars = preferences.getBoolean("progressBars", true);
    mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false);
    mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false);
    mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20);
    mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60);
    mScrollingButtons = preferences.getBoolean("scrolling_buttons", false);
    mDoubleScrolling = preferences.getBoolean("double_scrolling", false);
    mPrefCenterVertically = preferences.getBoolean("centerVertically", false);

    mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences);
    if (mGesturesEnabled) {
        mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0"));
        if (mGestureShake != 0) {
            mShakeEnabled = true;
        }
        mShakeIntensity = preferences.getInt("minShakeIntensity", 70);

        mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9"));
        mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0"));
        mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8"));
        mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17"));
        mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7"));
        mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3"));
        mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6"));
        mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12"));
        mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2"));
        mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11"));
    }
    if (mPrefTextSelection && mLongClickWorkaround) {
        mGestureLongclick = GESTURE_LOOKUP;
    }
    mShowAnimations = preferences.getBoolean("themeAnimations", false);
    if (mShowAnimations) {
        int animationDuration = preferences.getInt("animationDuration", 500);
        mAnimationDurationTurn = animationDuration;
        mAnimationDurationMove = animationDuration;
    }

    // allow screen orientation in reviewer only when fix preference is not set
    if (preferences.getBoolean("fixOrientation", false)) {
        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);
        }
    }

    if (preferences.getBoolean("keepScreenOn", false)) {
        this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    mSimpleInterface = preferences.getBoolean("simpleInterface", false);
    if (mSimpleInterface) {
        String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " ");
        mSimpleInterfaceExcludeTags = new ArrayList<String>();
        for (String t : tags.split(" ")) {
            if (t.length() > 0) {
                mSimpleInterfaceExcludeTags.add(t);
            }
        }
    }

    // These are preferences we pull out of the collection instead of SharedPreferences
    try {
        mShowNextReviewTime = AnkiDroidApp.getCol().getConf().getBoolean("estTimes");
        mShowRemainingCardCount = AnkiDroidApp.getCol().getConf().getBoolean("dueCounts");
    } catch (JSONException e) {
        throw new RuntimeException();
    }

    return preferences;
}