Example #1
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.optRojo:
       etTexto.setBackgroundColor(Color.rgb(255, 0, 0));
       break;
     case R.id.optVerde:
       etTexto.setBackgroundColor(Color.rgb(0, 255, 0));
       break;
     case R.id.optAzul:
       etTexto.setBackgroundColor(Color.rgb(0, 0, 255));
       break;
   }
   return true;
 }
Example #2
0
 private void updateCurrentColor(int color) {
   String hexColorString =
       ConvertUtils.toColorString(color, false).toUpperCase(Locale.getDefault());
   hexValView.setText(hexColorString);
   hexValView.setTextColor(hexValDefaultColor);
   hexValView.setBackgroundColor(color);
 }
  @Override
  public void onActivityCreated(Bundle aSavedState) {
    super.onActivityCreated(aSavedState);

    setRetainInstance(true);

    mMessage.setBackgroundColor(mPrefs.postBackgroundColor);
    mMessage.setTextColor(mPrefs.postFontColor);

    mExtras = getExtras();
    mReplyType = mExtras.getInt(Constants.EDITING, getArguments().getInt(Constants.EDITING, -1));
    mPostId = mExtras.getInt(Constants.POST_ID, getArguments().getInt(Constants.POST_ID, -1));
    mThreadId = mExtras.getInt(Constants.THREAD_ID, getArguments().getInt(Constants.THREAD_ID, -1));
    if (mReplyType < 0
        || mThreadId < 0
        || (mReplyType != AwfulMessage.TYPE_NEW_REPLY && mPostId < 0)) {
      Log.e(TAG, "MISSING ARGUMENTS!");
      getActivity().finish();
    }

    ((AwfulActivity) getActivity()).registerSyncService(mMessenger, mThreadId);
    getActivity()
        .getSupportLoaderManager()
        .restartLoader(Constants.REPLY_LOADER_ID, null, mReplyDataCallback);
    getActivity()
        .getContentResolver()
        .registerContentObserver(AwfulMessage.CONTENT_URI_REPLY, true, mReplyDataCallback);

    if (((AwfulActivity) getActivity()).isTV()) {
      mTitle.setText(getString(R.string.post_reply));
      mSubmit.setOnClickListener(onSubmitClick);
    }
  }
Example #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;
 }
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 void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.codelayout);

    LinearLayout MyLinear = (LinearLayout) findViewById(R.id.mylinear);
    MyLinear.setOrientation(LinearLayout.HORIZONTAL);

    Button MyBtn = (Button) findViewById(R.id.mybutton);
    MyBtn.setTextSize(40);

    EditText MyEdit = (EditText) findViewById(R.id.myedit);
    MyEdit.setBackgroundColor(0xff00ff00);
  }
Example #7
0
  @Override
  public void onActivityCreated(Bundle aSavedState) {
    super.onActivityCreated(aSavedState);
    if (DEBUG) Log.e(TAG, "onActivityCreated");

    mMessage.setBackgroundColor(ColorProvider.getBackgroundColor());
    mMessage.setTextColor(ColorProvider.getTextColor());
    getActivity()
        .getContentResolver()
        .registerContentObserver(AwfulThread.CONTENT_URI, true, mThreadObserver);
    refreshLoader();
    refreshThreadInfo();
  }
Example #8
0
 public void setTheme(int theme) {
   if (theme == THEME_LIGHT) {
     if (mStyle == STYLE_CLASSIC) {
       mBackImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
       mVoiceImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
       mEmptyImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
     }
     mSeparatorView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_separator));
     mSuggestionsRecyclerView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mCardView.setCardBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mSearchEditText.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mSearchEditText.setTextColor(ContextCompat.getColor(mContext, R.color.search_light_text));
     mSearchEditText.setHintTextColor(
         ContextCompat.getColor(mContext, R.color.search_light_text_hint));
   }
   if (theme == THEME_DARK) {
     if (mStyle == STYLE_CLASSIC) {
       mBackImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
       mVoiceImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
       mEmptyImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
     }
     mSeparatorView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_separator));
     mSuggestionsRecyclerView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mCardView.setCardBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mSearchEditText.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mSearchEditText.setTextColor(ContextCompat.getColor(mContext, R.color.search_dark_text));
     mSearchEditText.setHintTextColor(
         ContextCompat.getColor(mContext, R.color.search_dark_text_hint));
   }
 }
