Ejemplo n.º 1
0
  private LinearLayout getMainBody() {
    LinearLayout llMainBody = new LinearLayout(getContext());
    llMainBody.setOrientation(LinearLayout.VERTICAL);
    LayoutParams lpMain = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpMain.weight = 1;
    int dp_4 = dipToPx(getContext(), 4);
    lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
    llMainBody.setLayoutParams(lpMain);

    LinearLayout llContent = new LinearLayout(getContext());
    LayoutParams lpContent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpContent.weight = 1;
    llMainBody.addView(llContent, lpContent);

    // share content editor
    etContent = new EditText(getContext());
    etContent.setGravity(Gravity.LEFT | Gravity.TOP);
    etContent.setBackgroundDrawable(null);
    etContent.setText(String.valueOf(shareParamMap.get("text")));
    etContent.addTextChangedListener(this);
    LayoutParams lpEt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpEt.weight = 1;
    etContent.setLayoutParams(lpEt);
    llContent.addView(etContent);

    llContent.addView(getThumbView());
    llMainBody.addView(getBodyBottom());

    return llMainBody;
  }
  public void showShareCommentDialog(Context context, final DialogFlowController controller) {

    final EditText text = new EditText(context);
    text.setMinLines(5);
    text.setGravity(Gravity.TOP);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Share");
    builder.setMessage("Enter a comment (Optional)");
    builder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            controller.onContinue(text.getText().toString());
          }
        });
    builder.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            controller.onCancel();
          }
        });

    AlertDialog dialog = builder.create();
    dialog.setView(text);
    dialog.show();
  }
Ejemplo n.º 3
0
  private View createNameDialog(String titleText, String value, int identifier) {
    Point windowSize = getWindowSize(mContext.getWindowManager().getDefaultDisplay());
    int five_dip = ConvertToPx(mContext, 5);
    int dialogWidth = windowSize.x - 10 * five_dip;

    LinearLayout mainContainer = new LinearLayout(mContext);
    mainContainer.setOrientation(LinearLayout.VERTICAL);
    mainContainer.addView(getTitleTextView(titleText));
    mainContainer.setBackgroundColor(Color.argb(180, 255, 255, 255));

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(dialogWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams verticalDivider_params =
        new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
    layoutParams.gravity = Gravity.CENTER;
    mainContainer.setLayoutParams(layoutParams);

    EditText tv = new EditText(mContext);
    tv.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    tv.setText(value);
    tv.setEnabled(false);
    tv.setTextColor(Color.BLACK);
    tv.setGravity(Gravity.CENTER);
    layoutParams.setMargins(five_dip, five_dip * 3, five_dip, five_dip);
    tv.setLayoutParams(layoutParams);
    mainContainer.addView(tv);
    mainContainer.addView(getDivider(verticalDivider_params));
    addAlphabets(mainContainer);

    addButtons(mainContainer, identifier);
    edit_PlayerName = tv;
    return mainContainer;
  }
Ejemplo n.º 4
0
 @Override
 @NonNull
 protected LinearLayout makeCenterView() {
   LinearLayout rootLayout = new LinearLayout(activity);
   rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
   rootLayout.setOrientation(LinearLayout.VERTICAL);
   blackColorView = new ColorPanelView(activity);
   //noinspection ResourceType
   blackColorView.setId(BLACK_ID);
   blackColorView.setLayoutParams(
       new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
   blackColorView.setPointerDrawable(
       CompatUtils.getDrawable(activity, R.drawable.color_picker_cursor_bottom));
   blackColorView.setLockPointerInBounds(false);
   blackColorView.setOnColorChangedListener(
       new ColorPanelView.OnColorChangedListener() {
         @Override
         public void onColorChanged(ColorPanelView view, int color) {
           updateCurrentColor(color);
         }
       });
   rootLayout.addView(blackColorView);
   multiColorView = new ColorPanelView(activity);
   //noinspection ResourceType
   multiColorView.setId(MULTI_ID);
   multiColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
   multiColorView.setPointerDrawable(
       CompatUtils.getDrawable(activity, R.drawable.color_picker_cursor_top));
   multiColorView.setLockPointerInBounds(true);
   multiColorView.setOnColorChangedListener(
       new ColorPanelView.OnColorChangedListener() {
         @Override
         public void onColorChanged(ColorPanelView view, int color) {
           updateCurrentColor(color);
         }
       });
   rootLayout.addView(multiColorView);
   LinearLayout previewLayout = new LinearLayout(activity);
   previewLayout.setOrientation(LinearLayout.HORIZONTAL);
   previewLayout.setGravity(Gravity.CENTER);
   previewLayout.setLayoutParams(
       new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
   hexValView = new EditText(activity);
   hexValView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
   hexValView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
   hexValView.setImeOptions(EditorInfo.IME_ACTION_DONE);
   hexValView.setGravity(Gravity.CENTER);
   hexValView.setBackgroundColor(initColor);
   hexValView.setTextColor(Color.BLACK);
   hexValView.setShadowLayer(3, 0, 2, Color.WHITE); // 设置阴影,以便背景色为黑色系列时仍然看得见
   hexValView.setMinEms(6);
   hexValView.setMaxEms(8);
   hexValView.setPadding(0, 0, 0, 0);
   hexValView.setSingleLine(true);
   hexValView.setOnEditorActionListener(this);
   hexValDefaultColor = hexValView.getTextColors();
   previewLayout.addView(hexValView);
   rootLayout.addView(previewLayout);
   return rootLayout;
 }
Ejemplo n.º 5
0
  /** OnClickListener methods */
  @Override
  public void onClick(View view) {
    if (editText == null) {
      editText = new EditText(Utils.mainActivity);
      editText.setGravity(Gravity.CENTER);
      editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    }

    if (inputType != null) {
      if (inputType.toLowerCase().equals("numeric"))
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);
      else
        editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    } else if (lastLive instanceof Integer) editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    else editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

    textView.setVisibility(View.GONE);
    if (editText.getParent() != null) {
      ((LinearLayout) editText.getParent()).findViewById(tv_id).setVisibility(View.VISIBLE);
      ((LinearLayout) editText.getParent()).removeView(editText);
    }

    elementFrame.addView(editText);
    editText.setOnEditorActionListener(this);
    editText.setText(lastEdit.toString());
    editText.requestFocus();
    editText.setSelection(0, editText.getText().length());
    Utils.imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    et = new EditText(getActivity());

    getGame().addGoGameChangeListener(this);

    et.setText(getGame().getActMove().getComment());
    et.setHint(R.string.enter_your_comments_here);
    et.setGravity(Gravity.TOP);
    et.setTextColor(this.getResources().getColor(R.color.text_color_on_board_bg));

    et.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void afterTextChanged(Editable s) {
            getGame().getActMove().setComment(s.toString());
          }

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

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}
        });

    et.setLayoutParams(lp);
    return et;
  }
Ejemplo n.º 7
0
  // 初始化控件
  private void initView() {

    dialog = new ProgressDialog(this);
    edtTitle = (EditText) findViewById(R.id.EditTextTitle);
    edtContent = (EditText) findViewById(R.id.EditTextContent);

    if (id == null) {
      // 光标移到最上面
      edtContent.setGravity(Gravity.TOP);
    } else {
      // 光标移到最下面
      edtContent.setGravity(Gravity.BOTTOM);
    }

    // 隐藏按钮
    ImageButton editButton = (ImageButton) findViewById(R.id.edit_button);
    editButton.setVisibility(View.INVISIBLE);

    // 回退按钮
    ImageButton backButton = (ImageButton) findViewById(R.id.back_button);
    backButton.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            goBack();
          }
        });

    // 取消按钮
    Button cancelButton = (Button) findViewById(R.id.btnCancel);
    cancelButton.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            goBack();
          }
        });

    // 保存按钮
    Button saveButton = (Button) findViewById(R.id.btnSave);
    saveButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            doPost();
          }
        });
  }
Ejemplo n.º 8
0
  public void handleTextAlign(String textAlign, String verticalAlign) {
    int valign = field ? Gravity.CENTER_VERTICAL : Gravity.TOP;
    int align = Gravity.LEFT;

    if (textAlign != null) {
      if ("left".equals(textAlign)) {
        align = Gravity.LEFT;
      } else if ("center".equals(textAlign)) {
        align = Gravity.CENTER_HORIZONTAL;
      } else if ("right".equals(textAlign)) {
        align = Gravity.RIGHT;
      } else {
        Log.w(LCAT, "Unsupported alignment: " + textAlign);
      }
    } else {
      // Nothing has been set - let's set if something was set previously
      // You can do this with shortcut syntax - but long term maint of code is easier if it's
      // explicit
      Log.w(
          LCAT,
          "No alignment set - old horiz align was: "
              + (tv.getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK));

      if ((tv.getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK) != Gravity.NO_GRAVITY) {
        // Something was set before - so let's use it
        align = tv.getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK;
      }
    }

    if (verticalAlign != null) {
      if ("top".equals(verticalAlign)) {
        valign = Gravity.TOP;
      } else if ("middle".equals(verticalAlign)) {
        valign = Gravity.CENTER_VERTICAL;
      } else if ("bottom".equals(verticalAlign)) {
        valign = Gravity.BOTTOM;
      } else {
        Log.w(LCAT, "Unsupported alignment: " + verticalAlign);
      }
    } else {
      // Nothing has been set - let's set if something was set previously
      // You can do this with shortcut syntax - but long term maint of code is easier if it's
      // explicit
      Log.w(
          LCAT,
          "No alignment set - old vert align was: "
              + (tv.getGravity() & Gravity.VERTICAL_GRAVITY_MASK));

      if ((tv.getGravity() & Gravity.VERTICAL_GRAVITY_MASK) != Gravity.NO_GRAVITY) {
        // Something was set before - so let's use it
        valign = tv.getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
      }
    }

    tv.setGravity(valign | align);
  }
  private void build_scroll_view(RaceDetails rd) {
    // Erase the content of the scroll view
    LinearLayout pilot_list = (LinearLayout) findViewById(R.id.pilot_list);
    pilot_list.removeAllViews();

    for (int index = 0; index < main_application.nb_of_pilots; index++) {
      if (rd.isTherePilot(index)) {
        LinearLayout new_horiz_layout = new LinearLayout(this);
        new_horiz_layout.setLayoutParams(
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));
        new_horiz_layout.setOrientation(LinearLayout.HORIZONTAL);

        EditText new_text_view = new EditText(this);
        new_text_view.setText(main_application.getPilotName(index));
        new_text_view.setLayoutParams(
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));
        new_text_view.setInputType(
            InputType.TYPE_NULL); // The text cannot be edited with the soft keypad
        new_text_view.setFocusable(false); // The text cannot be edited
        new_horiz_layout.addView(new_text_view);

        ImageView new_image_view = new ImageView(this);
        new_image_view.setImageResource(R.drawable.kart);
        new_horiz_layout.addView(new_image_view);

        EditText new_text_view_car_id = new EditText(this);
        if (rd.pilot_to_car_mapping.matching.indexOfKey(index) >= 0) {
          new_text_view_car_id.setText(
              Integer.toString(rd.pilot_to_car_mapping.matching.get(index)));
        } else {
          // This pilot wasn't in the maximum matching, he therefore is assigned to a car number he
          // already got
          // Signal that by writing the car number red.
          new_text_view_car_id.setText(
              Integer.toString(rd.pilot_to_car_mapping.unmatched.get(index)));
          new_text_view_car_id.setTextColor(getResources().getColor(R.color.dark_red));
        }
        new_text_view_car_id.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        new_text_view_car_id.setInputType(
            InputType.TYPE_NULL); // The text cannot be edited with the soft keypad
        new_text_view_car_id.setFocusable(false); // The text cannot be edited
        new_text_view_car_id.setEms(3);
        new_text_view_car_id.setGravity(Gravity.RIGHT);
        new_horiz_layout.addView(new_text_view_car_id);

        pilot_list.addView(new_horiz_layout);
      }
    }

    // Redraw the scroll view
    pilot_list.invalidate();
  }
