OCRTest/src/main/java/edu/sfsu/cs/orange/ocr/CaptureActivity.java
private void retrievePreferences() {
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Retrieve from preferences, and set in this Activity, the language preferences
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    setSourceLanguage(prefs.getString(PreferencesActivity.KEY_SOURCE_LANGUAGE_PREFERENCE,
            CaptureActivity.DEFAULT_SOURCE_LANGUAGE_CODE));
    setTargetLanguage(prefs.getString(PreferencesActivity.KEY_TARGET_LANGUAGE_PREFERENCE,
            CaptureActivity.DEFAULT_TARGET_LANGUAGE_CODE));
    isTranslationActive = prefs.getBoolean(PreferencesActivity.KEY_TOGGLE_TRANSLATION, false);

    // Retrieve from preferences, and set in this Activity, the capture mode preference
      isContinuousModeActive = prefs.getBoolean(PreferencesActivity.KEY_CONTINUOUS_PREVIEW, CaptureActivity.DEFAULT_TOGGLE_CONTINUOUS);

    // Retrieve from preferences, and set in this Activity, the page segmentation mode preference
    String[] pageSegmentationModes = getResources().getStringArray(R.array.pagesegmentationmodes);
    String pageSegmentationModeName = prefs.getString(PreferencesActivity.KEY_PAGE_SEGMENTATION_MODE,
            pageSegmentationModes[0]);
    if (pageSegmentationModeName.equals(pageSegmentationModes[0])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_AUTO_OSD;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[1])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_AUTO;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[2])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_BLOCK;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[3])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_CHAR;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[4])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_COLUMN;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[5])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_LINE;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[6])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_WORD;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[7])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_BLOCK_VERT_TEXT;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[8])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SPARSE_TEXT;
    }

    // Retrieve from preferences, and set in this Activity, the OCR engine mode
    String[] ocrEngineModes = getResources().getStringArray(R.array.ocrenginemodes);
    String ocrEngineModeName = prefs.getString(PreferencesActivity.KEY_OCR_ENGINE_MODE, ocrEngineModes[0]);
    if (ocrEngineModeName.equals(ocrEngineModes[0])) {
      ocrEngineMode = TessBaseAPI.OEM_TESSERACT_ONLY;
    } else if (ocrEngineModeName.equals(ocrEngineModes[1])) {
      ocrEngineMode = TessBaseAPI.OEM_CUBE_ONLY;
    } else if (ocrEngineModeName.equals(ocrEngineModes[2])) {
      ocrEngineMode = TessBaseAPI.OEM_TESSERACT_CUBE_COMBINED;
    }

    // Retrieve from preferences, and set in this Activity, the character blacklist and whitelist
    characterBlacklist = OcrCharacterHelper.getBlacklist(prefs, sourceLanguageCodeOcr);
    characterWhitelist = OcrCharacterHelper.getWhitelist(prefs, sourceLanguageCodeOcr);

    prefs.registerOnSharedPreferenceChangeListener(listener);

    beepManager.updatePrefs();
  }
/**
   * Gets values from shared preferences and sets the corresponding data members in this activity.
   */
Gets values from shared preferences and sets the corresponding data members in this activity.
Gets values from shared preferences and sets the corresponding data members in this activity .
private void retrievePreferences() {
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    setSourceLanguage(prefs.getString(PreferencesActivity.KEY_SOURCE_LANGUAGE_PREFERENCE,
            CaptureActivity.DEFAULT_SOURCE_LANGUAGE_CODE));
    setTargetLanguage(prefs.getString(PreferencesActivity.KEY_TARGET_LANGUAGE_PREFERENCE,
            CaptureActivity.DEFAULT_TARGET_LANGUAGE_CODE));
    isTranslationActive = prefs.getBoolean(PreferencesActivity.KEY_TOGGLE_TRANSLATION, false);
      isContinuousModeActive = prefs.getBoolean(PreferencesActivity.KEY_CONTINUOUS_PREVIEW, CaptureActivity.DEFAULT_TOGGLE_CONTINUOUS);
    String[] pageSegmentationModes = getResources().getStringArray(R.array.pagesegmentationmodes);
    String pageSegmentationModeName = prefs.getString(PreferencesActivity.KEY_PAGE_SEGMENTATION_MODE,
            pageSegmentationModes[0]);
    if (pageSegmentationModeName.equals(pageSegmentationModes[0])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_AUTO_OSD;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[1])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_AUTO;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[2])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_BLOCK;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[3])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_CHAR;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[4])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_COLUMN;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[5])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_LINE;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[6])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_WORD;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[7])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_BLOCK_VERT_TEXT;
    } else if (pageSegmentationModeName.equals(pageSegmentationModes[8])) {
      pageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SPARSE_TEXT;
    }
    String[] ocrEngineModes = getResources().getStringArray(R.array.ocrenginemodes);
    String ocrEngineModeName = prefs.getString(PreferencesActivity.KEY_OCR_ENGINE_MODE, ocrEngineModes[0]);
    if (ocrEngineModeName.equals(ocrEngineModes[0])) {
      ocrEngineMode = TessBaseAPI.OEM_TESSERACT_ONLY;
    } else if (ocrEngineModeName.equals(ocrEngineModes[1])) {
      ocrEngineMode = TessBaseAPI.OEM_CUBE_ONLY;
    } else if (ocrEngineModeName.equals(ocrEngineModes[2])) {
      ocrEngineMode = TessBaseAPI.OEM_TESSERACT_CUBE_COMBINED;
    }
    characterBlacklist = OcrCharacterHelper.getBlacklist(prefs, sourceLanguageCodeOcr);
    characterWhitelist = OcrCharacterHelper.getWhitelist(prefs, sourceLanguageCodeOcr);
    prefs.registerOnSharedPreferenceChangeListener(listener);
    beepManager.updatePrefs();
  }
