Source:
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) { return; } for (DirChooserType dct : DirChooserType.values()) { if (requestCode == dct.requestCode) { setChosenDirectory(dct, data); if (dct.keyId == R.string.pref_cgeo_dir) { if (LocalStorage.setCgeoDir(Settings.getCgeoDir()) && Settings.isDbOnSDCard()) { DataStore.closeDb(); DataStore.init(); } } return; } } switch (requestCode) { case R.string.pref_mapDirectory: if (data.hasExtra(Intents.EXTRA_MAP_FILE)) { final String mapFile = data.getStringExtra(Intents.EXTRA_MAP_FILE); File file = new File(mapFile); if (!file.isDirectory()) { Settings.setMapFile(mapFile); if (!Settings.isValidMapFile(Settings.getMapFile())) { ActivityMixin.showToast(this, R.string.warn_invalid_mapfile); } else { Integer mapSourceId = mapFile.hashCode(); ListPreference mapSource = (ListPreference) getPreference(R.string.pref_mapsource); mapSource.setValue(mapSourceId.toString()); VALUE_CHANGE_LISTENER.onPreferenceChange(mapSource, mapSourceId); } } else { Settings.setMapFileDirectory(mapFile); } } initMapSourcePreference(); getPreference(R.string.pref_mapDirectory).setSummary(StringUtils.defaultString(Settings.getMapFileDirectory())); break; case R.string.pref_fakekey_ocde_authorization: setOCDEAuthTitle(); redrawScreen(R.string.preference_screen_ocde); break; case R.string.pref_fakekey_ocpl_authorization: setOCPLAuthTitle(); redrawScreen(R.string.preference_screen_ocpl); break; case R.string.pref_fakekey_twitter_authorization: setTwitterAuthTitle(); redrawScreen(R.string.preference_screen_twitter); break; default: throw new IllegalArgumentException(); } }

Target:
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) { return; } for (DirChooserType dct : DirChooserType.values()) { if (requestCode == dct.requestCode) { if (dct.keyId == R.string.pref_offline_cache_directory) { final File sourcePath = new File(Settings.getOfflineCacheDirectory()); setChosenDirectory(dct, data); final File targetPath = new File(data.getData().getPath()); changeOfflineCacheDirectory(SettingsActivity.this, sourcePath, targetPath); } else { setChosenDirectory(dct, data); } return; } } switch (requestCode) { case R.string.pref_mapDirectory: if (data.hasExtra(Intents.EXTRA_MAP_FILE)) { final String mapFile = data.getStringExtra(Intents.EXTRA_MAP_FILE); File file = new File(mapFile); if (!file.isDirectory()) { Settings.setMapFile(mapFile); if (!Settings.isValidMapFile(Settings.getMapFile())) { ActivityMixin.showToast(this, R.string.warn_invalid_mapfile); } else { Integer mapSourceId = mapFile.hashCode(); ListPreference mapSource = (ListPreference) getPreference(R.string.pref_mapsource); mapSource.setValue(mapSourceId.toString()); VALUE_CHANGE_LISTENER.onPreferenceChange(mapSource, mapSourceId); } } else { Settings.setMapFileDirectory(mapFile); } } initMapSourcePreference(); getPreference(R.string.pref_mapDirectory).setSummary(StringUtils.defaultString(Settings.getMapFileDirectory())); break; case R.string.pref_fakekey_ocde_authorization: setOCDEAuthTitle(); redrawScreen(R.string.preference_screen_ocde); break; case R.string.pref_fakekey_ocpl_authorization: setOCPLAuthTitle(); redrawScreen(R.string.preference_screen_ocpl); break; case R.string.pref_fakekey_twitter_authorization: setTwitterAuthTitle(); redrawScreen(R.string.preference_screen_twitter); break; default: throw new IllegalArgumentException(); } }