Example usage for android.app DialogFragment setArguments

List of usage examples for android.app DialogFragment setArguments

Introduction

In this page you can find the example usage for android.app DialogFragment setArguments.

Prototype

public void setArguments(Bundle args) 

Source Link

Document

Supply the construction arguments for this fragment.

Usage

From source file:de.dknapps.pswgendroid.ServiceDetailFragment.java

/**
 * Generiert das Passwort und zeigt es an.
 * /*w  w  w.j  a  v  a  2  s.co m*/
 * FIXME dkn Die callingActivity kann durch getActivity() ersetzt werden.
 */
public void onClickButtonDisplayPassword(final Activity callingActivity, final View buttonOpenUrl) {
    try {
        Bundle arguments = new Bundle();
        String password = getValidatedOrGeneratedPassword();
        String passwordExplanation = getPasswordExplanation(password);
        arguments.putString(PasswordDialog.ARG_PASSWORD, password);
        arguments.putString(PasswordDialog.ARG_PASSWORD_EXPLANATION, passwordExplanation);
        DialogFragment passwordDialog = new PasswordDialog();
        passwordDialog.setArguments(arguments);
        passwordDialog.show(getActivity().getFragmentManager(), "password_dialog");
    } catch (Exception e) {
        PswGenAdapter.handleThrowable(callingActivity, e);
    }
}

From source file:de.uulm.graphicalpasswords.opentapi.TAPICreatePasswordActivity.java

public void submit(View view) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor edit = sharedPref.edit();
    edit.putString("tapi_pw", arrayToString(input));
    edit.commit();// ww  w.  ja v a 2s  .co m

    Bundle bundle = new Bundle();
    bundle.putStringArray("input", input);
    DialogFragment dialog = new RememberPasswordDialogFragment();
    dialog.setArguments(bundle);
    dialog.show(getFragmentManager(), "remember");
}

From source file:com.sean.takeastand.ui.ScheduleListActivity.java

private void showTimePickerDialog(boolean startOrEndTime, boolean newAlarm) {
    Bundle args = new Bundle();
    args.putBoolean("StartOrEndButton", startOrEndTime);
    args.putBoolean("NewAlarm", newAlarm);
    DialogFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setArguments(args);
    try {/*from   w  w  w. j  a v a 2  s . co m*/
        timePickerFragment.show(getFragmentManager(), "timePicker");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.uulm.graphicalpasswords.opentapi.TAPICreatePasswordActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tapi_create_password);

    // Show the Up button in the action bar.
    setupActionBar();//from   w w  w  .  j ava 2s  .c  o m

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("tapi_length", "6"));
    input = new String[length];

    // Save Pictures in randomized order
    SharedPreferences.Editor editor = sharedPref.edit();
    Random random = new Random(System.currentTimeMillis());
    boolean[] usedImages = new boolean[TAPIActivity.IMAGES.length];
    Arrays.fill(usedImages, false);
    for (int i = 0; i < TAPIActivity.IMAGES.length; i++) {
        boolean pictureSet = false;
        int index = random.nextInt(TAPIActivity.IMAGES.length);
        do {
            if (!usedImages[index]) {
                editor.putInt("image" + i, TAPIActivity.IMAGES[index]);
                pictureSet = true;
                usedImages[index] = true;
            } else if (index == TAPIActivity.IMAGES.length - 1) {
                index = 0;
            } else {
                index++;
            }
        } while (!pictureSet);
    }
    editor.commit();

    for (int i = 0; i < images.length; i++) {
        images[i] = sharedPref.getInt("image" + i, 0);
    }

    EditText editText = (EditText) findViewById(R.id.tapi_edittext);
    text = editText.getText();
    back = (Button) findViewById(R.id.tapi_back);
    save = (Button) findViewById(R.id.tapi_save);

    TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    TableRow row = null;
    for (int i = 0; i < imageViews.length; i++) {
        if (i % 4 == 0) {
            row = new TableRow(this);
        }
        imageViews[i] = new PassImageView(this);
        imageViews[i].setLayoutParams(layoutParams);
        imageViews[i].setAdjustViewBounds(true);
        imageViews[i].setScaleType(ScaleType.CENTER_INSIDE);
        imageViews[i].setPadding(5, 5, 5, 5);
        imageViews[i].setImageResource(images[i]);
        row.addView(imageViews[i]);
        if (i % 4 == 3) {
            table.addView(row);
        }
        imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i]));
    }

    Bundle bundle = new Bundle();
    bundle.putInt("length", length);
    DialogFragment intro = new IntroDialogFragment();
    intro.setArguments(bundle);
    intro.show(getFragmentManager(), "intro");
}

