Пример #1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   main = getLayoutInflater().inflate(R.layout.account, null);
   list = (TableLayout) main.findViewById(R.id.accounttable);
   tvbalance = (TextView) main.findViewById(R.id.accountbalance);
   setContentView(main);
   prompt = getLayoutInflater().inflate(R.layout.dialogaccount, null);
   accamount = (MyTextBox) prompt.findViewById(R.id.accountamount);
   accnumber = (MyTextBox) prompt.findViewById(R.id.accountnumber);
   accbank = (MyTextBox) prompt.findViewById(R.id.accountbank);
   accname = (MyTextBox) prompt.findViewById(R.id.accountholder);
   dialog =
       new AlertDialog.Builder(this)
           .setPositiveButton("Submit", null)
           .setNegativeButton("Cancel", null)
           .setMessage("Fill up the details below. Our customer service will contact you shortly")
           .setTitle("Request payment")
           .create();
   dialog.setView(prompt);
   dialog.setOnShowListener(this);
   getActionBar().setDisplayHomeAsUpEnabled(true);
   getActionBar().setIcon(android.R.color.transparent);
   HashMap<String, Object> pars = new HashMap<String, Object>();
   pars.put("loginkey", Shared.loginkey);
   request = SimpleHttp.request("list", Shared.url + "profile/getAccountHistory", pars, this);
 }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_places);

    // Get and set the toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.places_toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_back_white_24dp);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
      getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    mProgress = (ProgressBar) findViewById(R.id.places_progress);
    mList = (ListView) findViewById(R.id.places_list);

    // Create the name dialog. This needs to be done only once
    mName = new EditText(this);
    mName.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mName.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    mNameDialog =
        new AlertDialog.Builder(this)
            .setTitle(R.string.places_name_dialog_title)
            .setView(mName)
            .setNegativeButton(R.string.places_name_dialog_cancel, null)
            .setPositiveButton(R.string.places_name_dialog_accept, null)
            .create();
    mNameDialog.setOnShowListener(this);

    // Load the primary places
    HttpRequest.get(this, API.URL.getPrimaryPlaces());
  }
  public void onClick(View view) {
    final Context context = view.getContext();

    AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    final EditText input = new EditText(context);
    input.setText(String.valueOf(degrees));
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    input.setSelectAllOnFocus(true);
    dialog.setView(input);
    dialog.setOnCancelListener((OnCancelListener) context);
    dialog.setPositiveButton(
        context.getString(R.string.ok),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            try {
              degrees = Double.parseDouble(input.getText().toString());
            } catch (NumberFormatException exception) {
              Toast.makeText(context, R.string.error_no_number_entered, Toast.LENGTH_SHORT).show();
            }
            dialog.cancel();
          }
        });
    dialog.setNeutralButton(
        context.getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
          }
        });

    AlertDialog finishedDialog = dialog.create();
    finishedDialog.setOnShowListener(Utils.getBrickDialogOnClickListener(context, input));

    finishedDialog.show();
  }