Example #9
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;
          }
        });
  }
  @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();
  }
  // disable edittext fields editable after updating the profile
  public void setEditableOff(EditText et) {
    et.setLongClickable(false);
    et.setClickable(false);
    et.setCursorVisible(false);
    et.setTextColor(Color.parseColor("#000000"));
    et.setFocusable(false);
    et.setClickable(false);
    et.setEnabled(false);
    et.setFocusable(false);
    et.setFocusableInTouchMode(false);
    et.setBackgroundColor(Color.parseColor("#FEFEEB"));
    et.requestFocus();

    findViewById(R.id.labelSection).setLayoutParams(new LinearLayout.LayoutParams(0, 0, 0f));
    findViewById(R.id.editSection)
        .setLayoutParams(
            new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 0.7f));
  }
Example #12
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);
  }
Example #13
0
  /**
   * createLinearLayout() creates the linear layout with EditText and Spinner views.
   *
   * @param hintTxt
   * @param optionList
   * @return LinearLayout
   */
  public LinearLayout createLinearLayout(String hintTxt, List<String> optionList) {

    LinearLayout linLayout = new LinearLayout(mContext); // creating LinearLayout
    linLayout.setOrientation(LinearLayout.HORIZONTAL); // specifying horizontal orientation
    linLayout.setId(LINEAR_LAYOUT_ID); // set id
    linLayout.setBackgroundColor(Color.parseColor("#FFFFFF")); // set background color

    // Add EditText
    LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    EditText edtTxt = new EditText(mContext);
    edtTxt.setHint(hintTxt);
    edtTxt.setBackgroundColor(Color.WHITE);
    edtTxt.setLayoutParams(lpView);
    linLayout.addView(edtTxt);

    // Add Spinner
    Spinner spinner = new Spinner(mContext);
    setSpinner(spinner, optionList);
    linLayout.addView(spinner);

    // return the linearLayout
    return linLayout;
  }
  private void initScreenLayout() {

    /*
     * The following three command lines you can use depending upon the
     * emulator device you are using.
     */

    // 320 x 480 (Tall Display - HVGA-P) [default]
    // 320 x 240 (Short Display - QVGA-L)
    // 240 x 320 (Short Display - QVGA-P)

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);

    // this.showAlert(dm.widthPixels +" "+ dm.heightPixels, dm.widthPixels
    // +" "+ dm.heightPixels, dm.widthPixels +" "+ dm.heightPixels, false);

    int height = dm.heightPixels;
    int width = dm.widthPixels;

    if (height < 400 || width < 300) {
      txtCalc.setTextSize(20);
    }

    if (width < 300) {
      btnMC.setTextSize(18);
      btnMR.setTextSize(18);
      btnMP.setTextSize(18);
      btnMM.setTextSize(18);
      btnBS.setTextSize(18);
      btnDivide.setTextSize(18);
      btnPlus.setTextSize(18);
      btnMinus.setTextSize(18);
      btnMultiply.setTextSize(18);
      btnEquals.setTextSize(18);
      btnPM.setTextSize(18);
      btnPerc.setTextSize(18);
      btnC.setTextSize(18);
      btnSqrRoot.setTextSize(18);
      btnNine.setTextSize(18);
      btnEight.setTextSize(18);
      btnSeven.setTextSize(18);
      btnSix.setTextSize(18);
      btnFive.setTextSize(18);
      btnFour.setTextSize(18);
      btnThree.setTextSize(18);
      btnTwo.setTextSize(18);
      btnOne.setTextSize(18);
      btnZero.setTextSize(18);
      btnDecimal.setTextSize(18);
      expSQ.setTextSize(18);
      expEX.setTextSize(18);
      nbtn1.setTextSize(18);
      nbtn2.setTextSize(18);
      nbtn3.setTextSize(18);
      nbtn4.setTextSize(18);
      nbtn5.setTextSize(18);
      nbtn6.setTextSize(18);
      nbtn7.setTextSize(18);
    }

    txtCalc.setTextColor(Color.WHITE);
    txtCalc.setBackgroundColor(Color.BLACK);
    txtCalc.setKeyListener(null);

    btnZero.setTextColor(Color.WHITE);
    btnOne.setTextColor(Color.WHITE);
    btnTwo.setTextColor(Color.WHITE);
    btnThree.setTextColor(Color.WHITE);
    btnFour.setTextColor(Color.WHITE);
    btnFive.setTextColor(Color.WHITE);
    btnSix.setTextColor(Color.WHITE);
    btnSeven.setTextColor(Color.WHITE);
    btnEight.setTextColor(Color.WHITE);
    btnNine.setTextColor(Color.WHITE);
    btnPM.setTextColor(Color.WHITE);
    btnDecimal.setTextColor(Color.WHITE);

    btnMP.setTextColor(Color.WHITE);
    btnMM.setTextColor(Color.WHITE);
    btnMR.setTextColor(Color.WHITE);
    btnMC.setTextColor(Color.WHITE);
    btnBS.setTextColor(Color.WHITE);
    btnC.setTextColor(Color.WHITE);
    btnPerc.setTextColor(Color.WHITE);
    btnSqrRoot.setTextColor(Color.WHITE);
    btnDivide.setTextColor(Color.WHITE);
    btnPlus.setTextColor(Color.WHITE);
    btnMinus.setTextColor(Color.WHITE);
    btnMultiply.setTextColor(Color.WHITE);
    btnEquals.setTextColor(Color.WHITE);
    expSQ.setTextColor(Color.WHITE);
    expEX.setTextColor(Color.WHITE);

    nbtn1.setTextColor(Color.WHITE);
    nbtn2.setTextColor(Color.WHITE);
    nbtn3.setTextColor(Color.WHITE);
    nbtn4.setTextColor(Color.WHITE);
    nbtn5.setTextColor(Color.WHITE);
    nbtn6.setTextColor(Color.WHITE);
    nbtn7.setTextColor(Color.WHITE);
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle SavedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_new_photo, parent, false);
    header = (ViewGroup) inflater.inflate(R.layout.item_header, postHashtags, false);

    photoFile = null;
    videoFile = null;

    postHashtags = (ListView) v.findViewById(R.id.post_hashtags);

    postTags = (RelativeLayout) v.findViewById(R.id.post_tags);
    postVisual = (RelativeLayout) v.findViewById(R.id.post_visual);
    postImage = (ImageView) v.findViewById(R.id.post_image);
    postDeny = (ImageButton) v.findViewById(R.id.post_deny);
    postAccept = (ImageButton) v.findViewById(R.id.post_accept);

    adapter =
        new PostAdapter<String>(
            getActivity().getApplicationContext(),
            R.layout.item_list_hashtags,
            R.id.text1,
            hashtags,
            this);
    try {
      postHashtags.addHeaderView(header, null, false);
    } catch (Exception e) {
    }
    postHashtags.setAdapter(adapter);

    adapter.notifyDataSetChanged();

    cautionHeader = (LinearLayout) header.findViewById(R.id.post_caution_container);
    cautionHeader.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            removeAllBadHashtags();
          }
        });

    int[] rainbow =
        getActivity().getApplicationContext().getResources().getIntArray(R.array.colorPicker);
    Random rn = new Random();
    int picker = rn.nextInt(rainbow.length);

    /**
     * suggestedHeader = (RelativeLayout) header.findViewById(R.id.post_suggested);
     * suggestedHeader.setBackgroundColor(rainbow[rn.nextInt(rainbow.length)]);
     * suggestedHeader.setOnClickListener(new View.OnClickListener() { @Override public void
     * onClick(View v) {
     *
     * <p>hideKeyboard(); mCallback.onSuggestions(); } });*
     */

    // yep
    // Accept or deny photo
    Drawable dDeny = getResources().getDrawable(R.drawable.icon_exit_c);
    dDeny.setColorFilter(rainbow[picker], PorterDuff.Mode.SRC_ATOP);
    postDeny.setImageDrawable(dDeny);
    postDeny.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            mCallback.onTransitionFromPostion(getArguments().getBoolean("from_camera", true));
            photoFile = null;
            videoFile = null;
          }
        });

    Drawable dAccept = getResources().getDrawable(R.drawable.icon_checkmark_c);
    dAccept.setColorFilter(rainbow[picker], PorterDuff.Mode.SRC_ATOP);
    postAccept.setImageDrawable(dAccept);
    postAccept.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            Bitmap data = getArguments().getParcelable("image");
            String videoPath = getArguments().getString("video", null);
            if (data != null) {
              saveScaledPhoto(data, videoPath);
              hideImage();
            }
          }
        });

    postCancel = (Button) v.findViewById(R.id.post_cancel);
    postCancel.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            showImage();
          }
        });

    // Hashtags
    postText = ((EditText) v.findViewById(R.id.post_text));
    postText.setBackgroundColor(rainbow[picker]);
    postText.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) {}

          @Override
          public void afterTextChanged(Editable s) {

            if (postText.length() > 0 && s.toString().contains(" ")) {
              String hashing = String.valueOf(postText.getText());
              postText.setText("");
              checkHashtag(hashing);
            }
          }
        });
    postText.setOnEditorActionListener(
        new EditText.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              if (postText.length() > 0) {
                String hashing = String.valueOf(postText.getText());
                postText.setText("");
                checkHashtag(hashing);
                return true;
              }
            }
            return false;
          }
        });

    postText.setFocusableInTouchMode(true);
    postText.requestFocus();
    InputMethodManager imm =
        (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(postText, InputMethodManager.SHOW_IMPLICIT);
    postText.setCursorVisible(true);

    int[] rainbowa =
        getActivity().getApplicationContext().getResources().getIntArray(R.array.colorPicker);
    Random rna = new Random();
    int pickera = rn.nextInt(rainbow.length);

    postDoneContainer = ((LinearLayout) header.findViewById(R.id.post_done_container));
    postDoneContainer.setBackgroundColor(rainbow[rn.nextInt(rainbow.length)]);
    postDoneContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            postDoneContainer.setEnabled(false);
            String hashing = String.valueOf(postText.getText());
            postText.setText("");
            checkHashtag(hashing);

            // Saving Hashtags
            ArrayList<String> cleanHashtags = cleanHashtags(hashtags);

            Hashtag hashtag = new Hashtag();

            for (int i = 0; i < cleanHashtags.size(); i++) {
              String hash = (String) cleanHashtags.get(i);
              hashtag.saveHashtag(hash); //
            }

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

            // Saving Selfie
            Selfie selfie = new Selfie();

            ParseObject location = ParseUser.getCurrentUser().getParseObject("location");

            if (photoFile == null) {
              Toast.makeText(
                      getActivity(), "Error saving: Not going to save properly", Toast.LENGTH_LONG)
                  .show();
            }

            if (videoFile != null) {
              selfie.setNewSelfie(
                  photoFile, ParseUser.getCurrentUser(), location, cleanHashtags, videoFile);
            } else {
              selfie.setNewSelfie(
                  photoFile, ParseUser.getCurrentUser(), location, cleanHashtags, null);
            }

            // Save the meal and return
            selfie.saveInBackground(
                new SaveCallback() {

                  @Override
                  public void done(ParseException e) {
                    if (e == null) {
                    } else {
                      Log.d("Error saving: ", e.getMessage());
                    }
                  }
                });
            postDoneContainer.setEnabled(true);
            mCallback.onHideFragment();
          }
        });

    postHashtags.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(postText.getWindowToken(), 0);
            postText.setCursorVisible(false);
            String hashing = String.valueOf(postText.getText());
            postText.setText("");
            checkHashtag(hashing);

            return false;
          }
        });

    v.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(postText.getWindowToken(), 0);
            postText.setCursorVisible(false);
            String hashing = String.valueOf(postText.getText());
            postText.setText("");
            checkHashtag(hashing);
            return false;
          }
        });

    adapter.registerDataSetObserver(
        new DataSetObserver() {
          @Override
          public void onChanged() {
            super.onChanged();
            setPlaceholder();
          }
        });

    checkHeader();

    return v;
  }