From source file:de.uulm.graphicalpasswords.openuyi.UYICreatePasswordActivity.java

public void submit(View view) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor edit = sharedPref.edit();
    edit.putString("uyi_pw", Picture.distortedToSortedString(selectedPictures));
    edit.commit();//  w ww  .  j a v a 2  s .co  m

    Bundle bundle = new Bundle();
    bundle.putIntArray("input", Picture.distortedToIntArray(selectedPictures));
    DialogFragment dialog = new RememberPasswordDialogFragment();
    dialog.setArguments(bundle);
    dialog.show(getFragmentManager(), "remember");
}

From source file:org.jmpm.ethbadge.MainActivity.java

public void runDialogPassword() {
    DialogFragment dialog = new DialogPassword();
    Bundle args = new Bundle();
    if (GlobalAppSettings.getInstance().usingDefaultSettings()) {
        args.putString("message",
                "WARNING: Your private key will be stored using this password. Choose a robust one!");
    }/*ww  w  . j  a v a2 s.  com*/
    dialog.setArguments(args);
    dialog.show(getFragmentManager(), "DialogPassword");
}

From source file:de.uulm.graphicalpasswords.openuyi.UYICreatePasswordActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_uyi_create_password);
    // Show the Up button in the action bar.
    setupActionBar();//www.j a va2 s . c om

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("uyi_length", "10"));

    originalViews = new ImageView[length];
    distortedViews = new ImageView[length];
    selectedPictures = new Picture[length];

    Bundle bundle = new Bundle();
    bundle.putInt("length", length);
    DialogFragment intro = new IntroDialogFragment();
    intro.setArguments(bundle);
    intro.show(getFragmentManager(), "intro");

    vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);

    Arrays.fill(selectedPictures, null);

    gallery = (Gallery) findViewById(R.id.uyi_gallery_originals);
    gallery.setAdapter(new UYIImageAdapter(this));

    gallery.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            ImageView viewOriginal = new ImageView(UYICreatePasswordActivity.this);
            ImageView viewDistorted = new ImageView(UYICreatePasswordActivity.this);

            int i = 0;
            for (; i < selectedPictures.length; i++) {
                if (i == selectedPictures.length - 1 && selectedPictures[i] != null) {
                    removePicture(i);
                }
                if (selectedPictures[i] == null || i == selectedPictures.length - 1) {
                    viewOriginal = originalViews[i];
                    viewDistorted = distortedViews[i];
                    selectedPictures[i] = ((UYIImageAdapter) parent.getAdapter()).getPicture(position);
                    vibrator.vibrate(100);

                    ScrollView sv = (ScrollView) findViewById(R.id.uyi_choosepi_scrollview);
                    int height = originalViews[0].getMeasuredHeight();
                    sv.scrollTo(0, (i * height) - 200);

                    break;
                }
            }

            int originalImageResource = ((UYIImageAdapter) parent.getAdapter()).getImageResource(position);
            viewOriginal.setImageResource(originalImageResource);
            viewDistorted.setImageResource(
                    ((UYIImageAdapter) parent.getAdapter()).getDistortedImageResource(position));
            ((UYIImageAdapter) parent.getAdapter()).removePicture(position);

            OnLongClickListener listener = new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    vibrator.vibrate(200);
                    int viewid = v.getId();
                    int index = -1;

                    for (int i = 0; i < originalViews.length; i++) {
                        if (originalViews[i].getId() == viewid) {
                            index = i;
                            break;
                        } else if (distortedViews[i].getId() == viewid) {
                            index = i;
                            break;
                        }
                    }
                    Bundle bundle = new Bundle();
                    bundle.putInt("index", index);
                    DialogFragment dialog = new DeleteImageDialogFragment();
                    dialog.setArguments(bundle);
                    dialog.show(getFragmentManager(), "delete");
                    return false;
                }
            };

            viewOriginal.setOnLongClickListener(listener);
            viewDistorted.setOnLongClickListener(listener);

            // Check
            int count = 0;
            for (int j = 0; j < selectedPictures.length; j++) {
                if (selectedPictures[j] != null) {
                    count++;
                }
            }
            if (count == selectedPictures.length) {
                findViewById(R.id.uyi_save).setClickable(true);
                findViewById(R.id.uyi_save).setEnabled(true);
            }
        }
    });

    table = (TableLayout) findViewById(R.id.uyi_choosepi_tablelayout);
    LayoutParams params = new LayoutParams(android.widget.TableRow.LayoutParams.WRAP_CONTENT,
            android.widget.TableRow.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;
    for (int i = 0; i < length; i++) {
        TableRow row = new TableRow(table.getContext());

        originalViews[i] = new ImageView(row.getContext());
        originalViews[i].setAdjustViewBounds(true);
        originalViews[i].setScaleType(ScaleType.FIT_XY);
        originalViews[i].setPadding(3, 3, 3, 3);
        originalViews[i].setImageResource(R.drawable.oempty);
        originalViews[i].setId(100 + i);

        distortedViews[i] = new ImageView(row.getContext());
        distortedViews[i].setAdjustViewBounds(true);
        distortedViews[i].setScaleType(ScaleType.FIT_XY);
        distortedViews[i].setPadding(3, 3, 3, 3);
        distortedViews[i].setImageResource(R.drawable.wempty);
        distortedViews[i].setId(1000 + i);

        ImageView arrow = new ImageView(row.getContext());
        arrow.setAdjustViewBounds(true);
        arrow.setScaleType(ScaleType.FIT_XY);
        arrow.setMaxWidth(80);
        arrow.setPadding(3, 3, 3, 3);
        arrow.setImageResource(R.drawable.arrow_active);
        arrow.setLayoutParams(params);

        row.addView(originalViews[i]);
        row.addView(arrow);
        row.addView(distortedViews[i]);
        table.addView(row);
    }
}