Пример #4
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    prefs = getArguments().getBooleanArray(DIALOG_LISTPREFS);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder
        .setTitle("CURRENCY LIST")
        .setMultiChoiceItems(
            R.array.currency_list,
            prefs,
            new DialogInterface.OnMultiChoiceClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                //                        tracker.put(which, isChecked);
                prefs[which] = isChecked;
              }
            })
        .setPositiveButton("OK", null);
    final AlertDialog d = builder.create();

    // add onShowListener with onClick - this will enable the onClick function to be stopped early
    // (i.e. no exiting) if no
    // currencies have been ticked
    d.setOnShowListener(
        new DialogInterface.OnShowListener() {

          @Override
          public void onShow(DialogInterface dialogInterface) {

            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(
                new View.OnClickListener() {

                  @Override
                  public void onClick(View view) {
                    boolean currencySelected = false;
                    for (boolean b : prefs) {
                      if (b) {
                        currencySelected = true;
                      }
                    }
                    if (!currencySelected) {
                      Toast.makeText(
                              getActivity(),
                              "You must select at least one currency.",
                              Toast.LENGTH_SHORT)
                          .show();
                      return;
                    }
                    // pass the information back to the main activity
                    CurrencyListDialog.this.mListener.onCompleteCurrencyListSelection(prefs);
                    dismiss();
                  }
                });
          }
        });
    return d;
  }
  private AlertDialog createEditSubjectDialog(
      final SubjectCard materia, final Runnable success, final Runnable failure) {
    View dialogContent = View.inflate(this, R.layout.edit_dialog, null);
    final TextView etNomeMateria = (TextView) dialogContent.findViewById(R.id.nome_materia);
    final TextView etProfessorName = (TextView) dialogContent.findViewById(R.id.professor_name);
    final TextView etAulasSemanais = (TextView) dialogContent.findViewById(R.id.maximo_atrasos);

    etNomeMateria.setText(materia.getData().getName());
    etProfessorName.setText(materia.getData().getProfessorName());
    etAulasSemanais.setText(Integer.toString(materia.getData().getWeeklyClasses()));

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setMessage("Edição de Matéria")
        .setView(dialogContent)
        .setPositiveButton(
            "Salvar",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                materia.setSubjectName(etNomeMateria.getText().toString());
                materia.setProfessorName(etProfessorName.getText().toString());
                materia.setAulasSemanais(Integer.parseInt(etAulasSemanais.getText().toString()));
                materia.update();
                updateTotal();
                if (success != null) success.run();
              }
            })
        .setNegativeButton(
            "Cancelar",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                if (failure != null) failure.run();
              }
            });

    AlertDialog dialog = builder.create();
    dialog.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
            if (failure != null) failure.run();
          }
        });
    dialog.setOnShowListener(
        new DialogInterface.OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            etNomeMateria.requestFocus();
            InputMethodManager imm =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(etNomeMateria, InputMethodManager.SHOW_IMPLICIT);
          }
        });
    return dialog;
  }
  /**
   * {@inheritDoc}
   *
   * <p>Creates the Dialog for this class and initializes the on click listeners for the different
   * buttons.
   */
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    final View theView = inflater.inflate(R.layout.fragment_register, null);

    errorText = (TextView) theView.findViewById(R.id.register_error_label);

    builder
        .setView(theView)
        .setPositiveButton(
            "Create Account",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                // Nothing for now, over-ride it below to allow for preventing the
                // dialog from closing
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                RegisterFragment.this.getDialog().cancel();
              }
            });

    builder.setTitle("Register Account");
    myDialog = builder.create();

    // Override the onShow for the dialog to make sure the button doesn't close the window
    // if something is not input correctly
    myDialog.setOnShowListener(
        new DialogInterface.OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            Button b = myDialog.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(
                new View.OnClickListener() {

                  @Override
                  public void onClick(View view) {
                    // attempt to register the user based on input variables
                    registerUser(theView);
                    // close only if registration was successful
                  }
                });
          }
        });

    return myDialog;
  }
Пример #7
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    groupId = getIntent().getStringExtra(MainMediator.GROUPID_EXTRA);

    builder = new LayoutDialogBuilder(this, R.layout.addgroup);
    builder.setTitle(R.string.edit_group);
    builder.setClickListener(this);

    alertDialog = builder.create();
    alertDialog.setOnShowListener(this);
    alertDialog.show();
  }
Пример #8
0
  @Override
  public void onResume() {
    super.onResume();
    MyApplication app = ((MyApplication) this.getApplication());
    if (System.currentTimeMillis() - app.mLastPause > 5000) {
      SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
      final String pwd = pref.getString("password", "");
      if (pwd.length() > 0) {
        final LinearLayout ll = (LinearLayout) findViewById(R.id.main_ll);
        ll.setVisibility(View.INVISIBLE);
        LayoutInflater inflater = MainActivity.this.getLayoutInflater();
        final View layout = inflater.inflate(R.layout.password, null);
        final AlertDialog d =
            new AlertDialog.Builder(context)
                .setView(layout)
                .setTitle("Enter Password")
                .setPositiveButton(android.R.string.ok, null)
                .setCancelable(false)
                // .setNegativeButton(android.R.string.cancel, null)
                .create();

        d.setOnShowListener(
            new DialogInterface.OnShowListener() {

              @Override
              public void onShow(DialogInterface dialog) {

                Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
                b.setOnClickListener(
                    new View.OnClickListener() {

                      @Override
                      public void onClick(View view) {
                        EditText new_password =
                            (EditText) layout.findViewById(R.id.et_checkpassword);
                        String password1 = new_password.getText().toString();
                        if (password1.equals(pwd)) {

                          ll.setVisibility(View.VISIBLE);
                          d.dismiss();
                        } else {
                          Toast.makeText(context, "Incorrect password", Toast.LENGTH_SHORT).show();
                        }
                      }
                    });
              }
            });
        d.show();
      }
    }
  }
Пример #9
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    MyLog.i("dialogEditItem", "onActivityCreated");
    mAlertDialog.setOnShowListener(
        new DialogInterface.OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            Button btnOK = mAlertDialog.getButton(Dialog.BUTTON_POSITIVE);
            btnOK.setTextSize(18);

            Button btnCancel = mAlertDialog.getButton(Dialog.BUTTON_NEGATIVE);
            btnCancel.setTextSize(18);

            Button btnDelete = mAlertDialog.getButton(Dialog.BUTTON_NEUTRAL);
            btnDelete.setTextSize(18);
          }
        });
  }
