Esempio n. 1
0
  @Override
  public void initButtons() {
    ImageButton take_picture = new ImageButton(a);
    take_picture.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    take_picture.setPadding(0, 0, 0, 0);
    take_picture.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            ((FragmentListener) a).doWait(true);

            cover_image_file = new File(DUMP, "temp_img.jpg");
            cover_image_uri = Uri.fromFile(cover_image_file);
            path_to_cover_image = cover_image_file.getAbsolutePath();
            Intent cameraIntent =
                new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                    .putExtra(MediaStore.EXTRA_OUTPUT, cover_image_uri);
            startActivityForResult(cameraIntent, Source.CAMERA);
          }
        });
    take_picture.setImageResource(R.drawable.camera_selector);

    ImageButton choose_picture = new ImageButton(a);
    choose_picture.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    choose_picture.setPadding(0, 0, 0, 0);
    choose_picture.setOnClickListener(choose_picture_listener);
    choose_picture.setImageResource(R.drawable.gallery_selector);

    ((FragmentListener) a).setButtonOptions(new ImageButton[] {take_picture, choose_picture});
  }
  public void initUI() {

    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    Context context = parent.getContext();
    ILayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
      createFeatureButton = new ImageButton(context);
      createFeatureButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      createFeatureButton.setBackground(
          Compat.getDrawable(context, R.drawable.editing_create_line));
      createFeatureButton.setPadding(0, padding, 0, padding);
      createFeatureButton.setOnClickListener(this);
      createFeatureButton.setOnTouchListener(this);
      parent.addView(createFeatureButton);

      selectEditableButton = new ImageButton(context);
      selectEditableButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      selectEditableButton.setBackground(
          Compat.getDrawable(context, R.drawable.editing_select_editable));
      selectEditableButton.setPadding(0, padding, 0, padding);
      selectEditableButton.setOnClickListener(this);
      selectEditableButton.setOnTouchListener(this);
      parent.addView(selectEditableButton);
    }

    selectAllButton = new ImageButton(context);
    selectAllButton.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.editing_select_all));
    selectAllButton.setPadding(0, padding, 0, padding);
    selectAllButton.setOnClickListener(this);
    selectAllButton.setOnTouchListener(this);
    parent.addView(selectAllButton);

    if (editLayer != null) {
      undoButton = new ImageButton(context);
      undoButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      undoButton.setBackground(Compat.getDrawable(context, R.drawable.editing_undo));
      undoButton.setPadding(0, padding, 0, padding);
      undoButton.setOnTouchListener(this);
      undoButton.setOnClickListener(this);
      parent.addView(undoButton);
      undoButton.setVisibility(View.GONE);

      commitButton = new ImageButton(context);
      commitButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      commitButton.setBackground(Compat.getDrawable(context, R.drawable.editing_commit));
      commitButton.setPadding(0, padding, 0, padding);
      commitButton.setOnTouchListener(this);
      commitButton.setOnClickListener(this);
      parent.addView(commitButton);
      commitButton.setVisibility(View.GONE);
    }
  }
Esempio n. 3
0
  @Override
  public View getView(Context context) {

    l = new LinearLayout(context);

    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    l.setLayoutParams(params);

    b = new ImageButton(context);
    b.setLayoutParams(params);
    b.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            ImageButtonModifier.this.onClick();
          }
        });
    b.setImageResource(myText);

    if (getTheme() != null) getTheme().applyNormal1(b);

    int p = 6;
    b.setPadding(p, p, p, p);

    l.addView(b);
    int p2 = 2;
    l.setPadding(p2, p2, p2, p2);

    return l;
  }
Esempio n. 4
0
    void update(final Task item) {
      task = item;
      int position = getPosition(item);
      Optional<?> thisHeader = groupFunction.apply(task);
      if (position >= 0 && thisHeader.isPresent()) {
        if (position == 0 || !thisHeader.equals(groupFunction.apply(getItem(position - 1)))) {
          header.setVisibility(View.VISIBLE);
          headerUnderline.setVisibility(View.VISIBLE);
          header.setText(thisHeader.get().toString());
        } else {
          header.setVisibility(View.GONE);
          headerUnderline.setVisibility(View.GONE);
        }
      } else {
        header.setVisibility(View.GONE);
        headerUnderline.setVisibility(View.GONE);
      }

      configureText(item);
      configureTimeText(item);
      configureStatus();
      textTitle.setClickable(isEditMode());
      textTime.setClickable(isEditMode());
      if (isSelected()) {
        this.convertView.setBackgroundColor(Color.rgb(50, 50, 50));
      } else {
        this.convertView.setBackgroundColor(
            getContext().getResources().getColor(android.R.color.background_dark));
      }
      if (canShowLevel()) {
        doneStatus.setPadding(task.getMasterTasks().size() * 32 + 5, 0, 5, 0);
      }
    }
