Source:
<code>public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { <START> case PublicIntent.REQUESTCODE_DECRYPTED: <END> try { String filename = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("RequiresEncrypt", ""); if (filename != null && filename.length() > 0) { if (CipherUtils.encryptFile(getActivity(), filename, true) == false) MessengerManager.showLongToast(getActivity(), getString(R.string.encryption_failed)); else PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putString("RequiresEncrypt", "").commit(); } } catch (Exception e) { MessengerManager.showLongToast(getActivity(), getString(R.string.encryption_failed)); e.printStackTrace(); } break; case PublicIntent.REQUESTCODE_FILEPICKER: if (data != null && data.getData() != null) { String tmpPath = ActionManager.getPath(getActivity(), data.getData()); if (tmpPath != null) { tmpFile = new File(tmpPath); if (StorageManager.shouldEncryptDecrypt(getActivity(), tmpPath)) { try { if (CipherUtils.decryptFile(getActivity(), tmpPath) == false) MessengerManager.showLongToast(getActivity(), getString(R.string.decryption_failed)); } catch (Exception e) { MessengerManager.showLongToast(getActivity(), getString(R.string.decryption_failed)); e.printStackTrace(); } } } else { ActionManager.actionDisplayError(ChildrenBrowserFragment.this, new AlfrescoAppException( getString(R.string.error_unknown_filepath), true)); } } break; case PublicIntent.REQUESTCODE_CREATE: if (createFile != null) { if (createFile.length() > 0 && lastModifiedDate < createFile.lastModified()) { tmpFile = createFile; createFile = null; } else { createFile.delete(); } } break; default: break; } }</code><technical_language>Externalized common code activityResult in a external common helper class</technical_language>

Target:
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PublicIntent.REQUESTCODE_DECRYPTED: try { String filename = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("RequiresEncrypt", ""); if (filename != null && filename.length() > 0) { if (CipherUtils.encryptFile(getActivity(), filename, true) == false) MessengerManager.showLongToast(getActivity(), getString(R.string.encryption_failed)); else PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putString("RequiresEncrypt", "").commit(); } } catch (Exception e) { MessengerManager.showLongToast(getActivity(), getString(R.string.encryption_failed)); e.printStackTrace(); } break; case PublicIntent.REQUESTCODE_FILEPICKER: if (data != null && data.getData() != null) { String tmpPath = ActionManager.getPath(getActivity(), data.getData()); if (tmpPath != null) { tmpFile = new File(tmpPath); if (StorageManager.shouldEncryptDecrypt(getActivity(), tmpPath)) { try { if (CipherUtils.decryptFile(getActivity(), tmpPath) == false) MessengerManager.showLongToast(getActivity(), getString(R.string.decryption_failed)); } catch (Exception e) { MessengerManager.showLongToast(getActivity(), getString(R.string.decryption_failed)); e.printStackTrace(); } } } else { ActionManager.actionDisplayError(ChildrenBrowserFragment.this, new AlfrescoAppException( getString(R.string.error_unknown_filepath), true)); } } break; default: break; } }