Example #16
0
        public void afterTextChanged(Editable s) {
          String inputTxt = txt.getText().toString().toLowerCase();

          String brightString = inputTxt;
          String colorString = "";
          int groupPosition;
          int count = 0;
          int countB = 0;

          expandAll();

          // fel, kolla en bool typ, om checkText = true;
          System.out.println("click: " + click);
          if (click == true) {
            click = false;
            return;
          }

          // check if the text contains a /
          if (inputTxt.contains("/") && inputTxt.length() > 1) {
            String[] separated = inputTxt.split("/");

            if (inputTxt.startsWith("/")) {
              brightString = separated[1];
              colorString = "";

              if (separated.length > 2) {
                brightString = separated[1];
                colorString = separated[2];
              }
            } else {
              if (separated.length > 1) {
                brightString = separated[0];
                colorString = separated[1];
              } else {
                brightString = separated[0];
                colorString = "";
              }
            }
          }

          // System.out.println("brString: " + brightString);
          // System.out.println("colString: " + colorString);

          // check the header
          for (int i = 0; i < listAdapter.getGroupCount(); i++) {

            // get the group header
            Brightness headerInfo = brightList.get(i);

            if (headerInfo.getName().startsWith(brightString)) {

              groupPosition = brightList.indexOf(headerInfo);
              txt.setBackgroundColor(android.graphics.Color.WHITE);
              countB = 1;

              // loop through the children
              for (int j = 0; j < headerInfo.getColorList().size(); j++) {

                // get the child info
                Color childInfo = headerInfo.getColorList().get(j);

                if (childInfo.getName().startsWith(colorString) && colorString.length() > 0) {

                  // expand other groups
                  collapseAll(groupPosition);
                  count = 1;

                  // check if the whole word is typed
                  if (colorString.contains(childInfo.getName())) {

                    index =
                        myList.getFlatListPosition(
                            ExpandableListView.getPackedPositionForChild(i, j));
                    myList.setItemChecked(index, true);
                  }
                }
              }

              if (count == 0 && colorString.length() > 0) {
                txt.setBackgroundColor(android.graphics.Color.RED);
                myList.setItemChecked(index, false);
                return;
              }
            }
            if (countB == 0 && brightString.length() > 0) {
              if (brightString.startsWith("/"))
                txt.setBackgroundColor(android.graphics.Color.WHITE);
              else txt.setBackgroundColor(android.graphics.Color.RED);
            }
          }
        }