Ejemplo n.º 10
0
 public TiUIText(TiViewProxy proxy, boolean field) {
   super(proxy);
   if (DBG) {
     Log.d(LCAT, "Creating a text field");
   }
   this.field = field;
   tv = new EditText(getProxy().getContext());
   if (field) {
     tv.setSingleLine();
     tv.setMaxLines(1);
   }
   tv.addTextChangedListener(this);
   tv.setOnEditorActionListener(this);
   tv.setOnFocusChangeListener(this); // TODO refactor to TiUIView?
   // tv.setPadding(5, 0, 5, 0);
   if (field) {
     tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
   } else {
     tv.setGravity(Gravity.TOP | Gravity.LEFT);
   }
   setNativeView(tv);
 }
Ejemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    uid = intent.getStringExtra("uid");
    et = new EditText(this);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    et.setLayoutParams(lp);
    et.setGravity(Gravity.LEFT | Gravity.TOP);

    setContentView(et);
  }
Ejemplo n.º 12
0
  // 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();
  }
Ejemplo n.º 13
0
  @SuppressLint("NewApi")
  public void onMenuCopyClicked() {
    String text =
        dobroitem.post.getMessage() == null
            ? dobroitem.post.getFormattedText().toString()
            : dobroitem.post.getMessage();
    /*
    Intent i = new Intent(getContext(), CopyPasteActivity.class);
    i.putExtra("text", );
    i.putExtra(GDActivity.GD_ACTION_BAR_TITLE, "Скопируйте текст");
    getContext().startActivity(i);
    */
    View v = null;
    if (Build.VERSION.SDK_INT < 11) {
      EditText edit = new EditText(getContext());
      edit.setPadding(10, 10, 10, 10);
      edit.setGravity(Gravity.TOP);
      edit.setTextColor(Color.BLACK);
      edit.setBackgroundColor(Color.WHITE);
      edit.setInputType(InputType.TYPE_NULL);
      edit.setHorizontallyScrolling(false);
      edit.setSingleLine(false);
      edit.setText(text);
      v = edit;
    } else {
      SharedPreferences prefs = DobroApplication.getApplicationStatic().getDefaultPrefs();
      int font_size = 10;
      try {
        font_size = Integer.parseInt(prefs.getString("font_size", "16"));
      } catch (Exception e) {
      }
      if (font_size < 10) font_size = 10;

      TextView edit = new TextView(getContext());
      edit.setPadding(10, 10, 10, 10);
      edit.setTextSize(font_size);
      edit.setTextColor(Color.BLACK);
      edit.setBackgroundColor(Color.WHITE);
      edit.setFocusable(true);
      edit.setTextIsSelectable(true);
      edit.setText(text);
      v = edit;
    }
    Dialog d = new Dialog(getContext(), android.R.style.Theme_NoTitleBar_Fullscreen);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setCanceledOnTouchOutside(true);
    d.setContentView(v);
    d.show();
  }
  public void switchToTextView(Context context, String blockname) {
    String blockLongText = getBlockLongText(blockname);

    if (blockname.equalsIgnoreCase("Hold To Edit")) {
      Toast.makeText(context, "Please Name The Block", Toast.LENGTH_LONG).show();
      return;
    }

    // do something when the button is clicked

    // in onCreate or any event where your want the user to
    tempBlockName = blockname;
    AlertDialog.Builder alert = new AlertDialog.Builder(context);

    alert.setTitle("Block Information?");
    alert.setMessage("Please Enter More Information For " + blockname);

    // Set an EditText view to get user input
    final EditText input = new EditText(context);
    input.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    input.setLines(10);
    input.setGravity(Gravity.TOP);
    input.setHorizontallyScrolling(false);
    input.setText(blockLongText);

    alert.setView(input);

    alert.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            String newtext = input.getText().toString();
            setBlockLongText(tempBlockName, newtext);
          }
        });

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

    alert.show();
  }
Ejemplo n.º 15
0
  private void showDialog(final String file, String value) {
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setPadding(30, 30, 30, 30);

    final EditText editText = new EditText(getActivity());
    editText.setGravity(Gravity.CENTER);
    editText.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (!Utils.DARKTHEME) editText.setTextColor(getResources().getColor(R.color.black));
    editText.setText(value);

    layout.addView(editText);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder
        .setView(layout)
        .setNegativeButton(
            getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {}
            })
        .setPositiveButton(
            getString(R.string.ok),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                Control.runCommand(
                    editText.getText().toString(),
                    file,
                    Control.CommandType.GENERIC,
                    getActivity());
                refreshLayout.setRefreshing(true);
                getHandler().postDelayed(refresh, 500);
              }
            })
        .show();
  }
Ejemplo n.º 16
0
  private void setupViews(Context context, AttributeSet attrs) {
    mImg = new ImageView(context);
    LayoutParams lp0 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    //		lp0.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    //		lp0.addRule(RelativeLayout.CENTER_VERTICAL);
    //		mImg.setPadding(0, 0, 10, 0);
    mImg.setImageResource(R.drawable.iphone_clean_icon);
    mImg.setVisibility(View.GONE);
    mImg.setId(R.id.iphonecontact_clear_edittext);
    addView(mImg, lp0);

    mImg.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            mEdt.setText("");
          }
        });

    mEdt = new EditText(context);
    mEdt.setBackgroundResource(android.R.color.transparent);
    if (mbg != null) {
      setBackgroundDrawable(mbg);
    }
    mEdt.setPadding(mEdtTextPaddingLeft, 0, 0, 0);
    mEdt.setTextSize(mEdtTextSize);
    mEdt.setGravity(Gravity.CENTER_VERTICAL);
    if (mEdtTextColor != 0) {
      mEdt.setTextColor(mEdtTextColor);
    }
    mEdt.setHint(mEdtHint);
    mEdt.setSingleLine(true);
    LayoutParams lp1 = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    addView(mEdt, lp1);
    mEdt.addTextChangedListener(new EditTextWatcher());
  }
