// Esse método trata os retornos
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    Bundle parametros = null;

    if (data != null) parametros = data.getExtras();
    if (requestCode == ExemploParametros) {
      switch (resultCode) {
        case RESULT_OK:
          if (parametros != null) {

            String valor = parametros.getString("VALOR");
            AlertDialog.Builder dlg = new AlertDialog.Builder(this);
            dlg.setMessage("O valor do parametro é: " + valor);
            dlg.setNeutralButton("OK", null);
            dlg.show();
          }

          break;

        case RESULT_CANCELED:
          AlertDialog.Builder dlg = new AlertDialog.Builder(this);
          dlg.setMessage("Operação cancelada");
          dlg.setNeutralButton("OK", null);
          dlg.show();

          break;
      }
    }
  }
  public void Activar(View view) {
    String codigo = editCodigoActivacion.getText().toString();

    if (codigo.equalsIgnoreCase(Codigo.codigo)) {
      SharedPreferences.Editor editor = Codigo.prefs.edit();
      editor.putString("Activacion", "Activado");
      editor.commit();

      AlertDialog.Builder alerta = new AlertDialog.Builder(CodigoActivacion.this);
      alerta.setTitle("Activado");
      alerta.setMessage("El producto se ha activado satisfactoriamente");
      alerta.setPositiveButton(
          "Aceptar",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
              Intent intent = new Intent(CodigoActivacion.this, MenuPrincipal.class);
              startActivity(intent);
              finish();
            }
          });
      alerta.setCancelable(false);
      alerta.show();

    } else {
      AlertDialog.Builder alerta = new AlertDialog.Builder(CodigoActivacion.this);
      alerta.setTitle("Código");
      alerta.setMessage("El código ingresado no es correcto, debe ingresar un código valido");
      alerta.setPositiveButton("Aceptar", null);
      alerta.setCancelable(false);
      alerta.show();
    }
  }