Esempio n. 5
0
 public cl(Activity activity, int i) {
   super(activity);
   oe = activity;
   setOnClickListener(this);
   oP = new ImageButton(activity);
   oP.setImageResource(0x1080017);
   oP.setBackgroundColor(0);
   oP.setOnClickListener(this);
   oP.setPadding(0, 0, 0, 0);
   int k = eu.a(activity, i);
   addView(oP, new android.widget.FrameLayout.LayoutParams(k, k, 17));
 }
  /**
   * Constructs a layout for the specified InfoBar. After calling this, be sure to set the message,
   * the buttons, and/or the custom content using setMessage(), setButtons(), and
   * setCustomContent().
   *
   * @param context The context used to render.
   * @param infoBarView InfoBarView that listens to events.
   * @param iconResourceId ID of the icon to use for the InfoBar.
   * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
   * @param message The message to show in the infobar.
   */
  public InfoBarLayout(
      Context context,
      InfoBarView infoBarView,
      int iconResourceId,
      Bitmap iconBitmap,
      CharSequence message) {
    super(context);
    mInfoBarView = infoBarView;

    // Grab the dimensions.
    Resources res = getResources();
    mMargin = res.getDimensionPixelOffset(R.dimen.infobar_margin);
    mIconSize = res.getDimensionPixelSize(R.dimen.infobar_icon_size);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mMargin, mMargin, mMargin, mMargin);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mMargin, -mMargin, -mMargin));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
      mIconView = new ImageView(context);
      if (iconResourceId != 0) {
        mIconView.setImageResource(iconResourceId);
      } else if (iconBitmap != null) {
        mIconView.setImageBitmap(iconBitmap);
      }
      mIconView.setLayoutParams(new LayoutParams(0, 0, mMargin / 2, 0));
      mIconView.getLayoutParams().width = mIconSize;
      mIconView.getLayoutParams().height = mIconSize;
      mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageTextView = (TextView) LayoutInflater.from(context).inflate(R.layout.infobar_text, null);
    mMessageTextView.setText(message, TextView.BufferType.SPANNABLE);
    mMessageTextView.setMovementMethod(LinkMovementMethod.getInstance());
    mMessageTextView.setLinkTextColor(mAccentColor);
    mMessageView = mMessageTextView;
  }
Esempio n. 7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cameraview);

    // image = (ImageView) findViewById(R.id.image);
    preview = (SurfaceView) findViewById(R.id.surface);

    previewHolder = preview.getHolder();
    previewHolder.addCallback(surfaceCallback);
    previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    previewHolder.setFixedSize(
        getWindow().getWindowManager().getDefaultDisplay().getWidth(),
        getWindow().getWindowManager().getDefaultDisplay().getHeight());

    nextButton = (ImageButton) findViewById(R.id.validateButton);
    nextButton.setBackgroundColor(Color.TRANSPARENT);
    nextButton.setPadding(0, 0, 0, 0);

    nextButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            //				finishActivity(1);
            camera.takePicture(null, null, photoCallback);
            //				finish();
          }
        });

    String maskPath = getIntent().getStringExtra("maskPath");
    try {
      // URL url = getClass().getResource("/assets/" + maskPath);
      File file = new File(maskPath);

      //    		String path = getFilesDir().getAbsolutePath() + "/assets/" + maskPath;
      //			URL url = new URL(path);
      //			Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
      FileInputStream stream = new FileInputStream(file);
      Bitmap bmp = BitmapFactory.decodeStream(stream);
      imageView = (ImageView) findViewById(R.id.imageView);
      imageView.setImageBitmap(bmp);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.out.println("unable to read file : " + e.toString());
    }
  }
  @Override
  public void addCustomActionButton(Drawable drawable, OnClickListener listener) {
    Resources resources = getResources();

    // The height will be scaled to match spec while keeping the aspect ratio, so get the scaled
    // width through that.
    int sourceHeight = drawable.getIntrinsicHeight();
    int sourceScaledHeight = resources.getDimensionPixelSize(R.dimen.toolbar_icon_height);
    int sourceWidth = drawable.getIntrinsicWidth();
    int sourceScaledWidth = sourceWidth * sourceScaledHeight / sourceHeight;
    int minPadding = resources.getDimensionPixelSize(R.dimen.min_toolbar_icon_side_padding);

    int sidePadding = Math.max((2 * sourceScaledHeight - sourceScaledWidth) / 2, minPadding);
    int topPadding = mCustomActionButton.getPaddingTop();
    int bottomPadding = mCustomActionButton.getPaddingBottom();
    mCustomActionButton.setPadding(sidePadding, topPadding, sidePadding, bottomPadding);
    mCustomActionButton.setImageDrawable(drawable);

    mCustomActionButton.setOnClickListener(listener);
    mCustomActionButton.setVisibility(VISIBLE);
  }