From source file:com.bonsai.btcreceive.MainActivity.java

private void showStateProgressDialog(String details) {
    DialogFragment df = new StateProgressDialogFragment();
    Bundle args = new Bundle();
    args.putString("details", details);
    df.setArguments(args);
    df.setCancelable(false);/*w  w  w  . j  av a2 s .  c  o  m*/
    df.show(getFragmentManager(), "state_progress_dialog");
    mStateProgressDialog = df;
}

From source file:com.bonsai.btcreceive.MainActivity.java

private void showSyncProgressDialog() {
    String details;//from w  w w  .j  a va  2 s . com

    switch (mWalletService.getSyncState()) {
    case CREATED:
        details = mRes.getString(R.string.sync_details_created);
        break;
    case RESTORE:
        details = mRes.getString(R.string.sync_details_restore);
        break;
    case STARTUP:
        details = mRes.getString(R.string.sync_details_startup);
        break;
    case RESCAN:
        details = mRes.getString(R.string.sync_details_rescan);
        break;
    case RERESCAN:
        details = mRes.getString(R.string.sync_details_rerescan);
        break;
    default:
        details = "???"; // Shouldn't happen
        break;
    }

    DialogFragment df = new SyncProgressDialogFragment();
    Bundle args = new Bundle();
    args.putString("details", details);
    df.setArguments(args);
    df.setCancelable(false);
    df.show(getFragmentManager(), "sync_progress_dialog");
    mSyncProgressDialog = df;
}

From source file:se.leap.bitmaskclient.ConfigurationWizard.java

/**
 * Open the new provider dialog with data
 *//*from   w  w  w .  j a  va2s  .  c  om*/
public void addAndSelectNewProvider(String main_url) {
    FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(NewProviderDialog.TAG);

    DialogFragment newFragment = new NewProviderDialog();
    Bundle data = new Bundle();
    data.putString(Provider.MAIN_URL, main_url);
    newFragment.setArguments(data);
    newFragment.show(fragment_transaction, NewProviderDialog.TAG);
}