Exemplo n.º 1
0
  public DateTimeInput(EditText parent, Mode mode) {
    mParent = parent;
    mMode = mode;

    if (mode == Mode.DATE) {
      mParent.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE);
      mFormat = android.text.format.DateFormat.getDateFormat(mParent.getContext());
    } else {
      mParent.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME);
      mFormat = android.text.format.DateFormat.getTimeFormat(mParent.getContext());
    }
  }
  private void initView() {
    // TODO Auto-generated method stub
    mButton = (Button) findViewById(R.id.yanzheng);
    mBtnYanzheng = (Button) findViewById(R.id.button1);
    mEditText = (EditText) findViewById(R.id.editText1);
    _InputMethodManager =
        (InputMethodManager) mEditText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    mButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stubs
            Intent _Intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:125904030106"));
            MainActivity.this.startActivity(_Intent);
            _TelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            mListenner = new MyPhoneStateListenner();
            _TelephonyManager.listen(mListenner, PhoneStateListener.LISTEN_CALL_STATE);
          }
        });
    mBtnYanzheng.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (mEditText.getText().toString().equals("1234")) {
              showDialog(1);
            } else {
              showDialog(2);
            }
          }
        });
  }
Exemplo n.º 3
0
 public static void closeSoft(final EditText editText) {
   // editText.setFocusable(false);
   InputMethodManager inputManager =
       (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   inputManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
   // inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,
   // InputMethodManager.HIDE_IMPLICIT_ONLY);
 }
Exemplo n.º 4
0
 public static void showSoft(final EditText editText) {
   editText.requestFocus();
   InputMethodManager inputManager =
       (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   inputManager.showSoftInput(editText, InputMethodManager.RESULT_SHOWN);
   // inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,
   // InputMethodManager.HIDE_IMPLICIT_ONLY);
 }
Exemplo n.º 5
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_edit, container, false);

    editText = (EditText) view.findViewById(R.id.memo_edit);
    editText.setFocusable(true);
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();
    InputMethodManager inputManager =
        (InputMethodManager)
            editText.getContext().getSystemService(getActivity().INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(0, inputManager.SHOW_FORCED);

    //        fragmentManager=getFragmentManager();
    //
    //        editText=(EditText)view.findViewById(R.id.memo_edit_edittext);
    //        editText.setVisibility(View.GONE);
    //        textView=(TextView)view.findViewById(R.id.memo_null_textview);
    //        textView.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Memo_Choose_Fragment memo_choose_fragment= (Memo_Choose_Fragment)
    // fragmentManager.findFragmentByTag("choose");
    //                FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
    //                fragmentTransaction.remove(memo_choose_fragment);
    //                fragmentTransaction.commit();
    //            }
    //        });
    //
    //        deleteBT=(Button)view.findViewById(R.id.memo_delete_button);
    //
    //        editBT=(Button)view.findViewById(R.id.memo_edit_button);
    //        editBT.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                textView.setVisibility(View.GONE);
    //                editText.setVisibility(View.VISIBLE);
    //                editText.setFocusable(true);
    //                editText.setFocusableInTouchMode(true);
    //                editText.requestFocus();
    //                editBT.setVisibility(View.GONE);
    //                deleteBT.setVisibility(View.GONE);
    //                InputMethodManager inputManager
    // =(InputMethodManager)editText.getContext().getSystemService(getActivity().INPUT_METHOD_SERVICE);
    //                inputManager.toggleSoftInput(0, inputManager.SHOW_FORCED);
    //            }
    //        });

    return view;
  }
Exemplo n.º 6
0
 public final void dg()
 {
     xf._mth02CA(xf.if.aRw);
     brx = true;
     if (brh.isFocused())
     {
         EditText edittext = brh;
         if (edittext != null)
         {
             ((InputMethodManager)edittext.getContext().getSystemService("input_method")).hideSoftInputFromWindow(edittext.getWindowToken(), 0);
         }
     } else
     if (bri.isFocused())
     {
         EditText edittext1 = bri;
         if (edittext1 != null)
         {
             ((InputMethodManager)edittext1.getContext().getSystemService("input_method")).hideSoftInputFromWindow(edittext1.getWindowToken(), 0);
         }
     }
     brA.dC();
     startActivityForResult(_cls026B.if._mth1D17(), 29386);
 }
Exemplo n.º 7
0
    @Override
    protected void onPostExecute(final JSONObject result) {
      dialog.dismiss();
      try {
        int[] attrs = {R.attr.font};
        TypedArray ta =
            editText
                .getContext()
                .obtainStyledAttributes(
                    new ColorPreferences(editText.getContext()).getFontStyle().getBaseId(), attrs);
        final String url = result.getJSONObject("data").getString("link");
        LinearLayout layout = new LinearLayout(editText.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);

        final TextView titleBox = new TextView(editText.getContext());
        titleBox.setText(url);
        layout.addView(titleBox);
        titleBox.setTextColor(ta.getColor(0, Color.WHITE));

        final EditText descriptionBox = new EditText(editText.getContext());
        descriptionBox.setHint(R.string.editor_title);
        descriptionBox.setTextColor(ta.getColor(0, Color.WHITE));

        ta.recycle();
        layout.setPadding(16, 16, 16, 16);
        layout.addView(descriptionBox);
        new AlertDialogWrapper.Builder(editText.getContext())
            .setTitle(R.string.editor_title_link)
            .setView(layout)
            .setPositiveButton(
                R.string.editor_action_link,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    String s = "[" + descriptionBox.getText().toString() + "](" + url + ")";
                    int start = Math.max(editText.getSelectionStart(), 0);
                    int end = Math.max(editText.getSelectionEnd(), 0);
                    editText.getText().insert(Math.max(start, end), s);
                  }
                })
            .show();

      } catch (Exception e) {
        new AlertDialogWrapper.Builder(c)
            .setTitle(R.string.err_title)
            .setMessage(R.string.editor_err_msg)
            .setPositiveButton(
                R.string.btn_ok,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {}
                })
            .show();
        e.printStackTrace();
      }
    }