Esempio n. 9
0
  @Override
  public void initData() {
    right1.setPadding(45, 50, 45, 50);
    getFooterButton(0)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                new Thread(
                        new Runnable() {

                          @Override
                          public void run() {
                            mHandler.sendEmptyMessage(UPDATE_CONTENT_1);
                          }
                        })
                    .start();
              }
            });

    getFooterButton(1)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                new Thread(
                        new Runnable() {

                          @Override
                          public void run() {
                            mHandler.sendEmptyMessage(UPDATE_CONTENT_2);
                          }
                        })
                    .start();
              }
            });

    getFooterButton(2)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                new Thread(
                        new Runnable() {

                          @Override
                          public void run() {
                            mHandler.sendEmptyMessage(UPDATE_CONTENT_3);
                          }
                        })
                    .start();
              }
            });

    getFooterButton(3)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                new Thread(
                        new Runnable() {

                          @Override
                          public void run() {
                            mHandler.sendEmptyMessage(UPDATE_CONTENT_4);
                          }
                        })
                    .start();
              }
            });

    right1.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent(MainActivity.this, GroupChatActivity.class));
          }
        });
  }
Esempio n. 10
0
  private void init(Context context) {
    int width = (int) context.getResources().getDimension(R.dimen.title_button_width);
    LayoutParams leftLayoutParams = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    imgLeft = new ImageButton(context);
    imgLeft.setId(R.id.common_title_left_img);
    imgLeft.setPadding(padding, padding, padding, padding);
    imgLeft.setLayoutParams(leftLayoutParams);
    imgLeft.setScaleType(ScaleType.CENTER_INSIDE);
    imgLeft.setBackgroundResource(R.drawable.b_button);
    imgLeft.setOnClickListener(this);
    if (leftDrawable == null && TextUtils.isEmpty(leftText)) {
      imgLeft.setImageResource(R.drawable.backarrow);
      imgLeft.setContentDescription("Back");
    } else {
      imgLeft.setImageDrawable(leftDrawable);
    }

    LayoutParams leftLayoutParams2 =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    btnLeft = new Button(context);
    btnLeft.setId(R.id.common_title_left_txt);
    btnLeft.setTextColor(getResources().getColor(R.color.blue));
    btnLeft.setLayoutParams(leftLayoutParams2);
    btnLeft.setMinimumWidth(width);
    btnLeft.setBackgroundResource(R.drawable.b_button);
    btnLeft.setOnClickListener(this);
    if (!TextUtils.isEmpty(leftText)) {
      btnLeft.setText(leftText);
    } else {
      btnLeft.setVisibility(View.INVISIBLE);
    }

    LayoutParams rightLayoutParams = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    rightLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    imgRight = new ImageButton(context);
    imgRight.setId(R.id.common_title_right_img);
    imgRight.setPadding(padding, padding, padding, padding);
    imgRight.setLayoutParams(rightLayoutParams);
    imgRight.setScaleType(ScaleType.CENTER_INSIDE);
    imgRight.setBackgroundResource(R.drawable.b_button);
    if (rightDrawable != null) {
      imgRight.setImageDrawable(rightDrawable);
    } else {
      imgRight.setVisibility(View.INVISIBLE);
    }

    LayoutParams rightLayoutParams2 =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    rightLayoutParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    btnRight = new Button(context);
    btnRight.setId(R.id.common_title_right_txt);
    btnRight.setTextColor(getResources().getColor(R.color.blue));
    btnRight.setLayoutParams(rightLayoutParams2);
    btnRight.setMinimumWidth(width);
    btnRight.setBackgroundResource(R.drawable.b_button);
    if (!TextUtils.isEmpty(rightText)) {
      btnRight.setText(rightText);
    } else {
      btnRight.setVisibility(View.INVISIBLE);
    }

    LayoutParams titleLayoutParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    titleLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.common_title_left_img);
    titleLayoutParams.addRule(RelativeLayout.LEFT_OF, R.id.common_title_right_img);
    txtTitle = new TextView(context);
    txtTitle.setId(R.id.common_title_title_txt);
    txtTitle.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.font_size_large_x));
    txtTitle.setLayoutParams(titleLayoutParams);
    txtTitle.setTextColor(getResources().getColor(R.color.blue));
    txtTitle.setBackgroundColor(0x00000000);
    txtTitle.setSingleLine();
    txtTitle.setEllipsize(TruncateAt.MARQUEE);
    txtTitle.setGravity(Gravity.CENTER);
    txtTitle.setSelected(true);
    if (title == null) {
      txtTitle.setText("");
    } else {
      txtTitle.setText(title);
    }

    LayoutParams divisionLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 2);
    divisionLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    View division = new View(context);
    division.setLayoutParams(divisionLayoutParams);
    division.setBackgroundColor(getResources().getColor(R.color.gray_division));
    this.addView(imgLeft);
    this.addView(btnLeft);
    this.addView(txtTitle);
    this.addView(imgRight);
    this.addView(btnRight);
    this.addView(division);
    setBackgroundColor(0xffffffff);
  }