Exemple #3
0
  public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    if (arg2 == 0) {
      AlertDialog.Builder raumDialog = new AlertDialog.Builder(this);
      raumDialog.setTitle("Informationen zum Raum " + nummer);
      raumDialog.setMessage("Hier stehen alle Informationen zum Raum.");
      raumDialog.setNeutralButton(
          "ok",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {}
          });
      raumDialog.show();
    }

    if (arg2 == 1) {
      AlertDialog.Builder raumDialog = new AlertDialog.Builder(this);
      raumDialog.setTitle("" + nummer);
      raumDialog.setIcon(R.drawable.raum_foto);
      raumDialog.setNeutralButton(
          "ok",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {}
          });
      raumDialog.show();
    }

    if (arg2 == 2) {
      Intent intent = new Intent(CamNavSicht.this, WebSicht.class);
      startActivity(intent);
    }
    if (arg2 == 3) {
      flip.setDisplayedChild(2);
    }
  }
  private void verifyBluetooth() {

    try {
      if (!BeaconManager.getInstanceForApplication(getApplicationContext()).checkAvailability()) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
        builder.setTitle("Bluetooth not enabled");
        builder.setMessage("Please enable bluetooth in settings and restart this application.");
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              @Override
              public void onDismiss(DialogInterface dialog) {
                System.exit(0);
              }
            });
        builder.show();
      }
    } catch (RuntimeException e) {
      final AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
      builder.setTitle("Bluetooth LE not available");
      builder.setMessage("Sorry, this device does not support Bluetooth LE.");
      builder.setPositiveButton(android.R.string.ok, null);
      builder.setOnDismissListener(
          new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
              System.exit(0);
            }
          });
      builder.show();
    }
  }
 @Override
 public void onClick(View arg0) {
   // TODO Auto-generated method stub
   if (arg0.equals(btnSure)) {
     if (etPasswd.getText().toString().trim().equals("666666")) {
       ly.removeAllViews();
       ly.addView(view);
       bPasswdOk = true;
     } else {
       AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
       b.setMessage(R.string.passwd_error);
       b.setPositiveButton(R.string.btn_sure, null);
       b.show();
     }
   } else if (arg0.equals(btnSaveIP)) {
     editor.putString(CONTROLLER_10_IP, etController10IP.getText().toString().trim());
     editor.putString(CONTROLLER_9_IP, etController9IP.getText().toString().trim());
     editor.putString(CONTROLLER_8_IP, etController8IP.getText().toString().trim());
     editor.putString(CONTROLLER_7_IP, etController7IP.getText().toString().trim());
     editor.putString(CONTROLLER_6_IP, etController6IP.getText().toString().trim());
     editor.putString(CONTROLLER_5_IP, etController5IP.getText().toString().trim());
     editor.putString(CONTROLLER_4_IP, etController4IP.getText().toString().trim());
     editor.putString(CONTROLLER_3_IP, etController3IP.getText().toString().trim());
     editor.putString(CONTROLLER_2_IP, etController2IP.getText().toString().trim());
     editor.putString(CONTROLLER_1_IP, etController1IP.getText().toString().trim());
     editor.commit();
     AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
     b.setMessage(R.string.save_ok);
     b.setPositiveButton(R.string.btn_sure, null);
     b.show();
   }
 }
  @OnClick(R.id.editGroupSaveButton)
  public void editGroup() {
    myProgressBar.setVisibility(View.VISIBLE);

    final ParseObject groupObject = TheGroupUtil.getCurrentGroup();

    if (editValid()) {
      groupObject.put(TheGroupUtil.GROUP_NAME, myName.getText().toString());
      groupObject.put(TheGroupUtil.GROUP_TYPE, getGroupType());
      groupObject.put(TheGroupUtil.GROUP_ONE_WORD, myOneWord.getText().toString());
      groupObject.put(TheGroupUtil.GROUP_LENGTHY_DESCRIPTION, myDescription.getText().toString());
      groupObject.put(TheGroupUtil.GROUP_BLOG_EXIST, getBlogCheck());
      groupObject.put(TheGroupUtil.GROUP_CALENDAR_EXIST, getCalendarCheck());

      if (TheNetUtil.isNetworkAvailable(this)) {
        groupObject.saveInBackground(
            new SaveCallback() {
              @Override
              public void done(ParseException e) {
                myProgressBar.setVisibility(View.INVISIBLE);
                if (e == null) {
                  // send user to the group looker page.
                  Intent intent = new Intent(EditGroupActivity.this, ViewGroupActivity.class);
                  startActivity(intent);
                }
              }
            });
      } else {
        myProgressBar.setVisibility(View.INVISIBLE);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle("Network is currently unavailable")
            .setMessage(
                "This group will be updated and shared with the world automatically once network is connected!");
        builder.setPositiveButton(
            android.R.string.ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                groupObject.saveEventually();
              }
            });
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.show();
      }
    } else {
      myProgressBar.setVisibility(View.INVISIBLE);
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setTitle("Cannot create group")
          .setMessage("Please make sure all of the information is filled out");
      builder.setPositiveButton(android.R.string.ok, null);
      builder.show();
    }
  }
  private void addFavorite() {
    // mURL = _mURL;title = _title;delay = _delay;state = _state;
    // create the database manager object
    db = new AABDatabaseManager(getActivity());
    ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays();
    Boolean found = false;
    // iterate the ArrayList, create new rows each time and add them
    // to the table widget.
    if (data.size() > 999) {
      AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

      alert.setMessage("Please delete a favorite from the favorites menu before adding more.");

      alert.setPositiveButton(
          "OK",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {}
          });
      alert.show();
    } else {
      for (int position = 0; position < data.size(); position++) {
        ArrayList<Object> row = data.get(position);

        String mCameraName = row.get(1).toString();
        if (mCameraName.equals(mURL)) {
          found = true;
          AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
          alert.setMessage("Camera already exists in favorites");
          alert.setPositiveButton(
              "OK",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {}
              });
          alert.show();
          db.close();
          break;
        }
      }
      if (!found) {
        try {
          db.addRow(mURL, title, delay, state);
          Toast.makeText(
                  getActivity().getApplicationContext(),
                  title + " added to favorites",
                  Toast.LENGTH_LONG)
              .show();

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      db.close();
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.imdbMenuItem:
       if (this.imdb != null) {
         Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("imdb:///title/" + this.imdb));
         Activity parent = this.getSherlockActivity();
         if (parent != null) {
           try {
             startActivity(intent);
           } catch (Exception e) {
             try {
               Intent market =
                   new Intent(
                       Intent.ACTION_VIEW, Uri.parse("market://details?id=com.imdb.mobile"));
               startActivity(market);
             } catch (Exception e2) {
               if (getSherlockActivity() != null) {
                 AlertDialog.Builder build = new AlertDialog.Builder(getSherlockActivity());
                 build.setMessage(R.string.imdb_view_error);
                 build.setPositiveButton(
                     R.string.ok,
                     new DialogInterface.OnClickListener() {
                       @Override
                       public void onClick(DialogInterface dialog, int which) {
                         dialog.cancel();
                       }
                     });
                 build.show();
               }
             }
           }
         }
       } else {
         AlertDialog.Builder build = new AlertDialog.Builder(getSherlockActivity());
         build.setMessage(R.string.wait_error);
         build.setPositiveButton(
             R.string.ok,
             new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int which) {
                 dialog.cancel();
               }
             });
         build.show();
       }
   }
   return super.onOptionsItemSelected(item);
 }
 /**
  * Tests if the game has ended. It tests if you have lost or you won and you can continue to the
  * next word. It gives the message to the user with a dialog.
  */
 public void gameEnd() {
   // the player has no guesses left and lost
   if (game.leftGuesses == 0) {
     AlertDialog.Builder end = new AlertDialog.Builder(GameActivity.this);
     end.setTitle(R.string.gameover);
     end.setMessage(getResources().getString(R.string.end) + game.word);
     end.setPositiveButton(
         R.string.end_button,
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             Intent intent = new Intent(GameActivity.this, HighscoreActivity.class);
             intent.putExtra("gamescore", game.score);
             intent.putExtra("wordlength", game.setLength);
             if (evilType) {
               intent.putExtra("gametype", "evil");
             } else {
               intent.putExtra("gametype", "good");
             }
             startActivity(intent);
             finish();
           }
         });
     // he must go to the highscorescreen
     end.setCancelable(false);
     end.create();
     end.show();
     // All the letters of the word have been guessed
   } else if (game.wordString().indexOf("-") < 0) {
     // The player gets a point
     game.addScore(1);
     AlertDialog.Builder end = new AlertDialog.Builder(GameActivity.this);
     end.setTitle(R.string.guessed);
     end.setMessage(getResources().getString(R.string.guess_end) + game.word);
     end.setPositiveButton(
         R.string.next_word,
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             nextWord();
           }
         });
     // The player must go to the next word
     end.setCancelable(false);
     end.create();
     end.show();
   }
 }