Ejemplo n.º 17
0
  public View generateView(final Context ctx) {
    if (idType.equals(Constantes.DIV)) {
      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.HORIZONTAL);

      LinearLayout.LayoutParams pTEXT =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      LinearLayout.LayoutParams pSEPARADOR =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      pTEXT.weight = 4;
      pSEPARADOR.weight = 1;
      pSEPARADOR.setMargins(20, 4, 0, 4);

      EditText left = new EditText(ctx);
      left.setLayoutParams(pTEXT);
      left.setBackgroundResource(R.drawable.fondo_edittext);
      left.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);

      EditText right = new EditText(ctx);
      right.setLayoutParams(pTEXT);
      right.setBackgroundResource(R.drawable.fondo_edittext);
      right.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);

      TextView separador = new TextView(ctx);
      separador.setLayoutParams(pSEPARADOR);

      left.setInputType(InputType.TYPE_CLASS_NUMBER);
      right.setInputType(InputType.TYPE_CLASS_NUMBER);

      separador.setText("/");
      separador.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
      editTexts = new ArrayList<>();
      editTexts.add(left);
      editTexts.add(right);

      ((LinearLayout) view).addView(left);
      ((LinearLayout) view).addView(separador);
      ((LinearLayout) view).addView(right);
    }
    if (idType.equals(Constantes.DATE)) {
      final Calendar myCalendar = Calendar.getInstance();
      final EditText fecha = new EditText(ctx);
      fecha.setBackgroundResource(R.drawable.fondo_edittext);
      fecha.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
      fecha.setEnabled(false);
      fecha.setGravity(Gravity.CENTER_VERTICAL);

      ImageButton pick = new ImageButton(ctx);
      pick.setBackgroundResource(R.drawable.button_gray);
      pick.setImageResource(R.drawable.ic_calendarwhite);

      LinearLayout.LayoutParams pButton =
          new LinearLayout.LayoutParams(
              0,
              (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_DIP, 48, ctx.getResources().getDisplayMetrics()));
      LinearLayout.LayoutParams pText =
          new LinearLayout.LayoutParams(
              0,
              (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_DIP, 48, ctx.getResources().getDisplayMetrics()));
      pButton.weight = 1;
      pText.weight = 4;
      pText.leftMargin =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 10, ctx.getResources().getDisplayMetrics());

      final DatePickerDialog.OnDateSetListener date =
          new DatePickerDialog.OnDateSetListener() {

            @Override
            public void onDateSet(DatePicker picker, int year, int monthOfYear, int dayOfMonth) {
              // TODO Auto-generated method stub
              myCalendar.set(Calendar.YEAR, year);
              myCalendar.set(Calendar.MONTH, monthOfYear);
              myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
              String myFormat = "yyyy/MM/dd"; // In which you need put here
              SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);

              fecha.setText(sdf.format(myCalendar.getTime()));
            }
          };

      pick.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              new DatePickerDialog(
                      ctx,
                      date,
                      myCalendar.get(Calendar.YEAR),
                      myCalendar.get(Calendar.MONTH),
                      myCalendar.get(Calendar.DAY_OF_MONTH))
                  .show();
            }
          });

      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.HORIZONTAL);
      ((LinearLayout) view).setGravity(Gravity.CENTER_VERTICAL);

      fecha.setLayoutParams(pText);
      pick.setLayoutParams(pButton);

      editTexts = new ArrayList<>();
      editTexts.add(fecha);

      ((LinearLayout) view).addView(pick);
      ((LinearLayout) view).addView(fecha);
    }
    if (idType.equals(Constantes.RADIO)) {
      view = new RadioGroup(ctx);
      for (VALUE v : values) {
        RadioButton b = new RadioButton(ctx);
        b.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        b.setText(v.getNameValue());
        ((RadioGroup) view).addView(b);
      }
      LinearLayout.LayoutParams p =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      p.leftMargin =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 10, ctx.getResources().getDisplayMetrics());
      ((RadioGroup) view).setGravity(Gravity.LEFT);
      view.setLayoutParams(p);
      ((RadioGroup) view).setOrientation(LinearLayout.HORIZONTAL);
      if (values.size() > 2) ((RadioGroup) view).setOrientation(LinearLayout.VERTICAL);
    }
    if (idType.equals(Constantes.CHECK)) {
      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.VERTICAL);
      checkBoxes = new ArrayList<>();
      int count = 0;

      LinearLayout tmp;
      tmp = new LinearLayout(ctx);
      tmp.setOrientation(LinearLayout.HORIZONTAL);
      for (VALUE v : values) {
        CheckBox c = new CheckBox(ctx);
        c.setText(v.getNameValue());
        c.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        checkBoxes.add(c);
        if (count == 0) {
          tmp.addView(c);
          count++;
          if (checkBoxes.size() == values.size()) {
            ((LinearLayout) view).addView(tmp);
          }
        } else if (count == 1) {
          tmp.addView(c);
          ((LinearLayout) view).addView(tmp);
          tmp = new LinearLayout(ctx);
          tmp.setOrientation(LinearLayout.HORIZONTAL);
          count = 0;
        }
      }
      /*view = new LinearLayout(ctx);
      ((LinearLayout)view).setOrientation(LinearLayout.VERTICAL);
      checkBoxes = new ArrayList<>();
      int count = 0;
      for (VALUE v : values) {
          CheckBox c = new CheckBox(ctx);
          c.setText(v.getNameValue());
          c.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
          checkBoxes.add(c);
          if(values.size() >= 3) {
              LinearLayout tmp = new LinearLayout(ctx);
              tmp.setOrientation(LinearLayout.HORIZONTAL);
              if (count < 2) {
                  tmp.addView(c);
                  count++;
              } else {
                  ((LinearLayout) view).addView(tmp);
                  count = 0;
              }
          }else{
              ((LinearLayout) view).addView(c);
          }
      }*/
    }
    if (idType.equals(Constantes.TEXT) || idType.equals(Constantes.NUM)) {
      view = new EditText(ctx);
      ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
      view.setBackgroundResource(R.drawable.fondo_edittext);
      view.setPadding(10, 5, 10, 5);

      if (idType.equals(Constantes.NUM)) {
        ((TextView) view)
            .setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
      }
      if (idType.equals(Constantes.TEXT)) {
        ((TextView) view).setLines(4);
        ((TextView) view).setGravity(Gravity.LEFT | Gravity.TOP);
      }
    }
    if (idType.equals(Constantes.PHOTO)) {
      LinearLayout.LayoutParams left =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      LinearLayout.LayoutParams right =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      left.weight = 3;
      right.weight = 2;
      buttons = new ArrayList<>();
      Button take = new Button(ctx);
      Button show = new Button(ctx);

      take.setText("Tomar Foto");
      take.setLayoutParams(left);
      take.setBackgroundResource(R.drawable.custom_button_blue_left);
      take.setTextColor(Color.WHITE);
      show.setText("Ver");
      show.setLayoutParams(right);
      show.setBackgroundResource(R.drawable.custom_button_blue_right);
      show.setTextColor(Color.WHITE);
      show.setEnabled(false);

      buttons.add(take);
      buttons.add(show);

      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.HORIZONTAL);
      // ((LinearLayout)view).addView(take);
      // ((LinearLayout)view).addView(show);
    }

    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sharedPrefs = new SharedPrefs(this);

    SharedPrefs.initializeInstance(this);

    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));

    databaseHandler = new DatabaseHandler(getBaseContext());

    credentials = new Credential(getApplicationContext(), this);

    editTextUsername = (EditText) findViewById(R.id.editTextUsername);
    editTextPassword = (EditText) findViewById(R.id.editTextPassword);
    submitButton = (RobotoButtonBold) findViewById(R.id.submit_button);

    toggleBtn = (ImageView) findViewById(R.id.rememberSwitch);
    editTextUsername.setGravity(Gravity.CENTER);
    editTextPassword.setGravity(Gravity.CENTER);

    editTextPassword.setOnEditorActionListener(
        new EditText.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              logIn();
              return true;
            }
            return false;
          }
        });

    editTextUsername.setOnEditorActionListener(
        new EditText.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              logIn();
              return true;
            }
            return false;
          }
        });

    // set ddatabaseHandler size
    //            getDBSize();

    if (!credentials.getUsername().isEmpty()) {
      Log.i(
          "MainActivity", "U: " + credentials.getUsername() + "/ P: " + credentials.getPassword());
      editTextUsername.setText(credentials.getUsername());
      editTextPassword.setText(credentials.getPassword());
    }

    // if the app is configured
    if (sharedPrefs.getValueBol(SharedPrefs.KEY_CONFIGURED)) {

    } else {
      //            getDBSize();
      Intent intent = new Intent(this, WelcomeActivity.class);
      startActivity(intent);
    }
  }
  @Override
  public void setValues(
      DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly, ViewIdGenerator vig) {
    super.setValues(kind, entry, state, readOnly, vig);
    // Remove edit texts that we currently have
    if (mFieldEditTexts != null) {
      for (EditText fieldEditText : mFieldEditTexts) {
        mFields.removeView(fieldEditText);
      }
      mFieldEditTexts = null;
    }
    if (localGroupsSelectors != null) {
      for (View view : localGroupsSelectors) {
        mFields.removeView(view);
      }
      localGroupsSelectors = null;
    }
    boolean hidePossible = false;

    int fieldCount = kind.fieldList.size();
    if (LocalGroup.CONTENT_ITEM_TYPE.equals(kind.mimeType))
      localGroupsSelectors = new LocalGroupsSelector[fieldCount];
    else mFieldEditTexts = new EditText[fieldCount];
    for (int index = 0; index < fieldCount; index++) {
      final EditField field = kind.fieldList.get(index);
      if (LocalGroup.CONTENT_ITEM_TYPE.equals(kind.mimeType)) {
        final LocalGroupsSelector localGroupsSelector =
            new LocalGroupsSelector(mContext, entry, field.column);
        localGroupsSelector.setOnGroupSelectListener(
            new OnGroupSelectListener() {
              @Override
              public void onGroupChanged() {
                setDeleteButtonVisible(localGroupsSelector.getGroupId() > -1);
              }
            });
        // Show the delete button if we have a non-null value
        setDeleteButtonVisible(localGroupsSelector.getGroupId() > -1);
        localGroupsSelectors[index] = localGroupsSelector;
        mFields.addView(localGroupsSelector);
      } else {
        final EditText fieldView = new EditText(mContext);
        /*Begin: Modified by bxinchun for change the layout 2012/07/24*/
        /*Begin: Modified by xiepengfei for change the layout 2012/05/02*/
        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT,
                field.isMultiLine() ? LayoutParams.WRAP_CONTENT : mMinFieldHeight);
        params.bottomMargin = 10;
        fieldView.setLayoutParams(params);
        /*End: Modified by xiepengfei for change the layout 2012/05/02*/
        /*End: Modified by bxinchun for change the layout 2012/07/24*/

        // Set either a minimum line requirement or a minimum height (because {@link TextView}
        // only takes one or the other at a single time).
        if (field.minLines != 0) {
          fieldView.setMinLines(field.minLines);
        } else {
          fieldView.setMinHeight(mMinFieldHeight);
        }
        fieldView.setTextAppearance(getContext(), android.R.style.TextAppearance_Medium);
        fieldView.setGravity(Gravity.TOP);
        /*Begin: Modified by xiepengfei for change the layout 2012/05/02*/
        fieldView.setBackgroundResource(R.drawable.edit_editor_background);
        fieldView.setTextSize(20);
        fieldView.setTextColor(Color.BLACK);
        /*End: Modified by xiepengfei for change the layout 2012/05/02*/
        mFieldEditTexts[index] = fieldView;
        fieldView.setId(vig.getId(state, kind, entry, index));
        if (field.titleRes > 0) {
          fieldView.setHint(field.titleRes);
        }
        int inputType = field.inputType;
        fieldView.setInputType(inputType);
        if (inputType == InputType.TYPE_CLASS_PHONE) {
          PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(mContext, fieldView);
        }

        // Show the "next" button in IME to navigate between text fields
        // TODO: Still need to properly navigate to/from sections without text fields,
        // See Bug: 5713510
        fieldView.setImeOptions(EditorInfo.IME_ACTION_NEXT);

        // Read current value from state
        final String column = field.column;
        final String value = entry.getAsString(column);
        fieldView.setText(value);

        // Show the delete button if we have a non-null value
        setDeleteButtonVisible(value != null);

        // Prepare listener for writing changes
        fieldView.addTextChangedListener(
            new TextWatcher() {
              @Override
              public void afterTextChanged(Editable s) {
                // Trigger event for newly changed value
                onFieldChanged(column, s.toString());
              }

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

              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {}
            });

        fieldView.setEnabled(isEnabled() && !readOnly);

        if (field.shortForm) {
          hidePossible = true;
          mHasShortAndLongForms = true;
          fieldView.setVisibility(mHideOptional ? View.VISIBLE : View.GONE);
        } else if (field.longForm) {
          hidePossible = true;
          mHasShortAndLongForms = true;
          fieldView.setVisibility(mHideOptional ? View.GONE : View.VISIBLE);
        } else {
          // Hide field when empty and optional value
          final boolean couldHide = (!ContactsUtils.isGraphic(value) && field.optional);
          final boolean willHide = (mHideOptional && couldHide);
          fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
          hidePossible = hidePossible || couldHide;
        }

        mFields.addView(fieldView);
      }
    }

    // When hiding fields, place expandable
    setupExpansionView(hidePossible, mHideOptional);
    mExpansionView.setEnabled(!readOnly && isEnabled());
  }