Пример #10
0
 /**
  * 显示一个对话框
  *
  * @param context 上下文对象,最好给Activity,否则需要android.permission.SYSTEM_ALERT_WINDOW
  * @param title 标题
  * @param message 消息
  * @param confirmButton 确认按钮
  * @param confirmButtonClickListener 确认按钮点击监听器
  * @param centerButton 中间按钮
  * @param centerButtonClickListener 中间按钮点击监听器
  * @param cancelButton 取消按钮
  * @param cancelButtonClickListener 取消按钮点击监听器
  * @param onShowListener 显示监听器
  * @param cancelable 是否允许通过点击返回按钮或者点击对话框之外的位置关闭对话框
  * @param onCancelListener 取消监听器
  * @param onDismissListener 销毁监听器
  * @return 对话框
  */
 public static AlertDialog showAlert(
     Context context,
     String title,
     String message,
     String confirmButton,
     DialogInterface.OnClickListener confirmButtonClickListener,
     String centerButton,
     DialogInterface.OnClickListener centerButtonClickListener,
     String cancelButton,
     DialogInterface.OnClickListener cancelButtonClickListener,
     DialogInterface.OnShowListener onShowListener,
     boolean cancelable,
     DialogInterface.OnCancelListener onCancelListener,
     DialogInterface.OnDismissListener onDismissListener) {
   AlertDialog.Builder promptBuilder = new AlertDialog.Builder(context);
   if (title != null) {
     promptBuilder.setTitle(title);
   }
   if (message != null) {
     promptBuilder.setMessage(message);
   }
   if (confirmButton != null) {
     promptBuilder.setPositiveButton(confirmButton, confirmButtonClickListener);
   }
   if (centerButton != null) {
     promptBuilder.setNeutralButton(centerButton, centerButtonClickListener);
   }
   if (cancelButton != null) {
     promptBuilder.setNegativeButton(cancelButton, cancelButtonClickListener);
   }
   promptBuilder.setCancelable(true);
   if (cancelable) {
     promptBuilder.setOnCancelListener(onCancelListener);
   }
   AlertDialog alertDialog = promptBuilder.create();
   if (!(context instanceof Activity)) {
     alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
   }
   alertDialog.setOnDismissListener(onDismissListener);
   alertDialog.setOnShowListener(onShowListener);
   alertDialog.show();
   return alertDialog;
 }
Пример #11
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_object, null);
    setupPaintroidButton(dialogView);
    setupGalleryButton(dialogView);
    setupCameraButton(dialogView);

    AlertDialog dialog = null;
    AlertDialog.Builder dialogBuilder =
        new CustomAlertDialogBuilder(getActivity())
            .setView(dialogView)
            .setTitle(R.string.new_sprite_dialog_title);
    if (wizardStep == DialogWizardStep.STEP_1) {
      dialog = createDialogStepOne(dialogBuilder);
    } else if (wizardStep == DialogWizardStep.STEP_2) {
      dialog = createDialogStepTwo(dialogBuilder);
    }
    dialog.setOnShowListener(
        new DialogInterface.OnShowListener() {

          @Override
          public void onShow(final DialogInterface dialog) {
            Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            button.setOnClickListener(
                new View.OnClickListener() {

                  @Override
                  public void onClick(View view) {
                    if (handleOkButton()) {
                      dialog.dismiss();
                    }
                  }
                });
          }
        });
    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    return dialog;
  }
Пример #12
0
    public static void showStandAloneDialog(Activity fromActivity, String mergeToken) {
        LayoutInflater inflater = LayoutInflater.from(fromActivity);
        tradSignInView = new TradSignInView();
        tradSignInView.mergeToken = mergeToken;
        final View signInView = tradSignInView.onCreateView(fromActivity, inflater, null, null);
        signInView.findViewById(R.id.custom_signin_button).setVisibility(View.GONE);
        progress = (ProgressBar) signInView.findViewById(R.id.trad_signin_progress);

        dialog = new AlertDialog.Builder(fromActivity)
                .setTitle(R.string.jr_capture_trad_signin_dialog_title)
                .setView(signInView)
                .setCancelable(false)
                .setPositiveButton(R.string.jr_capture_signin_view_button_title, null)
                .setNegativeButton(android.R.string.cancel, null)
                .create();
        dialog.setCanceledOnTouchOutside(false);

        // http://stackoverflow.com/questions/2620444/how-to-prevent-a-dialog-from-closing-when-a-button-is-clicked
        dialog.setOnShowListener(new DialogInterface.OnShowListener() {
            public void onShow(DialogInterface _) {
                signInButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
                signInButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        tradSignInView.onStandAloneClick();
                    }
                });
                cancelButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
                cancelButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        Jump.fireHandlerOnFailure(new Jump.SignInResultHandler.SignInError(
                                AUTHENTICATION_CANCELED_BY_USER, null, null));
                        dialog.dismiss();
                    }
                });
            }
        });
        dialog.show();
    }