Example #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addcar);
    // wzemame podadenata poziciq podadena ot Spisyka
    Bundle extras = getIntent().getExtras();
    int NumbPosition = 0;
    if (extras != null) {
      NumbPosition = extras.getInt("N_Item");
      // NumbPosition = extras.getString("name");
      // and get whatever type user account id is
    }
    DBOperations dbOperations = new DBOperations(this);
    try {
      dbOperations.open();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    ArrayList<CarItem> temp = new ArrayList<CarItem>();
    temp = dbOperations.getAllCars();
    CarItem theItem = temp.get(NumbPosition);
    // VIZUALIZACIQ I ZAKLUCHWANE
    Button SaveB = (Button) findViewById(R.id.saveb);
    SaveB.setVisibility(View.GONE); // View.VISIBLE  View.INVISIBLE
    final TextView Caption = (TextView) findViewById(R.id.textView2);
    Caption.setText("Car Data");
    final EditText textRNUMBER = (EditText) findViewById(R.id.textRNUMBER);
    final EditText textBRAND = (EditText) findViewById(R.id.textBRAND);
    final EditText textMODEL = (EditText) findViewById(R.id.textMODEL);
    final EditText textYEARPR = (EditText) findViewById(R.id.textYEARPR);
    final EditText textENUMBER = (EditText) findViewById(R.id.textENUMBER);
    final EditText textBNUMBER = (EditText) findViewById(R.id.textBNUMBER);
    // final EditText textCOLOR=(EditText) findViewById(R.id.textCOLOR);
    final Spinner spiner = (Spinner) findViewById(R.id.textCOLOR);
    spiner.setVisibility(View.GONE);

    final EditText Spinner = (EditText) findViewById(R.id.editTextSPINER);
    Spinner.setText(theItem.getCColor());
    Spinner.setVisibility(View.VISIBLE);
    Spinner.setEnabled(false);
    Spinner.setTextColor(Color.LTGRAY);
    Spinner.setBackgroundColor(Color.TRANSPARENT);

    final EditText textCUBICS = (EditText) findViewById(R.id.textCUBICS);
    final EditText textINFO = (EditText) findViewById(R.id.textINFO);
    final EditText textOWNER = (EditText) findViewById(R.id.textOWNER);
    final EditText textPHONE = (EditText) findViewById(R.id.textPHONE);

    textRNUMBER.setEnabled(false);
    textBRAND.setEnabled(false);
    textMODEL.setEnabled(false);
    textYEARPR.setEnabled(false);
    textENUMBER.setEnabled(false);
    textBNUMBER.setEnabled(false);
    textCUBICS.setEnabled(false);
    textINFO.setEnabled(false);
    // textINFO.setTextColor(Color.LTGRAY);

    textOWNER.setEnabled(false);
    textPHONE.setEnabled(false);

    textRNUMBER.setBackgroundColor(Color.TRANSPARENT);
    textBRAND.setBackgroundColor(Color.TRANSPARENT);
    textMODEL.setBackgroundColor(Color.TRANSPARENT);
    textYEARPR.setBackgroundColor(Color.TRANSPARENT);
    textENUMBER.setBackgroundColor(Color.TRANSPARENT);
    textBNUMBER.setBackgroundColor(Color.TRANSPARENT);
    textCUBICS.setBackgroundColor(Color.TRANSPARENT);
    textINFO.setBackgroundColor(Color.TRANSPARENT);
    textOWNER.setBackgroundColor(Color.TRANSPARENT);
    textPHONE.setBackgroundColor(Color.TRANSPARENT);

    textRNUMBER.setText(theItem.getRegNumber());
    textBRAND.setText(theItem.getBrand());
    textMODEL.setText(theItem.getModel());
    textYEARPR.setText(String.valueOf(theItem.getYearProd()));
    textENUMBER.setText(theItem.getEngNumber());
    textBNUMBER.setText(theItem.getBdyNumber());
    textCUBICS.setText(String.valueOf(theItem.getCubics()));
    textINFO.setText(theItem.getInfo());
    textOWNER.setText(theItem.getOwner());
    textPHONE.setText(theItem.getPhone());

    ImageButton btnBack = (ImageButton) findViewById(R.id.imageButton2);
    btnBack.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
  }
