Example #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    switch (id) {
      case R.id.menu_reload:
        loadDiary();
        break;
      case R.id.menu_delete:
        showDeleteDialog();
        break;
      case R.id.font_large:
        editText_Content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
        break;
      case R.id.font_normal:
        editText_Content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
        break;
      case R.id.font_small:
        editText_Content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
        break;
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.specialcodedialog);

    app = (MyApp) this.getApplication();

    codeField = (EditText) this.findViewById(R.id.SpecialCodeField);
    okButton = (ImageButton) this.findViewById(R.id.specialCodeOkButton);
    okButton.setOnClickListener(this);
    cancelButton = (ImageButton) this.findViewById(R.id.specialCodeCancelButton);
    cancelButton.setOnClickListener(this);
    failText = (TextView) findViewById(R.id.SpecialCodeFail);

    codeField.setTextColor(this.getResources().getColor(R.color.dark_blue));
    codeField.setTextSize(TEXT_CODE_SIZE);

    failText.setTypeface(app.getTextFont());
    failText.setTextColor(this.getResources().getColor(R.color.dark_blue));
    failText.setTextSize(TEXT_FAIL_SIZE);
    failText.setText(DEFAULT_TEXT_FAIL);

    app = (MyApp) this.getApplication();
    currentPlayer = app.getCurrentPlayer();
  }
Example #3
0
  public StringWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mAnswer = new EditText(context);

    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    params.setMargins(7, 5, 7, 5);
    mAnswer.setLayoutParams(params);

    // capitalize the first letter of the sentence
    mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));

    // needed to make long read only text scroll
    mAnswer.setHorizontallyScrolling(false);
    mAnswer.setSingleLine(false);

    if (prompt != null) {
      mReadOnly = prompt.isReadOnly();
      String s = prompt.getAnswerText();
      if (s != null) {
        mAnswer.setText(s);
      }

      if (mReadOnly) {
        mAnswer.setBackgroundDrawable(null);
        mAnswer.setFocusable(false);
        mAnswer.setClickable(false);
      }
    }

    addView(mAnswer);
  }
  public void photoNameInputAlert() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(getString(R.string.app_name));

    answerText = new EditText(this);
    answerText.setHint("Answer Here");
    answerText.setTextSize(20);
    answerText.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    answerText.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);

    alert.setView(answerText);

    alert.setPositiveButton(
        "Okay",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            checkAnswer(answerText.getText().toString());
          }
        });
    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled.
          }
        });
    alert.setNeutralButton(
        "Say It!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            startVoiceRecognitionActivity();
          }
        });
    alert.show();
  }
Example #5
0
  public MyEditText(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.My_EditText, defStyle, 0);
    mHint = a.getText(R.styleable.My_EditText_text_hint);
    mTextColor = a.getColor(R.styleable.My_EditText_text_color, Color.BLACK);
    mTextSize = a.getDimension(R.styleable.My_EditText_text_size, 15);
    mBgColor = a.getColor(R.styleable.My_EditText_bg_color, Color.parseColor("#aaaaaa"));
    a.recycle();

    // 加载组合控件布局
    LayoutInflater.from(context).inflate(R.layout.my_edittext, this);
    mEditText = (EditText) findViewById(R.id.my_et);
    mDelete = (ImageView) findViewById(R.id.my_delete);

    // 设置组合控件自定义属性
    if (!TextUtils.isEmpty(mHint)) {
      mEditText.setHint(mHint);
    }
    mEditText.setTextSize(mTextSize);
    mEditText.setTextColor(mTextColor);
    mEditText.setBackgroundColor(mBgColor);

    // 删除键监听,点击删除输入框内容
    mDelete.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            mEditText.setText("");
            mDelete.setVisibility(View.GONE);
          }
        });

    // 输入框内容监听,内容为空,隐藏删除键;反之,显示删除键
    mEditText.addTextChangedListener(
        new TextWatcher() {

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

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

          @Override
          public void afterTextChanged(Editable s) {
            if (s != null && s.toString().trim() != null) {
              mDelete.setVisibility(View.VISIBLE);
            } else {
              mDelete.setVisibility(View.GONE);
            }

            if (mWatcher != null) {
              mWatcher.textChange(s);
            }
          }
        });
  }
Example #6
0
 public static void setTheViewTextSize(View v, int width, int height) {
   if (v instanceof TextView) {
     ((TextView) v).setTextSize(adjustFontSize(width, height));
   } else if (v instanceof EditText) {
     ((EditText) v).setTextSize(adjustFontSize(width, height));
   } else if (v instanceof Button) {
     ((Button) v).setTextSize(adjustFontSize(width, height));
   }
 }
Example #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.tget); // Layouts xmls exist for both landscape or portrait modes

    Intent intent = getIntent();
    String title = intent.getStringExtra(TITLE);
    if (title != null) setTitle(title);
    ArrayList<String> consoleText = intent.getStringArrayListExtra(CONSOLE_TEXT);
    if (theText == null) theText = "";

    lockReleased = false;

    theTextView = (EditText) findViewById(R.id.the_text); // The text display area

    int count = consoleText.size();
    for (int i = 0; i < count; ++i) {
      theText = theText + consoleText.get(i) + '\n';
    }

    theText = theText + Run.TextInputString;
    PromptIndex = theText.length();

    theTextView.setText(theText); // The Editor's display text
    theTextView.setTypeface(Typeface.MONOSPACE);
    theTextView.setSelection(theText.length());

    Basic.TextStyle style = Basic.defaultTextStyle; // Get text color from Settings
    theTextView.setTextColor(style.mTextColor);
    theTextView.setBackgroundColor(style.mBackgroundColor);
    theTextView.setCursorVisible(true);

    theTextView.setTextSize(1, Settings.getFont(this));

    theTextView.addTextChangedListener(inputTextWatcher);

    theTextView.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              handleEOL();
              return true;
            }
            return false;
          }
        });
  }
Example #8
0
 // �޸�����������пؼ��������С
 public static void changeTextSize(ViewGroup root, int size, Activity act) {
   for (int i = 0; i < root.getChildCount(); i++) {
     View v = root.getChildAt(i);
     if (v instanceof TextView) {
       ((TextView) v).setTextSize(size);
     } else if (v instanceof Button) {
       ((Button) v).setTextSize(size);
     } else if (v instanceof EditText) {
       ((EditText) v).setTextSize(size);
     } else if (v instanceof ViewGroup) {
       changeTextSize((ViewGroup) v, size, act);
     }
   }
 }