Пример #13
0
  public static Dialog buildAlertDialog(
      View view,
      int icon,
      String title,
      boolean hasCancel,
      int middleButtonText,
      final AlertDialogCallbacks callbacks) {
    AlertDialog.Builder builder =
        new AlertDialog.Builder(view.getContext())
            .setIcon(icon)
            .setView(view)
            .setTitle(title)
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {}
                });

    if (hasCancel) {
      builder
          .setCancelable(true)
          .setNegativeButton(
              android.R.string.cancel,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {}
              });
    }

    if (middleButtonText != 0) {
      builder.setNeutralButton(
          middleButtonText,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {}
          });
    }

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(
        new DialogInterface.OnShowListener() {
          @Override
          public void onShow(DialogInterface di) {
            Button b = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    if (callbacks.onOK()) dialog.dismiss();
                  }
                });

            b = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
            b.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    if (callbacks.onNeutralButton()) dialog.dismiss();
                  }
                });
          }
        });

    return dialog;
  }
Пример #14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    context = this;
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    final String pwd = pref.getString("password", "");
    if (pwd == null || pwd.equals("") || pwd.length() <= 0) {
      LayoutInflater inflater = MainActivity.this.getLayoutInflater();
      final View layout = inflater.inflate(R.layout.new_password, null);
      final AlertDialog d =
          new AlertDialog.Builder(context)
              .setView(layout)
              .setTitle("Create Password")
              .setPositiveButton(android.R.string.ok, null)
              .setCancelable(false)
              // .setNegativeButton(android.R.string.cancel, null)
              .create();

      d.setOnShowListener(
          new DialogInterface.OnShowListener() {

            @Override
            public void onShow(DialogInterface dialog) {

              Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
              b.setOnClickListener(
                  new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                      EditText new_password = (EditText) layout.findViewById(R.id.EditText_Pwd1);
                      EditText confirm_password =
                          (EditText) layout.findViewById(R.id.EditText_Pwd2);
                      String password1 = new_password.getText().toString();
                      String password2 = confirm_password.getText().toString();
                      if (password1.equals("")) {
                        Toast.makeText(context, "Please enter valid password", Toast.LENGTH_SHORT)
                            .show();
                      } else if (password1.equals(password2)) {
                        SharedPreferences sharedPref =
                            PreferenceManager.getDefaultSharedPreferences(context);
                        SharedPreferences.Editor editor = sharedPref.edit();
                        editor.putString("password", password1);
                        editor.commit();
                        d.dismiss();
                        Intent intent = new Intent(context, BackgroundService.class);
                        if (!BackgroundService.STARTED) {
                          startService(intent);
                        }
                        doBindService();
                      } else {
                        Toast.makeText(context, "Passwords do not match", Toast.LENGTH_SHORT)
                            .show();
                      }
                    }
                  });
            }
          });
      d.show();

    } else {
      Intent intent = new Intent(context, BackgroundService.class);
      if (!BackgroundService.STARTED) {
        startService(intent);
      }
      doBindService();
    }
  }
Пример #15
0
  public boolean onOptionsItemSelected(MenuItem item) {
    int choice = item.getItemId(); // what user selected

    // Create an album

    if (choice == R.id.create_new_album) {
      // Set up a new Dialog Window for Creating a new Album

      final EditText filler =
          new EditText(this); // this is the text shown in the field prior to user input

      filler.setHint("Album Name");

      final AlertDialog create_album =
          new AlertDialog.Builder(this)
              .setView(filler)
              .setTitle(R.string.create_album)

              // set the submit button guidelines, need to override user operations on the click

              .setPositiveButton(R.string.submit, null)

              // set the cancel button guidelines

              .setNegativeButton(R.string.cancel, null)
              .create();

      // clicking overrride operations

      create_album.setOnShowListener(
          new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
              Button b = create_album.getButton(AlertDialog.BUTTON_POSITIVE);
              b.setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      String result = filler.getText().toString();

                      // Can't allow empty string

                      if (result.length() == 0) {
                        Toast.makeText(context, "You must enter an album name.", Toast.LENGTH_SHORT)
                            .show();
                      }

                      // Try to Create a new album via the Controller

                      else {
                        if (c.createAlbum(result)) {
                          Toast toast =
                              Toast.makeText(
                                  context, "Created album: " + result, Toast.LENGTH_SHORT);
                          toast.show();
                          create_album.dismiss();
                          refresh();
                        } else {
                          Toast toast =
                              Toast.makeText(context, "Album already exists.", Toast.LENGTH_SHORT);
                          toast.show();
                        }
                      }
                    }
                  });
            }
          });

      create_album.show();
    }

    return true;
  }
  private static void applySortTargets(
      AlertDialog dlg,
      final Activity activity,
      final List<LatLon> intermediates,
      final TIntArrayList originalPositions,
      final List<String> names,
      final ArrayAdapter<LatLon> listadapter,
      final ProgressBar pb,
      final TextView textInfo) {
    dlg.setOnShowListener(
        new OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog)
                .getButton(AlertDialog.BUTTON_NEUTRAL)
                .setOnClickListener(
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {

                        new AsyncTask<Void, Void, int[]>() {

                          protected void onPreExecute() {
                            pb.setVisibility(View.VISIBLE);
                            textInfo.setVisibility(View.VISIBLE);
                          };

                          protected int[] doInBackground(Void[] params) {
                            ArrayList<LatLon> lt = new ArrayList<LatLon>(intermediates);
                            LatLon start;
                            if (activity instanceof MapActivity) {
                              start =
                                  new LatLon(
                                      ((MapActivity) activity).getMapView().getLatitude(),
                                      ((MapActivity) activity).getMapView().getLongitude());
                            } else {
                              start = lt.get(0);
                            }
                            LatLon end = lt.remove(lt.size() - 1);
                            return new TspAnt().readGraph(lt, start, end).solve();
                          };

                          protected void onPostExecute(int[] result) {
                            pb.setVisibility(View.GONE);
                            List<LatLon> alocs = new ArrayList<LatLon>();
                            List<String> anames = new ArrayList<String>();
                            TIntArrayList newOriginalPositions = new TIntArrayList();
                            for (int i = 0; i < result.length; i++) {
                              if (result[i] > 0) {
                                LatLon loc = intermediates.get(result[i] - 1);
                                alocs.add(loc);
                                newOriginalPositions.add(
                                    originalPositions.get(intermediates.indexOf(loc)));
                                anames.add(names.get(result[i] - 1));
                              }
                            }
                            intermediates.clear();
                            intermediates.addAll(alocs);
                            names.clear();
                            names.addAll(anames);
                            originalPositions.clear();
                            originalPositions.addAll(newOriginalPositions);
                            listadapter.notifyDataSetChanged();
                          };
                        }.execute(new Void[0]);
                      }
                    });
          }
        });
  }
