android.app.DialogFragment Java Examples

The following examples show how to use android.app.DialogFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SyncableActivity.java    From moVirt with Apache License 2.0 6 votes vote down vote up
@OptionsItem(R.id.menu_connection)
public void onConnectionInfo() {
    AllAccounts allAccounts = rxStore.getAllAccountsWrapped();

    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> errors = new ArrayList<>();

    for (ConnectionInfo info : failedInfos) {
        final MovirtAccount account = allAccounts.getAccountById(info.getAccountId());
        if (account == null) {
            continue;
        }

        names.add(account.getName());
        errors.add(info.getMessage(this));
    }

    DialogFragment dialogFragment = ConnInfoDialogFragment.newInstance(names, errors);
    dialogFragment.show(getFragmentManager(), "connection_info");
}
 
Example #2
Source File: DatePickerFragmentActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	// Capture UI elements
	mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
	mPickDate = (Button) findViewById(R.id.pickDate);

	// Set an OnClickListener for the Change the Date Button
	mPickDate.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			
			// Create a new DatePickerFragment
			DialogFragment newFragment = new DatePickerFragment();
			
			// Display DatePickerFragment
			newFragment.show(getFragmentManager(), "DatePicker");
		}
	});
}
 
Example #3
Source File: MainActivity.java    From developerWorks with Apache License 2.0 6 votes vote down vote up
/**
 * The DashboardFragment wants the MainActivity to know that the user has
 * interacted with it. It's up to the MainActivity to take action, leaving
 * the Fragment uncluttered.
 *
 * @param item The item that was touched by the user and that this method needs
 *             to do something with.
 */
@Override
public void onDashboardFragmentInteraction(IotDeviceContent.IotDeviceItem item) {
    Toast.makeText(getApplicationContext(), "Howdy from IotDeviceItem: " + item.toString(), Toast.LENGTH_LONG).show();

    // Display the SelectAction DialogFragment to let the user pick the action they
    /// want to invoke. For now, all actions must be no-arg.
    List<Pair<String, String>> actions = item.actions;
    String[] actionsArray = new String[actions.size()];
    int aa = 0; // It's a throw-away variable. Get over it.
    for (Pair<String, String> action : actions) {
        actionsArray[aa++] = action.getLeft() + ":=> " + action.getRight();
    }
    DialogFragment dialogFragment = ActionDialogFragment.newInstance(item.deviceId, actionsArray);
    dialogFragment.show(getFragmentManager(), ActionDialogFragment.FRAGMENT_TAG);
}
 
Example #4
Source File: ImportFragment.java    From android-sholi with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
    String policy = sharedPref.getString(
            SettingsActivity.KEY_IMPORT_MERGE_POLICY,
            getResources().getString(R.string.setting_import_default_value));

    setRetainInstance(true);
    ImportTask task = new ImportTask(getArguments().getString(ARG_DATA), policy);
    _taskRef = new WeakReference<ImportTask>(task);
    task.execute();

    setCancelable(false);
    setStyle(DialogFragment.STYLE_NO_TITLE, 0);
}
 
Example #5
Source File: WelcomeFragment.java    From SecondScreen with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    // Change window title
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getActivity().setTitle(getResources().getString(R.string.app_name));
    else
        getActivity().setTitle(" " + getResources().getString(R.string.app_name));

    // Don't show the Up button in the action bar, and disable the button
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(false);

    // Floating action button
    FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action_welcome);
    floatingActionButton.setImageResource(R.drawable.ic_action_new);
    floatingActionButton.setOnClickListener(v -> {
        DialogFragment newProfileFragment = new NewProfileDialogFragment();
        newProfileFragment.show(getFragmentManager(), "new");
    });
}
 
Example #6
Source File: FragmentDialog.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
void showDialog() {
    mStackLevel++;

    // DialogFragment.show() will take care of adding the fragment
    // in a transaction.  We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    DialogFragment newFragment = MyDialogFragment.newInstance(mStackLevel);
    newFragment.show(ft, "dialog");
}
 