Esempio n. 11
0
  // Draws the Events
  private void drawEvents() {

    int counter = 0;
    layout.removeAllViews();
    for (JSONObject j : events) {
      try {
        final String eid = j.getString("eid");
        final String name = j.getString("name");
        final int icon = j.getInt("icon");
        final int creator = j.getInt("creator");
        String update = j.getString("updated");
        final String temp = j.getString("datetime");
        String month = temp.substring(5, 7);
        String day = temp.substring(8, 10);
        String date = day + '-' + month;

        RelativeLayout.LayoutParams lp_icon = new RelativeLayout.LayoutParams(height, height);
        RelativeLayout.LayoutParams lp_button = new RelativeLayout.LayoutParams(width, height);
        RelativeLayout.LayoutParams lp_date = new RelativeLayout.LayoutParams(dateWidth, height);
        RelativeLayout.LayoutParams lp_div = new RelativeLayout.LayoutParams(width, divHeight);

        /**
         * Adds the icon: to limit the use of data we store the images in a local database, and in
         * an online database. Whenever someone uploads a new icon a new random icon_ID gets
         * generated when the icon_ID in your local DB doesn't equal the one in the online database,
         * the one in the online DB gets downloaded and the offline DB gets updated with this EID
         * and image.
         */
        lp_icon.setMargins(0, (height + divHeight) * counter, 0, 0);
        final ImageButton img = new ImageButton(this);
        if (icon == 0) {
          img.setImageResource(R.drawable.group);
          img.setPadding(12, 12, 12, 12);
          user_db.deleteBlob(eid);
        } else {
          if (icon == user_db.getVersion(eid)) {
            byte[] image = user_db.getBlob(eid);
            img.setImageBitmap(BitmapFactory.decodeByteArray(image, 0, image.length));
            img.setPadding(7, 7, 7, 7);
          } else {
            String tag_icon = "req_icon";
            StringRequest stringRequest =
                new StringRequest(
                    Request.Method.POST,
                    URL_ICON,
                    new Response.Listener<String>() {

                      @Override
                      public void onResponse(String response) {
                        try {
                          JSONObject jObj = new JSONObject(response);
                          boolean error = jObj.getBoolean("error");

                          if (!error) {
                            byte[] blob = Base64.decode(jObj.getString("blob"), Base64.DEFAULT);
                            if (user_db.getVersion(eid) == 0) {
                              user_db.addBLOB(eid, icon, blob);
                            } else {
                              user_db.updateBlob(eid, icon, blob);
                            }
                            img.setImageBitmap(BitmapFactory.decodeByteArray(blob, 0, blob.length));
                            img.setPadding(7, 7, 7, 7);
                          }
                        } catch (JSONException e) {
                          e.printStackTrace();
                        }
                      }
                    },
                    new Response.ErrorListener() {

                      @Override
                      public void onErrorResponse(VolleyError error) {}
                    }) {

                  @Override
                  protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("tag", "get");
                    params.put("eid", eid);
                    return params;
                  }
                };
            AppController.getInstance().addToRequestQueue(stringRequest, tag_icon);
          }
        }
        img.setLayoutParams(lp_icon);
        img.setBackground(null);
        img.setScaleType(ImageView.ScaleType.FIT_CENTER);
        layout.addView(img);

        // Add the button
        lp_button.setMargins(height, (height + divHeight) * counter, height, 0);
        TextView button = new TextView(this);
        button.setText(name);
        button.setTypeface(express);
        button.setTextSize(getResources().getDimension(R.dimen.button_text));
        button.setTextColor(getResources().getColor(R.color.black));
        button.setGravity(Gravity.CENTER_VERTICAL);
        button.setLayoutParams(lp_button);
        layout.addView(button);
        button.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, EventActivity.class);
                Bundle b = new Bundle();
                b.putString("eid", eid);
                b.putString("name", name);
                b.putInt("icon", icon);
                b.putInt("creator", creator);
                b.putString("date", temp);
                intent.putExtras(b);
                startActivity(intent);
              }
            });

        // Add the Date
        if (!month.equals("00") && !day.equals("00")) {
          lp_date.setMargins(0, (height + divHeight) * counter, 0, 0);
          lp_date.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
          TextView datetime = new TextView(this);
          datetime.setText(date);
          datetime.setGravity(Gravity.CENTER);
          datetime.setLayoutParams(lp_date);
          layout.addView(datetime);
        }

        // Add the Divider
        lp_div.setMargins(height, (height + divHeight) * counter + height, 20, 0);
        ImageView div = new ImageView(this);
        div.setImageResource(R.drawable.divider);
        div.setLayoutParams(lp_div);
        layout.addView(div);

        counter++;
      } catch (JSONException ex) {

      }
    }
  }
  public ToolbarDisplayLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(HORIZONTAL);

    mActivity = (BrowserApp) context;

    LayoutInflater.from(context).inflate(R.layout.toolbar_display_layout, this);

    mTitle = (ThemedTextView) findViewById(R.id.url_bar_title);
    mTitlePadding = mTitle.getPaddingRight();

    final Resources res = getResources();

    mUrlColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_urltext));
    mBlockedColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_blockedtext));
    mDomainColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_domaintext));
    mPrivateDomainColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_domaintext_private));

    mFavicon = (ImageButton) findViewById(R.id.favicon);
    mSiteSecurity = (ImageButton) findViewById(R.id.site_security);

    if (NewTabletUI.isEnabled(context)) {
      mSiteSecurity.setVisibility(View.VISIBLE);
      // TODO: Rename this resource and remove this call when new tablet is default.
      mSiteSecurity.setImageResource(R.drawable.new_tablet_site_security_level);

      // TODO: This can likely be set statically in resources when new tablet is default.
      // Dynamically update parameters for new tablet.
      final LinearLayout.LayoutParams lp =
          (LinearLayout.LayoutParams) mSiteSecurity.getLayoutParams();
      lp.height = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_height);
      lp.width = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_width);
      // TODO: Override a common static value when new tablet is standard.
      lp.rightMargin = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_right_margin);
      mSiteSecurity.setLayoutParams(lp);
      final int siteSecurityVerticalPadding =
          res.getDimensionPixelSize(R.dimen.new_tablet_site_security_padding_vertical);
      final int siteSecurityHorizontalPadding =
          res.getDimensionPixelSize(R.dimen.new_tablet_site_security_padding_horizontal);
      mSiteSecurity.setPadding(
          siteSecurityHorizontalPadding,
          siteSecurityVerticalPadding,
          siteSecurityHorizontalPadding,
          siteSecurityVerticalPadding);

      // We don't show favicons in the toolbar on new tablet. Note that while we could
      // null the favicon reference, we don't do so to avoid excessive null-checking.
      removeView(mFavicon);
    } else {
      if (Versions.feature16Plus) {
        mFavicon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
      }
      mFaviconSize = Math.round(Favicons.browserToolbarFaviconSize);
    }

    mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE);

    mSiteIdentityPopup = new SiteIdentityPopup(mActivity);
    mSiteIdentityPopup.setAnchor(mSiteSecurity);

    mStop = (ImageButton) findViewById(R.id.stop);
    mPageActionLayout = (PageActionLayout) findViewById(R.id.page_action_layout);
  }
  @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);
  }