Пример #17
0
  @Override
  public Dialog onCreateDialog(Bundle bundle) {
    View rootView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_login, null);

    usernameEditText = (EditText) rootView.findViewById(R.id.dialog_login_username);
    passwordEditText = (EditText) rootView.findViewById(R.id.dialog_login_password);
    showPasswordCheckBox =
        (CheckBox) rootView.findViewById(R.id.dialog_login_checkbox_showpassword);

    usernameEditText.setText("");
    passwordEditText.setText("");

    showPasswordCheckBox.setChecked(false);

    showPasswordCheckBox.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (showPasswordCheckBox.isChecked()) {
              passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT);
            } else {
              passwordEditText.setInputType(
                  InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }
          }
        });

    final AlertDialog loginDialog =
        new AlertDialog.Builder(getActivity())
            .setView(rootView)
            .setTitle(R.string.login)
            .setPositiveButton(R.string.login, null)
            .setNeutralButton(R.string.password_forgotten, null)
            .create();
    loginDialog.setCanceledOnTouchOutside(true);
    loginDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    loginDialog.setOnShowListener(
        new OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            InputMethodManager inputManager =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.showSoftInput(usernameEditText, InputMethodManager.SHOW_IMPLICIT);

            Button loginButton = loginDialog.getButton(AlertDialog.BUTTON_POSITIVE);
            loginButton.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    handleLoginButtonClick();
                  }
                });

            Button passwordForgottenButton = loginDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
            passwordForgottenButton.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    handlePasswordForgottenButtonClick();
                  }
                });
          }
        });

    return loginDialog;
  }
Пример #18
0
  /**
   * 生成した時に呼び出される。
   *
   * @param savedInstanceState 保存した時のインスタンスの状態
   * @return ダイアログ
   */
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    mLogger.d("IN");

    // 引数を取得する。
    mCategoryData = (CategoryData) getArguments().getSerializable(ExtraKey.CATEGORY_DATA);

    LayoutInflater inflater = getActivity().getLayoutInflater();
    View rootView = inflater.inflate(R.layout.dialog_category_detail, null);

    mCategoryNameValue = (TextView) rootView.findViewById(R.id.categoryNameValue);
    mCategoryNameValue.setText(mCategoryData.getName());

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.category_detail_dialog_title);
    builder.setPositiveButton(R.string.dialog_update_button, null);
    builder.setNeutralButton(R.string.dialog_delete_button, null);
    builder.setNegativeButton(R.string.dialog_close_button, null);
    builder.setView(rootView);
    AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    // ボタン押下でダイアログが閉じないようにリスナーを設定する。
    dialog.setOnShowListener(
        new OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog)
                .getButton(Dialog.BUTTON_POSITIVE)
                .setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        doUpdate();
                      }
                    });

            ((AlertDialog) dialog)
                .getButton(Dialog.BUTTON_NEUTRAL)
                .setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        doDelete();
                      }
                    });

            ((AlertDialog) dialog)
                .getButton(Dialog.BUTTON_NEGATIVE)
                .setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        doCancel();
                      }
                    });
          }
        });

    mLogger.d("OUT(OUT)");
    return dialog;
  }