Example #18
0
 /**
  * Set Background color of View.
  *
  * @param color The background color of view.
  */
 @Override
 public void setBackgroundColor(int color) {
   super.setBackgroundColor(color);
   mBackgroundColor = color;
 }
  @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);
  }
Example #20
0
  /** Wird der Button suchen gedrückt wird ein Event ausgelöst der eine neue Activity startet */
  public void onClick(View arg0) {
    if (arg0 == suchen) {
      Intent in = new Intent(GastFrageSicht.this, CamNavSicht.class);
      if (choice == 1) {
        try {
          // kontrolliere ob die Nummer auch stimmt, wenn ja gib sie weiter an
          // die nächste Activity und starte sie
          if (h.beuthCheck(text.getText().toString())) {
            in.putExtra("Nummer", text.getText().toString());
            startActivity(in);
          } else {
            // Dialog Fehler
            if (KontoControl.getSPRACHE().equals("english")) {
              Toast toast =
                  Toast.makeText(this, "Sorry, this room does not exist!", Toast.LENGTH_SHORT);
              toast.show();
            } else {
              Toast toast =
                  Toast.makeText(
                      this, "Tut mir leid. Diesen Raum gibt es nicht!", Toast.LENGTH_SHORT);
              toast.show();
            }
          }
        } catch (StringIndexOutOfBoundsException e) {
          if (KontoControl.getSPRACHE().equals("english")) {
            Toast toast = Toast.makeText(this, "No room number was entered.", Toast.LENGTH_SHORT);
            toast.show();
          } else {
            Toast toast =
                Toast.makeText(this, "Es wurde keine Raumnummer eingegeben.", Toast.LENGTH_SHORT);
            toast.show();
          }
        }
      }

      if (choice == 2) {
        in.putExtra("Nummer", spinVorlesung.getSelectedItem().toString());
        startActivity(in);
      }

      if (choice == 3) {
        if (!spinBeRaeume.getSelectedItem().toString().equals("Keine")) {
          in.putExtra("Nummer", spinBeRaeume.getSelectedItem().toString());
          startActivity(in);
        } else {
          // Dialog Fehler
          if (KontoControl.getSPRACHE().equals("english")) {
            Toast toast = Toast.makeText(this, "There are no special rooms.", Toast.LENGTH_SHORT);
            toast.show();
          } else {
            Toast toast =
                Toast.makeText(this, "Keine besonderen Räume vorhanden.", Toast.LENGTH_SHORT);
            toast.show();
          }
        }
      }
    }

    if (arg0 == hausSwitcher) {
      if (index == 1) {
        hausSwitcher.setDisplayedChild(1);
        index = 0;
      } else {
        hausSwitcher.setDisplayedChild(0);
        index = 1;
      }
    }

    if (arg0 == r1) {
      r1.setBackgroundResource(R.drawable.radio_button_an);
      text.setBackgroundColor(Color.WHITE);
      spinZeit.setEnabled(false);
      spinVorlesung.setEnabled(false);
      spinBeRaeume.setEnabled(false);
      r2.setBackgroundResource(R.drawable.radio_button_aus);
      r3.setBackgroundResource(R.drawable.radio_button_aus);
      choice = 1;
    }

    if (arg0 == r2) {
      r2.setBackgroundResource(R.drawable.radio_button_an);
      text.setBackgroundColor(Color.DKGRAY);
      spinZeit.setEnabled(true);
      spinVorlesung.setEnabled(true);
      spinBeRaeume.setEnabled(false);
      r1.setBackgroundResource(R.drawable.radio_button_aus);
      r3.setBackgroundResource(R.drawable.radio_button_aus);
      choice = 2;
    }

    if (arg0 == r3) {
      r3.setBackgroundResource(R.drawable.radio_button_an);
      text.setBackgroundColor(Color.DKGRAY);
      spinZeit.setEnabled(false);
      spinVorlesung.setEnabled(false);
      spinBeRaeume.setEnabled(true);
      r1.setBackgroundResource(R.drawable.radio_button_aus);
      r2.setBackgroundResource(R.drawable.radio_button_aus);
      choice = 3;
    }
  }
Example #21
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;
          }
        });
  }