Example #9
0
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   Logger.debug("PostFragment CreateView");
   MainActivity activity = (MainActivity) getActivity();
   PostState.getState().setListener(this);
   UserPreferenceHelper preferenceHelper = new UserPreferenceHelper(activity);
   View v = inflater.inflate(R.layout.fragment_post, null);
   buttonTweet = getTweetButton(v);
   buttonTweet.setOnClickListener(this);
   editText = getEditText(v);
   textViewCount = getCountTextView(v);
   int textSize = preferenceHelper.getValue(R.string.key_setting_text_size, 10);
   editText.addTextChangedListener(this);
   editText.setOnFocusChangeListener(this);
   editText.setTextSize(textSize + 4);
   editText.setMovementMethod(
       new ArrowKeyMovementMethod() {
         @Override
         protected boolean right(TextView widget, Spannable buffer) {
           // Don't back to Home
           return widget.getSelectionEnd() == widget.length() || super.right(widget, buffer);
         }
       });
   ImageButton imageButtonDeleteText = (ImageButton) v.findViewById(R.id.button_post_delete);
   imageButtonDeleteText.setOnClickListener(this);
   ImageButton imageButtonMedia = (ImageButton) v.findViewById(R.id.button_post_media);
   imageButtonMedia.setOnClickListener(this);
   ImageButton imageButtonMenu = (ImageButton) v.findViewById(R.id.button_post_menu);
   imageButtonMenu.setOnClickListener(this);
   // Reply view
   viewGroupReply = getReplyViewGroup(v);
   ImageButton imageButtonDeleteReply =
       (ImageButton) viewGroupReply.findViewById(R.id.button_post_reply_delete);
   imageButtonDeleteReply.setOnClickListener(this);
   // Media view
   viewGroupMedia = getMediaViewGroup(v);
   ImageView imageViewMedia = (ImageView) viewGroupMedia.findViewById(R.id.image_post_media);
   ImageButton imageButtonDeleteMedia =
       (ImageButton) viewGroupMedia.findViewById(R.id.button_post_media_delete);
   imageViewMedia.setOnClickListener(this);
   imageButtonDeleteMedia.setOnClickListener(this);
   editText.requestFocus();
   return v;
 }
Example #10
0
  protected void createEditTextView() {
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.setMargins(0, 10, 0, 10);
    EditText edittTxt = new EditText(this);

    edittTxt.setHint("Subject Name");
    edittTxt.setLayoutParams(params);
    //
    edittTxt.setInputType(InputType.TYPE_CLASS_TEXT);
    edittTxt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    edittTxt.setId(hint);
    hint++;
    etArray.add(edittTxt);
    l.addView(edittTxt);
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    editText = (EditText) findViewById(R.id.EditText01);
    seekBar = (SeekBar) findViewById(R.id.SeekBar01);
    btn = (Button) findViewById(R.id.btnSave);

    btn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {}
        });

    // ---load the SharedPreferences object---
    // SharedPreferences prefs = getSharedPreferences(prefName, MODE_PRIVATE);
    prefs = getSharedPreferences(prefName, MODE_PRIVATE);

    // ---set the TextView font size to the previously saved values---
    float fontSize = prefs.getFloat(FONT_SIZE_KEY, 12);

    // ---init the SeekBar and EditText---
    seekBar.setProgress((int) fontSize);
    editText.setText(prefs.getString(TEXT_VALUE_KEY, ""));
    editText.setTextSize(seekBar.getProgress());

    seekBar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // ---change the font size of the EditText---
            editText.setTextSize(progress);
          }
        });
  }
  private void initOtherViews() {
    RelativeLayout.LayoutParams captureButtonParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    captureButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    captureButtonParams.topMargin = screenHeight / 30;
    captureButton.setLayoutParams(captureButtonParams);
    captureText.setLayoutParams(captureButtonParams);
    captureText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 40);

    RelativeLayout.LayoutParams nameEditParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    nameEditParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    nameEditParams.addRule(RelativeLayout.BELOW, captureButton.getId());
    nameEditParams.topMargin = screenHeight / 30;
    nameEdit.setLayoutParams(nameEditParams);
    nameEdit.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 42);
    nameEdit.setTextColor(Color.BLACK);

    RelativeLayout.LayoutParams saveButtonParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    saveButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    saveButtonParams.addRule(RelativeLayout.BELOW, nameEdit.getId());
    saveButtonParams.topMargin = screenHeight / 30;
    saveButton.setLayoutParams(saveButtonParams);
    saveButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 40);

    if (!isTraining) {
      deleteButtonFirstPos = screenHeight / 8 + screenHeight / 15;
      deleteButtonSecondPos = 3 * screenHeight / 8 + 2 * screenHeight / 15;
      RelativeLayout.LayoutParams deleteButtonParams =
          new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
      deleteButtonParams.topMargin = deleteButtonFirstPos;
      deleteButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      deleteButton.setLayoutParams(deleteButtonParams);
      deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 42);
    }
  }
Example #13
0
 protected final void DV()
 {
   t.d("!32@/B4Tb64lLpKNhhU94SG29vC9zoVXGkMM", "init getintent mobile:" + aMQ);
   izI = ((MMFormInputView)findViewById(a.i.bind_mcontact_verify_num));
   izI.setImeOption(5);
   izI.setInputType(3);
   iyu = izI.getContentEditText();
   izJ = ((TextView)findViewById(a.i.mobileverify_resend_bt));
   izK = ((TextView)findViewById(a.i.mobileverify_counting_tv));
   izg = ((TextView)findViewById(a.i.bind_mcontact_verify_hint));
   izg.setText(aMQ);
   aMQ = am.xx(aMQ);
   izJ.setText(getString(a.n.mobileverify_resend));
   izL = ((TextView)findViewById(a.i.bind_mcontact_verify_tip));
   gmh = ((Button)findViewById(a.i.next_btn));
   izM = ((ScrollView)findViewById(a.i.scroll));
   grS = getResources().getStringArray(a.c.sms_content);
   Object localObject = getString(a.n.regbymobile_reg_input_verify_tip);
   izL.setText(Html.fromHtml((String)localObject));
   localObject = new di(this);
   izK.setVisibility(0);
   izK.setText(getResources().getQuantityString(a.l.mobileverify_send_code_tip, iwr, new Object[] { Integer.valueOf(iwr) }));
   aMp();
   izR = false;
   iyu.setFilters(new InputFilter[] { localObject });
   iyu.addTextChangedListener(new MMEditText.c(iyu, null, 12));
   gmh.setOnClickListener(new dj(this));
   gmh.setEnabled(false);
   iyu.setTextSize(15.0F);
   iyu.addTextChangedListener(new dk(this));
   izJ.setOnClickListener(new dl(this));
   izJ.setEnabled(false);
   a(new do(this));
   iyu.setOnEditorActionListener(new dp(this));
   iyu.setOnKeyListener(new dq(this));
 }
  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());
  }
Example #15
0
  @Override
  protected void onResume() {
    super.onResume();

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    float textSize = Float.valueOf(preferences.getString("textSize", "16"));
    mBodyText.setTextSize(textSize);

    Cursor cursor = managedQuery(mUri, PROJECTION, null, null, null);
    Note note = Note.fromCursor(cursor);
    cursor.close();

    if (note != null) {
      if (mOriginalNote == null) mOriginalNote = note;
      mBodyText.setTextKeepState(note.getBody());

      Boolean rememberPosition = preferences.getBoolean("rememberPosition", true);
      if (rememberPosition == true) {
        mBodyText.setSelection(note.getCursor());
        mBodyText.scrollTo(0, note.getScrollY());
      }
    }
  }