Пример #19
0
  private void startDeviceActivation() {
    final AlertDialog activationDialog = new AlertDialog.Builder(HomeScreen.this).create();
    activationDialog.setTitle("App Activation");

    View view = LayoutInflater.from(this).inflate(R.layout.appactivation, null);
    activationDialog.setView(view);
    final EditText serverip_t = (EditText) view.findViewById(R.id.serverip);
    final EditText portno_t = (EditText) view.findViewById(R.id.portno);
    final EditText emailid_t = (EditText) view.findViewById(R.id.emailid);
    final EditText password_t = (EditText) view.findViewById(R.id.password);
    activationDialog.setCancelable(false);

    activationDialog.setButton(
        AlertDialog.BUTTON_POSITIVE, "Submit", (DialogInterface.OnClickListener) null);

    activationDialog.setButton2(
        "Cancel",
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface arg0, int arg1) {
            finish();
          }
        });

    activationDialog.setOnShowListener(
        new DialogInterface.OnShowListener() {

          @Override
          public void onShow(DialogInterface d) {
            Button submit = activationDialog.getButton(AlertDialog.BUTTON_POSITIVE);
            submit.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    String serverip = serverip_t.getText().toString();
                    String portnoStr = portno_t.getText().toString();
                    String emailid = emailid_t.getText().toString();
                    String password = password_t.getText().toString();
                    if (serverip == null
                        || serverip.trim().length() == 0
                        || portnoStr == null
                        || portnoStr.trim().length() == 0
                        || emailid == null
                        || emailid.trim().length() == 0
                        || password == null
                        || password.trim().length() == 0) {
                      ViewHelper.getOkModal(
                              HomeScreen.this,
                              "App Activation Failure",
                              "All the fields are required for a successful activation")
                          .show();
                      return;
                    }

                    Handler handler =
                        new Handler() {
                          @Override
                          public void handleMessage(Message msg) {
                            int what = msg.what;
                            if (what == 1) {
                              activationDialog.dismiss();
                              showBeans();
                            }
                          }
                        };

                    int portno = Integer.parseInt(portnoStr);
                    ActivationRequest activationRequest =
                        new ActivationRequest(serverip, portno, emailid, password);
                    new ToActivateDevice(HomeScreen.this, handler, activationRequest).execute();
                  }
                });
          }
        });

    activationDialog.show();
  }
Пример #20
0
  // show the created dialog
  public void showDialog() {

    // register the listener (to check when the dialog is instantiated)
    mAlertDialog.setOnShowListener(this);
    mAlertDialog.show();
  }
Пример #21
0
  @Override
  protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    AlertDialog dialog = null;
    switch (id) {
      case DIALOG_CREATE_MASTER_PASSWORD:
        final EditText input1 = getTextBox(R.string.masterpassword_password);
        final EditText input2 = getTextBox(R.string.masterpassword_confirm);
        linearLayout.addView(input1);
        linearLayout.addView(input2);

        builder
            .setTitle(R.string.masterpassword_create_title)
            .setView((View) linearLayout)
            .setPositiveButton(
                R.string.button_ok,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    JSONObject jsonPref = new JSONObject();
                    try {
                      jsonPref.put("name", PREFS_MP_ENABLED);
                      jsonPref.put("type", "string");
                      jsonPref.put("value", input1.getText().toString());

                      GeckoEvent event =
                          GeckoEvent.createBroadcastEvent("Preferences:Set", jsonPref.toString());
                      GeckoAppShell.sendEventToGecko(event);
                    } catch (Exception ex) {
                      Log.e(LOGTAG, "Error setting master password", ex);
                    }
                    return;
                  }
                })
            .setNegativeButton(
                R.string.button_cancel,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    return;
                  }
                });
        dialog = builder.create();
        dialog.setOnShowListener(
            new DialogInterface.OnShowListener() {
              @Override
              public void onShow(DialogInterface dialog) {
                input1.setText("");
                input2.setText("");
                input1.requestFocus();
              }
            });

        PasswordTextWatcher watcher = new PasswordTextWatcher(input1, input2, dialog);
        input1.addTextChangedListener((TextWatcher) watcher);
        input2.addTextChangedListener((TextWatcher) watcher);

        break;
      case DIALOG_REMOVE_MASTER_PASSWORD:
        final EditText input = getTextBox(R.string.masterpassword_password);
        linearLayout.addView(input);

        builder
            .setTitle(R.string.masterpassword_remove_title)
            .setView((View) linearLayout)
            .setPositiveButton(
                R.string.button_ok,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    PrefsHelper.setPref(PREFS_MP_ENABLED, input.getText().toString());
                  }
                })
            .setNegativeButton(
                R.string.button_cancel,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    return;
                  }
                });
        dialog = builder.create();
        dialog.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              @Override
              public void onDismiss(DialogInterface dialog) {
                input.setText("");
              }
            });
        dialog.setOnShowListener(
            new DialogInterface.OnShowListener() {
              @Override
              public void onShow(DialogInterface dialog) {
                input.setText("");
              }
            });
        input.addTextChangedListener(new EmptyTextWatcher(input, dialog));
        break;
      default:
        return null;
    }

    return dialog;
  }
  /**
   * Prepare dialog for entering a custom label. The input value is trimmed: white spaces before and
   * after the input text is removed.
   *
   * <p>If the final value is empty, this change request is ignored; no empty text is allowed in any
   * custom label.
   */
  private Dialog createCustomDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    final LayoutInflater layoutInflater = LayoutInflater.from(builder.getContext());
    builder.setTitle(R.string.customLabelPickerTitle);

    final View view = layoutInflater.inflate(R.layout.contact_editor_label_name_dialog, null);
    final EditText editText = (EditText) view.findViewById(R.id.custom_dialog_content);
    editText.setInputType(INPUT_TYPE_CUSTOM);
    editText.setSaveEnabled(true);

    builder.setView(view);
    editText.requestFocus();

    builder.setPositiveButton(
        android.R.string.ok,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            final String customText = editText.getText().toString().trim();
            if (ContactsUtils.isGraphic(customText)) {
              final List<EditType> allTypes = RawContactModifier.getValidTypes(mState, mKind, null);
              mType = null;
              for (EditType editType : allTypes) {
                if (editType.customColumn != null) {
                  mType = editType;
                  break;
                }
              }
              if (mType == null) return;

              mEntry.put(mKind.typeColumn, mType.rawValue);
              mEntry.put(mType.customColumn, customText);
              rebuildLabel();
              requestFocusForFirstEditField();
              onLabelRebuilt();
            }
          }
        });

    builder.setNegativeButton(android.R.string.cancel, null);

    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(
        new OnShowListener() {
          @Override
          public void onShow(DialogInterface dialogInterface) {
            updateCustomDialogOkButtonState(dialog, editText);
          }
        });
    editText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {
            updateCustomDialogOkButtonState(dialog, editText);
          }
        });
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    return dialog;
  }