Exemple #10
0
 private AlertDialog showDownloadDialog() {
   AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
   downloadDialog.setTitle(title);
   downloadDialog.setMessage(message);
   downloadDialog.setPositiveButton(
       buttonYes,
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialogInterface, int i) {
           String packageName = targetApplications.get(0);
           Uri uri = Uri.parse("market://details?id=" + packageName);
           Intent intent = new Intent(Intent.ACTION_VIEW, uri);
           try {
             activity.startActivity(intent);
           } catch (ActivityNotFoundException anfe) {
             // Hmm, market is not installed
             Log.w(TAG, "Google Play is not installed; cannot install " + packageName);
           }
         }
       });
   downloadDialog.setNegativeButton(
       buttonNo,
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialogInterface, int i) {}
       });
   return downloadDialog.show();
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    int extraWifiState =
        intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);

    switch (extraWifiState) {
      case WifiManager.WIFI_STATE_ENABLED:
        Toast.makeText(act, "Wifi Habilitada", Toast.LENGTH_SHORT);

        ConnectivityManager conMan =
            (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE);
        while (conMan.getActiveNetworkInfo() == null
            || conMan.getActiveNetworkInfo().getState() != NetworkInfo.State.CONNECTED) {
          try {
            Thread.sleep(2000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
        Toast.makeText(act, "Wifi Conectada", Toast.LENGTH_SHORT);
        break;

      case WifiManager.WIFI_STATE_DISABLED:
        alertDialog.show();
        Log.d("AlertDialog", "un dialogo");
        break;
    }
  }
  @Override
  public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("确定删除吗");
    builder.setPositiveButton(
        "确定",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            addresses.remove(arg2);
            adapter.setData(addresses);
          }
        });

    builder.setNegativeButton(
        "取消",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub

          }
        });
    builder.create();
    builder.show();
    return false;
  }
  @Override
  protected void onProgressUpdate(String... values) {
    super.onProgressUpdate(values);

    // EditText passwordField = (EditText)
    // parent.findViewById(R.id.LoginScreen_EditTextPassword);

    String[] message_parts = values[0].split(":");

    // FORMAT: [TYPE]:[EMAIL]:[TOKEN]:[DATA]:[EOP]
    // 0 1 2 3 4
    Log.v("REC_M", "RECEIVED:" + values[0]);

    if (message_parts.length == 5) {
      String TYPE = message_parts[0];
      String Status = message_parts[3];

      Log.v("TYPE", "TYPE:" + TYPE);

      if (TYPE.equals("STATUS")) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(parent);
        alertDialog.setTitle("             User Alert !");
        alertDialog.setMessage(Status);
        alertDialog.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {}
            });

        alertDialog.show();
        (parent.findViewById(R.id.ForgotPassword_ButtonResetPassword)).setEnabled(true);
      }
    }
  }