Example #7
Source File: AccountManagementFragment.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onSignOutClicked() {
    // In case the user reached this fragment without being signed in, we guard the sign out so
    // we do not hit a native crash.
    if (!ChromeSigninController.get(getActivity()).isSignedIn()) return;

    final Activity activity = getActivity();
    final DialogFragment clearDataProgressDialog = new ClearDataProgressDialog();
    SigninManager.get(activity).signOut(null, new SigninManager.WipeDataHooks() {
        @Override
        public void preWipeData() {
            clearDataProgressDialog.show(
                    activity.getFragmentManager(), CLEAR_DATA_PROGRESS_DIALOG_TAG);
        }
        @Override
        public void postWipeData() {
            if (clearDataProgressDialog.isAdded()) {
                clearDataProgressDialog.dismissAllowingStateLoss();
            }
        }
    });
    AccountManagementScreenHelper.logEvent(
            ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT,
            mGaiaServiceType);
}
 
Example #8
Source File: AccountManagementFragment.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onSignOutClicked() {
    // In case the user reached this fragment without being signed in, we guard the sign out so
    // we do not hit a native crash.
    if (!ChromeSigninController.get().isSignedIn()) return;

    final Activity activity = getActivity();
    final DialogFragment clearDataProgressDialog = new ClearDataProgressDialog();
    SigninManager.get(activity).signOut(null, new SigninManager.WipeDataHooks() {
        @Override
        public void preWipeData() {
            clearDataProgressDialog.show(
                    activity.getFragmentManager(), CLEAR_DATA_PROGRESS_DIALOG_TAG);
        }
        @Override
        public void postWipeData() {
            if (clearDataProgressDialog.isAdded()) {
                clearDataProgressDialog.dismissAllowingStateLoss();
            }
        }
    });
    AccountManagementScreenHelper.logEvent(
            ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT,
            mGaiaServiceType);
}
 
Example #9
Source File: AccountManagementFragment.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onSignOutClicked() {
    // In case the user reached this fragment without being signed in, we guard the sign out so
    // we do not hit a native crash.
    if (!ChromeSigninController.get(getActivity()).isSignedIn()) return;

    final Activity activity = getActivity();
    final DialogFragment clearDataProgressDialog = new ClearDataProgressDialog();
    SigninManager.get(activity).signOut(null, new SigninManager.WipeDataHooks() {
        @Override
        public void preWipeData() {
            clearDataProgressDialog.show(
                    activity.getFragmentManager(), CLEAR_DATA_PROGRESS_DIALOG_TAG);
        }
        @Override
        public void postWipeData() {
            if (clearDataProgressDialog.isAdded()) {
                clearDataProgressDialog.dismissAllowingStateLoss();
            }
        }
    });
    AccountManagementScreenHelper.logEvent(
            ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT,
            mGaiaServiceType);
}
 
Example #10
Source File: DialogUtil.java    From Augendiagnose with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Display an error and either go back to the current activity or finish the current activity.
 *
 * @param activity       the current activity
 * @param resource       the error message
 * @param finishActivity a flag indicating if the activity should be finished.
 * @param args           arguments for the error message
 */
public static void displayError(@NonNull final Activity activity, final int resource, final boolean finishActivity,
								final Object... args) {
	MessageDialogListener listener = null;

	if (finishActivity) {
		listener = new MessageDialogListener() {
			/**
			 * The serial version id.
			 */
			private static final long serialVersionUID = 1L;

			@Override
			public void onDialogClick(final DialogFragment dialog) {
				activity.finish();
			}

			@Override
			public void onDialogCancel(final DialogFragment dialog) {
				activity.finish();
			}
		};
	}
	displayError(activity, resource, listener, args);
}
 
Example #11
Source File: CommonFragment.java    From FileManager with Apache License 2.0 6 votes vote down vote up
@OnClick({R.id.fab_scoll_top, R.id.fab_create_file, R.id.fab_create_floder})
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.fab_scoll_top:
            recyclerView.smoothScrollToPosition(0);
            floatingMenu.close(true);
            break;
        case R.id.fab_create_file:
            floatingMenu.close(true);
            DialogFragment fileDialog = CreateFileDialog.create(path);
            fileDialog.show(getActivity().getFragmentManager(), DIALOGTAG);
            break;
        case R.id.fab_create_floder:
            floatingMenu.close(true);
            DialogFragment folderDialog = CreateFolderDialog.create(path);
            folderDialog.show(getActivity().getFragmentManager(), DIALOGTAG);
            break;
    }
}
 
