public static void saveFile( final FileDialogCallback callback, final FragmentManager fragmentManager, final String title, final String message, final File defaultFile, final String checkMsg) { // Message is received after file is selected Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { if (message.what == FileDialogFragment.MESSAGE_OKAY) { callback.onFileSelected( new File(message.getData().getString(FileDialogFragment.MESSAGE_DATA_FILE)), message.getData().getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED)); } } }; // Create a new Messenger for the communication back final Messenger messenger = new Messenger(returnHandler); DialogFragmentWorkaround.INTERFACE.runnableRunDelayed( new Runnable() { @Override public void run() { FileDialogFragment fileDialog = FileDialogFragment.newInstance(messenger, title, message, defaultFile, checkMsg); fileDialog.show(fragmentManager, "fileDialog"); } }); }
private void showUserIdInfo(final int position) { final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); final int isVerified = mUserIdsAdapter.getIsVerified(position); DialogFragmentWorkaround.INTERFACE.runnableRunDelayed( new Runnable() { public void run() { UserIdInfoDialogFragment dialogFragment = UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); } }); }
/** Show dialog where to export keys */ public void showExportKeysDialog( final long[] masterKeyIds, final String exportFilename, final boolean showSecretCheckbox) { mExportFilename = exportFilename; // Message is received after file is selected Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { if (message.what == FileDialogFragment.MESSAGE_OKAY) { Bundle data = message.getData(); mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); exportKeys(masterKeyIds, data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED)); } } }; // Create a new Messenger for the communication back final Messenger messenger = new Messenger(returnHandler); DialogFragmentWorkaround.INTERFACE.runnableRunDelayed( new Runnable() { public void run() { String title = null; if (masterKeyIds == null) { // export all keys title = mActivity.getString(R.string.title_export_keys); } else { // export only key specified at data uri title = mActivity.getString(R.string.title_export_key); } String message = mActivity.getString(R.string.specify_file_to_export_to); String checkMsg = showSecretCheckbox ? mActivity.getString(R.string.also_export_secret_keys) : null; mFileDialog = FileDialogFragment.newInstance(messenger, title, message, exportFilename, checkMsg); mFileDialog.show(mActivity.getSupportFragmentManager(), "fileDialog"); } }); }
/** Displays an install or start orbot dialog depending on orbot's presence and state */ public void showDialog() { DialogFragmentWorkaround.INTERFACE.runnableRunDelayed( new Runnable() { public void run() { Runnable ignoreTor = new Runnable() { @Override public void run() { Intent intent = new Intent(); mCryptoInputParcel.addParcelableProxy(ParcelableProxy.getForNoProxy()); intent.putExtra(RESULT_CRYPTO_INPUT, mCryptoInputParcel); setResult(RESULT_OK, intent); finish(); } }; Runnable dialogDismissed = new Runnable() { @Override public void run() { finish(); } }; if (OrbotHelper.putOrbotInRequiredState( R.string.orbot_ignore_tor, ignoreTor, dialogDismissed, Preferences.getPreferences(OrbotRequiredDialogActivity.this).getProxyPrefs(), OrbotRequiredDialogActivity.this)) { // no action required after all Intent intent = new Intent(); intent.putExtra(RESULT_CRYPTO_INPUT, mCryptoInputParcel); setResult(RESULT_OK, intent); } } }); }