Example #16
0
  void applyPreferences() {
    // InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_CLASS_TEXT |
    // InputType.TYPE_TEXT_FLAG_MULTI_LINE
    mText.setInputType(
        InputType.TYPE_TEXT_FLAG_MULTI_LINE
            | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_VARIATION_NORMAL
            | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
            | InputType.TYPE_CLASS_TEXT);
    // ScrollView mScrollView = (ScrollView) this.findViewById(R.id.scrollView);

    TPApplication.instance.updateSettings();
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    /** ****************************** font face */
    String font = sharedPref.getString("font", "Monospace");

    if (font.equals("Serif")) mText.setTypeface(Typeface.SERIF);
    else if (font.equals("Sans Serif")) mText.setTypeface(Typeface.SANS_SERIF);
    else mText.setTypeface(Typeface.MONOSPACE);

    /** ****************************** font size */
    String fontsize = sharedPref.getString("fontsize", "Medium");

    if (fontsize.equals("Extra Small")) mText.setTextSize(12.0f);
    else if (fontsize.equals("Small")) mText.setTextSize(16.0f);
    else if (fontsize.equals("Medium")) mText.setTextSize(20.0f);
    else if (fontsize.equals("Large")) mText.setTextSize(24.0f);
    else if (fontsize.equals("Huge")) mText.setTextSize(28.0f);
    else mText.setTextSize(20.0f);

    /** ****************************** Colors */
    int bgcolor = sharedPref.getInt("bgcolor", 0xFFCCCCCC);
    // mScrollView.setBackgroundColor(bgcolor);
    mText.setBackgroundColor(bgcolor);

    int fontcolor = sharedPref.getInt("fontcolor", 0xFF000000);
    mText.setTextColor(fontcolor);

    // title.setTextColor(bgcolor);
    // title.setBackgroundColor(fontcolor);
  }
  @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);
  }
  @SuppressWarnings("deprecation")
  private View generateView() {
    LinearLayout rootLayout = new LinearLayout(getContext());
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    rootLayout.setMinimumWidth(DimensionUtility.dp2px(260));

    GradientDrawable gradientDrawable =
        new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM,
            new int[] {Color.argb(0xCC, 0xFF, 0xFF, 0xFF), Color.argb(0xCC, 0xFF, 0xFF, 0xFF)});
    gradientDrawable.setCornerRadius(DimensionUtility.dp2px(6));
    gradientDrawable.setStroke(1, Color.parseColor("#CFFFFFFF"));

    rootLayout.setBackgroundDrawable(gradientDrawable);
    int padding = DimensionUtility.dp2px(8);
    rootLayout.setPadding(padding, padding, padding, padding);

    titleLabel = new TextView(getContext());
    titleLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    titleLabel.setGravity(Gravity.CENTER);
    titleLabel.setTextColor(Color.parseColor("#333333"));

    LinearLayout.LayoutParams titleParams =
        new LinearLayout.LayoutParams(fillParent(), wrapContent());
    rootLayout.addView(titleLabel, titleParams);

    messageLabel = new TextView(getContext());
    messageLabel.setTextColor(Color.parseColor("#333333"));
    messageLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    messageLabel.setGravity(Gravity.CENTER);
    LinearLayout.LayoutParams messageParams =
        new LinearLayout.LayoutParams(fillParent(), wrapContent());
    messageParams.topMargin = DimensionUtility.dp2px(10);
    rootLayout.addView(messageLabel, messageParams);

    text = new EditText(getContext());
    text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    text.setInputType(InputType.TYPE_CLASS_TEXT);
    LinearLayout.LayoutParams textParams =
        new LinearLayout.LayoutParams(fillParent(), wrapContent());
    textParams.topMargin = DimensionUtility.dp2px(8);
    rootLayout.addView(text, textParams);

    LinearLayout container = new LinearLayout(getContext());
    container.setOrientation(LinearLayout.HORIZONTAL);
    container.setWeightSum(2);

    positiveButton = new Button(getContext());
    LinearLayout.LayoutParams positiveParams =
        new LinearLayout.LayoutParams(fillParent(), wrapContent());
    positiveParams.weight = 1;
    container.addView(positiveButton, positiveParams);

    negativeButton = new Button(getContext());
    LinearLayout.LayoutParams negativeParams =
        new LinearLayout.LayoutParams(fillParent(), wrapContent());
    negativeParams.weight = 1;
    container.addView(negativeButton, negativeParams);

    positiveButton.setOnClickListener(this);
    negativeButton.setOnClickListener(this);

    LinearLayout.LayoutParams ctrParams =
        new LinearLayout.LayoutParams(fillParent(), wrapContent());
    ctrParams.topMargin = DimensionUtility.dp2px(8);
    rootLayout.addView(container, ctrParams);

    return rootLayout;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.read:
        String str = readDiary(fileName);
        editText1.setText(str);
        return true;
      case R.id.delete:
        dialogView = (View) View.inflate(MainActivity.this, R.layout.dialog2, null);
        AlertDialog.Builder dlg = new AlertDialog.Builder(MainActivity.this);

        dialogtext2 = (TextView) dialogView.findViewById(R.id.dialogText2);

        dlg.setTitle("일기삭제");

        dialogtext2.setText(textView1.getText().toString() + "일기를 삭제하시겠습니까?");

        dlg.setView(dialogView);

        dlg.setPositiveButton(
            "확인",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                File file = new File("/data/data/com.example.user.myapplication/files/" + fileName);
                file.delete();
                Toast.makeText(getApplicationContext(), "삭제했습니다.", Toast.LENGTH_SHORT).show();
                editText1.setText(" ");
                /*
                 final String strSDpath = Environment.getExternalStorageDirectory().getAbsolutePath();
                     File file = new Filie(strSDpath+"/mydiary/"+fileName);
                     file.delete();

                */

              }
            });

        dlg.setNegativeButton(
            "취소",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {}
            });

        dlg.show();

      case R.id.large:
        editText1.setTextSize(100.0f);
        break;
      case R.id.medium:
        editText1.setTextSize(50.0f);
        break;
      case R.id.small:
        editText1.setTextSize(30.0f);
        break;
    }
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Example #20
0
  private void initView() {
    titleItem = (StoreTitleItem) findViewById(R.id.main_title);

    seacrhing_bar = (RelativeLayout) findViewById(R.id.seacrhing_bar);
    LinearLayout.LayoutParams searchLayoutParams =
        (android.widget.LinearLayout.LayoutParams) seacrhing_bar.getLayoutParams();
    searchLayoutParams.height = ((mainLogic.screenHeight * 74) / 1280);
    searchLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    seacrhing_bar.setLayoutParams(searchLayoutParams);

    searchEdit = (EditText) findViewById(R.id.seacrhing_park_et);
    searchEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 24) / 720);
    searchEdit.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == 3) {

              String key = searchEdit.getText().toString();
              if (key != null && !key.equals("")) {
                Intent intent = new Intent(StoreMainActivity.this, SearchResultActivity.class);
                intent.putExtra(StoreConstant.SEARCHKEY, key);
                startActivity(intent);
              } else {
                showToast(getResources().getString(R.string.park_place_edit_hint));
              }
            }
            return true;
          }
        });

    searchBtn = (TextView) findViewById(R.id.seacrhing_park_btn);
    searchBtn.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 24) / 720);
    searchBtn.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            String key = searchEdit.getText().toString();
            if (key != null && !key.equals("")) {
              Intent intent = new Intent(StoreMainActivity.this, SearchResultActivity.class);
              intent.putExtra(StoreConstant.SEARCHKEY, key);
              startActivity(intent);
            } else {
              showToast(getResources().getString(R.string.park_place_edit_hint));
            }
          }
        });

    radioGroup = (LinearLayout) findViewById(R.id.radiobutton);
    RelativeLayout.LayoutParams radioGroupParams =
        (android.widget.RelativeLayout.LayoutParams) radioGroup.getLayoutParams();
    radioGroupParams.height = ((mainLogic.screenHeight * 90) / 1280);
    radioGroupParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
    radioGroup.setLayoutParams(radioGroupParams);

    allarrowTextView = (TextView) findViewById(R.id.tab_all_arrow);
    RelativeLayout.LayoutParams params1 = (LayoutParams) allarrowTextView.getLayoutParams();
    params1.width = ((mainLogic.screenWidth * 19) / 720);
    params1.height = ((mainLogic.screenHeight * 13) / 1280);
    allarrowTextView.setLayoutParams(params1);

    neararrowTextView = (TextView) findViewById(R.id.tab_near_arrow);
    RelativeLayout.LayoutParams params2 = (LayoutParams) neararrowTextView.getLayoutParams();
    params2.width = ((mainLogic.screenWidth * 19) / 720);
    params2.height = ((mainLogic.screenHeight * 13) / 1280);
    neararrowTextView.setLayoutParams(params2);

    allLoyout = (RelativeLayout) findViewById(R.id.tab_all_layout);
    allTextView = (TextView) findViewById(R.id.tab_all);
    allTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 30) / 720);
    allLoyout.setOnClickListener(this);

    nearLoyout = (RelativeLayout) findViewById(R.id.tab_near_layout);
    nearTextView = (TextView) findViewById(R.id.tab_near);
    nearTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 30) / 720);
    nearLoyout.setOnClickListener(this);

    listView = (PullRefreshListView) findViewById(R.id.main_listview);
    listView.setOnRefreshListener(
        new OnRefreshListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            refresh();
          }
        });
    // 加载更多
    listView.setNewScrollerListener(
        new NewScrollerListener() {
          private boolean isLoadMoreFile = false;

          @Override
          public void newScrollChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            if ((scrollState == OnScrollListener.SCROLL_STATE_IDLE
                    || scrollState == OnScrollListener.SCROLL_STATE_FLING)
                && isLoadMoreFile) {
              startToLoadMore();
            }
          }

          @Override
          public void newScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            // TODO Auto-generated method stub
            isLoadMoreFile = (firstVisibleItem + visibleItemCount == totalItemCount) ? true : false;
          }
        });
    adapter = new AllshoppingAdapter(getApplicationContext(), mBitmapUtils, goodsDetailInfos);
    listView.setAdapter(adapter);

    findGoods();
  }
  public ActionBarMenuItem setIsSearchField(boolean value) {
    if (value && searchField == null) {
      searchField = new EditText(getContext());
      searchField.setTextSize(18);
      searchField.setTextColor(0xffffffff);
      searchField.setSingleLine(true);
      searchField.setBackgroundResource(R.drawable.search_light_states);
      searchField.setPadding(0, 0, 0, 0);
      searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
      if (android.os.Build.VERSION.SDK_INT < 11) {
        searchField.setOnCreateContextMenuListener(
            new OnCreateContextMenuListener() {
              public void onCreateContextMenu(
                  ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
                menu.clear();
              }
            });
      } else {
        searchField.setCustomSelectionActionModeCallback(
            new ActionMode.Callback() {
              public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
              }

              public void onDestroyActionMode(ActionMode mode) {}

              public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
              }

              public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
              }
            });
      }
      searchField.setOnEditorActionListener(
          new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
              if (actionId == EditorInfo.IME_ACTION_SEARCH
                  || event != null
                      && event.getAction() == KeyEvent.ACTION_UP
                      && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
                AndroidUtilities.hideKeyboard(searchField);
              }
              return false;
            }
          });
      searchField.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
              if (listener != null) {
                listener.onTextChanged(searchField);
              }
            }

            @Override
            public void afterTextChanged(Editable s) {}
          });

      /*
          ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
      if (img != null) {
          img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
      }
           */
      try {
        Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        mCursorDrawableRes.setAccessible(true);
        mCursorDrawableRes.set(searchField, R.drawable.search_carret);
      } catch (Exception e) {
        // nothing to do
      }
      if (Build.VERSION.SDK_INT >= 11) {
        searchField.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_ACTION_SEARCH);
        searchField.setTextIsSelectable(false);
      } else {
        searchField.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
      }
      parentMenu.addView(searchField, 0);
      LinearLayout.LayoutParams layoutParams =
          (LinearLayout.LayoutParams) searchField.getLayoutParams();
      layoutParams.weight = 1;
      layoutParams.width = 0;
      layoutParams.gravity = Gravity.CENTER_VERTICAL;
      layoutParams.height = AndroidUtilities.dp(36);
      layoutParams.rightMargin = AndroidUtilities.dp(22);
      layoutParams.leftMargin = AndroidUtilities.dp(6);
      searchField.setLayoutParams(layoutParams);
      searchField.setVisibility(GONE);
    }
    isSearchField = value;
    return this;
  }