Example #12
Source File: OAuthDialogFragment.java    From mirror with Apache License 2.0 5 votes vote down vote up
public static OAuthDialogFragment newInstance(
        GenericUrl authorizationRequestUrl,
        DialogFragmentController controller) {
    Bundle args = new Bundle();
    args.putString(ARG_AUTHORIZATION_REQUEST_URL, authorizationRequestUrl.build());
    args.putString(ARG_AUTHORIZATION_TYPE, AUTHORIZATION_IMPLICIT);

    OAuthDialogFragment frag = new OAuthDialogFragment();
    frag.setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Holo_Light_NoActionBar_Fullscreen);
    frag.setArguments(args);
    frag.setController(controller);
    return frag;
}
 
Example #13
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
void showDialog(String text) {
    // DialogFragment.show() will take care of adding the fragment
    // in a transaction.  We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentTransaction ft = getFragmentManager().beginTransaction();

    DialogFragment newFragment = MyDialogFragment.newInstance(text);

    // Show the dialog.
    newFragment.show(ft, "dialog");
}
 
Example #14
Source File: DialogHelper.java    From turbo-editor with GNU General Public License v3.0 5 votes vote down vote up
private static void showDialog(Activity activity, Class clazz, String tag) {
    FragmentManager fm = activity.getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(tag);
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    try {
        ((DialogFragment) clazz.newInstance()).show(ft, tag);
    } catch (InstantiationException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
Example #15
Source File: DialogUtil.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Display the info of this photo.
 *
 * @param activity the triggering activity
 * @param eyePhoto the photo for which the image should be displayed.
 */
public static void displayImageInfo(@NonNull final Activity activity, @NonNull final EyePhoto eyePhoto) {
	StringBuilder message = new StringBuilder();
	message.append(formatImageInfoLine(activity, R.string.imageinfo_line_filename, eyePhoto.getFilename()));
	message.append(formatImageInfoLine(activity, R.string.imageinfo_line_filedate, eyePhoto.getDateString(activity)));

	try {
		JpegMetadata metadata = JpegSynchronizationUtil.getJpegMetadata(eyePhoto.getAbsolutePath());

		if (metadata.getPerson() != null && metadata.getPerson().length() > 0) {
			message.append(formatImageInfoLine(activity, R.string.imageinfo_line_name, metadata.getPerson()));
		}
		if (metadata.getComment() != null && metadata.getComment().length() > 0) {
			message.append(formatImageInfoLine(activity, R.string.imageinfo_line_comment, metadata.getComment()));
		}
	}
	catch (Exception e) {
		// cannot append metadata.
	}

	Bundle bundle = new Bundle();
	bundle.putCharSequence(PARAM_MESSAGE, fromHtml(message.toString()));
	bundle.putString(PARAM_TITLE, activity.getString(R.string.title_dialog_image_info));
	bundle.putInt(PARAM_ICON, R.drawable.ic_title_info);
	DialogFragment fragment = new DisplayMessageDialogFragment();
	fragment.setArguments(bundle);
	fragment.show(activity.getFragmentManager(), fragment.getClass().toString());
}
 
Example #16
Source File: GenericAlertDialogFragment.java    From United4 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Factory for an alert dialog
 * @param s the title and message of the new dialog
 * @param manager the fragment manager used to show the dialog
 */
public static void newInstance(String s, FragmentManager manager) {
    DialogFragment f = new GenericAlertDialogFragment();
    Bundle args = new Bundle();
    args.putString("text", s);
    f.setArguments(args);
    f.show(manager, "dialog");
}
 
Example #17
Source File: DialogHelper.java    From NotificationPeekPort with Apache License 2.0 5 votes vote down vote up
public static void showAboutDialog(Activity activity) {
    FragmentManager fm = activity.getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();

    ((DialogFragment) Fragment
            .instantiate(activity, AboutDialogFragment.class.getName()))
            .show(ft, ABOUT_DIALOG_TAG);
}
 
Example #18
Source File: FingerprintAuthenticationDialogFragment.java    From UAF with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Do not create a new Fragment when the Activity is re-created such as orientation changes.
    setRetainInstance(true);
    setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog);
}
 