Ejemplo n.º 20
0
  @Override
  public void setValues(
      DataKind kind,
      ValuesDelta entry,
      RawContactDelta state,
      boolean readOnly,
      ViewIdGenerator vig) {
    super.setValues(kind, entry, state, readOnly, vig);
    // Remove edit texts that we currently have
    if (mFieldEditTexts != null) {
      for (EditText fieldEditText : mFieldEditTexts) {
        mFields.removeView(fieldEditText);
      }
    }
    boolean hidePossible = false;

    int fieldCount = kind.fieldList.size();
    mFieldEditTexts = new EditText[fieldCount];
    for (int index = 0; index < fieldCount; index++) {
      final EditField field = kind.fieldList.get(index);
      final EditText fieldView = new EditText(mContext);
      fieldView.setLayoutParams(
          new LinearLayout.LayoutParams(
              LayoutParams.MATCH_PARENT,
              field.isMultiLine() ? LayoutParams.WRAP_CONTENT : mMinFieldHeight));
      // Set either a minimum line requirement or a minimum height (because {@link TextView}
      // only takes one or the other at a single time).
      if (field.minLines != 0) {
        fieldView.setMinLines(field.minLines);
      } else {
        fieldView.setMinHeight(mMinFieldHeight);
      }
      fieldView.setTextAppearance(getContext(), android.R.style.TextAppearance_Medium);
      fieldView.setGravity(Gravity.TOP);
      mFieldEditTexts[index] = fieldView;
      fieldView.setId(vig.getId(state, kind, entry, index));

      if (field.titleRes > 0) {
        fieldView.setHint(field.titleRes);
      }
      /** M:AAS @ { update fieldView's hint text */
      if (Phone.CONTENT_ITEM_TYPE.equals(kind.mimeType)) {
        int type = SimUtils.isAdditionalNumber(entry) ? 1 : 0;
        ExtensionManager.getInstance()
            .getContactDetailExtension()
            .updateView(
                fieldView,
                type,
                ContactDetailExtension.VIEW_UPDATE_HINT,
                ExtensionManager.COMMD_FOR_AAS);
      }
      /** M: @ } */

      /** M: New Feature xxx @{ */
      /* original code int inputType = field.inputType; */
      final int inputType = field.inputType;
      /** @} */
      fieldView.setInputType(inputType);
      if (inputType == InputType.TYPE_CLASS_PHONE) {
        /** M: New Feature xxx @{ */
        /*
         * original code
         * PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher
         * (mContext, fieldView);
         */
        // add by mediatek
        ExtensionManager.getInstance()
            .getContactDetailExtension()
            .setViewKeyListener(fieldView, ContactPluginDefault.COMMD_FOR_OP01);
        PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(mContext, fieldView, null);
        /** @} */
      }

      // Show the "next" button in IME to navigate between text fields
      // TODO: Still need to properly navigate to/from sections without text fields,
      // See Bug: 5713510
      fieldView.setImeOptions(EditorInfo.IME_ACTION_NEXT);

      // Read current value from state
      final String column = field.column;
      final String value = entry.getAsString(column);

      /*
       * Bug Fix by Mediatek Begin.
       *   Original Android's code:
       *     xxx
       *   CR ID: ALPS00244669
       *   Descriptions:
       */
      Log.i(TAG, "setValues setFilter");
      fieldView.setFilters(new InputFilter[] {new InputFilter.LengthFilter(FIELD_VIEW_MAX)});
      /*
       * Bug Fix by Mediatek End.
       */

      fieldView.setText(value);

      // Show the delete button if we have a non-null value
      setDeleteButtonVisible(value != null);

      // Prepare listener for writing changes
      fieldView.addTextChangedListener(
          new TextWatcher() {
            /** M: New Feature xxx @{ */
            int location = 0;

            /** @} */
            @Override
            public void afterTextChanged(Editable s) {
              // Trigger event for newly changed value
              /** M: New Feature Easy Porting @{ */
              /* original code onFieldChanged(column, s.toString()); */
              String phoneText = s.toString();
              phoneText =
                  ExtensionManager.getInstance()
                      .getContactDetailExtension()
                      .TextChanged(
                          inputType, s, phoneText, location, ContactPluginDefault.COMMD_FOR_OP01);
              onFieldChanged(column, phoneText);
              /** @} */
            }

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

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
          });

      fieldView.setEnabled(isEnabled() && !readOnly);

      if (field.shortForm) {
        hidePossible = true;
        mHasShortAndLongForms = true;
        fieldView.setVisibility(mHideOptional ? View.VISIBLE : View.GONE);
      } else if (field.longForm) {
        hidePossible = true;
        mHasShortAndLongForms = true;
        fieldView.setVisibility(mHideOptional ? View.GONE : View.VISIBLE);
      } else {
        // Hide field when empty and optional value
        final boolean couldHide = (!ContactsUtils.isGraphic(value) && field.optional);
        final boolean willHide = (mHideOptional && couldHide);
        fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
        hidePossible = hidePossible || couldHide;
      }

      mFields.addView(fieldView);
    }

    // When hiding fields, place expandable
    setupExpansionView(hidePossible, mHideOptional);
    mExpansionView.setEnabled(!readOnly && isEnabled());
  }
Ejemplo n.º 21
0
  private void initMyGroupView() {
    ll = (LinearLayout) findViewById(R.id.l1);
    DisplayMetrics metric = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metric);
    /**
     * *******************************************************************************************
     */
    mvg = new MyViewGroup(NewSMSActivity.this);
    mvg.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 70));
    //		mvg.setBackgroundColor(Color.GREEN);
    etMess = new EditText(NewSMSActivity.this);
    etMess.setFilters(new InputFilter[] {new InputFilter.LengthFilter(15)});
    etMess.setSelection(etMess.getText().length());
    etMess.setGravity(Gravity.CENTER_VERTICAL);
    etMess.setMinWidth(100);
    etMess.setHeight(60);
    etMess.setTag("edit");
    etMess.getBackground().setAlpha(0);
    etMess.setId(extiTextId);
    etMess.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {

            if (isNum(s.toString())) {
              if (s.length() >= 1) {
                boolean bool = false;
                // length() == 15直接生成按钮
                if (s.length() == 15) {
                  bool = true;
                }
                // 字数没有满足15个验证是否有空格
                if (!bool) {
                  String c = s.toString().substring(start, start + count);
                  for (int i = 0; i < chars.length; i++) {
                    if (chars[i].equals(c)) {
                      bool = true;
                      break;
                    }
                  }
                }
                // bool == true 生成Button
                if (bool) {
                  createView1(s.toString(), s.toString());
                  etMess.setText("");
                }
                // 检测输入框数据是否已经换行
                final View child = mvg.getChildAt(mvg.getChildCount() - 1);
                autoHeight(child);
              }
            } else {
              adapter.getFilter().filter(s);
              queryListView.setVisibility(View.VISIBLE);
            }
          }

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

          @Override
          public void afterTextChanged(Editable s) {}
        });
    mvg.addView(etMess);
    ll.addView(mvg);
    etMess.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              if (isNum(etMess.getText().toString().trim())) {
                createView1(etMess.getText().toString().trim(), etMess.getText().toString().trim());
                etMess.setText("");
              } else {
                etMess.setText("");
                queryListView.setVisibility(View.INVISIBLE);
              }
            }
          }
        });
  }
Ejemplo n.º 22
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int margin = Utils.dpToPx(0.02f * Utils.getDisplayMetrics().widthPixels);

    SpannableStringBuilder prettyMessage = new SpannableStringBuilder(message);
    int italicsFrom = message.indexOf(italicsString),
        italicsTo = italicsFrom + italicsString.length();
    prettyMessage.setSpan(
        new StyleSpan(Typeface.ITALIC), italicsFrom, italicsTo, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    this.layout = new LinearLayout(this);
    this.layout.setOrientation(Orientation.VERTICAL);
    this.setContentView(this.layout);

    ScrollView sv = new ScrollView(this);
    LayoutParams scrollParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    scrollParams.weight = 1;
    // this.layout.addView(sv, scrollParams);

    LinearLayout innerLayout = new LinearLayout(this);
    innerLayout.setOrientation(Orientation.VERTICAL);
    LayoutParams ilParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    ilParams.weight = 1;
    sv.addView(innerLayout, ilParams);

    this.messageText = new TextView(this);
    messageText.setText(prettyMessage);
    messageText.setTextSize(14);
    messageText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    LayoutParams textParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    textParams.weight = 0;
    textParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
    textParams.setMargins(margin, margin, margin, margin / 2);
    this.layout.addView(messageText, textParams);

    final EditText sender = new EditText(this);
    sender.setInputType(InputType.TYPE_CLASS_TEXT);
    sender.setHint("Je e-mailadres (als je iets terug wilt horen)");
    LayoutParams senderParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    senderParams.weight = 0;
    senderParams.setMargins(margin, 0, margin, 0);
    this.layout.addView(sender, senderParams);

    final EditText detail = new EditText(this);
    detail.setHint("Wat wil je zeggen?");
    detail.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    detail.setGravity(Gravity.TOP);
    LayoutParams detailParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    detailParams.weight = 0.5f;
    detailParams.setMargins(margin, 0, margin, 0);
    this.layout.addView(detail, detailParams);

    loading = new ProgressBar(activity);
    loading.setIndeterminate(true);

    submit = new Button(this);
    submit.setText("Versturen");
    submitParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    submitParams.weight = 0;
    submitParams.setMargins(0, 0, 0, margin);
    submitParams.gravity = Gravity.CENTER;

    submit.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            activity.hideOnScreenKeyboard(sender.getWindowToken());
            activity.hideOnScreenKeyboard(detail.getWindowToken());
            layout.removeView(submit);
            layout.addView(loading, submitParams);
            new FeedbackSender(sender.getText().toString(), detail.getText().toString()).execute();
          }
        });

    this.layout.addView(submit, submitParams);
  }