Example #22
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;
  }
Example #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(Settings.getSreenOrientation(this));
    originalText = Editor.DisplayText; // Save in case of BACK Key

    setContentView(R.layout.search); // Layouts xmls exist for both landscape or portrait modes

    rText = (EditText) findViewById(R.id.replace_text); // The replace text
    sText = (EditText) findViewById(R.id.search_text); // The search for text

    nextButton = (Button) findViewById(R.id.next_button); // The buttons
    replaceButton = (Button) findViewById(R.id.replace_button);
    replaceAllButton = (Button) findViewById(R.id.replace_all_button);
    doneButton = (Button) findViewById(R.id.done_button);

    theTextView = (EditText) findViewById(R.id.the_text); // The text display area
    theTextView.setText(Editor.DisplayText); // The Editor's display text

    if (Settings.getEditorColor(this).equals("BW")) {
      theTextView.setTextColor(0xff000000);
      theTextView.setBackgroundColor(0xffffffff);
      rText.setTextColor(0xff000000);
      rText.setBackgroundColor(0xffffffff);
      theTextView.setTextColor(0xff000000);
      theTextView.setBackgroundColor(0xffffffff);
    } else if (Settings.getEditorColor(this).equals("WB")) {
      theTextView.setTextColor(0xffffffff);
      theTextView.setBackgroundColor(0xff000000);
      rText.setTextColor(0xffffffff);
      rText.setBackgroundColor(0xff000000);
      sText.setTextColor(0xffffffff);
      sText.setBackgroundColor(0xff000000);
    } else if (Settings.getEditorColor(this).equals("WBL")) {
      theTextView.setTextColor(0xffffffff);
      theTextView.setBackgroundColor(0xff006478);
      rText.setTextColor(0xffffffff);
      rText.setBackgroundColor(0xff006478);
      sText.setTextColor(0xffffffff);
      sText.setBackgroundColor(0xff006478);
    }

    theTextView.setTextSize(1, Settings.getFont(this));

    // If there is a block of text selected in the Editor then make that
    // block of text the search for text

    if (Editor.selectionStart != Editor.selectionEnd) {
      int s = Editor.selectionStart;
      int e = Editor.selectionEnd;
      if (e < s) {
        s = e;
        e = Editor.selectionStart;
      }
      sText.setText(Editor.DisplayText.substring(s, e));
    }

    Index = -1; // Current Index into text, set for nothing found
    nextIndex = 0; // next Index

    nextButton.setOnClickListener(
        new OnClickListener() { // ***** Next Button ****

          public void onClick(View v) {
            Editor.DisplayText =
                theTextView.getText().toString(); // Grab the text that the user is seeing
            // She may edited it
            if (nextIndex < 0) nextIndex = 0; // If nextIndex <0 then a previous search
            // search has finished. Start next search
            // from the start
            if (doNext()) return; // If this next found something, return
            nextIndex = -1; // Else indicate not found and (Index also -1 now)
            Toaster(searchText + " not found."); // tell the user not found
            return;
          }
        });

    replaceButton.setOnClickListener(
        new OnClickListener() { // ***** Replace Button ****

          public void onClick(View v) {
            if (Index < 0) { // If nothing has been found....
              Toaster("Nothing found to replace");
              return;
            }
            doReplace(); // else replace what was found
            return;
          }
        });

    replaceAllButton.setOnClickListener(
        new OnClickListener() { // ******* Replace All Button *****

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

    doneButton.setOnClickListener(
        new OnClickListener() { // **** Done Button ****

          public void onClick(View v) {
            Editor.DisplayText =
                theTextView.getText().toString(); // Grab the text that the user is seeing
            Editor.mText.setText(Editor.DisplayText); // Set the Editor's EditText TextView text
            if (!mChanged) {
              mChanged = !originalText.equals(Editor.DisplayText); // She may have edited it
            }
            if (mChanged) {
              Basic.Saved = false;
            }
            if (nextIndex < 0) nextIndex = 0; // If nextIndex indicates done, then set to start
            if (Index < 0) Index = 0; // If Index indicates not found, set to start
            if (nextIndex < Index) {
              int ni = nextIndex;
              nextIndex = Index;
              Index = ni;
            }
            Editor.mText.setSelection(Index, nextIndex); // Set the cursor or selection highlight
            finish(); // Done with this module
            return;
          }
        });
  }
 public void setTextSize(float size) {
   mEdt.setTextSize(size);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.activity_edit_alert);

    viewHeader = (TextView) findViewById(R.id.view_alert_header);

    buttonSave = (Button) findViewById(R.id.edit_alert_save);
    buttonRemove = (Button) findViewById(R.id.edit_alert_remove);
    buttonTest = (Button) findViewById(R.id.edit_alert_test);
    buttonalertMp3 = (Button) findViewById(R.id.Button_alert_mp3_file);
    buttonPreSnooze = (Button) findViewById(R.id.edit_alert_pre_snooze);

    alertText = (EditText) findViewById(R.id.edit_alert_text);
    alertThreshold = (EditText) findViewById(R.id.edit_alert_threshold);
    alertMp3File = (EditText) findViewById(R.id.edit_alert_mp3_file);

    checkboxAllDay = (CheckBox) findViewById(R.id.check_alert_time);

    layoutTimeBetween = (LinearLayout) findViewById(R.id.time_between);
    timeInstructions = (LinearLayout) findViewById(R.id.time_instructions);
    timeInstructionsStart = (TextView) findViewById(R.id.time_instructions_start);
    timeInstructionsEnd = (TextView) findViewById(R.id.time_instructions_end);

    viewTimeStart = (TextView) findViewById(R.id.view_alert_time_start);
    viewTimeEnd = (TextView) findViewById(R.id.view_alert_time_end);
    editSnooze = (EditText) findViewById(R.id.edit_snooze);
    reraise = (EditText) findViewById(R.id.reraise);

    viewAlertOverrideText = (TextView) findViewById(R.id.view_alert_override_silent);
    checkboxAlertOverride = (CheckBox) findViewById(R.id.check_override_silent);
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    addListenerOnButtons();

    if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
      viewHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      buttonSave.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      buttonRemove.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      buttonTest.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      buttonalertMp3.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      buttonSave.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      buttonPreSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      alertText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      alertThreshold.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      alertMp3File.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);

      checkboxAllDay.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);

      viewTimeStart.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      viewTimeEnd.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      editSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      reraise.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      viewAlertOverrideText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);

      ((TextView) findViewById(R.id.view_alert_text)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      ((TextView) findViewById(R.id.view_alert_threshold))
          .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      ((TextView) findViewById(R.id.view_alert_default_snooze))
          .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      ((TextView) findViewById(R.id.view_alert_mp3_file))
          .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      ((TextView) findViewById(R.id.view_alert_time)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
      ((TextView) findViewById(R.id.view_alert_time_between))
          .setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    if (!doMgdl) {
      alertThreshold.setInputType(InputType.TYPE_CLASS_NUMBER);
      alertThreshold.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
      alertThreshold.setKeyListener(DigitsKeyListener.getInstance(false, true));
    }

    uuid = getExtra(savedInstanceState, "uuid");
    String status;
    if (uuid == null) {
      // This is a new alert
      above = Boolean.parseBoolean(getExtra(savedInstanceState, "above"));
      checkboxAllDay.setChecked(true);
      checkboxAlertOverride.setChecked(true);

      audioPath = "";
      alertMp3File.setText(shortPath(audioPath));
      alertMp3File.setKeyListener(null);
      defaultSnooze = SnoozeActivity.getDefaultSnooze(above);
      buttonRemove.setVisibility(View.GONE);
      // One can not snooze an alert that is still not in the database...
      buttonPreSnooze.setVisibility(View.GONE);
      status = "Adding " + (above ? "high" : "low") + " alert";
      startHour = 0;
      startMinute = 0;
      endHour = 23;
      endMinute = 59;
      alertReraise = 1;
    } else {
      // We are editing an alert
      AlertType at = AlertType.get_alert(uuid);
      if (at == null) {
        Log.wtf(TAG, "Error editing alert, when that alert does not exist...");
        Intent returnIntent = new Intent();
        setResult(RESULT_CANCELED, returnIntent);
        finish();
        return;
      }

      above = at.above;
      alertText.setText(at.name);
      alertThreshold.setText(unitsConvert2Disp(doMgdl, at.threshold));
      checkboxAllDay.setChecked(at.all_day);
      checkboxAlertOverride.setChecked(at.override_silent_mode);
      defaultSnooze = at.default_snooze;
      if (defaultSnooze == 0) {
        SnoozeActivity.getDefaultSnooze(above);
      }

      audioPath = at.mp3_file;
      alertMp3File.setText(shortPath(audioPath));

      status = "editing " + (above ? "high" : "low") + " alert";
      startHour = AlertType.time2Hours(at.start_time_minutes);
      startMinute = AlertType.time2Minutes(at.start_time_minutes);
      endHour = AlertType.time2Hours(at.end_time_minutes);
      endMinute = AlertType.time2Minutes(at.end_time_minutes);
      alertReraise = at.minutes_between;

      if (uuid.equals(AlertType.LOW_ALERT_55)) {
        // This is the 55 alert, can not be edited
        alertText.setKeyListener(null);
        alertThreshold.setKeyListener(null);
        buttonalertMp3.setEnabled(false);
        checkboxAllDay.setEnabled(false);
        checkboxAlertOverride.setEnabled(false);
        reraise.setEnabled(false);
      }
    }
    reraise.setText(String.valueOf(alertReraise));
    alertMp3File.setKeyListener(null);
    viewHeader.setText(status);
    setDefaultSnoozeSpinner();
    setPreSnoozeSpinner();
    enableAllDayControls();
    enableVibrateControls();
  }
  public void init(String[][] result) {

    MaterialEditText Shopname = (MaterialEditText) findViewById(R.id.billMerch);
    MaterialEditText Dates = (MaterialEditText) findViewById(R.id.billDate);
    MaterialEditText Times = (MaterialEditText) findViewById(R.id.billTime);
    MaterialEditText Total = (MaterialEditText) findViewById(R.id.billTotal);

    if (result[0][0].equalsIgnoreCase("No Error")) {
      if (result[1][0] != null) {
        Shopname.setText(result[1][0]);
      }
      if (result[2][0] != null) {
        Dates.setText(result[2][0]);
      }
      if (result[3][0] != null) {
        Times.setText(result[3][0]);
        Log.v(LOGTAG, "Time" + result[3][0]);
      }
      if (result[4][0] != null) {
        Total.setText(result[4][0]);
      }

      TableLayout ll = (TableLayout) findViewById(R.id.allitems);

      TextView column1 = new TextView(this);
      column1.setTextColor(getResources().getColor(R.color.text_colors));
      column1.setTextSize(20);
      TextView column2 = new TextView(this);
      column2.setTextColor(getResources().getColor(R.color.text_colors));
      column2.setTextSize(20);
      TextView column3 = new TextView(this);
      column3.setTextColor(getResources().getColor(R.color.text_colors));
      column3.setTextSize(20);
      //            column3.setGravity(Gravity);

      TableRow row = new TableRow(this);
      TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
      column1.setText("Item Name");
      column2.setText("Quantity");
      column3.setText("Subtotal");
      row.addView(column1);
      row.addView(column2);
      row.addView(column3);

      ll.addView(row);
      for (int i = 0; i < result[5].length; i++) {
        EditText item = new EditText(this);
        item.setTextColor(getResources().getColor(R.color.text_colors));
        item.setTextSize(20);
        EditText quantity = new EditText(this);
        quantity.setTextColor(getResources().getColor(R.color.text_colors));
        quantity.setTextSize(20);
        EditText subtotal = new EditText(this);
        subtotal.setTextColor(getResources().getColor(R.color.text_colors));
        subtotal.setTextSize(20);

        row = new TableRow(this);
        lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
        Log.v(LOGTAG, "Length :" + Integer.toString(result[5].length));
        item.setText(result[5][i]);
        quantity.setText(result[6][i]);
        subtotal.setText(result[7][i]);
        row.addView(item);
        row.addView(quantity);
        row.addView(subtotal);

        ll.addView(row);
      }

      String title = "Filtration Has Succeeded...";

      String msg =
          "Make sure every field has correct information\n" + "You can either save or cancel";

      new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
          .setTitleText(title)
          .setContentText(msg)
          .show();

    } else {

      String title = "Filtration Could Not Complete...";
      String msg =
          "Process has Failed\n"
              + "The process could not capture all the details,\n"
              + "You could either retry or enter the details manually and save.";

      new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
          .setTitleText(title)
          .setContentText(msg)
          .setConfirmText("Ok")
          .show();
    }
  }
  @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());
  }
  private void callDialog(final String fromWhere) {
    builderEnterPin = new Dialog(SettingsActivity.this);

    builderEnterPin
        .getWindow()
        .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    builderEnterPin.requestWindowFeature(Window.FEATURE_NO_TITLE);

    builderEnterPin.setCancelable(false);
    builderEnterPin.setTitle(getString(R.string.app_name));
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.pin_screen, null);
    builderEnterPin.setContentView(view);

    TextView txtEnterPinToLogout = (TextView) view.findViewById(R.id.txtEnterPinToLogout);

    txtEnterPinToLogout.setText(mLanguageManager.getEnterPinToLogout());

    txtEnterPinToLogout.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, FontManager.getInstance().getFontSize());

    editEnterPinToExit = (EditText) view.findViewById(R.id.editPinToExit);
    btnCancel = (Button) view.findViewById(R.id.btnCloseLayout);

    editEnterPinToExit.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, FontManager.getInstance().getFontSize());
    btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_PX, FontManager.getInstance().getFontSize());

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editEnterPinToExit.getWindowToken(), 0);

    String enterPin = mLanguageManager.getEnterPin();
    String cancel = mLanguageManager.getCancel();

    editEnterPinToExit.setHint(enterPin);
    btnCancel.setText(cancel);

    btnCancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            InputMethodManager imm =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editEnterPinToExit.getWindowToken(), 0);
            builderEnterPin.dismiss();
          }
        });

    editEnterPinToExit.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.toString().length() >= 4) {
              InputMethodManager imm =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(editEnterPinToExit.getWindowToken(), 0);

              String userPin = Prefs.getKey(Prefs.USER_PIN);
              String adminPin = Prefs.getKey(Prefs.EXIT_PIN);

              // changes as on 10th December 2013
              if (Validator.isValidNumber(s.toString())) {
                if (fromWhere.equals(Global.FROM_EXIT)) {
                  if (s.toString().equalsIgnoreCase(adminPin)) {
                    WSWaiterPin wsWaiterPin = new WSWaiterPin();
                    wsWaiterPin.setWaiterCode(Prefs.getKey(Prefs.WAITER_CODE));
                    wsWaiterPin.setMacAddress(Utils.getMacAddress());
                    // wsWaiterPin.setMacAddress("20");
                    wsWaiterPin.setWaiterPin(userPin);

                    if (mUtils.isConnected()) {
                      // connected, then only send
                      // logout request to the server
                      logoutAsyncTask =
                          new LogoutAsyncTask(
                              SettingsActivity.this, wsWaiterPin, Global.FROM_SETTINGS, fromWhere);
                      logoutAsyncTask.execute();
                    } else {
                      // no internet connectivity
                      // exit from the system
                      WaiterPadResponse result = new WaiterPadResponse();
                      result.setError(false);
                      logoutMessage(result, fromWhere);
                    }
                  } else {
                    editEnterPinToExit.setText("");
                    String message = mLanguageManager.getEnterValidExitPin();
                    showMessage(message);
                  }
                } else {
                  boolean isNumber = Validator.containsOnlyNumbers(s.toString());
                  if (isNumber) {
                    WSWaiterPin wsWaiterPin = new WSWaiterPin();
                    wsWaiterPin.setWaiterCode(Prefs.getKey(Prefs.WAITER_CODE));
                    wsWaiterPin.setMacAddress(Utils.getMacAddress());
                    wsWaiterPin.setWaiterPin(s.toString());

                    logoutAsyncTask =
                        new LogoutAsyncTask(
                            SettingsActivity.this, wsWaiterPin, Global.FROM_SETTINGS, fromWhere);
                    logoutAsyncTask.execute();
                  } else {
                    editEnterPinToExit.setText("");
                    String message = mLanguageManager.getEnterValidPin();
                    showMessage(message);
                  }
                }
              } else {
                String message = mLanguageManager.getEnterValidPin();
                editEnterPinToExit.setText("");
                showMessage(message);
              }
            }
          }

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

          @Override
          public void afterTextChanged(Editable s) {}
        });

    builderEnterPin.show();
  }
  protected void onCreateContent(LinearLayout parent) {
    SizeHelper.prepare(context);

    LinearLayout rlCountry = new LinearLayout(context);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(96));
    params.setMargins(
        SizeHelper.fromPx(26), SizeHelper.fromPxWidth(32), SizeHelper.fromPxWidth(26), 0);
    rlCountry.setLayoutParams(params);
    rlCountry.setId(Res.id.rl_country);

    TextView tv = new TextView(context);
    LinearLayout.LayoutParams tvParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    tvParams.gravity = Gravity.CENTER_VERTICAL;
    tv.setLayoutParams(tvParams);
    tv.setPadding(SizeHelper.fromPxWidth(14), 0, SizeHelper.fromPxWidth(14), 0);
    int resid = R.getStringRes(context, "smssdk_country");
    tv.setText(resid);
    tv.setTextColor(0xff000000);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    rlCountry.addView(tv);

    TextView tvCountry = new TextView(context);
    tvCountry.setId(Res.id.tv_country);
    LinearLayout.LayoutParams tvCountryParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    tvCountryParams.gravity = Gravity.CENTER_VERTICAL;
    tvCountryParams.weight = 1;
    tvCountryParams.rightMargin = SizeHelper.fromPxWidth(14);
    tvCountry.setLayoutParams(tvCountryParams);
    tvCountry.setGravity(Gravity.RIGHT);
    tvCountry.setPadding(SizeHelper.fromPxWidth(14), 0, SizeHelper.fromPxWidth(14), 0);
    tvCountry.setTextColor(0xff45c01a);
    tvCountry.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    rlCountry.addView(tvCountry);

    parent.addView(rlCountry);

    View line = new View(context);
    LinearLayout.LayoutParams lineParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, SizeHelper.fromPxWidth(1));
    lineParams.leftMargin = SizeHelper.fromPxWidth(26);
    lineParams.rightMargin = SizeHelper.fromPxWidth(26);
    line.setLayoutParams(lineParams);
    line.setBackgroundColor(Res.color.smssdk_gray_press);
    parent.addView(line);

    LinearLayout phoneLayout = new LinearLayout(context);
    LinearLayout.LayoutParams phoneParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(70));
    phoneParams.setMargins(
        SizeHelper.fromPxWidth(26), SizeHelper.fromPxWidth(30), SizeHelper.fromPxWidth(26), 0);
    phoneLayout.setLayoutParams(phoneParams);

    TextView countryNum = new TextView(context);
    countryNum.setId(Res.id.tv_country_num);
    LinearLayout.LayoutParams countryNumParams =
        new LinearLayout.LayoutParams(
            SizeHelper.fromPxWidth(104), LinearLayout.LayoutParams.MATCH_PARENT);
    countryNum.setLayoutParams(countryNumParams);
    countryNum.setGravity(Gravity.CENTER);
    countryNum.setTextColor(0xff353535);
    countryNum.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    resid = R.getBitmapRes(context, "smssdk_input_bg_focus");
    countryNum.setBackgroundResource(resid);
    phoneLayout.addView(countryNum);

    LinearLayout wrapperLayout = new LinearLayout(context);
    LinearLayout.LayoutParams wrapperParams =
        new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
    wrapperParams.weight = 1;
    wrapperLayout.setLayoutParams(wrapperParams);
    resid = R.getBitmapRes(context, "smssdk_input_bg_special_focus");
    wrapperLayout.setBackgroundResource(resid);

    EditText writePhone = new EditText(context);
    writePhone.setId(Res.id.et_write_phone);
    LinearLayout.LayoutParams writePhoneParams =
        new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT);
    writePhoneParams.gravity = Gravity.CENTER_VERTICAL;
    writePhoneParams.setMargins(SizeHelper.fromPxWidth(10), 0, SizeHelper.fromPxWidth(10), 0);
    writePhoneParams.weight = 1;
    writePhone.setLayoutParams(writePhoneParams);
    writePhone.setBackgroundDrawable(null);
    resid = R.getStringRes(context, "smssdk_write_mobile_phone");
    writePhone.setHint(resid);
    writePhone.setInputType(InputType.TYPE_CLASS_PHONE);
    writePhone.setTextColor(0xff353535);
    writePhone.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    wrapperLayout.addView(writePhone);

    ImageView image = new ImageView(context);
    image.setId(Res.id.iv_clear);
    LinearLayout.LayoutParams imageParams =
        new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(24), SizeHelper.fromPxWidth(24));
    imageParams.gravity = Gravity.CENTER_VERTICAL;
    imageParams.rightMargin = SizeHelper.fromPxWidth(20);
    image.setLayoutParams(imageParams);
    resid = R.getBitmapRes(context, "smssdk_clear_search");
    image.setBackgroundResource(resid);
    image.setScaleType(ScaleType.CENTER_INSIDE);
    image.setVisibility(View.GONE);
    wrapperLayout.addView(image);
    phoneLayout.addView(wrapperLayout);
    parent.addView(phoneLayout);

    Button nextBtn = new Button(context);
    nextBtn.setId(Res.id.btn_next);
    LinearLayout.LayoutParams nextParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(72));
    nextParams.setMargins(
        SizeHelper.fromPxWidth(26), SizeHelper.fromPxWidth(36), SizeHelper.fromPxWidth(26), 0);
    nextBtn.setLayoutParams(nextParams);
    resid = R.getBitmapRes(context, "smssdk_btn_disenable");
    nextBtn.setBackgroundResource(resid);
    resid = R.getStringRes(context, "smssdk_next");
    nextBtn.setText(resid);
    nextBtn.setTextColor(0xffffffff);
    nextBtn.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25));
    nextBtn.setPadding(0, 0, 0, 0);
    parent.addView(nextBtn);
  }
