@Override
  public void onClick(View v) {
    if (v == mSave) {
      save();
    } else if (v == mDefaults) {
      loadData(true);
      mHasChanges = true;
      updateButtons();
    } else if (v == mReload) {
      loadData(false);
      mHasChanges = false;
      updateButtons();
    } else if (v == mNumLevels) {
      mDialog.setMessage(2 + " - " + mSensorRange);
      mEditor.setText(String.valueOf(mLevels.length + 1));
      mEditor.selectAll();
      mEditedId = -1337;
      mDialog.show();
    } else {
      int id = v.getId();
      int value = -1;
      int min = 0;
      int max = 0;
      if (id >= 2000 && id < 3000) {
        value = mLevels[id - 2000];
        min = 0;
        max = mSensorRange;
      } else if (id >= 3000 && id < 4000) {
        value = mLcdValues[id - 3000];
        min =
            Settings.System.getInt(
                getContentResolver(),
                Settings.System.LIGHT_SCREEN_DIM,
                android.os.Power.BRIGHTNESS_DIM);
        max = android.os.Power.BRIGHTNESS_ON;
      } else if (id >= 4000 && id < 5000) {
        value = mBtnValues[id - 4000];
        min = android.os.Power.BRIGHTNESS_OFF;
        max = android.os.Power.BRIGHTNESS_ON;
      } else if (id >= 5000 && id < 6000) {
        value = mKbValues[id - 5000];
        min = android.os.Power.BRIGHTNESS_OFF;
        max = android.os.Power.BRIGHTNESS_ON;
      } else {
        value = -1;
      }

      if (value >= 0) {
        mDialog.setMessage(min + " - " + max);
        mEditor.setText(String.valueOf(value));
        mEditor.selectAll();
        mEditedId = id;
        mDialog.show();
      }
    }
  }
  private void updateViews() {
    if (!mDebugging) {
      mViewDebug.setVisibility(View.GONE);
      mLvDebug.setVisibility(View.GONE);

      if (mIsLoading && !mSharedPrefs.getBoolean("pref_disable_splash", false)) {
        mIitcWebView.setVisibility(View.GONE);
        mImageLoading.setVisibility(View.VISIBLE);
      } else {
        mIitcWebView.setVisibility(View.VISIBLE);
        mImageLoading.setVisibility(View.GONE);
      }
    } else {
      // if the debug container is invisible (and we are about to show it), select the text box
      final boolean select = mViewDebug.getVisibility() != View.VISIBLE;

      mImageLoading.setVisibility(View.GONE); // never show splash screen while debugging
      mViewDebug.setVisibility(View.VISIBLE);

      if (select) {
        mEditCommand.requestFocus();
        mEditCommand.selectAll();
      }

      if (mShowMapInDebug) {
        mBtnToggleMap.setImageResource(R.drawable.ic_action_view_as_list);
        mIitcWebView.setVisibility(View.VISIBLE);
        mLvDebug.setVisibility(View.GONE);
      } else {
        mBtnToggleMap.setImageResource(R.drawable.ic_action_map);
        mIitcWebView.setVisibility(View.GONE);
        mLvDebug.setVisibility(View.VISIBLE);
      }
    }
  }
    @Override
    public void prepare(ViewGroup layout) {
      super.prepare(layout);
      EditText prompt = (EditText) layout.findViewById(R.id.js_modal_dialog_prompt);
      prompt.setVisibility(View.VISIBLE);

      if (mDefaultPromptText.length() > 0) {
        prompt.setText(mDefaultPromptText);
        prompt.selectAll();
      }
    }
Example #4
0
  /** {@inheritDoc} */
  @Override
  @NonNull
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    final EditText editText = new EditText(getContext());
    editText.setText(mText);
    //noinspection deprecation
    editText.setTextColor(getResources().getColor(R.color.textColor));
    editText.selectAll();

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

    builder
        .setTitle(mTitle)
        .setMessage(mMessage)
        .setCancelable(true)
        .setView(editText)
        .setPositiveButton(
            android.R.string.ok,
            new DialogInterface.OnClickListener() {
              /**
               * Handler for click event
               *
               * @param dialog Dialog
               * @param whichButton Selected option
               */
              @Override
              public void onClick(DialogInterface dialog, int whichButton) {
                onTextEntered(editText.getText().toString());

                dialog.dismiss();
              }
            })
        .setNegativeButton(
            android.R.string.cancel,
            new DialogInterface.OnClickListener() {
              /**
               * Handler for click event
               *
               * @param dialog Dialog
               * @param whichButton Selected option
               */
              @Override
              public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
              }
            });

    AlertDialog dialog = builder.create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    return dialog;
  }
  // The return value is sent elsewhere. TODO in java, in SendMessage in C++.
  public void inputBox(String title, String defaultText, String defaultAction) {
    final FrameLayout fl = new FrameLayout(this);
    final EditText input = new EditText(this);
    input.setGravity(Gravity.CENTER);

    FrameLayout.LayoutParams editBoxLayout =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    editBoxLayout.setMargins(2, 20, 2, 20);
    fl.addView(input, editBoxLayout);

    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setText(defaultText);
    input.selectAll();

    // Lovely!
    AlertDialog.Builder bld = null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) bld = new AlertDialog.Builder(this);
    else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
      bld = createDialogBuilderWithTheme();
    else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
      bld = createDialogBuilderWithDeviceTheme();
    else bld = createDialogBuilderNew();

    AlertDialog dlg =
        bld.setView(fl)
            .setTitle(title)
            .setPositiveButton(
                defaultAction,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    NativeApp.sendMessage("inputbox_completed", input.getText().toString());
                    d.dismiss();
                  }
                })
            .setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    NativeApp.sendMessage("inputbox_failed", "");
                    d.cancel();
                  }
                })
            .create();

    dlg.setCancelable(true);
    dlg.show();
  }