Example #19
Source File: DialogHelper.java    From NotificationPeekPort with Apache License 2.0 5 votes vote down vote up
public static void showHelpDialog(Activity activity) {
    FragmentManager fm = activity.getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();

    ((DialogFragment) Fragment
            .instantiate(activity, HelpDialogFragment.class.getName()))
            .show(ft, ABOUT_DIALOG_TAG);
}
 
Example #20
Source File: OAuthDialogFragment.java    From android-oauth-client with Apache License 2.0 5 votes vote down vote up
private OAuthDialogFragment(android.app.DialogFragment fragment, boolean fullScreen,
    boolean horizontalProgress, boolean hideFullScreenTitle) {
    super(fragment);
    this.mFullScreen = fullScreen;
    this.mHorizontalProgress = horizontalProgress;
    this.mHideFullScreenTitle = hideFullScreenTitle;
}
 
Example #21
Source File: ActionModePresenter.java    From FileManager with Apache License 2.0 5 votes vote down vote up
@Override
public void clickRename() {

    String parentPath = FileUtils.getDirName(mFiles[0]);
    if (parentPath.length() != 1) {
        parentPath = parentPath.substring(0, parentPath.length() - 1);
    }

    DialogFragment renameDialog = RenameDialog.instantiate(
            parentPath, mList.get(0));
    mView.showDialog(renameDialog);
    RxBus.getDefault().post(new TypeEvent(AppConstant.CLEAN_ACTIONMODE));

}
 
Example #22
Source File: AbstractBrowserFragment.java    From SimpleExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.createfile:
            final DialogFragment dialog1 = new CreateFileDialog();
            dialog1.show(fm, AbstractBrowserActivity.TAG_DIALOG);
            return true;
        case R.id.createfolder:
            final DialogFragment dialog2 = new CreateFolderDialog();
            dialog2.show(fm, AbstractBrowserActivity.TAG_DIALOG);
            return true;
        default:
            return false;
    }
}
 
Example #23
Source File: ActivityBase.java    From ghwatch with Apache License 2.0 5 votes vote down vote up
/**
 * Show dialog. Dialog is shown only if no other dialog is shown currently.
 *
 * @param dialog to show
 * @return true if shown, false if not.
 */
protected boolean showDialog(DialogFragment dialog) {
  Fragment f = this.getFragmentManager().findFragmentByTag(FRAGMENT_DIALOG);
  if (f == null) {
    dialog.show(this.getFragmentManager(), FRAGMENT_DIALOG);
    return true;
  } else {
    return false;
  }
}
 
Example #24
Source File: SettingsActivity.java    From good-weather with GNU General Public License v3.0 5 votes vote down vote up
private void updateSummary(String key, boolean changing) {
    switch (key) {
        case Constants.KEY_PREF_TEMPERATURE:
            entrySummary(key);
            if (changing) {
                getActivity().sendBroadcast(new Intent(Constants.ACTION_FORCED_APPWIDGET_UPDATE));
            }
            break;
        case Constants.KEY_PREF_HIDE_DESCRIPTION:
            if (changing) {
                getActivity().sendBroadcast(new Intent(Constants.ACTION_FORCED_APPWIDGET_UPDATE));
            }
            break;
        case Constants.KEY_PREF_INTERVAL_NOTIFICATION:
            entrySummary(key);
            if (changing) {
                Preference pref = findPreference(key);
                NotificationService.setNotificationServiceAlarm(getActivity(), pref.isEnabled());
            }
            break;
        case Constants.PREF_LANGUAGE:
            entrySummary(key);
            if (changing) {
                DialogFragment dialog = new SettingsAlertDialog().newInstance(R.string.restart_dialog_message);
                dialog.show(getActivity().getFragmentManager(), "restartApp");
            }
            break;
        case Constants.PREF_THEME:
            entrySummary(key);
            if (changing) {
                GoodWeatherApp app = (GoodWeatherApp) getActivity().getApplication();
                app.reloadTheme();
                app.applyTheme(getActivity());
                restartApp(getActivity());
            }
            break;
    }
}
 