Ejemplo n.º 23
0
  @SuppressWarnings("deprecation")
  private void init(Context context, int initialColor) {
    setPadding(UI.dialogMargin, UI.dialogMargin, UI.dialogMargin, UI.dialogMargin);
    final int eachW = (UI._18sp * 7) >> 1;
    final boolean smallScreen = (UI.isLowDpiScreen && !UI.isLargeScreen);
    initialColor = 0xff000000 | (initialColor & 0x00ffffff);
    hsv = new HSV();
    hsv.fromRGB(initialColor);
    hsvTmp = new HSV();
    bmpRect = new Rect(0, 0, 1, 1);
    this.initialColor = initialColor;
    currentColor = initialColor;
    sliderColor = (UI.isAndroidThemeLight() ? 0xff000000 : 0xffffffff);
    final LinearLayout l = new LinearLayout(context);
    l.setId(1);
    l.setWeightSum(2);
    LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    addView(l, p);
    final TextView lbl = new TextView(context);
    lbl.setBackgroundDrawable(new ColorDrawable(initialColor));
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            smallScreen ? (UI.defaultControlSize) >> 1 : UI.defaultControlSize);
    lp.weight = 1;
    lp.rightMargin = UI.controlSmallMargin;
    l.addView(lbl, lp);
    bgCurrent = new ColorDrawable(initialColor);
    lblCurrent = new TextView(context);
    lblCurrent.setBackgroundDrawable(bgCurrent);
    lp =
        new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            smallScreen ? (UI.defaultControlSize) >> 1 : UI.defaultControlSize);
    lp.weight = 1;
    lp.leftMargin = UI.controlSmallMargin;
    l.addView(lblCurrent, lp);

    final int textSize = (smallScreen ? UI._14sp : UI._18sp);
    TextView lblTit = new TextView(context);
    lblTit.setId(2);
    lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    lblTit.setSingleLine();
    lblTit.setGravity(Gravity.CENTER);
    lblTit.setText("H");
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.BELOW, 1);
    addView(lblTit, p);
    lblTit = new TextView(context);
    lblTit.setId(3);
    lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    lblTit.setSingleLine();
    lblTit.setGravity(Gravity.CENTER);
    lblTit.setText("S");
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.BELOW, 1);
    addView(lblTit, p);
    lblTit = new TextView(context);
    lblTit.setId(4);
    lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    lblTit.setSingleLine();
    lblTit.setGravity(Gravity.CENTER);
    lblTit.setText("V");
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.BELOW, 1);
    addView(lblTit, p);

    barH = new BgSeekBar(context);
    barH.setId(5);
    barH.setMax(360);
    barH.setValue((int) (hsv.h * 360.0));
    barH.setSliderMode(true);
    barH.setVertical(true);
    p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.leftMargin = ((eachW - UI.defaultControlSize) >> 1);
    p.addRule(RelativeLayout.ALIGN_LEFT, 2);
    p.addRule(RelativeLayout.BELOW, 2);
    p.addRule(RelativeLayout.ABOVE, 6);
    addView(barH, p);
    barS = new BgSeekBar(context);
    barS.setMax(100);
    barS.setValue((int) (hsv.s * 100.0));
    barS.setSliderMode(true);
    barS.setVertical(true);
    p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.leftMargin = ((eachW - UI.defaultControlSize) >> 1);
    p.addRule(RelativeLayout.ALIGN_LEFT, 3);
    p.addRule(RelativeLayout.BELOW, 3);
    p.addRule(RelativeLayout.ABOVE, 6);
    addView(barS, p);
    barV = new BgSeekBar(context);
    barV.setMax(100);
    barV.setValue((int) (hsv.v * 100.0));
    barV.setSliderMode(true);
    barV.setVertical(true);
    p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.leftMargin = ((eachW - UI.defaultControlSize) >> 1);
    p.addRule(RelativeLayout.ALIGN_LEFT, 4);
    p.addRule(RelativeLayout.BELOW, 4);
    p.addRule(RelativeLayout.ABOVE, 6);
    addView(barV, p);

    txtH = new EditText(context);
    txtH.setId(6);
    txtH.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txtH.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtH.setSingleLine();
    txtH.setGravity(Gravity.CENTER);
    txtH.setText(Integer.toString((int) (hsv.h * 360.0)));
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ABOVE, 7);
    addView(txtH, p);
    txtS = new EditText(context);
    txtS.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txtS.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtS.setSingleLine();
    txtS.setGravity(Gravity.CENTER);
    txtS.setText(Integer.toString((int) (hsv.s * 100.0)));
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ABOVE, 7);
    addView(txtS, p);
    txtV = new EditText(context);
    txtV.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txtV.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtV.setSingleLine();
    txtV.setGravity(Gravity.CENTER);
    txtV.setText(Integer.toString((int) (hsv.v * 100.0)));
    p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ABOVE, 7);
    addView(txtV, p);

    txt = new EditText(context);
    txt.setId(7);
    txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    txt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txt.setSingleLine();
    txt.setGravity(Gravity.CENTER);
    txt.setText(ColorUtils.toHexColor(initialColor));
    p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    p.topMargin = UI.dialogMargin;
    p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    addView(txt, p);

    lbl.setOnClickListener(this);
    barH.setOnBgSeekBarChangeListener(this);
    barH.setOnBgSeekBarDrawListener(this);
    barS.setOnBgSeekBarChangeListener(this);
    barS.setOnBgSeekBarDrawListener(this);
    barV.setOnBgSeekBarChangeListener(this);
    barV.setOnBgSeekBarDrawListener(this);
    txtH.addTextChangedListener(this);
    txtS.addTextChangedListener(this);
    txtV.addTextChangedListener(this);
    txt.addTextChangedListener(this);
  }
Ejemplo n.º 24
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.add_task);

    ArrayList<Task> tasks;
    try {
      tasks = TodoUtil.loadTasksFromFile();
    } catch (IOException e) {
      Log.e(TAG, e.getMessage(), e);
      tasks = new ArrayList<Task>();
    }

    final Intent intent = getIntent();
    final String action = intent.getAction();
    // create shortcut and exit
    // create shortcut and exit
    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
      Log.d(TAG, "Setting up shortcut icon");
      setupShortcut();
      finish();
      return;
    } else if (Intent.ACTION_SEND.equals(action)) {
      Log.d(TAG, "Share");
      share_text = (String) intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
      Log.d(TAG, share_text);
    }

    m_app = (TodoApplication) getApplication();
    // title bar label
    titleBarLabel = (TextView) findViewById(R.id.title_bar_label);

    // text
    final EditText textInputField = (EditText) findViewById(R.id.taskText);
    textInputField.setGravity(Gravity.TOP);

    if (share_text != null) {
      textInputField.setText(share_text);
    }

    Task task = (Task) getIntent().getSerializableExtra(Constants.EXTRA_TASK);
    if (task != null) {
      m_backup = task;
      textInputField.setText(task.inFileFormat());
      setTitle(R.string.update);
      titleBarLabel.setText(R.string.update);
    } else {
      setTitle(R.string.addtask);
      titleBarLabel.setText(R.string.addtask);
    }

    textInputField.setSelection(textInputField.getText().toString().length());

    // priorities
    priorities = (Spinner) findViewById(R.id.priorities);
    final ArrayList<String> prioArr = new ArrayList<String>();
    prioArr.add("Priority");
    prioArr.addAll(Priority.rangeInCode(Priority.A, Priority.E));
    priorities.setAdapter(Util.newSpinnerAdapter(this, prioArr));
    if (m_backup != null) {
      int index = prioArr.indexOf(m_backup.getPriority().getCode());
      priorities.setSelection(index < 0 ? 0 : index);
    }
    priorities.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            int cursorPosition = textInputField.getSelectionStart();
            String currentText = textInputField.getText().toString();
            Priority priority = Priority.NONE;
            if (position > 0) {
              String item = prioArr.get(position);
              char p = item.charAt(0);
              priority = Priority.toPriority(p);
            }
            String text = PriorityTextSplitter.getInstance().split(currentText).text;
            textInputField.setText(Strings.insertPadded(text, 0, priority.inFileFormat()));
            textInputField.setSelection(
                CursorPositionCalculator.calculate(
                    cursorPosition, currentText, textInputField.getText().toString()));
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    // projects
    projects = (Spinner) findViewById(R.id.projects);
    final ArrayList<String> projectsArr = TaskHelper.getProjects(tasks);
    projectsArr.add(0, "Project");
    projects.setAdapter(Util.newSpinnerAdapter(this, projectsArr));
    projects.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            if (position > 0) {
              int cursorPosition = textInputField.getSelectionStart();
              String currentText = textInputField.getText().toString();
              String item = "+" + projectsArr.get(position);
              textInputField.setText(Strings.insertPadded(currentText, cursorPosition, item));
              textInputField.setSelection(
                  CursorPositionCalculator.calculate(
                      cursorPosition, currentText, textInputField.getText().toString()));
            }
            projects.setSelection(0);
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    // contexts
    contexts = (Spinner) findViewById(R.id.contexts);
    final ArrayList<String> contextsArr = TaskHelper.getContexts(tasks);
    contextsArr.add(0, "Context");
    contexts.setAdapter(Util.newSpinnerAdapter(this, contextsArr));
    contexts.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            if (position > 0) {
              int cursorPosition = textInputField.getSelectionStart();
              String currentText = textInputField.getText().toString();
              String item = "@" + contextsArr.get(position);
              textInputField.setText(Strings.insertPadded(currentText, cursorPosition, item));
              textInputField.setSelection(
                  CursorPositionCalculator.calculate(
                      cursorPosition, currentText, textInputField.getText().toString()));
            }
            contexts.setSelection(0);
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    // cancel
    Button cancel = (Button) findViewById(R.id.cancel);
    cancel.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    // add
    Button addBtn = (Button) findViewById(R.id.addTask);
    if (m_backup != null) {
      addBtn.setText(R.string.update);
    }
    addBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // strip line breaks
            final String input =
                textInputField.getText().toString().replaceAll("\\r\\n|\\r|\\n", " ");

            TodoApplication app = (TodoApplication) getApplication();
            DropboxAPI api = app.getAPI();
            new AsyncTask<Object, Void, Boolean>() {
              protected void onPreExecute() {
                m_ProgressDialog =
                    ProgressDialog.show(AddTask.this, getTitle(), "Please wait...", true);
              }

              @Override
              protected Boolean doInBackground(Object... params) {
                try {
                  DropboxAPI api = (DropboxAPI) params[0];
                  Task task = (Task) params[1];
                  String input = (String) params[2];
                  TodoApplication m_app = (TodoApplication) params[3];
                  if (api != null) {
                    if (task != null) {
                      task.update(input);
                      return m_app.m_util.updateTask(task);
                    } else {
                      return m_app.m_util.addTask(input);
                    }
                  }
                } catch (Exception e) {
                  Log.e(TAG, "input: " + input + " - " + e.getMessage());
                }
                return false;
              }

              protected void onPostExecute(Boolean result) {
                if (result) {
                  String res =
                      m_backup != null
                          ? getString(R.string.updated_task)
                          : getString(R.string.added_task);
                  Util.showToastLong(AddTask.this, res);
                  finish();
                } else {
                  String res =
                      m_backup != null
                          ? getString(R.string.update_task_failed)
                          : getString(R.string.add_task_failed);
                  Util.showToastLong(AddTask.this, res);
                }
              }
            }.execute(api, m_backup, input, m_app);
          }
        });
  }
  @Override
  public void createControl(TitaniumModuleManager tmm) {
    tv = new EditText(tmm.getAppContext());
    tv.isFocusable();
    tv.setId(100);

    tv.addTextChangedListener(this);
    tv.setOnEditorActionListener(this);
    tv.setText(value);
    tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    tv.setPadding(4, 2, 4, 2);
    tv.setSingleLine();
    TitaniumUIHelper.styleText(tv, fontSize, fontWeight);

    if (color != null) {
      tv.setTextColor(TitaniumColorHelper.parseColor(color));
    }
    if (backgroundColor != null) {
      tv.setBackgroundColor(TitaniumColorHelper.parseColor(backgroundColor));
    }

    cancelBtn = new ImageButton(tmm.getAppContext());
    cancelBtn.isFocusable();
    cancelBtn.setId(101);
    cancelBtn.setPadding(0, 0, 0, 0);
    Drawable d = new BitmapDrawable(this.getClass().getResourceAsStream("cancel.png"));
    cancelBtn.setImageDrawable(d);
    cancelBtn.setMinimumWidth(48);

    cancelBtn.setVisibility(showCancel ? View.VISIBLE : View.GONE);
    cancelBtn.setOnClickListener(
        new OnClickListener() {

          public void onClick(View view) {
            handler.sendEmptyMessage(MSG_CANCEL);
          }
        });

    RelativeLayout layout = new RelativeLayout(tmm.getAppContext());
    control = layout;

    layout.setGravity(Gravity.NO_GRAVITY);
    layout.setPadding(0, 0, 0, 0);
    if (barColor != null) {
      layout.setBackgroundColor(TitaniumColorHelper.parseColor(barColor));
    }

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.addRule(RelativeLayout.LEFT_OF, 101);
    params.setMargins(4, 4, 0, 4);
    layout.addView(tv, params);

    params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.setMargins(0, 4, 4, 4);
    layout.addView(cancelBtn, params);
  }