Example #30
0
  private void createNewContactObject(String type, View my_contact_view) {
    if (my_contact_view == null) {
      my_contact_view = fragment_mycontact.getView();
    }

    if (my_contact_view == null) return;

    LinearLayout ll_data;
    List<String> list = new ArrayList<String>();
    int it = android.text.InputType.TYPE_CLASS_TEXT;
    int hint = 0;

    // Typen setzen:
    List<Integer> list_number = new ArrayList<Integer>();

    for (int i = 0; i < array_en_type.length; i++) {
      if (array_en_type[i].equals(type)) {
        list_number.add(i);
      }
    }

    for (int i = 0; i < list_number.size(); i++) {
      list.add((array_en_name[list_number.get(i)]));
    }

    final String[] spinnerArray = list.toArray(new String[list.size()]);

    // -----------

    LinearLayout ll_telephone =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_telephone);
    LinearLayout ll_email =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_email);
    LinearLayout ll_other =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_other);

    // new row
    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);

    DisplayMetrics tmp_metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(tmp_metrics);
    int resolution_width = tmp_metrics.widthPixels;

    final boolean large_screen = (resolution_width >= 720);

    final EditText et = new EditText(this);
    LayoutParams lp_et;
    lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);

    if (type.equals("number")) {
      ll_data = ll_telephone;

      it = InputType.TYPE_CLASS_PHONE;

      hint = R.string.telephone;

    } else if (type.equals("email")) {
      ll_data = ll_email;

      it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;

      hint = R.string.email;

    } else {
      ll_data = ll_other;

      if (type.equals("address")) {

        et.setMinLines(1);
        et.setMaxLines(3);
        et.setLines(2);

        hint = R.string.address;
        it =
            InputType.TYPE_CLASS_TEXT
                | InputType
                    .TYPE_TEXT_FLAG_MULTI_LINE; // android.text.InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS;
        lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, large_screen ? 130 : 90, 1);

        row.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT, (large_screen ? 130 : 90) + 20));

        et.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
        // et.setGravity(Gravity.LEFT | Gravity.TOP );

      } else if (type.equals("website")) {
        hint = R.string.website;
        it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      }
    }

    ((LinearLayout) ll_data.getParent()).setVisibility(LinearLayout.VISIBLE);

    et.setTextSize(large_screen ? 16 : 14); // EditText-Textgr��e
    et.setEms(10);
    et.setHint(hint);

    et.setInputType(it);

    lp_et.setMargins(0, 3, 0, 0);
    et.setLayoutParams(lp_et);

    Spinner spinner = new Spinner(this);
    LayoutParams lp_spinner =
        new LayoutParams(
            large_screen ? Functions.dpsToPx(this, 100) : Functions.dpsToPx(this, 80), /*300 : 200*/
            LayoutParams.MATCH_PARENT);

    lp_spinner.setMargins(0, 3, 0, 0);

    MySpinnerArrayAdapter dataAdapter = new MySpinnerArrayAdapter(this, list, large_screen);

    dataAdapter.setDropDownViewResource(
        android.support.v7.appcompat.R.layout.support_simple_spinner_dropdown_item);

    spinner.setAdapter(dataAdapter);
    spinner.setLayoutParams(lp_spinner);

    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(
              final AdapterView<?> adapterView, final View view, int arg2, long arg3) {
            final Spinner spinner = (Spinner) adapterView;
            MySpinnerArrayAdapter adapter = (MySpinnerArrayAdapter) spinner.getAdapter();
            if (adapter
                .getItem(arg2)
                .toLowerCase(new Locale("en"))
                .equals(getString(R.string.en_custom).toLowerCase(new Locale("en")))) {

              LinearLayout ll = new LinearLayout(MainActivity.this);
              final EditText et = new EditText(MainActivity.this);

              LinearLayout.LayoutParams layoutParams =
                  new LinearLayout.LayoutParams(
                      LinearLayout.LayoutParams.MATCH_PARENT,
                      LinearLayout.LayoutParams.WRAP_CONTENT);
              layoutParams.setMargins(0, 20, 0, 0);

              et.setTextColor(Color.BLACK);
              et.requestFocus();

              // et.setHint(R.string.place);

              ll.addView(et, layoutParams);

              AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
              builder
                  .setView(ll)
                  .setTitle(R.string.message_custom_en)
                  .setPositiveButton(
                      android.R.string.ok,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                          String[] newItems = new String[spinnerArray.length + 1];
                          System.arraycopy(spinnerArray, 0, newItems, 0, spinnerArray.length);
                          newItems[newItems.length - 1] = et.getText().toString();

                          MySpinnerArrayAdapter adapter =
                              new MySpinnerArrayAdapter(
                                  getApplicationContext(),
                                  newItems,
                                  ((MySpinnerArrayAdapter) spinner.getAdapter()).getLargeScreen());
                          spinner.setAdapter(adapter);
                          spinner.setSelection(newItems.length - 1);
                        }
                      })
                  .setNegativeButton(
                      android.R.string.cancel,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {}
                      })
                  .create()
                  .show();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    Button btn = new Button(this);
    btn.setText("x");
    LayoutParams lp_btn = new LayoutParams(Functions.dpsToPx(this, 32), LayoutParams.WRAP_CONTENT);
    lp_btn.setMargins(-10, 0, -10, 0);
    btn.setLayoutParams(lp_btn);
    btn.setBackgroundColor(Color.TRANSPARENT);

    btn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (((LinearLayout) v.getParent().getParent()).getChildCount() == 1) {
              ((LinearLayout) v.getParent().getParent().getParent()).setVisibility(View.GONE);
            }
            ((LinearLayout) v.getParent().getParent()).removeView((LinearLayout) v.getParent());
          }
        });

    row.addView(et);
    row.addView(spinner);
    row.addView(btn);

    row.setTag(type);

    ll_data.addView(row);
  }