Example #6
0
 protected void onResume() {
   super.onResume();
   if (mPrefs == null) {
     mPrefs = getPreferences(Context.MODE_PRIVATE);
   }
   // XXX: this function kept throwing NPEs here without the above.
   // seems like onCreate() is not called first?
   if (mPrefs.contains("saved-braindump-text")) {
     mText.setText(mPrefs.getString("saved-braindump-text", ""));
     mText.selectAll(); // select it all, so we can erase if we want.
   }
   // in case we ran login, reload the sid cookie.
   mHivemind.reloadSidCookie();
 }
  /**
   * Initiate the synchronous acronym lookup when the user presses the "Lookup Acronym Sync" button.
   */
  public void expandAcronymSync(View v) {
    // Try to get an acronym entered by the user.
    final String acronym = Utils.uppercaseInput(this, mEditText.getText().toString().trim(), true);

    if (acronym != null) {
      Log.d(TAG, "calling expandAcronymSync() for " + acronym);

      // Synchronously expand the acronym.
      if (getOps().expandAcronymSync(acronym) == false)
        // Show error message to user.
        Utils.showToast(this, "Call already in progress");

      // Return focus to edit box and select all text in it
      // after query.
      mEditText.requestFocus();
      mEditText.selectAll();
    }
  }
  @ActionMethod(ids = R.id.mainmenu_bookmark)
  public void showBookmarkDialog(final ActionEx action) {
    final int page = documentModel.getCurrentViewPageIndex();

    final String message = getManagedComponent().getString(R.string.add_bookmark_name);

    final BookSettings bs = getBookSettings();
    final int offset = bs != null ? bs.firstPageOffset : 1;

    final EditText input =
        (EditText) LayoutInflater.from(getManagedComponent()).inflate(R.layout.bookmark_edit, null);
    input.setText(getManagedComponent().getString(R.string.text_page) + " " + (page + offset));
    input.selectAll();

    final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this);
    builder.setTitle(R.string.menu_add_bookmark).setMessage(message).setView(input);
    builder.setPositiveButton(R.id.actions_addBookmark, new EditableValue("input", input));
    builder.setNegativeButton().show();
  }
  @Override
  public boolean onJsPrompt(
      XWalkView view,
      String url,
      String message,
      String defaultValue,
      final JsPromptResult result) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
    dialogBuilder
        .setTitle(mJSPromptTitle)
        .setMessage(message)
        .setPositiveButton(
            mOKButton,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                result.confirm(mPromptText.getText().toString());
                dialog.dismiss();
              }
            })
        .setNegativeButton(
            mCancelButton,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                result.cancel();
                dialog.dismiss();
              }
            });
    mPromptText = new EditText(mContext);
    mPromptText.setVisibility(View.VISIBLE);
    mPromptText.setText(defaultValue);
    mPromptText.selectAll();

    dialogBuilder.setView(mPromptText);
    mDialog = dialogBuilder.create();
    mDialog.show();
    return false;
  }
  @Override
  public void onClick(View v) {
    String username = usernameField.getText().toString();
    String password = passwordField.getText().toString();
    String passwordAgain = confirmPasswordField.getText().toString();

    String email = null;
    if (config.isParseLoginEmailAsUsername()) {
      email = usernameField.getText().toString();
    } else if (emailField != null) {
      email = emailField.getText().toString();
    }

    String name = null;
    if (nameField != null) {
      name = nameField.getText().toString();
    }

    if (username.length() == 0) {
      if (config.isParseLoginEmailAsUsername()) {
        showToast(R.string.com_parse_ui_no_email_toast);
      } else {
        showToast(R.string.com_parse_ui_no_username_toast);
      }
    } else if (password.length() == 0) {
      showToast(R.string.com_parse_ui_no_password_toast);
    } else if (password.length() < minPasswordLength) {
      showToast(
          getResources()
              .getQuantityString(
                  R.plurals.com_parse_ui_password_too_short_toast,
                  minPasswordLength,
                  minPasswordLength));
    } else if (passwordAgain.length() == 0) {
      showToast(R.string.com_parse_ui_reenter_password_toast);
    } else if (!password.equals(passwordAgain)) {
      showToast(R.string.com_parse_ui_mismatch_confirm_password_toast);
      confirmPasswordField.selectAll();
      confirmPasswordField.requestFocus();
    } else if (email != null && email.length() == 0) {
      showToast(R.string.com_parse_ui_no_email_toast);
    } else if (name != null && name.length() == 0) {
      showToast(R.string.com_parse_ui_no_name_toast);
    } else {
      ParseUser user = new ParseUser();

      // Set standard fields
      user.setUsername(username);
      user.setPassword(password);
      user.setEmail(email);

      // Set additional custom fields only if the user filled it out
      if (name.length() != 0) {
        user.put(USER_OBJECT_NAME_FIELD, name);
      }

      loadingStart();
      user.signUpInBackground(
          new SignUpCallback() {

            @Override
            public void done(ParseException e) {
              if (isActivityDestroyed()) {
                return;
              }

              if (e == null) {
                loadingFinish();
                signupSuccess();
              } else {
                loadingFinish();
                if (e != null) {
                  debugLog(
                      getString(R.string.com_parse_ui_login_warning_parse_signup_failed)
                          + e.toString());
                  switch (e.getCode()) {
                    case ParseException.INVALID_EMAIL_ADDRESS:
                      showToast(R.string.com_parse_ui_invalid_email_toast);
                      break;
                    case ParseException.USERNAME_TAKEN:
                      showToast(R.string.com_parse_ui_username_taken_toast);
                      break;
                    case ParseException.EMAIL_TAKEN:
                      showToast(R.string.com_parse_ui_email_taken_toast);
                      break;
                    default:
                      showToast(R.string.com_parse_ui_signup_failed_unknown_toast);
                  }
                }
              }
            }
          });
    }
  }
 /** See {@link android.widget.EditText#selectAll()}. */
 public void selectAll() {
   editText.selectAll();
 }
 @Override
 protected void onResume() {
   super.onResume();
   queryTextView.selectAll();
 }
  // View.OnClickListener method (create account button clicked)
  @Override
  public void onClick(View view) {
    String password = mEdtPassword.getText().toString();
    String passwordAgain = mEdtConfirmPassword.getText().toString();
    String name = mEdtName.getText().toString();

    if (password.length() == 0) {
      showSnack(R.string.com_parse_ui_no_password_toast);
    } else if (password.length() < mMinPasswordLength) {
      showSnack(
          getResources()
              .getQuantityString(
                  R.plurals.com_parse_ui_password_too_short_toast,
                  mMinPasswordLength,
                  mMinPasswordLength));
    } else if (passwordAgain.length() == 0) {
      showSnack(R.string.com_parse_ui_reenter_password_toast);
    } else if (!password.equals(passwordAgain)) {
      showSnack(R.string.com_parse_ui_mismatch_confirm_password_toast);
      mEdtConfirmPassword.selectAll();
      mEdtConfirmPassword.requestFocus();
    } else if (name.length() == 0) {
      showSnack(R.string.com_parse_ui_no_name_toast);
    } else {
      final ParseUser user = ParseObject.create(ParseUser.class);

      // Set standard fields
      user.setUsername(mEmailAddress);
      user.setEmail(mEmailAddress);
      user.setPassword(password);

      // Set additional custom fields only if the user filled it out
      if (name.length() != 0) {
        user.put(SignInActivity.USER_OBJECT_NAME_FIELD, name);
      }

      loadingStart();
      user.signUpInBackground(
          new SignUpCallback() {

            @Override
            public void done(ParseException e) {
              if (isActivityDestroyed()) {
                Log.e(LOG_TAG, "Activity was destroyed during sign up");
                return;
              }

              loadingFinish();
              if (e == null) {
                signUpSuccess(user);
              } else {
                switch (e.getCode()) {
                  case ParseException.INVALID_EMAIL_ADDRESS:
                    showSnack(R.string.com_parse_ui_invalid_email_toast);
                    break;
                  case ParseException.USERNAME_TAKEN:
                    showSnack(R.string.com_parse_ui_username_taken_toast);
                    break;
                  case ParseException.EMAIL_TAKEN:
                    showSnack(R.string.com_parse_ui_email_taken_toast);
                    break;
                  default:
                    Log.e(LOG_TAG, "Error signing up " + mEmailAddress + ": " + e.toString());
                    showSnack(R.string.com_parse_ui_signup_failed_unknown_toast);
                }
              }
            }
          });
    }
  }
 @Override
 public boolean onTouch(View v, MotionEvent arg1) {
   // ((EditText)v).setText("");
   ((EditText) v).selectAll();
   return false;
 }
 private void notifyUser(int msgId) {
   mDur.requestFocus();
   mDur.selectAll();
   Toast.makeText(this, msgId, Toast.LENGTH_SHORT).show();
   return;
 }