Exemplo n.º 8
0
 @Override
 public void onFocusChange(View v, boolean hasFocus) {
   EditText textView = (EditText) v;
   InputMethodManager imm =
       (InputMethodManager)
           textView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   String hint;
   if (hasFocus) {
     hint = textView.getHint().toString();
     textView.setTag(hint);
     textView.setHint("");
     imm.showSoftInput(textView, InputMethodManager.SHOW_FORCED);
   } else {
     hint = textView.getTag().toString();
     textView.setHint(hint);
   }
 }
Exemplo n.º 9
0
  public static void showKeyboard(EditText target) {
    target.requestFocus();
    InputMethodManager imm =
        (InputMethodManager) target.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    // Either show it once
    imm.showSoftInput(target, InputMethodManager.SHOW_FORCED);

    // Or toggle it twice with forced and hide with not force
    imm.toggleSoftInputFromWindow(
        target.getWindowToken(),
        InputMethodManager.SHOW_FORCED,
        InputMethodManager.HIDE_NOT_ALWAYS);
    imm.toggleSoftInputFromWindow(
        target.getWindowToken(),
        InputMethodManager.SHOW_FORCED,
        InputMethodManager.HIDE_NOT_ALWAYS);
  }
Exemplo n.º 10
0
 public static String getText(
     EditText editText, Pattern pattern, int errMsgResId, Object... errMsgFormatArgs)
     throws ValidationException {
   return getText(
       editText, pattern, editText.getContext().getString(errMsgResId, errMsgFormatArgs));
 }
  @SuppressWarnings("deprecation")
  @Override
  public int finishUpload(String attachments, String attachmentsCheck, String picUrl, Uri uri) {
    String selectedImagePath2 = FunctionUtil.getPath(this, uri);
    final int index = bodyText.getSelectionStart();
    this.act.appendAttachments_(attachments);
    act.appendAttachments_check_(attachmentsCheck);
    String spantmp = "[img]./" + picUrl + "[/img]";
    if (!StringUtil.isEmpty(selectedImagePath2)) {
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      Bitmap bitmap = BitmapFactory.decodeFile(selectedImagePath2, options); // 此时返回 bm 为空
      options.inJustDecodeBounds = false;
      DisplayMetrics dm = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(dm);
      int screenwidth = (int) (dm.widthPixels * 0.75);
      int screenheigth = (int) (dm.heightPixels * 0.75);
      int width = options.outWidth;
      int height = options.outHeight;
      float scaleWidth = ((float) screenwidth) / width;
      float scaleHeight = ((float) screenheigth) / height;
      if (scaleWidth < scaleHeight && scaleWidth < 1f) { // 不能放大啊,然后主要是哪个小缩放到哪个就行了
        options.inSampleSize = (int) (1 / scaleWidth);
      } else if (scaleWidth >= scaleHeight && scaleHeight < 1f) {
        options.inSampleSize = (int) (1 / scaleHeight);
      } else {
        options.inSampleSize = 1;
      }
      bitmap = BitmapFactory.decodeFile(selectedImagePath2, options);
      BitmapDrawable bd = new BitmapDrawable(bitmap);
      Drawable drawable = (Drawable) bd;
      drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
      SpannableString spanStringS = new SpannableString(spantmp);
      ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
      spanStringS.setSpan(span, 0, spantmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

      if (bodyText.getText().toString().replaceAll("\\n", "").trim().equals("")) { // NO INPUT DATA
        bodyText.append(spanStringS);
        bodyText.append("\n");
      } else {
        if (index <= 0 || index >= bodyText.length()) { // pos @ begin /
          // end
          if (bodyText.getText().toString().endsWith("\n")) {
            bodyText.append(spanStringS);
            bodyText.append("\n");
          } else {
            bodyText.append("\n");
            bodyText.append(spanStringS);
            bodyText.append("\n");
          }
        } else {
          bodyText.getText().insert(index, spanStringS);
        }
      }
    } else {
      if (bodyText.getText().toString().replaceAll("\\n", "").trim().equals("")) { // NO INPUT DATA
        bodyText.append("[img]./" + picUrl + "[/img]\n");
      } else {
        if (index <= 0 || index >= bodyText.length()) { // pos @ begin /
          // end
          if (bodyText.getText().toString().endsWith("\n")) {
            bodyText.append("[img]./" + picUrl + "[/img]\n");
          } else {
            bodyText.append("\n[img]./" + picUrl + "[/img]\n");
          }
        } else {
          bodyText.getText().insert(index, "[img]./" + picUrl + "[/img]");
        }
      }
    }
    InputMethodManager imm =
        (InputMethodManager) bodyText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
    return 1;
  }
Exemplo n.º 12
0
 public UploadImgur(EditText editText) {
   this.c = editText.getContext();
   this.editText = editText;
   dialog = new ProgressDialog(c);
 }
Exemplo n.º 13
0
 private void showKeyboard() {
   InputMethodManager inputMethodManager =
       (InputMethodManager)
           messageEditText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   inputMethodManager.showSoftInput(messageEditText, InputMethodManager.SHOW_IMPLICIT);
 }