Exemple #14
0
  private void handleGevondenAlert(final Clue selectedClue, final Clue currentTargetClue) {
    AlertDialog.Builder alert = new AlertDialog.Builder(context);

    alert.setTitle("Gevonden: " + currentTargetClue.getName());
    alert.setMessage("Woord");

    // Set an EditText view to get user input
    final EditText input = new EditText(context);
    alert.setView(input);

    alert.setPositiveButton(
        "Versturen",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            String word = input.getText().toString();
            new GevondenTask(context, huntedService, word, selectedClue.getName()).execute(null);
            //				map.createMapOverlay();
            //				map.moveMapToClue(selectedClue);
            // Do something with value!
          }
        });

    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled.
          }
        });

    alert.show();
  }
Exemple #15
0
 public static void doodleAddText(final Context context, final DoodleView doodleView) {
   AlertDialog.Builder builder = new AlertDialog.Builder(context);
   builder.setTitle("请输入文字");
   final EditText editText = new EditText(context);
   builder.setView(editText);
   builder.setPositiveButton(
       "确定",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           String text = editText.getText().toString();
           doodleView.setMode(DoodleView.Mode.TEXT_MODE);
           doodleView.addTextAction(text);
           Toast.makeText(
                   context,
                   context.getString(R.string.set_doodle_font_size_and_position),
                   Toast.LENGTH_LONG)
               .show();
         }
       });
   builder.setNegativeButton(
       "取消",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {}
       });
   builder.show();
 }
 /**
  * 显示对话框
  *
  * @param title 对话框标题
  * @param message 对话框内容
  */
 protected void showAlertDialog(String title, String message) {
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setTitle(title);
   builder.setMessage(message);
   builder.setPositiveButton(getString(android.R.string.ok), null);
   builder.show();
 }
 private void showErrorMessage(int message) {
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setMessage(message);
   builder.setPositiveButton(R.string.button_ok, new FinishListener(this));
   builder.setOnCancelListener(new FinishListener(this));
   builder.show();
 }
  private void promptScoutName() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Enter your name");
    builder.setCancelable(false);

    // Set up the input
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);

    // Affirmative response
    builder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            scout = input.getText().toString().toUpperCase();
            if (scout.equals("")) promptScoutName();
            else {
              getPreferences(MODE_PRIVATE)
                  .edit()
                  .putString(getString(R.string.preference_scout), scout)
                  .apply();
              updateNameField();
            }
          }
        });
    builder.show();
  }
  /**
   * Onclick para el boton de actualizar los aeropuertos.
   *
   * @param v
   */
  public void onClickActualizarAeropuertos(View v) {
    AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
    alertbox.setMessage(
        "Esta operación puede tardar varios minutos y se aconseja tener Wifi (Podrás seguir utilizando la aplicación)");
    alertbox.setTitle("Actualizar Aeropuertos");
    alertbox.setPositiveButton(
        "Si",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface arg0, int arg1) {
            if (tieneRed()) {
              actualizarAeropuertos(ORIGENES);
            } else {
              Toast toast =
                  Toast.makeText(
                      context, "Necesitas internet para actualizar.", Toast.LENGTH_SHORT);
              toast.show();
            }
          }
        });

    alertbox.setNegativeButton(
        "No",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface arg0, int arg1) {}
        });
    alertbox.show();
  }
  /**
   * @brief rateUS method
   * @param v
   * @detail This method is called when the rateUs button is clicked this calls another method
   *     launchmarket which handles the call and contains the app's market link
   */
  public void rateUS(View v) {
    final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(vibr);

    final AlertDialog.Builder alertbox = new AlertDialog.Builder(CaptureActivity.this);

    alertbox.setMessage(R.string.rate_us_text); // Message to be displayed

    alertbox.setPositiveButton(
        R.string.yes_btn,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            launchMarket();
          }
        });

    alertbox.setNegativeButton(
        R.string.no_btn,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {}
        });

    // show the alert box will be swapped by other code later
    alertbox.show();
  }
  public void showEditDialog(
      Context context, String hintText, String OKText, final DialogCallBack callBack) {
    final EditText et_search;
    AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_view, null);
    dialog.setView(layout);
    et_search = (EditText) layout.findViewById(R.id.searchC);
    et_search.setHint(hintText);
    dialog.setPositiveButton(
        OKText,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            String s = et_search.getText().toString().trim();
            callBack.exectEditEvent(s);
          }
        });

    dialog.setNegativeButton(
        R.string.cancel,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {}
        });
    dialog.show();
  }
  private void showDurationDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_mms_duration);
    String title = getResources().getString(R.string.duration_selector_title);
    builder.setTitle(title + (mPosition + 1) + "/" + mSlideshowModel.size());

    builder.setItems(
        R.array.select_dialog_items,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            if ((which >= 0) && (which < NUM_DIRECT_DURATIONS)) {
              mSlideshowEditor.changeDuration(mPosition, (which + 1) * 1000);
            } else {
              Intent intent = new Intent(SlideEditorActivity.this, EditSlideDurationActivity.class);
              intent.putExtra(EditSlideDurationActivity.SLIDE_INDEX, mPosition);
              intent.putExtra(EditSlideDurationActivity.SLIDE_TOTAL, mSlideshowModel.size());
              intent.putExtra(
                  EditSlideDurationActivity.SLIDE_DUR,
                  mSlideshowModel.get(mPosition).getDuration() / 1000); // in seconds
              startActivityForResult(intent, REQUEST_CODE_CHANGE_DURATION);
            }
            dialog.dismiss();
          }
        });

    builder.show();
  }
  private void confirmDeleteDialog(OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    View contents = View.inflate(this, R.layout.delete_thread_dialog_view, null);
    TextView msg = (TextView) contents.findViewById(R.id.message);
    msg.setText(R.string.confirm_delete_selected_messages);

    final CheckBox checkbox = (CheckBox) contents.findViewById(R.id.delete_locked);

    if (mSelectedLockedUris.size() == 0) {
      checkbox.setVisibility(View.GONE);
    } else {
      checkbox.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mIsDeleteLockChecked = checkbox.isChecked();
            }
          });
    }
    builder.setTitle(R.string.confirm_dialog_title);
    builder.setIconAttribute(android.R.attr.alertDialogIcon);
    builder.setCancelable(true);
    builder.setPositiveButton(R.string.yes, listener);
    builder.setNegativeButton(R.string.no, null);
    builder.setView(contents);
    builder.show();
  }
  private void showLayoutSelectorDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_mms_layout);

    String title = getResources().getString(R.string.layout_selector_title);
    builder.setTitle(title + (mPosition + 1) + "/" + mSlideshowModel.size());

    LayoutSelectorAdapter adapter = new LayoutSelectorAdapter(this);
    builder.setAdapter(
        adapter,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case 0: // Top text.
                mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_TOP_TEXT);
                break;
              case 1: // Bottom text.
                mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_BOTTOM_TEXT);
                break;
            }
            dialog.dismiss();
          }
        });

    builder.show();
  }
  /**
   * This displays a pop up that asks the user whether they want to add the appointment to their
   * native android calendar. If yes, another method is invoked to do this.
   *
   * @param details all of the details about the appointment
   * @param id the id of the appointment in the database
   */
  private void addToCalendarQuestion(final HashMap<String, String> details, final int id) {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle("Add To Calendar");
    alert.setMessage("Do you want to add this appointment to your phones calendar?");

    alert.setPositiveButton(
        "Yes",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            addToCalendar(details, id);
          }
        });

    alert.setNegativeButton(
        "No",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            finish();
            getIntent();
          }
        });

    alert.show();
  }
 private void ShowSaveConfirmDialog() {
   AlertDialog.Builder builder =
       new AlertDialog.Builder(this, android.R.layout.select_dialog_item);
   builder.setNegativeButton(
       getResources().getString(R.string.cancel),
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           Toast.makeText(P005AlertDialogProf.this, "Negative", Toast.LENGTH_SHORT).show();
           textViewP005.setText(R.string.failed);
         }
       });
   builder.setPositiveButton(
       getResources().getString(R.string.save),
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           Toast.makeText(P005AlertDialogProf.this, "Positive", Toast.LENGTH_SHORT).show();
           textViewP005.setText(R.string.successful);
         }
       });
   builder.setTitle("Are you sure?");
   builder.setIcon(R.drawable.fadein);
   builder.create();
   builder.show();
 }
