List of usage examples for android.app DialogFragment show
public int show(FragmentTransaction transaction, String tag)
From source file:org.alfresco.mobile.android.application.fragments.properties.DetailsFragment.java
public void openin() { if (isRestrictable) { return;/*from www . jav a 2s.co m*/ } Bundle b = new Bundle(); // 3 cases SynchroManager syncManager = SynchroManager.getInstance(getActivity()); Account acc = SessionUtils.getAccount(getActivity()); if (syncManager.isSynced(SessionUtils.getAccount(getActivity()), node)) { final File syncFile = syncManager.getSyncFile(acc, node); if (syncFile == null || !syncFile.exists()) { MessengerManager.showLongToast(getActivity(), getString(R.string.sync_document_not_available)); return; } long datetime = syncFile.lastModified(); setDownloadDateTime(new Date(datetime)); if (DataProtectionManager.getInstance(getActivity()).isEncryptionEnable()) { // IF sync file + sync activate + data protection ActionManager.actionView(this, syncFile, new ActionManagerListener() { @Override public void onActivityNotFoundException(ActivityNotFoundException e) { OpenAsDialogFragment.newInstance(syncFile).show(getActivity().getFragmentManager(), OpenAsDialogFragment.TAG); } }); } else { // If sync file + sync activate ActionManager.openIn(this, syncFile, MimeTypeManager.getMIMEType(getActivity(), syncFile.getName()), PublicIntent.REQUESTCODE_SAVE_BACK); } } else { // Other case b.putParcelable(DownloadDialogFragment.ARGUMENT_DOCUMENT, (Document) node); b.putInt(DownloadDialogFragment.ARGUMENT_ACTION, DownloadDialogFragment.ACTION_OPEN); DialogFragment frag = new DownloadDialogFragment(); frag.setArguments(b); frag.show(getFragmentManager(), DownloadDialogFragment.TAG); } }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
/** * this is to fix old method which when called in onResume() would create a * second dialog overlaying the first. The first was actually not removed. * Doing a commit after the remove() and starting a second FragmentTransaction * seems to fix the duplicate dialog bug. * * @param dialog//from w w w . jav a 2 s .c o m * @param tag */ private void showDialogFragment(android.app.DialogFragment dialog, String tag) { FragmentTransaction backupFt = getFragmentManager().beginTransaction(); Fragment backupPrev = getFragmentManager().findFragmentByTag(tag); if (backupPrev != null) { backupFt.remove(backupPrev); backupFt.commit(); // apply the remove backupFt = getFragmentManager().beginTransaction(); // start a new transaction } backupFt.addToBackStack(null); dialog.show(backupFt, tag); }
From source file:org.alfresco.mobile.android.application.fragments.properties.DetailsFragment.java
public void share() { if (node.isFolder()) { return;// w w w . java2s . co m } if (node instanceof NodeSyncPlaceHolder) { SynchroManager syncManager = SynchroManager.getInstance(getActivity()); Account acc = SessionUtils.getAccount(getActivity()); final File syncFile = syncManager.getSyncFile(acc, node); if (syncFile == null || !syncFile.exists()) { MessengerManager.showLongToast(getActivity(), getString(R.string.sync_document_not_available)); return; } long datetime = syncFile.lastModified(); setDownloadDateTime(new Date(datetime)); if (DataProtectionManager.getInstance(getActivity()).isEncryptionEnable()) { // IF sync file + sync activate + data protection ActionManager.actionSend(getActivity(), syncFile, new ActionManagerListener() { @Override public void onActivityNotFoundException(ActivityNotFoundException e) { } }); } else { // If sync file + sync activate ActionManager.actionSend(getActivity(), syncFile); } return; } if (alfSession instanceof RepositorySession) { // Only sharing as attachment is allowed when we're not on a cloud // account Bundle b = new Bundle(); b.putParcelable(DownloadDialogFragment.ARGUMENT_DOCUMENT, (Document) node); b.putInt(DownloadDialogFragment.ARGUMENT_ACTION, DownloadDialogFragment.ACTION_EMAIL); DialogFragment frag = new DownloadDialogFragment(); frag.setArguments(b); frag.show(getFragmentManager(), DownloadDialogFragment.TAG); } else { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.app_name); builder.setMessage(R.string.link_or_attach); builder.setPositiveButton(R.string.full_attachment, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Bundle b = new Bundle(); b.putParcelable(DownloadDialogFragment.ARGUMENT_DOCUMENT, (Document) node); b.putInt(DownloadDialogFragment.ARGUMENT_ACTION, DownloadDialogFragment.ACTION_EMAIL); DialogFragment frag = new DownloadDialogFragment(); frag.setArguments(b); frag.show(getFragmentManager(), DownloadDialogFragment.TAG); } }); builder.setNegativeButton(R.string.link_to_repo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (parentNode != null) { String path = parentNode.getPropertyValue(PropertyIds.PATH); if (path.length() > 0) { if (path.startsWith("/Sites/")) { // Get past the '/Sites/' String sub1 = path.substring(7); // Find end of site name int idx = sub1.indexOf('/'); if (idx == -1) { idx = sub1.length(); } String siteName = sub1.substring(0, idx); String nodeID = NodeRefUtils.getCleanIdentifier(node.getIdentifier()); String fullPath = String.format(getString(R.string.cloud_share_url), ((CloudSession) alfSession).getNetwork().getIdentifier(), siteName, nodeID); ActionManager.actionShareLink(DetailsFragment.this, fullPath); } else { Log.i(getString(R.string.app_name), "Site path not as expected: no /sites/"); } } else { Log.i(getString(R.string.app_name), "Site path not as expected: no parent path"); } } else { Log.i(getString(R.string.app_name), "Site path not as expected: No parent folder"); } dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:android.support.v14.preference.PreferenceFragment.java
/** * Called when a preference in the tree requests to display a dialog. Subclasses should * override this method to display custom dialogs or to handle dialogs for custom preference * classes./*from w ww . j a v a 2 s . com*/ * * @param preference The Preference object requesting the dialog. */ @Override public void onDisplayPreferenceDialog(Preference preference) { boolean handled = false; if (getCallbackFragment() instanceof OnPreferenceDisplayDialogCallback) { handled = ((OnPreferenceDisplayDialogCallback) getCallbackFragment()).onPreferenceDisplayDialog(this, preference); } if (!handled && getActivity() instanceof OnPreferenceDisplayDialogCallback) { handled = ((OnPreferenceDisplayDialogCallback) getActivity()).onPreferenceDisplayDialog(this, preference); } if (handled) { return; } // check if dialog is already showing if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) { return; } final DialogFragment f; if (preference instanceof EditTextPreference) { f = EditTextPreferenceDialogFragment.newInstance(preference.getKey()); } else if (preference instanceof ListPreference) { f = ListPreferenceDialogFragment.newInstance(preference.getKey()); } else if (preference instanceof MultiSelectListPreference) { f = MultiSelectListPreferenceDialogFragment.newInstance(preference.getKey()); } else { throw new IllegalArgumentException("Tried to display dialog for unknown " + "preference type. Did you forget to override onDisplayPreferenceDialog()?"); } f.setTargetFragment(this, 0); f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG); }
From source file:amhamogus.com.daysoff.fragments.AddEventFragment.java
@Override public void onClick(View view) { Bundle args;//from w w w .j a va2s .c o m DialogFragment timePicker; switch (view.getId()) { case R.id.event_checkbox_food: if (((CheckBox) view).isChecked()) { checkedActivities[0] = "Eat a meal"; } else { checkedActivities[0] = ""; } break; case R.id.event_checkbox_movie: if (((CheckBox) view).isChecked()) { checkedActivities[1] = "Watch a movie"; } else { checkedActivities[1] = ""; } break; case R.id.event_checkbox_outdoors: if (((CheckBox) view).isChecked()) { checkedActivities[2] = "Go for a walk"; } else { checkedActivities[2] = ""; } break; case R.id.start_time_btn: args = new Bundle(); args.putInt("HOUR", hour); args.putInt("MINUTE", minute); timeLabel = (TextView) view; timePicker = new TimePickerFragment(); timePicker.setArguments(args); timePicker.setTargetFragment(this, 0); timePicker.show(getFragmentManager(), "timePicker"); break; case R.id.end_time_btn: args = new Bundle(); args.putInt("HOUR", futureHour); args.putInt("MINUTE", futureMinute); timeLabel = (TextView) view; timePicker = new TimePickerFragment(); timePicker.setArguments(args); timePicker.setTargetFragment(this, 0); timePicker.show(getFragmentManager(), "timePicker"); break; } }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle option item selections. int id = item.getItemId(); DialogFragment df; switch (id) { case R.id.refresh_data: df = new DialogFragment() { @Override//w ww . j a v a 2s. c om public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Reload Data?"); builder.setMessage("This will clear all your current results. Continue?"); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); reloadData(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return builder.create(); } }; df.show(getFragmentManager(), null); break; case R.id.about: df = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.about)); builder.setMessage(getString(R.string.about_description)); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return builder.create(); } }; df.show(getFragmentManager(), ""); break; case R.id.action_search: openSearch(); break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:org.opendatakit.survey.activities.MainMenuActivity.java
@Override public void onBackPressed() { if ((currentFragment == ScreenList.WEBKIT) && getInstanceId() != null && getCurrentForm() != null && getCurrentForm().tableId != null) { // try to retrieve the active dialog DialogFragment dialog = (DialogFragment) getFragmentManager().findFragmentByTag(BACKPRESS_DIALOG_TAG); if (dialog != null && dialog.getDialog() != null) { // as-is } else {// www .j a v a 2 s .c o m dialog = new BackPressWebkitConfirmationDialogFragment(); } dialog.show(getFragmentManager(), BACKPRESS_DIALOG_TAG); } else { popBackStack(); } }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
private void showEapTlsWifiConfigCreationDialog() { DialogFragment fragment = WifiEapTlsCreateDialogFragment.newInstance(null); fragment.show(getFragmentManager(), WifiEapTlsCreateDialogFragment.class.getName()); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java
/** * Private helper method to reload data, presenting dialog on failure. *//*ww w .j a va 2s . co m*/ private void reloadData() { final ProgressDialog progressDialog = ProgressDialog.show(MainActivity.this, "", "Loading..."); // If successful, notify all that that refreshed. Runnable successHandler = new Runnable() { @Override public void run() { synchronized (RHCareerFairLayout.refreshCompaniesNotifier) { RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged(); } synchronized (RHCareerFairLayout.refreshMapNotifier) { RHCareerFairLayout.refreshMapNotifier.notifyChanged(); } progressDialog.dismiss(); } }; // If exception or failure, show error message, and ask if they want to retry. Runnable exceptionHandler = new Runnable() { @Override public void run() { progressDialog.dismiss(); runOnUiThread(new Runnable() { @Override public void run() { DialogFragment df = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Error"); builder.setMessage( getResources().getString(R.string.loadingStatus_errorDownloadingData)); builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); reloadData(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return builder.create(); } }; df.show(getFragmentManager(), null); } }); } }; Runnable failHandler = new Runnable() { @Override public void run() { progressDialog.dismiss(); runOnUiThread(new Runnable() { @Override public void run() { DialogFragment df = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Error"); builder.setMessage( getResources().getString(R.string.loadingStatus_errorParsingData)); builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); reloadData(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return builder.create(); } }; df.show(getFragmentManager(), null); } }); } }; GetAllDataRequest req = new GetAllDataRequest(successHandler, exceptionHandler, failHandler); Log.d(RHCareerFairLayout.RH_CFL, "Data not saved or outdated. Downloading."); ConnectionManager.enqueueRequest(req); }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
@Override public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); switch (key) { case MANAGE_LOCK_TASK_LIST_KEY: showManageLockTaskListPrompt(R.string.lock_task_title, new ManageLockTaskListCallback() { @Override//from ww w .j a v a 2 s .c o m public void onPositiveButtonClicked(String[] lockTaskArray) { mDevicePolicyManager.setLockTaskPackages(DeviceAdminReceiver.getComponentName(getActivity()), lockTaskArray); } }); return true; case CHECK_LOCK_TASK_PERMITTED_KEY: showCheckLockTaskPermittedPrompt(); return true; case RESET_PASSWORD_KEY: showResetPasswordPrompt(); return false; case LOCK_NOW_KEY: lockNow(); return true; case START_LOCK_TASK: getActivity().startLockTask(); return true; case STOP_LOCK_TASK: try { getActivity().stopLockTask(); } catch (IllegalStateException e) { // no lock task present, ignore } return true; case WIPE_DATA_KEY: showWipeDataPrompt(); return true; case REMOVE_DEVICE_OWNER_KEY: showRemoveDeviceOwnerPrompt(); return true; case REQUEST_BUGREPORT_KEY: requestBugReport(); return true; case REQUEST_PROCESS_LOGS: showFragment(new ProcessLogsFragment()); return true; case SET_ACCESSIBILITY_SERVICES_KEY: // Avoid starting the same task twice. if (mGetAccessibilityServicesTask != null && !mGetAccessibilityServicesTask.isCancelled()) { mGetAccessibilityServicesTask.cancel(true); } mGetAccessibilityServicesTask = new GetAccessibilityServicesTask(); mGetAccessibilityServicesTask.execute(); return true; case SET_INPUT_METHODS_KEY: // Avoid starting the same task twice. if (mGetInputMethodsTask != null && !mGetInputMethodsTask.isCancelled()) { mGetInputMethodsTask.cancel(true); } mGetInputMethodsTask = new GetInputMethodsTask(); mGetInputMethodsTask.execute(); return true; case SET_DISABLE_ACCOUNT_MANAGEMENT_KEY: showSetDisableAccountManagementPrompt(); return true; case GET_DISABLE_ACCOUNT_MANAGEMENT_KEY: showDisableAccountTypeList(); return true; case CREATE_AND_MANAGE_USER_KEY: showCreateAndManageUserPrompt(); return true; case REMOVE_USER_KEY: showRemoveUserPrompt(); return true; case BLOCK_UNINSTALLATION_BY_PKG_KEY: showBlockUninstallationByPackageNamePrompt(); return true; case BLOCK_UNINSTALLATION_LIST_KEY: showBlockUninstallationPrompt(); return true; case ENABLE_SYSTEM_APPS_KEY: showEnableSystemAppsPrompt(); return true; case ENABLE_SYSTEM_APPS_BY_PACKAGE_NAME_KEY: showEnableSystemAppByPackageNamePrompt(); return true; case ENABLE_SYSTEM_APPS_BY_INTENT_KEY: showFragment(new EnableSystemAppsByIntentFragment()); return true; case HIDE_APPS_KEY: showHideAppsPrompt(false); return true; case UNHIDE_APPS_KEY: showHideAppsPrompt(true); return true; case SUSPEND_APPS_KEY: showSuspendAppsPrompt(false); return true; case UNSUSPEND_APPS_KEY: showSuspendAppsPrompt(true); return true; case MANAGE_APP_RESTRICTIONS_KEY: showFragment(new ManageAppRestrictionsFragment()); return true; case APP_RESTRICTIONS_MANAGING_PACKAGE_KEY: showFragment(new AppRestrictionsManagingPackageFragment()); return true; case SET_PERMISSION_POLICY_KEY: showSetPermissionPolicyDialog(); return true; case MANAGE_APP_PERMISSIONS_KEY: showFragment(new ManageAppPermissionsFragment()); return true; case INSTALL_KEY_CERTIFICATE_KEY: showFileViewerForImportingCertificate(INSTALL_KEY_CERTIFICATE_REQUEST_CODE); return true; case REMOVE_KEY_CERTIFICATE_KEY: choosePrivateKeyForRemoval(); return true; case INSTALL_CA_CERTIFICATE_KEY: showFileViewerForImportingCertificate(INSTALL_CA_CERTIFICATE_REQUEST_CODE); return true; case GET_CA_CERTIFICATES_KEY: showCaCertificateList(); return true; case REMOVE_ALL_CERTIFICATES_KEY: mDevicePolicyManager.uninstallAllUserCaCerts(mAdminComponentName); showToast(R.string.all_ca_certificates_removed); return true; case MANAGED_PROFILE_SPECIFIC_POLICIES_KEY: showFragment(new ProfilePolicyManagementFragment(), ProfilePolicyManagementFragment.FRAGMENT_TAG); return true; case LOCK_SCREEN_POLICY_KEY: showFragment(new LockScreenPolicyFragment.Container()); return true; case PASSWORD_CONSTRAINTS_KEY: showFragment(new PasswordConstraintsFragment.Container()); return true; case SYSTEM_UPDATE_POLICY_KEY: showFragment(new SystemUpdatePolicyFragment()); return true; case SET_ALWAYS_ON_VPN_KEY: showFragment(new AlwaysOnVpnFragment()); return true; case NETWORK_STATS_KEY: showFragment(new NetworkUsageStatsFragment()); return true; case DELEGATED_CERT_INSTALLER_KEY: showFragment(new DelegatedCertInstallerFragment()); return true; case DISABLE_STATUS_BAR: setStatusBarDisabled(true); return true; case REENABLE_STATUS_BAR: setStatusBarDisabled(false); return true; case DISABLE_KEYGUARD: setKeyGuardDisabled(true); return true; case REENABLE_KEYGUARD: setKeyGuardDisabled(false); return true; case START_KIOSK_MODE: showManageLockTaskListPrompt(R.string.kiosk_select_title, new ManageLockTaskListCallback() { @Override public void onPositiveButtonClicked(String[] lockTaskArray) { startKioskMode(lockTaskArray); } }); return true; case CAPTURE_IMAGE_KEY: dispatchCaptureIntent(MediaStore.ACTION_IMAGE_CAPTURE, CAPTURE_IMAGE_REQUEST_CODE, mImageUri); return true; case CAPTURE_VIDEO_KEY: dispatchCaptureIntent(MediaStore.ACTION_VIDEO_CAPTURE, CAPTURE_VIDEO_REQUEST_CODE, mVideoUri); return true; case CREATE_WIFI_CONFIGURATION_KEY: showWifiConfigCreationDialog(); return true; case CREATE_EAP_TLS_WIFI_CONFIGURATION_KEY: showEapTlsWifiConfigCreationDialog(); return true; case MODIFY_WIFI_CONFIGURATION_KEY: showFragment(new WifiModificationFragment()); return true; case SHOW_WIFI_MAC_ADDRESS_KEY: showWifiMacAddress(); return true; case SET_USER_RESTRICTIONS_KEY: showFragment(new UserRestrictionsDisplayFragment()); return true; case REBOOT_KEY: reboot(); return true; case SET_SHORT_SUPPORT_MESSAGE_KEY: showFragment(SetSupportMessageFragment.newInstance(SetSupportMessageFragment.TYPE_SHORT)); return true; case SET_LONG_SUPPORT_MESSAGE_KEY: showFragment(SetSupportMessageFragment.newInstance(SetSupportMessageFragment.TYPE_LONG)); return true; case SAFETYNET_ATTEST: DialogFragment safetynetFragment = new SafetyNetFragment(); safetynetFragment.show(getFragmentManager(), SafetyNetFragment.class.getName()); return true; } return false; }