Пример #23
0
  private void notifyServerTimeout() {
    if (mServerTimeoutDialog == null) {
      // for updating last position and duration.
      if (getPlayer().isVideoCanSeek() || getPlayer().canSeekForward()) {
        getPlayer().seekTo(getPlayer().getVideoPosition());
      }
      getPlayer().setDuration(getPlayer().getVideoLastDuration());
      AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
      mServerTimeoutDialog =
          builder
              .setTitle(mPluginContext.getString(R.string.server_timeout_title))
              .setMessage(mPluginContext.getString(R.string.server_timeout_message))
              .setNegativeButton(
                  android.R.string.cancel,
                  new OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                      if (LOG) {
                        Log.v(TAG, "NegativeButton.onClick() mIsShowDialog=" + mIsShowDialog);
                      }
                      getPlayer().showEnded();
                      getPlayer().notifyCompletion();
                    }
                  })
              .setPositiveButton(
                  mPluginContext.getString(R.string.resume_playing_resume),
                  new OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                      if (LOG) {
                        Log.v(TAG, "PositiveButton.onClick() mIsShowDialog=" + mIsShowDialog);
                      }
                      getPlayer()
                          .startVideo(
                              true,
                              getPlayer().getVideoPosition(),
                              getPlayer().getVideoLastDuration());

                      getPlayer().updateProgressBar();
                    }
                  })
              .create();
      mServerTimeoutDialog.setOnDismissListener(
          new OnDismissListener() {

            public void onDismiss(DialogInterface dialog) {
              if (LOG) {
                Log.v(TAG, "mServerTimeoutDialog.onDismiss()");
              }
              mIsShowDialog = false;
            }
          });
      mServerTimeoutDialog.setOnShowListener(
          new OnShowListener() {

            public void onShow(DialogInterface dialog) {
              if (LOG) {
                Log.v(TAG, "mServerTimeoutDialog.onShow()");
              }
              mIsShowDialog = true;
            }
          });
    }
    mServerTimeoutDialog.show();
  }