Ejemplo n.º 26
0
  private LinearLayout createProductInfo(com.app.commons.JSONObject jo) {
    JSONArray ja = jo.getJSONArray("settleGoods");
    if (ja == null || ja.length() == 0) {
      return null;
    }
    final String productSku = jo.getString("productSku");
    LinearLayout info = new LinearLayout(CartActivtiy.this);
    int cart_height = Math.round(getResources().getDimension(R.dimen.cart_height));
    info.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    info.setMinimumHeight(cart_height);
    info.setOrientation(LinearLayout.HORIZONTAL);
    info.setGravity(Gravity.CENTER_VERTICAL);
    info.setBackgroundResource(R.drawable.border2);
    info.setPadding(10, 0, 10, 0);
    final CheckBox rb = new CheckBox(CartActivtiy.this);
    rb.setPadding(0, 0, 10, 0);
    rb.setButtonDrawable(R.drawable.checkbox);
    if (jo.getBoolean("checked")) {
      rb.setChecked(true);
      settleNum = settleNum + 1;
    } else {
      rb.setChecked(false);
    }
    rb.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            Map<String, Object> param = new HashMap<>();
            param.put("ids", productSku);
            param.put("checkeds", rb.isChecked() ? "Y" : "N");
            Utils.asyncHttpRequestPost(
                Constants.URL_CART_CHANGESTATUS,
                param,
                new JsonHttpResponseHandler() {
                  @Override
                  public void onSuccess(int statusCode, Header[] headers, JSONObject res) {
                    com.app.commons.JSONObject jo = new com.app.commons.JSONObject(res);
                    if (statusCode == 200) {
                      if (jo.getBoolean("success")) {
                        flushCartInfo();
                      } else {
                        Toast.makeText(
                                CartActivtiy.this, jo.getString("errMsg"), Toast.LENGTH_SHORT)
                            .show();
                        flushCartInfo();
                      }
                    } else {
                      Toast.makeText(CartActivtiy.this, statusCode, Toast.LENGTH_SHORT).show();
                    }
                  }
                });
          }
        });
    info.addView(rb);
    LinearLayout center = new LinearLayout(CartActivtiy.this);
    LinearLayout.LayoutParams centerLP =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    centerLP.weight = 1;
    center.setOrientation(LinearLayout.VERTICAL);
    center.setLayoutParams(centerLP);
    center.setPadding(10, 0, 0, 0);
    int wh2 = Math.round(getResources().getDimension(R.dimen.btn_cart_height));
    if (ja != null && ja.length() > 0) {
      ImageView iv = new ImageView(CartActivtiy.this);
      int wh = Math.round(getResources().getDimension(R.dimen.cart_img_wh));
      iv.setLayoutParams(new ViewGroup.LayoutParams(wh, wh));
      iv.setImageResource(R.drawable.loading);
      Utils.asyncLoadInternetImageView(
          iv, Constants.URL_IMAGE + "/200X200" + ja.getJSONObject(0).getString("photoUrl"));
      info.addView(iv);
      TextView tv = new TextView(CartActivtiy.this);
      if (ja.length() == 1) {
        tv.setText(ja.getJSONObject(0).getString("goodsName"));
      } else {
        tv.setText(getResources().getString(R.string.goods_set));
      }
      center.addView(tv);
      LinearLayout bottom = new LinearLayout(CartActivtiy.this);
      bottom.setLayoutParams(
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
      bottom.setOrientation(LinearLayout.HORIZONTAL);
      bottom.setPadding(0, 15, 0, 0);
      LinearLayout.LayoutParams wrap = new LinearLayout.LayoutParams(wh2, wh2);
      wrap.setMargins(5, 0, 5, 0);
      final EditText et = new EditText(CartActivtiy.this);
      et.setBackgroundResource(R.drawable.wrapcontent);
      et.setText(jo.getString("number"));
      et.setSingleLine(true);
      et.setKeyListener(new DigitsKeyListener(false, false));
      et.setLayoutParams(wrap);
      et.setGravity(Gravity.RIGHT);
      et.setPadding(5, 2, 5, 2);
      et.setFocusable(true);
      et.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (editable.length() == 0) {
                editable.append(String.valueOf(def_num));
              } else if (Integer.parseInt(editable.toString()) <= 0) {
                editable.replace(0, 1, String.valueOf(def_num));
              } else if (editable.length() > 2) {
                editable.replace(0, editable.length(), String.valueOf(def_maxnum));
              }
              Map<String, Object> param = new HashMap<>();
              param.put("id", productSku);
              param.put("count", editable.toString());
              Utils.asyncHttpRequestPost(
                  Constants.URL_CART_CHANGENUMBER,
                  param,
                  new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, JSONObject res) {
                      com.app.commons.JSONObject jo = new com.app.commons.JSONObject(res);
                      if (statusCode == 200) {
                        if (jo.getBoolean("success")) {
                          flushCartInfo();
                        } else {
                          Toast.makeText(
                                  CartActivtiy.this, jo.getString("errMsg"), Toast.LENGTH_SHORT)
                              .show();
                          flushCartInfo();
                        }
                      } else {
                        Toast.makeText(CartActivtiy.this, statusCode, Toast.LENGTH_SHORT).show();
                      }
                    }
                  });
            }
          });
      ImageView sub = new ImageView(CartActivtiy.this);
      sub.setScaleType(ImageView.ScaleType.FIT_CENTER);
      sub.setLayoutParams(wrap);
      sub.setImageResource(R.drawable.cart_sub);
      sub.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              int num = Integer.parseInt(et.getText().toString());
              if (num > 1) {
                et.setText(String.valueOf((num - 1)));
              }
            }
          });
      ImageView add = new ImageView(CartActivtiy.this);
      add.setLayoutParams(wrap);
      add.setScaleType(ImageView.ScaleType.FIT_CENTER);
      add.setImageResource(R.drawable.cart_add);
      add.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Integer num = Integer.parseInt(et.getText().toString());
              et.setText(String.valueOf(num + 1));
            }
          });
      bottom.addView(sub);
      bottom.addView(et);
      bottom.addView(add);
      if (jo.getString("remark") != null) {
        TextView remark = new TextView(CartActivtiy.this);
        remark.setText(jo.getString("remark"));
        remark.setTextColor(getResources().getColor(R.color.red));
        bottom.addView(remark);
      }
      center.addView(bottom);
    }
    LinearLayout right = new LinearLayout(CartActivtiy.this);
    right.setOrientation(LinearLayout.VERTICAL);
    right.setGravity(Gravity.CENTER);
    right.setPadding(0, 0, 0, 5);
    TextView tv2 = new TextView(CartActivtiy.this);
    tv2.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    tv2.setGravity(Gravity.CENTER);
    tv2.setText("¥" + jo.getString("amount"));
    tv2.setTextColor(getResources().getColor(R.color.red));
    right.addView(tv2);
    ImageButton ib = new ImageButton(CartActivtiy.this);
    int cdelw = Math.round(getResources().getDimension(R.dimen.cart_delete_width));
    int cdelh = Math.round(getResources().getDimension(R.dimen.cart_delete_height));
    ib.setLayoutParams(new ViewGroup.LayoutParams(cdelw, cdelh));
    ib.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ib.setBackgroundResource(R.drawable.border3);
    ib.setImageResource(R.drawable.cart_delete);
    ib.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("ids", productSku);
            Utils.asyncHttpRequestPost(
                Constants.URL_CART_DELETEPRODUCTS,
                param,
                new JsonHttpResponseHandler() {
                  @Override
                  public void onSuccess(int statusCode, Header[] headers, JSONObject res) {
                    com.app.commons.JSONObject jo = new com.app.commons.JSONObject(res);
                    if (statusCode == 200) {
                      if (jo.getBoolean("success")) {
                        flushCartInfo();
                      } else {
                        Toast.makeText(
                                CartActivtiy.this, jo.getString("errMsg"), Toast.LENGTH_SHORT)
                            .show();
                        flushCartInfo();
                      }
                    } else {
                      Toast.makeText(CartActivtiy.this, statusCode, Toast.LENGTH_SHORT).show();
                    }
                  }
                });
          }
        });
    right.addView(ib);
    info.addView(center);
    info.addView(right);
    return info;
  }