private void retrievePreferences ( ) { prefs = PreferenceManager . getDefaultSharedPreferences ( this ) ; PreferenceManager . setDefaultValues ( this , R . xml . preferences , false ) ; setSourceLanguage ( prefs . getString ( PreferencesActivity . KEY_SOURCE_LANGUAGE_PREFERENCE , CaptureActivity . DEFAULT_SOURCE_LANGUAGE_CODE ) ) ; setTargetLanguage ( prefs . getString ( PreferencesActivity . KEY_TARGET_LANGUAGE_PREFERENCE , CaptureActivity . DEFAULT_TARGET_LANGUAGE_CODE ) ) ; isTranslationActive = prefs . getBoolean ( PreferencesActivity . KEY_TOGGLE_TRANSLATION , false ) ; isContinuousModeActive = prefs . getBoolean ( PreferencesActivity . KEY_CONTINUOUS_PREVIEW , CaptureActivity . DEFAULT_TOGGLE_CONTINUOUS ) ; String [ ] pageSegmentationModes = getResources ( ) . getStringArray ( R . array . pagesegmentationmodes ) ; String pageSegmentationModeName = prefs . getString ( PreferencesActivity . KEY_PAGE_SEGMENTATION_MODE , pageSegmentationModes [ 0 ] ) ; if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 0 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_AUTO_OSD ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 1 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_AUTO ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 2 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SINGLE_BLOCK ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 3 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SINGLE_CHAR ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 4 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SINGLE_COLUMN ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 5 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SINGLE_LINE ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 6 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SINGLE_WORD ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 7 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SINGLE_BLOCK_VERT_TEXT ; } else if ( pageSegmentationModeName . equals ( pageSegmentationModes [ 8 ] ) ) { pageSegmentationMode = TessBaseAPI . PageSegMode . PSM_SPARSE_TEXT ; } String [ ] ocrEngineModes = getResources ( ) . getStringArray ( R . array . ocrenginemodes ) ; String ocrEngineModeName = prefs . getString ( PreferencesActivity . KEY_OCR_ENGINE_MODE , ocrEngineModes [ 0 ] ) ; if ( ocrEngineModeName . equals ( ocrEngineModes [ 0 ] ) ) { ocrEngineMode = TessBaseAPI . OEM_TESSERACT_ONLY ; } else if ( ocrEngineModeName . equals ( ocrEngineModes [ 1 ] ) ) { ocrEngineMode = TessBaseAPI . OEM_CUBE_ONLY ; } else if ( ocrEngineModeName . equals ( ocrEngineModes [ 2 ] ) ) { ocrEngineMode = TessBaseAPI . OEM_TESSERACT_CUBE_COMBINED ; } characterBlacklist = OcrCharacterHelper . getBlacklist ( prefs , sourceLanguageCodeOcr ) ; characterWhitelist = OcrCharacterHelper . getWhitelist ( prefs , sourceLanguageCodeOcr ) ; prefs . registerOnSharedPreferenceChangeListener ( listener ) ; beepManager . updatePrefs ( ) ; }
Gets values from shared preferences and sets the corresponding data members in this activity.
Gets values from shared preferences and sets the corresponding data members in this activity .
// Retrieve from preferences, and set in this Activity, the language preferences
 // Retrieve from preferences, and set in this Activity, the capture mode preference
 // Retrieve from preferences, and set in this Activity, the page segmentation mode preference
 // Retrieve from preferences, and set in this Activity, the OCR engine mode
 // Retrieve from preferences, and set in this Activity, the character blacklist and whitelist