Пример #24
0
  /**
   * 生成した時に呼び出される。
   *
   * @param savedInstanceState 保存した時のインスタンスの状態
   * @return ダイアログ
   */
  @SuppressLint("InflateParams")
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    mLogger.d("IN");

    LayoutInflater inflater = getActivity().getLayoutInflater();
    View rootView = inflater.inflate(R.layout.dialog_login, null);

    // 入力項目を取得する。
    mUserNameValue = (EditText) rootView.findViewById(R.id.userNameValue);
    mPasswordValue = (EditText) rootView.findViewById(R.id.passwordValue);

    // ログインダイアログを生成する。
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_login_title);
    builder.setPositiveButton(R.string.dialog_login_button, null);
    builder.setNeutralButton(R.string.dialog_regist_user_button, null);
    builder.setNegativeButton(R.string.dialog_end_button, null);
    builder.setView(rootView);
    AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    // ボタン押下でダイアログが閉じないようにリスナーを設定する。
    dialog.setOnShowListener(
        new OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            // ログインボタン
            ((AlertDialog) dialog)
                .getButton(Dialog.BUTTON_POSITIVE)
                .setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        doLoginButton();
                      }
                    });

            // ユーザ登録ボタン
            ((AlertDialog) dialog)
                .getButton(Dialog.BUTTON_NEUTRAL)
                .setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        doRegistUserButton();
                      }
                    });

            // 終了ボタン
            ((AlertDialog) dialog)
                .getButton(Dialog.BUTTON_NEGATIVE)
                .setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        doEndButton();
                      }
                    });
          }
        });

    mLogger.d("OUT(OK)");
    return dialog;
  }
Пример #25
0
  public boolean onContextItemSelected(MenuItem item) {
    int choice = item.getItemId(); // what user selected

    // Rename an Album

    if (choice == R.id.rename_album) {
      if (album_holder.size() == 0) {
        Toast toast = Toast.makeText(context, "No Album Selected", Toast.LENGTH_SHORT);
        toast.show();
        return false;
      }

      // Set up a new Dialog Window for Rename the current Album

      final EditText filler =
          new EditText(this); // this is the text shown in the field prior to user input

      filler.setHint("Album Name");

      final AlertDialog rename_album =
          new AlertDialog.Builder(this)
              .setView(filler)
              .setTitle(R.string.rename_album)

              // set the submit button guidelines, need to override user operations on the click

              .setPositiveButton(R.string.submit, null)

              // set the cancel button guidelines

              .setNegativeButton(R.string.cancel, null)
              .create();

      // clicking overrride operations

      rename_album.setOnShowListener(
          new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
              Button butt = rename_album.getButton(AlertDialog.BUTTON_POSITIVE);
              butt.setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      String result = filler.getText().toString();

                      // Can't allow empty string

                      if (result.length() == 0) {
                        Toast.makeText(context, "You must enter an album name.", Toast.LENGTH_SHORT)
                            .show();
                      }

                      // Try to Rename a new album via the Controller

                      else {
                        if (album_holder.get(0).album_name.compareToIgnoreCase(result) == 0) {
                          Toast toast =
                              Toast.makeText(
                                  context,
                                  "You have to specify a different name from the old one",
                                  Toast.LENGTH_SHORT);
                          toast.show();
                          return;
                        }

                        if (b.findAlbum(result) != null) {
                          Toast toast =
                              Toast.makeText(
                                  context, "Album name already exists", Toast.LENGTH_SHORT);
                          toast.show();
                          return;
                        }

                        c.renameAlbum(album_holder.get(0).album_name, result);
                        Toast toast =
                            Toast.makeText(
                                context,
                                "Renamed album: "
                                    + album_holder.get(0).album_name
                                    + " to "
                                    + result,
                                Toast.LENGTH_SHORT);
                        toast.show();
                        rename_album.dismiss();
                        refresh();
                      }
                    }
                  });
            }
          });

      rename_album.show();
    }

    // Open an album

    else if (choice == R.id.open_album) {
      if (album_holder.size() == 0) {
        Toast toast = Toast.makeText(context, "No Album Selected", Toast.LENGTH_SHORT);
        toast.show();
        return false;
      }

      // switch to another activity

      Intent i = new Intent(context, AlbumActivity.class);
      i.putExtra(Constants.ALBUM_NAME, album_holder.get(0).album_name);
      context.startActivity(i);
    }

    // Delete an Album

    else if (choice == R.id.delete_album) {
      if (album_holder.size() == 0) {
        Toast toast = Toast.makeText(context, "No Album Selected", Toast.LENGTH_SHORT);
        toast.show();
        return false;
      }

      final AlertDialog delete =
          new AlertDialog.Builder(this)
              .setTitle("Delete Album")
              .setMessage("Delete Selected Album?")
              .setCancelable(false)

              // set the submit button guidelines, need to override user operations on the click

              .setPositiveButton(R.string.submit, null)

              // set the cancel button guidelines

              .setNegativeButton(R.string.cancel, null)
              .create();

      delete.setOnShowListener(
          new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
              Button b = delete.getButton(AlertDialog.BUTTON_POSITIVE);

              b.setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      String album = album_holder.get(0).album_name;

                      if (c.deleteAlbum(album_holder.get(0).album_name) == true) {
                        Toast toast =
                            Toast.makeText(context, "Deleted album: " + album, Toast.LENGTH_SHORT);
                        toast.show();
                        delete.dismiss();
                        refresh();
                      }
                    }
                  });
            }
          });

      delete.show();
    }

    return true;
  }