Exemple #27
0
  public void park(final Activity ctx) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx);
    final String regno = pref("regno", "", ctx);
    final String msg = "Alustan parkimist s›idukile " + regno + " tsoonis " + key;

    alertBuilder
        .setMessage(msg + "?")
        .setCancelable(false)
        .setPositiveButton(
            "Jah",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                String msg = regno + " " + key;
                SmsManager sm = SmsManager.getDefault();
                sm.sendTextMessage("1902", null, msg, null, null);
                send_notification("Parkimine alustatud ", "s›iduk " + regno + " tsoon " + key, ctx);
                set_pref("parking_active", "true", ctx);
                set_pref("start_time", new Long(SystemClock.elapsedRealtime()).toString(), ctx);
                ctx.finish();
              }
            })
        .setNegativeButton(
            "Ei",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
              }
            });

    alertBuilder.create();
    alertBuilder.show();
  }
  private void ShowCustomAlertDialog() {

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    View view = layoutInflater.inflate(R.layout.p005customalertdialog, null);
    builder.setView(view);

    final AlertDialog alertDialog = builder.create();
    builder.setTitle("Are you sure!");
    builder.show();
    Button buttonSaveP005 = (Button) view.findViewById(R.id.buttonSaveP005);
    Button buttonCancelP005 = (Button) view.findViewById(R.id.buttonCancelP005);

    buttonSaveP005.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            textViewP005.setText(R.string.successful);
            alertDialog.dismiss();
            alertDialog.cancel();
          }
        });
    buttonCancelP005.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            textViewP005.setText(R.string.failed);
            alertDialog.cancel();
            alertDialog.dismiss();
          }
        });
  }
Exemple #29
0
  /**
   * Function to show settings alert dialog On pressing Settings button will lauch Settings Options
   */
  public void showSettingsAlert() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);

    // Setting Dialog Title
    alertDialog.setTitle("GPS is settings");

    // Setting Dialog Message
    alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");

    // On pressing Settings button
    alertDialog.setPositiveButton(
        "Settings",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
          }
        });

    // on pressing cancel button
    alertDialog.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
          }
        });

    // Showing Alert Message
    alertDialog.show();
  }
  public void submit(View view) {
    AlertDialog.Builder saveDialog = new AlertDialog.Builder(this);
    saveDialog.setTitle("Confirm Receipt");
    saveDialog.setMessage("Confirm Receipt of Delivery?");
    saveDialog.setPositiveButton(
        "Yes",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            drawing.setDrawingCacheEnabled(true);
            Bitmap sign = drawing.getDrawingCache();

            // CONVERT TO BYTE ARRAY
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            sign.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
            byte[] byteArray = byteArrayOutputStream.toByteArray();

            // CONVERT TO BASE 64
            String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
            confirmReceipt(encoded);
          }
        });

    saveDialog.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
          }
        });

    saveDialog.show();
  }