Example #25
Source File: CheckNewsTask.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(final JSONArray newsList)
{
    
    if (newsList != null && newsList.length() > 0 && !serverConn.hasError())
        for (int i = 0; i < newsList.length(); i++)
            if (!isCancelled() && !Thread.interrupted())
                try
                {
                    
                    final JSONObject newsItem = newsList.getJSONObject(i);
                    
                    final DialogFragment newFragment = RMBTAlertDialogFragment.newInstance(
                            newsItem.optString("title", activity.getString(R.string.news_title)),
                            newsItem.optString("text", activity.getString(R.string.news_no_message)), null);
                    
                    newFragment.show(activity.getFragmentManager(), "dialog");
                    
                    if (newsItem.has("uid"))
                    {
                        if (lastNewsUid < newsItem.getLong("uid"))
                            lastNewsUid = newsItem.getLong("uid");
                    }
                }
                catch (final JSONException e)
                {
                    e.printStackTrace();
                }
    
    ConfigHelper.setLastNewsUid(activity.getApplicationContext(), lastNewsUid);
}
 
Example #26
Source File: DateModule.java    From react-native-date with MIT License 5 votes vote down vote up
@ReactMethod
public void showTimepickerWithInitialDateInMilliseconds(String initialDateString, Callback errorCallback,
                                          Callback successCallback) {
    DialogFragment dateDialog = new TimePicker(DateFormatHelper.parseDateInMilliseconds(Long.parseLong(initialDateString)),
            errorCallback, successCallback);
  Activity activity = getCurrentActivity();
  if (activity != null) {
    dateDialog.show(activity.getFragmentManager(), "timePicker");
  }
}
 
Example #27
Source File: RTProxyImpl.java    From Android-RTEditor with Apache License 2.0 5 votes vote down vote up
@Override
/* @inheritDoc */
public void openDialogFragment(String fragmentTag, DialogFragment fragment) {
    Activity activity = getActivity();
    if (activity != null) {
        FragmentManager fragmentMgr = activity.getFragmentManager();
        FragmentTransaction ft = fragmentMgr.beginTransaction();
        DialogFragment oldFragment = (DialogFragment) fragmentMgr
                .findFragmentByTag(fragmentTag);
        if (oldFragment == null) {
            fragment.show(ft, fragmentTag);
        }
    }
}
 
Example #28
Source File: MainActivity.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
@Override
public void showExpertModeDialog() {
    SharedPreferences prefMain = U.getPrefMain(this);
    SharedPreferences prefNew = U.getPrefNew(this);
    String size = prefNew.getString("size", "reset");
    int height;
    int width;

    if("reset".equals(size)) {
        height = prefMain.getInt("height", 0);
        width = prefMain.getInt("width", 0);
    } else {
        Scanner scanner = new Scanner(size);
        scanner.useDelimiter("x");

        width = scanner.nextInt();
        height = scanner.nextInt();

        scanner.close();
    }

    Bundle bundle = new Bundle();
    if(prefMain.getBoolean("landscape", false)) {
        bundle.putString("height", Integer.toString(width));
        bundle.putString("width", Integer.toString(height));
    } else {
        bundle.putString("height", Integer.toString(height));
        bundle.putString("width", Integer.toString(width));
    }

    DialogFragment sizeFragment = new ExpertModeSizeDialogFragment();
    sizeFragment.setArguments(bundle);
    sizeFragment.show(getFragmentManager(), "expert-mode-size");
}
 
Example #29
Source File: CustomKeysActivity.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
private void showAddDialog(int index, String word) {
    DialogFragment newFragment = new AddWordDialogFragment();
    Bundle args = new Bundle();
    args.putInt("index", index);
    args.putString("word", word);
    newFragment.setArguments(args);
    newFragment.show(getFragmentManager(), "new_word");
}
 
Example #30
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
void showDialog(String text) {
    // DialogFragment.show() will take care of adding the fragment
    // in a transaction.  We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentTransaction ft = getFragmentManager().beginTransaction();

    DialogFragment newFragment = MyDialogFragment.newInstance(text);

    // Show the dialog.
    newFragment.show(ft, "dialog");
}