Ejemplo n.º 27
0
  private View getView(int mId, cl.tdc.felipe.tdc.objects.Relevar.Item item) {
    String type = item.getType();
    List<String> values = item.getValues();
    LinearLayout contenido = new LinearLayout(this);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    contenido.setLayoutParams(params);
    params.setMargins(0, 6, 0, 0);
    contenido.setOrientation(LinearLayout.VERTICAL);
    contenido.setGravity(Gravity.CENTER_HORIZONTAL);
    String comment = "";

    if (type.equals("SELECT")) {
      Spinner s = new Spinner(this);
      s.setBackgroundResource(R.drawable.spinner_bg);
      s.setLayoutParams(
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      ArrayAdapter<String> adapter =
          new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, values);
      s.setAdapter(adapter);
      String id = mId + item.getId() + item.getName() + values.toString();
      s.setId(Funciones.str2int(id));
      String Selected = reg.getString("SELECT" + s.getId());
      s.setSelection(adapter.getPosition(Selected));
      contenido.addView(s);
      item.setVista(s);

      comment = reg.getString("COMMENTSELECT" + s.getId());

    } else if (type.equals("CHECK")) {
      LinearLayout checkboxLayout = new LinearLayout(this);
      checkboxLayout.setLayoutParams(
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      checkboxLayout.setOrientation(LinearLayout.VERTICAL);
      ArrayList<CheckBox> checkBoxes = new ArrayList<>();
      int count = 0;
      while (count < values.size()) {
        LinearLayout dump = new LinearLayout(this);
        dump.setOrientation(LinearLayout.HORIZONTAL);
        dump.setGravity(Gravity.CENTER_HORIZONTAL);
        dump.setLayoutParams(
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        for (int p = 0; p < 3; p++) {
          if (count < values.size()) {
            String state = values.get(count);
            CheckBox cb = new CheckBox(this);
            String id = mId + item.getId() + item.getName() + values.get(count);
            cb.setId(Funciones.str2int(id));
            cb.setChecked(reg.getBoolean("CHECK" + cb.getId()));
            cb.setText(state);

            checkBoxes.add(cb);
            dump.addView(cb);
            if (count == 0) comment = reg.getString("COMMENTCHECK" + cb.getId());
            count++;
            vistas.add(cb);
          }
        }
        checkboxLayout.addView(dump);
      }
      makeOnlyOneCheckable(checkBoxes);
      item.setCheckBoxes(checkBoxes);
      contenido.addView(checkboxLayout);
    } else if (type.equals("NUM")) {
      EditText e = new EditText(this);
      e.setBackgroundResource(R.drawable.fondo_edittext);
      e.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

      String id = mId + item.getId() + item.getName();
      e.setId(Funciones.str2int(id));
      e.setText(reg.getString("TEXT" + e.getId()));
      e.setLayoutParams(new LinearLayout.LayoutParams(100, ViewGroup.LayoutParams.WRAP_CONTENT));
      e.setGravity(Gravity.CENTER_HORIZONTAL);
      vistas.add(e);
      item.setVista(e);
      contenido.addView(e);

      comment = reg.getString("COMMENTTEXT" + e.getId());
    } else if (type.equals("VARCHAR")) {
      EditText e = new EditText(this);
      e.setBackgroundResource(R.drawable.fondo_edittext);
      e.setInputType(InputType.TYPE_CLASS_TEXT);
      e.setLines(2);
      e.setGravity(Gravity.LEFT | Gravity.TOP);

      String id = mId + item.getId() + item.getName();
      e.setId(Funciones.str2int(id));
      e.setText(reg.getString("TEXT" + e.getId()));
      vistas.add(e);
      item.setVista(e);
      contenido.addView(e);
      comment = reg.getString("COMMENTTEXT" + e.getId());
    }

    if (!item.getName().equals("COMENTARIOS")) {
      EditText comentario = new EditText(this);
      comentario.setLayoutParams(params);
      comentario.setBackgroundResource(R.drawable.fondo_edittext);
      comentario.setLines(3);
      comentario.setText(comment);
      comentario.setHint("Observaciones");
      item.setDescription(comentario);
      contenido.addView(comentario);
    }
    return contenido;
  }
Ejemplo n.º 28
0
  @Override
  protected Dialog onCreateDialog(int id, Bundle args) {
    // TODO Auto-generated method stub
    switch (id) {
      case DIALOG1_KEY:
        {
          ProgressDialog dialog = new ProgressDialog(this);
          dialog.setMessage("Loading..");
          dialog.setIndeterminate(true);
          dialog.setCancelable(true);
          return dialog;
        }
      case DIALOG2_KEY:
        {
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setTitle("첨부파일 목록");
          View v = getLayoutInflater().inflate(R.layout.dialog_file_list, null);
          mLvFile = (ListView) v.findViewById(R.id.lvFile);
          mLvFile.setOnItemClickListener(
              new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                  KnouNoticeFileInfo attacheFileInfo =
                      (KnouNoticeFileInfo) parent.getItemAtPosition(position);
                  dismissDialog(DIALOG2_KEY);
                  Bundle bundle = new Bundle();
                  bundle.putString("FILESRC", attacheFileInfo.href);
                  bundle.putString("FILENAME", attacheFileInfo.fileName);
                  showDialog(DIALOG5_KEY, bundle);
                }
              });
          mLvFile.setAdapter(mCustomerArrayAdapter);
          builder.setView(v);
          builder.setNegativeButton(
              "닫기",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  dismissDialog(DIALOG2_KEY);
                }
              });
          return builder.create();
        }

      case DIALOG3_KEY:
        {
          ProgressDialog dialog = new ProgressDialog(this);
          dialog.setMessage("File.. Download");
          dialog.setIndeterminate(true);
          dialog.setCancelable(true);
          return dialog;
        }

      case DIALOG4_KEY:
        {
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setCancelable(true);
          builder.setTitle("메모");
          final EditText etMemo = new EditText(this);
          etMemo.setLayoutParams(
              new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
          etMemo.setText(mKnouNoticeInfo.memo);
          etMemo.setGravity(Gravity.TOP);
          etMemo.setLines(10);
          builder.setView(etMemo);
          builder.setPositiveButton(
              "저장",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  mKnouNoticeInfo.memo = etMemo.getText().toString();
                  setChangeKnouNoticeInfo(mKnouNoticeInfo);
                  if (mKnouNoticeInfo.memo != null) {
                    if (!mKnouNoticeInfo.memo.trim().equals("")) {
                      mBtnMemo.setText("메모(O)");
                    } else {
                      mBtnMemo.setText("메모(X)");
                    }
                  } else {
                    mBtnMemo.setText("메모(X)");
                  }
                }
              });
          builder.setNegativeButton(
              "닫기",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  dismissDialog(DIALOG4_KEY);
                }
              });
          return builder.create();
        }

      case DIALOG5_KEY:
        {
          final String fileSrc = args.getString("FILESRC");
          final String fileName = args.getString("FILENAME");
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setCancelable(true);
          builder.setTitle("파일 다운로드");
          File fileHome = HelpF.getHomeFileLoc();
          final File file = new File(fileHome.getAbsolutePath(), fileName);
          boolean bExistsFile = file.isFile();
          String message = "";
          if (!bExistsFile) {
            builder.setMessage("파일을 다운로드 하시겠습니까?");
            message = "다운로드";
          } else {
            builder.setMessage("파일이 존재합니다. 다운로드 하시겠습니까?");
            message = "덮어쓰기";
          }

          builder.setPositiveButton(
              message,
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  if (HelpF.Wifi3gConnectivity(NoticeRead.this) == false) {
                    HelpF.SSMessage(NoticeRead.this, "네트워크 연결 상태를 확인해 주세요.");
                    return;
                  }
                  new FileDownLoadTask(fileSrc, fileName).execute(0);
                }
              });

          if (bExistsFile) {
            builder.setNeutralButton(
                "열기",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    if (true) {
                      HelpF.goIntentFileView(NoticeRead.this, file.getAbsolutePath());
                    }
                  }
                });
          }
          builder.setNegativeButton(
              "닫기",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  dismissDialog(DIALOG5_KEY);
                }
              });
          return builder.create();
        }
    }
    return null;
  }
Ejemplo n.º 29
0
  /**
   * Generates match tables of the currently active tournament
   *
   * @param roundNumber Current round number
   */
  public void createMatchTable(int roundNumber) {

    rounds = tournament.getRounds();
    Log.d("ScoresFragment", rounds[0].getGames()[0].getAwayPlayer().getName());
    Game[] games = rounds[roundNumber - 1].getGames();
    LinearLayout linearContainerTop = new LinearLayout(getActivity().getBaseContext());
    LinearLayout.LayoutParams paramsContainerTop =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearContainerTop.setLayoutParams(paramsContainerTop);
    containerId = containerId + multiplier;
    containerIDs.add(containerId);
    linearContainerTop.setId(containerId);
    linearContainerTop.setBackgroundColor(getResources().getColor(R.color.darkgray));
    linearContainerTop.setOrientation(LinearLayout.VERTICAL);

    for (int i = 0; i < games.length; i++) {

      int id = i;
      Player homePlayer = games[i].getHomePlayer();
      Player awayPlayer = games[i].getAwayPlayer();

      LinearLayout linearContainer = new LinearLayout(getActivity().getBaseContext());
      LinearLayout.LayoutParams paramsContainer =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

      linearContainer.setLayoutParams(paramsContainer);
      linearContainer.setId(6);
      linearContainer.setBackgroundColor(getResources().getColor(R.color.darkgray));
      linearContainer.setOrientation(LinearLayout.HORIZONTAL);

      TextView homeText = new TextView(getActivity().getBaseContext());
      homeText.setId(1);
      LinearLayout.LayoutParams paramsHomeText = new LinearLayout.LayoutParams(0, 130, 0.5f);
      homeText.setGravity(Gravity.CENTER);
      paramsHomeText.setMargins(10, 10, 10, 0);
      homeText.setLayoutParams(paramsHomeText);
      homeText.setText(homePlayer.getName());
      homeText.setTextSize(18);

      TextView midText = new TextView(getActivity().getBaseContext());
      LinearLayout.LayoutParams paramsMidText =
          new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.1f);
      paramsMidText.setMargins(10, 10, 10, 0);

      midText.setGravity(Gravity.CENTER);
      midText.setLayoutParams(paramsMidText);
      midText.setId(3);
      midText.setText("-");

      LinearLayout.LayoutParams paramsAwayText = new LinearLayout.LayoutParams(0, 130, 0.5f);
      TextView awayText = new TextView(getActivity().getBaseContext());
      awayText.setId(2);
      awayText.setText(awayPlayer.getName());
      awayText.setTextSize(18);
      paramsAwayText.setMargins(10, 10, 10, 0);

      awayText.setLayoutParams(paramsAwayText);
      awayText.setGravity(Gravity.CENTER);

      EditText homeScore = new EditText(getActivity().getBaseContext());
      homeScoreId = homeScoreId + multiplier;
      homeScoreIDs.add(homeScoreId);
      LinearLayout.LayoutParams paramsHomeScore =
          new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.2f);
      homeScore.setGravity(Gravity.CENTER);
      paramsHomeScore.setMargins(10, 10, 10, 0);
      homeScore.setLayoutParams(paramsHomeScore);
      homeScore.setText(Integer.toString(games[i].getHomeScore()));
      homeScore.setInputType(InputType.TYPE_CLASS_NUMBER);
      homeScore.setId(homeScoreId);

      EditText awayScore = new EditText(getActivity().getBaseContext());
      awayScoreId = awayScoreId + multiplier;
      awayScoreIDs.add(awayScoreId);
      LinearLayout.LayoutParams paramsAwayScore =
          new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.2f);
      awayScore.setGravity(Gravity.CENTER);
      paramsAwayScore.setMargins(10, 10, 10, 0);
      awayScore.setLayoutParams(paramsAwayScore);
      awayScore.setInputType(InputType.TYPE_CLASS_NUMBER);
      awayScore.setText(Integer.toString(games[i].getAwayScore()));
      awayScore.setId(awayScoreId);

      linearContainer.addView(homeText);
      linearContainer.addView(homeScore);
      linearContainer.addView(midText);

      linearContainer.addView(awayScore);

      linearContainer.addView(awayText);
      linearContainerTop.addView(linearContainer);
    }
    layout.addView(linearContainerTop);
  }
Ejemplo n.º 30
0
  @Override
  public View createView(LayoutInflater inflater) {
    if (fragmentView == null) {
      searching = false;
      searchWas = false;

      actionBar.setBackButtonImage(R.drawable.ic_ab_back);
      actionBar.setAllowOverlayTitle(true);
      if (isAlwaysShare) {
        actionBar.setTitle(
            LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
      } else if (isNeverShare) {
        actionBar.setTitle(
            LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
      } else {
        actionBar.setTitle(
            isBroadcast
                ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)
                : LocaleController.getString("NewGroup", R.string.NewGroup));
        actionBar.setSubtitle(
            LocaleController.formatString(
                "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
      }

      actionBar.setActionBarMenuOnItemClick(
          new ActionBar.ActionBarMenuOnItemClick() {
            @Override
            public void onItemClick(int id) {
              if (id == -1) {
                finishFragment();
              } else if (id == done_button) {
                if (selectedContacts.isEmpty()) {
                  return;
                }
                ArrayList<Integer> result = new ArrayList<>();
                result.addAll(selectedContacts.keySet());
                if (isAlwaysShare || isNeverShare) {
                  if (delegate != null) {
                    delegate.didSelectUsers(result);
                  }
                  finishFragment();
                } else {
                  Bundle args = new Bundle();
                  args.putIntegerArrayList("result", result);
                  args.putBoolean("broadcast", isBroadcast);
                  presentFragment(new GroupCreateFinalActivity(args));
                }
              }
            }
          });
      ActionBarMenu menu = actionBar.createMenu();
      menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

      searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
      searchListViewAdapter.setCheckedMap(selectedContacts);
      searchListViewAdapter.setUseUserCell(true);
      listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
      listViewAdapter.setCheckedMap(selectedContacts);

      fragmentView = new LinearLayout(getParentActivity());
      LinearLayout linearLayout = (LinearLayout) fragmentView;
      linearLayout.setOrientation(LinearLayout.VERTICAL);

      FrameLayout frameLayout = new FrameLayout(getParentActivity());
      linearLayout.addView(frameLayout);
      LinearLayout.LayoutParams layoutParams =
          (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
      layoutParams.gravity = Gravity.TOP;
      frameLayout.setLayoutParams(layoutParams);

      userSelectEditText = new EditText(getParentActivity());
      userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      userSelectEditText.setHintTextColor(0xff979797);
      userSelectEditText.setTextColor(0xff212121);
      userSelectEditText.setInputType(
          InputType.TYPE_TEXT_VARIATION_FILTER
              | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
              | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
      userSelectEditText.setMinimumHeight(AndroidUtilities.dp(54));
      userSelectEditText.setSingleLine(false);
      userSelectEditText.setLines(2);
      userSelectEditText.setMaxLines(2);
      userSelectEditText.setVerticalScrollBarEnabled(true);
      userSelectEditText.setHorizontalScrollBarEnabled(false);
      userSelectEditText.setPadding(0, 0, 0, 0);
      userSelectEditText.setImeOptions(
          EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
      userSelectEditText.setGravity(
          (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
      AndroidUtilities.clearCursorDrawable(userSelectEditText);
      frameLayout.addView(userSelectEditText);
      FrameLayout.LayoutParams layoutParams1 =
          (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams();
      layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
      layoutParams1.leftMargin = AndroidUtilities.dp(10);
      layoutParams1.rightMargin = AndroidUtilities.dp(10);
      layoutParams1.gravity = Gravity.TOP;
      userSelectEditText.setLayoutParams(layoutParams1);

      if (isAlwaysShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "AlwaysShareWithPlaceholder", R.string.AlwaysShareWithPlaceholder));
      } else if (isNeverShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "NeverShareWithPlaceholder", R.string.NeverShareWithPlaceholder));
      } else {
        userSelectEditText.setHint(
            LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
      }
      if (Build.VERSION.SDK_INT >= 11) {
        userSelectEditText.setTextIsSelectable(false);
      }
      userSelectEditText.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(
                CharSequence charSequence, int start, int count, int after) {
              if (!ignoreChange) {
                beforeChangeIndex = userSelectEditText.getSelectionStart();
                changeString = new SpannableString(charSequence);
              }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (!ignoreChange) {
                boolean search = false;
                int afterChangeIndex = userSelectEditText.getSelectionEnd();
                if (editable.toString().length() < changeString.toString().length()) {
                  String deletedString = "";
                  try {
                    deletedString =
                        changeString.toString().substring(afterChangeIndex, beforeChangeIndex);
                  } catch (Exception e) {
                    FileLog.e("tmessages", e);
                  }
                  if (deletedString.length() > 0) {
                    if (searching && searchWas) {
                      search = true;
                    }
                    Spannable span = userSelectEditText.getText();
                    for (int a = 0; a < allSpans.size(); a++) {
                      XImageSpan sp = allSpans.get(a);
                      if (span.getSpanStart(sp) == -1) {
                        allSpans.remove(sp);
                        selectedContacts.remove(sp.uid);
                      }
                    }
                    if (!isAlwaysShare && !isNeverShare) {
                      actionBar.setSubtitle(
                          LocaleController.formatString(
                              "MembersCount",
                              R.string.MembersCount,
                              selectedContacts.size(),
                              maxCount));
                    }
                    listView.invalidateViews();
                  } else {
                    search = true;
                  }
                } else {
                  search = true;
                }
                if (search) {
                  String text = userSelectEditText.getText().toString().replace("<", "");
                  if (text.length() != 0) {
                    searching = true;
                    searchWas = true;
                    if (listView != null) {
                      listView.setAdapter(searchListViewAdapter);
                      searchListViewAdapter.notifyDataSetChanged();
                      if (android.os.Build.VERSION.SDK_INT >= 11) {
                        listView.setFastScrollAlwaysVisible(false);
                      }
                      listView.setFastScrollEnabled(false);
                      listView.setVerticalScrollBarEnabled(true);
                    }
                    if (emptyTextView != null) {
                      emptyTextView.setText(
                          LocaleController.getString("NoResult", R.string.NoResult));
                    }
                    searchListViewAdapter.searchDialogs(text);
                  } else {
                    searchListViewAdapter.searchDialogs(null);
                    searching = false;
                    searchWas = false;
                    listView.setAdapter(listViewAdapter);
                    listViewAdapter.notifyDataSetChanged();
                    if (android.os.Build.VERSION.SDK_INT >= 11) {
                      listView.setFastScrollAlwaysVisible(true);
                    }
                    listView.setFastScrollEnabled(true);
                    listView.setVerticalScrollBarEnabled(false);
                    emptyTextView.setText(
                        LocaleController.getString("NoContacts", R.string.NoContacts));
                  }
                }
              }
            }
          });

      LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
      emptyTextLayout.setVisibility(View.INVISIBLE);
      emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
      linearLayout.addView(emptyTextLayout);
      layoutParams = (LinearLayout.LayoutParams) emptyTextLayout.getLayoutParams();
      layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
      emptyTextLayout.setLayoutParams(layoutParams);
      emptyTextLayout.setOnTouchListener(
          new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              return true;
            }
          });

      emptyTextView = new TextView(getParentActivity());
      emptyTextView.setTextColor(0xff808080);
      emptyTextView.setTextSize(20);
      emptyTextView.setGravity(Gravity.CENTER);
      emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
      emptyTextLayout.addView(emptyTextView);
      layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      emptyTextView.setLayoutParams(layoutParams);

      FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
      emptyTextLayout.addView(frameLayout2);
      layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      frameLayout2.setLayoutParams(layoutParams);

      listView = new LetterSectionsListView(getParentActivity());
      listView.setEmptyView(emptyTextLayout);
      listView.setVerticalScrollBarEnabled(false);
      listView.setDivider(null);
      listView.setDividerHeight(0);
      listView.setFastScrollEnabled(true);
      listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
      listView.setAdapter(listViewAdapter);
      if (Build.VERSION.SDK_INT >= 11) {
        listView.setFastScrollAlwaysVisible(true);
        listView.setVerticalScrollbarPosition(
            LocaleController.isRTL
                ? ListView.SCROLLBAR_POSITION_LEFT
                : ListView.SCROLLBAR_POSITION_RIGHT);
      }
      linearLayout.addView(listView);
      layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      listView.setLayoutParams(layoutParams);
      listView.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
              TLRPC.User user = null;
              if (searching && searchWas) {
                user = searchListViewAdapter.getItem(i);
              } else {
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (row < 0 || section < 0) {
                  return;
                }
                user = (TLRPC.User) listViewAdapter.getItem(section, row);
              }
              if (user == null) {
                return;
              }

              boolean check = true;
              if (selectedContacts.containsKey(user.id)) {
                check = false;
                try {
                  XImageSpan span = selectedContacts.get(user.id);
                  selectedContacts.remove(user.id);
                  SpannableStringBuilder text =
                      new SpannableStringBuilder(userSelectEditText.getText());
                  text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                  allSpans.remove(span);
                  ignoreChange = true;
                  userSelectEditText.setText(text);
                  userSelectEditText.setSelection(text.length());
                  ignoreChange = false;
                } catch (Exception e) {
                  FileLog.e("tmessages", e);
                }
              } else {
                if (selectedContacts.size() == maxCount) {
                  return;
                }
                ignoreChange = true;
                XImageSpan span = createAndPutChipForUser(user);
                span.uid = user.id;
                ignoreChange = false;
              }
              if (!isAlwaysShare && !isNeverShare) {
                actionBar.setSubtitle(
                    LocaleController.formatString(
                        "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
              }
              if (searching || searchWas) {
                ignoreChange = true;
                SpannableStringBuilder ssb = new SpannableStringBuilder("");
                for (ImageSpan sp : allSpans) {
                  ssb.append("<<");
                  ssb.setSpan(
                      sp,
                      ssb.length() - 2,
                      ssb.length(),
                      SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                userSelectEditText.setText(ssb);
                userSelectEditText.setSelection(ssb.length());
                ignoreChange = false;

                searchListViewAdapter.searchDialogs(null);
                searching = false;
                searchWas = false;
                listView.setAdapter(listViewAdapter);
                listViewAdapter.notifyDataSetChanged();
                if (android.os.Build.VERSION.SDK_INT >= 11) {
                  listView.setFastScrollAlwaysVisible(true);
                }
                listView.setFastScrollEnabled(true);
                listView.setVerticalScrollBarEnabled(false);
                emptyTextView.setText(
                    LocaleController.getString("NoContacts", R.string.NoContacts));
              } else {
                if (view instanceof UserCell) {
                  ((UserCell) view).setChecked(check, true);
                }
              }
            }
          });
      listView.setOnScrollListener(
          new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
              if (i == SCROLL_STATE_TOUCH_SCROLL) {
                AndroidUtilities.hideKeyboard(userSelectEditText);
              }
              if (listViewAdapter != null) {
                listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE);
              }
            }

            @Override
            public void onScroll(
                AbsListView absListView,
                int firstVisibleItem,
                int visibleItemCount,
                int totalItemCount) {
              if (absListView.isFastScrollEnabled()) {
                AndroidUtilities.clearDrawableAnimation(absListView);
              }
            }
          });
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }