Exemplo n.º 1
0
  private void addSearchLayout(RelativeLayout layout, TiViewProxy searchView, TiUIView search) {
    RelativeLayout.LayoutParams p = createBasicSearchLayout();
    p.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    TiDimension rawHeight;
    if (searchView.hasProperty(TiC.PROPERTY_HEIGHT)) {
      rawHeight = TiConvert.toTiDimension(searchView.getProperty(TiC.PROPERTY_HEIGHT), 0);
    } else {
      rawHeight = TiConvert.toTiDimension(MIN_SEARCH_HEIGHT, 0);
    }
    p.height = rawHeight.getAsPixels(layout);

    View nativeView = search.getNativeView();
    layout.addView(nativeView, p);

    p = createBasicSearchLayout();
    p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    p.addRule(RelativeLayout.BELOW, nativeView.getId());
    ViewParent parentWrapper = wrapper.getParent();
    if (parentWrapper != null && parentWrapper instanceof ViewGroup) {
      // get the previous layout params so we can reset with new layout
      ViewGroup.LayoutParams lp = wrapper.getLayoutParams();
      ViewGroup parentView = (ViewGroup) parentWrapper;
      // remove view from parent
      parentView.removeView(wrapper);
      // add new layout
      layout.addView(wrapper, p);
      parentView.addView(layout, lp);

    } else {
      layout.addView(wrapper, p);
    }
    this.searchLayout = layout;
  }
Exemplo n.º 2
0
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    // Create a text view supposed to display tuto messages
    if (mTutoTextView == null) {
      mTutoTextView = new TextView(getContext());
      mTutoTextView.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
      mTutoTextView.setTextColor(getResources().getColor(R.color.white));
      mTutoTextView.setTypeface(null, Typeface.BOLD);
      mTutoTextView.setBackgroundResource(R.color.alpha_shadow);
      mTutoTextView.setGravity(Gravity.CENTER);
      final int padding = getResources().getDimensionPixelSize(R.dimen.default_padding);
      mTutoTextView.setPadding(padding, 2 * padding, padding, padding);

      final RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      mTutoTextView.setLayoutParams(layoutParams);
    }

    mAnimationLayer.addView(mTutoTextView);
    displayCurrentStepMessage(false);
  }
Exemplo n.º 3
0
  private void init() {
    setHardwareAccelerated(true);

    boolean hasShot =
        getContext()
            .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE)
            .getBoolean("hasShot" + getConfigOptions().showcaseId, false);
    if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) {
      // The showcase has already been shot once, so we don't need to do anything
      setVisibility(View.GONE);
      mIsRedundant = true;
      return;
    }

    mShowcaseRadius = mMetricScale * INNER_CIRCLE_RADIUS;
    setOnTouchListener(this);

    if (!mOptions.noButton && mEndButton.getParent() == null) {
      RelativeLayout.LayoutParams lps = getConfigOptions().buttonLayoutParams;
      if (lps == null) {
        lps = (LayoutParams) generateDefaultLayoutParams();
        lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        int margin = ((Number) (mMetricScale * 12)).intValue();
        lps.setMargins(margin, margin, margin, margin);
      }
      mEndButton.setLayoutParams(lps);
      mEndButton.setText(mButtonText != null ? mButtonText : getResources().getString(R.string.ok));
      if (!mHasCustomClickListener) {
        mEndButton.setOnClickListener(this);
      }
      addView(mEndButton);
    }
  }
Exemplo n.º 4
0
  protected void setRightButtonText(String text) {
    RelativeLayout rightView = (RelativeLayout) findViewById(R.id.right_view);
    rightView.removeAllViews();

    int padding = dp2px(6);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.setMargins(0, 0, dp2px(8), 0);
    TextView tv = new TextView(this);
    tv.setText(text);
    tv.setTextColor(0xFF666666);
    tv.setTextSize(16.f);
    tv.setLayoutParams(lp);
    tv.setBackgroundResource(R.drawable.btn_gray);
    tv.setPadding(2 * padding, padding, 2 * padding, padding);
    tv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onRightButtonClicked(v);
          }
        });

    rightView.addView(tv);
    rightView.setVisibility(View.VISIBLE);
  }
Exemplo n.º 5
0
  public void setTitle(
      String title, float fontSize, int fontColor, TitleAlign align, String titlePic) {
    if (titlePic == null || titlePic.length() < 1) {
      this._labTitle.setText(title);
      this._labTitle.setTextColor(fontColor);
      this._labTitle.setVisibility(VISIBLE);
      this._labTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
      this._imgTitlePic.setVisibility(INVISIBLE);
    } else {
      Bitmap bitmap = BitmapFactory.decodeFile(titlePic);
      this._imgTitlePic.setImageBitmap(bitmap);
      this._labTitle.setVisibility(INVISIBLE);
      this._imgTitlePic.setVisibility(VISIBLE);
    }

    RelativeLayout.LayoutParams lp =
        (RelativeLayout.LayoutParams) this._imgTitlePic.getLayoutParams();

    switch (align) {
      case left:
        lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        this._labTitle.setGravity(Gravity.START);
        break;
      case center:
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
        this._labTitle.setGravity(Gravity.CENTER);
        break;
      case right:
        lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        this._labTitle.setGravity(Gravity.END);
        break;
    }
    this._imgTitlePic.setLayoutParams(lp);
  }
Exemplo n.º 6
0
  // Initializes the origin state of the layer
  private void initState() {

    // Sticks container to right or left
    RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) mSlidingLayer.getLayoutParams();
    int textResource;
    Drawable d;

    if (mStickContainerToRightLeftOrMiddle.equals("right")) {
      textResource = R.string.app_name;
      d = getResources().getDrawable(R.drawable.ic_launcher);

      rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else if (mStickContainerToRightLeftOrMiddle.equals("left")) {
      textResource = R.string.swipe_left_label;
      d = getResources().getDrawable(R.drawable.container_rocket_left);

      rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    } else if (mStickContainerToRightLeftOrMiddle.equals("top")) {
      textResource = R.string.swipe_up_label;
      d = getResources().getDrawable(R.drawable.container_rocket);

      mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_TOP);
      rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
      rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width);
    } else if (mStickContainerToRightLeftOrMiddle.equals("bottom")) {
      textResource = R.string.swipe_down_label;
      d = getResources().getDrawable(R.drawable.container_rocket);

      mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_BOTTOM);
      rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
      rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width);
    } else {
      textResource = R.string.swipe_label;
      d = getResources().getDrawable(R.drawable.container_rocket);

      rlp.addRule(RelativeLayout.CENTER_IN_PARENT);
      rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
    }

    d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
    swipeText.setCompoundDrawables(null, d, null, null);
    swipeText.setText(getResources().getString(textResource));
    mSlidingLayer.setLayoutParams(rlp);

    // Sets the shadow of the container
    if (mShowShadow) {
      mSlidingLayer.setShadowWidthRes(R.dimen.shadow_width);
      mSlidingLayer.setShadowDrawable(R.drawable.sidebar_shadow);
    } else {
      mSlidingLayer.setShadowWidth(0);
      mSlidingLayer.setShadowDrawable(null);
    }
    if (mShowOffset) {
      mSlidingLayer.setOffsetWidth(getResources().getDimensionPixelOffset(R.dimen.offset_width));
    } else {
      mSlidingLayer.setOffsetWidth(0);
    }
  }
Exemplo n.º 7
0
  private RelativeLayout createPin() {
    final RelativeLayout pinLayout = new RelativeLayout(getContext());
    pinLayout.setVisibility(View.INVISIBLE);

    final Pin pin = new Pin(getContext());
    pin.setId(ID_PIN);
    final RelativeLayout.LayoutParams pinParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pinParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    pinParams.addRule(RelativeLayout.ALIGN_BOTTOM, ID_PIN_TEXT);
    pinParams.addRule(RelativeLayout.ALIGN_TOP, ID_PIN_TEXT);
    pin.setLayoutParams(pinParams);
    pinLayout.addView(pin);

    final TextView indicatorTextView = new TextView(getContext());
    indicatorTextView.setId(ID_PIN_TEXT);
    final RelativeLayout.LayoutParams indicatorParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    indicatorParams.addRule(RelativeLayout.LEFT_OF, ID_PIN);
    indicatorTextView.setLayoutParams(indicatorParams);
    indicatorTextView.setTextColor(Color.WHITE);
    indicatorTextView.setGravity(Gravity.CENTER);
    indicatorTextView.setBackgroundColor(GREY_LIGHT);
    pinLayout.addView(indicatorTextView);

    return pinLayout;
  }
Exemplo n.º 8
0
  @OnClick(R.id.iv_full)
  public void onWindow(View v) {

    RelativeLayout.LayoutParams lpFull =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    lpFull.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lpFull.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    lpFull.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    lpFull.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    RelativeLayout.LayoutParams lpWindow =
        new RelativeLayout.LayoutParams(
            DensityUtils.dp2px(this, 1000), DensityUtils.dp2px(this, 600));
    lpWindow.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

    if (mStatus == STATUS.FULL) {
      mLayout.setLayoutParams(lpWindow);
      mStatus = STATUS.WINDOW;
      mButtonFull.setBackgroundResource(R.drawable.video_qp);
      mClose.setVisibility(View.VISIBLE);
    } else {
      mLayout.setLayoutParams(lpFull);
      mStatus = STATUS.FULL;
      mButtonFull.setBackgroundResource(R.drawable.video_sx);
      mClose.setVisibility(View.INVISIBLE);
    }
  }
Exemplo n.º 9
0
  private ImageView initializeImageView() {
    ImageView image;
    image = new ImageView(this.activity);
    image.setId(IMAGE_ID);
    image.setAdjustViewBounds(true);
    image.setScaleType(this.style.imageScaleType);

    // set the image drawable if not null
    if (null != this.style.imageDrawable) {
      image.setImageDrawable(this.style.imageDrawable);
    }

    // set the image resource if not 0. This will overwrite the drawable
    // if both are set
    if (this.style.imageResId != 0) {
      image.setImageResource(this.style.imageResId);
    }

    RelativeLayout.LayoutParams imageParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    imageParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);

    image.setLayoutParams(imageParams);

    return image;
  }
 private void initDeleteIcons() {
   int deleteIconViews[] = {
     R.id.deleteIcon1,
     R.id.deleteIcon2,
     R.id.deleteIcon3,
     R.id.deleteIcon4,
     R.id.deleteIcon5,
     R.id.deleteIcon6,
     R.id.deleteIcon7,
     R.id.deleteIcon8,
     R.id.deleteIcon9,
     R.id.deleteIcon10
   };
   RelativeLayout.LayoutParams deleteIconParams =
       new RelativeLayout.LayoutParams(screenHeight / 20, screenHeight / 20);
   deleteIconParams.alignWithParent = true;
   deleteIconParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
   deleteIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
   deleteIconParams.bottomMargin = 3;
   deleteIconParams.rightMargin = 3;
   for (int i = 0; i < deleteIconViews.length; i++) {
     ImageView deleteIcon = (ImageView) findViewById(deleteIconViews[i]);
     deleteIcon.setLayoutParams(deleteIconParams);
     deleteIcon.setOnClickListener(deleteIconClickListener);
     deleteIcon.setVisibility(View.GONE);
     deleteIcons.add(deleteIcon);
   }
 }
Exemplo n.º 11
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View vi = convertView;
    if (vi == null) {
      vi = inflater.inflate(R.layout.row_chat_box, null);
    }
    try {
      JSONObject json_data = new JSONObject(data.get(position));
      LinearLayout right_delete_box = (LinearLayout) vi.findViewById(R.id.right_delete_box);
      LinearLayout left_delete_box = (LinearLayout) vi.findViewById(R.id.left_delete_box);
      LinearLayout row_box = (LinearLayout) vi.findViewById(R.id.row_box);
      LinearLayout chat_box = (LinearLayout) vi.findViewById(R.id.chat_box);
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_box.getLayoutParams();
      int left = Math.round(100 * this.context.getResources().getDisplayMetrics().density);
      int top = Math.round(5 * this.context.getResources().getDisplayMetrics().density);
      int right = Math.round(10 * this.context.getResources().getDisplayMetrics().density);
      if (json_data.getString("sender_id").equals(jsonuser.getString(TblUsers.USER_ID))) {
        params.setMargins(left, top, right, top);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        row_box.setBackgroundResource(R.drawable.bg_chat_box);
        chat_box.findViewById(R.id.img_mark).setVisibility(View.VISIBLE);
        right_delete_box.setVisibility(View.GONE);
        left_delete_box.setVisibility(View.VISIBLE);

        if (json_data.getString("read").equals("0")) {
          chat_box.findViewById(R.id.img_mark).setVisibility(View.GONE);
        }
      } else {
        params.setMargins(right, top, left, top);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
        row_box.setBackgroundResource(R.drawable.bg_button_deactive);
        chat_box.findViewById(R.id.img_mark).setVisibility(View.GONE);
        right_delete_box.setVisibility(View.VISIBLE);
        left_delete_box.setVisibility(View.GONE);
      }

      if (ChatBoxActivity.allow_edit == 0) {
        right_delete_box.setVisibility(View.GONE);
        left_delete_box.setVisibility(View.GONE);
      }
      chat_box.setLayoutParams(params);

      right_delete_box.setClickable(true);
      right_delete_box.setOnClickListener(deleteMessage(position, data.get(position)));

      left_delete_box.setClickable(true);
      left_delete_box.setOnClickListener(deleteMessage(position, data.get(position)));

      ((TextView) vi.findViewById(R.id.chat_text)).setText(json_data.getString("conversation"));
      ((TextView) vi.findViewById(R.id.chat_text)).setAutoLinkMask(1);

      String timing_send =
          FormatDateTime.formatAutoGetDateTimeForMessage(json_data.getString("timing_send"));
      ((TextView) vi.findViewById(R.id.message_time)).setText(timing_send);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return vi;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    list = new ListView(getActivity());
    list.setBackgroundColor(Color.WHITE);
    borrowedBooks = new ArrayList<>();

    // Initiate progressbar
    pb = new ProgressBar(getActivity()); // Init the progressbar
    pb.setId(1); // Give pb an id
    pb.setVisibility(View.INVISIBLE); // Set progressbar visibility

    // Progressbar details
    RelativeLayout.LayoutParams progressBarDetails =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    progressBarDetails.addRule(RelativeLayout.CENTER_HORIZONTAL);
    progressBarDetails.addRule(RelativeLayout.CENTER_VERTICAL);

    if (borrowedBooks.isEmpty()) {
      try {
        requestRequests(BookshelfConstants.CONNECTION_URI);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    } else {
      updateDisplay();
    }
    return list;
  }
Exemplo n.º 13
0
  void showTextSearchControls(boolean show) {

    Log.i(
        "showTextSearchControls",
        "show = " + show + " myPanel.ControlPanel " + myPanel.ControlPanel);

    if (myPanel.ControlPanel == null) {
      myPanel.ControlPanel = new ControlPanel(this);

      myPanel.ControlPanel.addButton(
          ActionCode.FIND_PREVIOUS, false, R.drawable.text_search_previous);
      myPanel.ControlPanel.addButton(
          ActionCode.CLEAR_FIND_RESULTS, true, R.drawable.text_search_close);
      myPanel.ControlPanel.addButton(ActionCode.FIND_NEXT, false, R.drawable.text_search_next);

      RelativeLayout root = (RelativeLayout) findViewById(R.id.root_view);

      RelativeLayout.LayoutParams p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      p.addRule(RelativeLayout.CENTER_HORIZONTAL);
      root.addView(myPanel.ControlPanel, p);
    }

    if (myPanel.ControlPanel != null) {
      if (show) {
        myPanel.ControlPanel.show(true);
      } else {
        myPanel.ControlPanel.hide(false);
      }
    }
  }
Exemplo n.º 14
0
  /** Adds a hint button to the keyboard */
  private void addHintButton() {
    // now adds button to show hint
    RelativeLayout rl = (RelativeLayout) findViewById(R.id.gra_layout);
    RelativeLayout.LayoutParams lp = createButtonLayoutParams();

    Button btn = createButton("hint", 35, null);
    final Button btnfinal = btn;
    btn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            TextView textView1 = (TextView) findViewById(R.id.text_message);
            if (!hintOn) {
              showHint();
              changeButtonBackground(btnfinal, R.drawable.small_button_clicked, 100);
              hintOn = true;
            } else {
              textView1.setText("");
              changeButtonBackground(btnfinal, R.drawable.small_button, 100);
              hintOn = false;
            }
          }
        });
    lp.addRule(RelativeLayout.RIGHT_OF, 34);
    lp.addRule(RelativeLayout.BELOW, 30);
    rl.addView(btn, lp);
  }
Exemplo n.º 15
0
  @Override
  public void onGUICreate() {
    ApplicationScreen.getGUIManager().removeViews(modeSwitcher, R.id.specialPluginsLayout3);

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

    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    if (!CameraController.isRemoteCamera()) {
      ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3))
          .addView(this.modeSwitcher, params);
    }

    this.modeSwitcher.setLayoutParams(params);

    if (ModePreference.compareTo("0") == 0)
      ApplicationScreen.getGUIManager()
          .showHelp(
              "Dro help",
              ApplicationScreen.getAppResources().getString(R.string.Dro_Help),
              R.drawable.plugin_help_dro,
              "droShowHelp");
  }
Exemplo n.º 16
0
  // shared image container
  private RelativeLayout getThumbView() {
    rlThumb = new RelativeLayout(getContext());
    rlThumb.setId(1);
    int dp_82 = dipToPx(getContext(), 82);
    int dp_98 = dipToPx(getContext(), 98);
    LayoutParams lpThumb = new LayoutParams(dp_82, dp_98);
    rlThumb.setLayoutParams(lpThumb);

    ivImage = new ImageView(getContext());
    int resId = getBitmapRes(activity, "btn_back_nor");
    if (resId > 0) {
      ivImage.setBackgroundResource(resId);
    }
    ivImage.setScaleType(ScaleType.CENTER_INSIDE);
    ivImage.setImageBitmap(image);

    int dp_4 = dipToPx(getContext(), 4);
    ivImage.setPadding(dp_4, dp_4, dp_4, dp_4);
    int dp_74 = dipToPx(getContext(), 74);
    RelativeLayout.LayoutParams lpImage = new RelativeLayout.LayoutParams(dp_74, dp_74);
    int dp_16 = dipToPx(getContext(), 16);
    int dp_8 = dipToPx(getContext(), 8);
    lpImage.setMargins(0, dp_16, dp_8, 0);
    ivImage.setLayoutParams(lpImage);
    ivImage.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (image != null && !image.isRecycled()) {
              PicViewer pv = new PicViewer();
              pv.setImageBitmap(image);
              pv.show(activity, null);
            }
          }
        });
    rlThumb.addView(ivImage);

    Button btn = new Button(getContext());
    btn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // remove the photo to share
            rlThumb.setVisibility(View.GONE);
            ivPin.setVisibility(View.GONE);
            removeImage(imgInfo);
          }
        });
    resId = getBitmapRes(activity, "img_cancel");
    if (resId > 0) {
      btn.setBackgroundResource(resId);
    }
    int dp_20 = dipToPx(getContext(), 20);
    RelativeLayout.LayoutParams lpBtn = new RelativeLayout.LayoutParams(dp_20, dp_20);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    btn.setLayoutParams(lpBtn);
    rlThumb.addView(btn);

    rlThumb.setVisibility(View.GONE);
    return rlThumb;
  }
Exemplo n.º 17
0
  // page body
  private LinearLayout getPageBody() {
    llBody = new LinearLayout(getContext());
    llBody.setId(2);
    int resId = getBitmapRes(activity, "edittext_back");
    if (resId > 0) {
      llBody.setBackgroundResource(resId);
    }
    llBody.setOrientation(LinearLayout.VERTICAL);
    RelativeLayout.LayoutParams lpBody =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpBody.addRule(RelativeLayout.ALIGN_LEFT, llTitle.getId());
    lpBody.addRule(RelativeLayout.BELOW, llTitle.getId());
    lpBody.addRule(RelativeLayout.ALIGN_RIGHT, llTitle.getId());
    if (!dialogMode) {
      lpBody.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    int dp_3 = dipToPx(getContext(), 3);
    lpBody.setMargins(dp_3, dp_3, dp_3, dp_3);
    llBody.setLayoutParams(lpBody);

    llBody.addView(getMainBody());
    llBody.addView(getSep());
    llBody.addView(getPlatformList());

    return llBody;
  }
Exemplo n.º 18
0
  // title bar
  private TitleLayout getPageTitle() {
    llTitle = new TitleLayout(getContext());
    llTitle.setId(1);
    //		int resId = getBitmapRes(activity, "title_back");
    //		if (resId > 0) {
    //			llTitle.setBackgroundResource(resId);
    //		}
    llTitle.getBtnBack().setOnClickListener(this);
    int resId = getStringRes(activity, "multi_share");
    if (resId > 0) {
      llTitle.getTvTitle().setText(resId);
    }
    llTitle.getBtnRight().setVisibility(View.VISIBLE);
    resId = getStringRes(activity, "share");
    if (resId > 0) {
      llTitle.getBtnRight().setText(resId);
    }
    llTitle.getBtnRight().setOnClickListener(this);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    llTitle.setLayoutParams(lp);

    return llTitle;
  }
Exemplo n.º 19
0
 private RelativeLayout.LayoutParams createBasicSearchLayout() {
   RelativeLayout.LayoutParams p =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
   p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
   p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
   return p;
 }
Exemplo n.º 20
0
  public void startTextAnimation() {

    mTxtTitle.setText(mConfigSplash.getTitleSplash());
    mSubTxtTitle.setText(mConfigSplash.getSubTitleSplash());
    mTxtTitle.setTextSize(mConfigSplash.getTitleTextSize());
    mTxtTitle.setTextColor(getResources().getColor(mConfigSplash.getTitleTextColor()));
    if (!mConfigSplash.getTitleFont().isEmpty()) setFont(mConfigSplash.getTitleFont());

    if (!mConfigSplash.getSubTitleFont().isEmpty()) setSubFont(mConfigSplash.getSubTitleFont());

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.BELOW, R.id.flCentral);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    mTxtTitle.setLayoutParams(params);
    mTxtTitle.setVisibility(View.VISIBLE);
    mSubTxtTitle.setVisibility(View.VISIBLE);
    YoYo.with(mConfigSplash.getAnimTitleTechnique())
        .withListener(
            new Animator.AnimatorListener() {
              @Override
              public void onAnimationStart(Animator animation) {}

              @Override
              public void onAnimationEnd(Animator animation) {
                animationsFinished();
              }

              @Override
              public void onAnimationCancel(Animator animation) {}

              @Override
              public void onAnimationRepeat(Animator animation) {}
            })
        .duration(mConfigSplash.getAnimTitleDuration())
        .playOn(mTxtTitle);

    YoYo.with(mConfigSplash.getAnimTitleTechnique())
        .withListener(
            new Animator.AnimatorListener() {
              @Override
              public void onAnimationStart(Animator animation) {}

              @Override
              public void onAnimationEnd(Animator animation) {
                animationsFinished();
              }

              @Override
              public void onAnimationCancel(Animator animation) {}

              @Override
              public void onAnimationRepeat(Animator animation) {}
            })
        .duration(mConfigSplash.getAnimTitleDuration())
        .playOn(mSubTxtTitle);
  }
Exemplo n.º 21
0
  public HsvColorPickerDialog(
      Context context, int initialColor, final OnColorSelectedListener listener) {
    super(context);
    this.listener = listener;
    this.selectedColor = initialColor;
    this.density = context.getResources().getDisplayMetrics().density;
    RelativeLayout layout = new RelativeLayout(context);

    colorWheel = new HSVColorWheel(context, initialColor);
    colorWheel.setId(ViewDefine.ViewID_Color_Wheel);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lp.bottomMargin = getViewDP(ViewDefine.Type_View_BottomMargin);
    layout.addView(colorWheel, lp);

    valueSlider = new HSVValueSlider(context);
    valueSlider.setId(ViewDefine.ViewID_Value_Slider);
    lp =
        new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, getViewDP(ViewDefine.Type_ValueSlider_Height));
    lp.bottomMargin = getViewDP(ViewDefine.Type_View_BottomMargin);
    lp.addRule(RelativeLayout.BELOW, ViewDefine.ViewID_Color_Wheel);
    layout.addView(valueSlider, lp);

    selectedColorView = new View(context);
    selectedColorView.setBackgroundColor(selectedColor);
    lp =
        new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, getViewDP(ViewDefine.Type_ValueSlider_Height));
    lp.addRule(RelativeLayout.BELOW, ViewDefine.ViewID_Value_Slider);
    FrameLayout selectedColorborder = new FrameLayout(context);
    selectedColorborder.addView(selectedColorView);
    layout.addView(selectedColorborder, lp);
    selectedColorView.setBackgroundColor(ViewDefine.BORDER_COLOR);

    colorWheel.setListener(
        new OnColorSelectedListener() {
          @Override
          public void colorSelected(Integer color) {
            valueSlider.setColor(color, true);
          }
        });
    valueSlider.setListener(
        new OnColorSelectedListener() {
          @Override
          public void colorSelected(Integer color) {
            selectedColor = color;
            selectedColorView.setBackgroundColor(color);
          }
        });

    setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), clickListener);
    setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), clickListener);

    int tmp = getViewDP(ViewDefine.Type_Whole_Padding);
    setView(layout, tmp, tmp / 2, tmp, tmp / 2);
    setTitle("Pick a Color(HSV)");
  }
Exemplo n.º 22
0
 /**
  * Adds non-clickable space fillers buttons to keyboard.
  *
  * @param sym
  * @param i
  */
 private void addFalseButt(String sym, int i) {
   Button b1 = createButton(sym, i, null);
   RelativeLayout rl1 = (RelativeLayout) findViewById(R.id.gra_layout);
   RelativeLayout.LayoutParams lp1 = createButtonLayoutParams();
   lp1.addRule(RelativeLayout.RIGHT_OF, i - 1);
   lp1.addRule(RelativeLayout.BELOW, 30);
   b1.setEnabled(false);
   rl1.addView(b1, lp1);
 }
  /** Create the view in which the video will be rendered. */
  private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms =
        new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.VISIBLE);
    mProgressBar.setEnabled(true);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
  }
Exemplo n.º 24
0
  private void setupView() {
    setContentView(R.layout.activity_play);

    mStage = (Stage) getIntent().getSerializableExtra(Constants.EXTRA_KEY_STAGE);
    mStageId = PreferenceHelper.loadStageId(getApplicationContext());

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
      actionBar.setTitle(mStage.getName());
    }

    long countDownTime = mStage.getTimeLimit();
    int numberOfWidthPieces = mStage.getNumberOfHorizontalPieces();
    int numberOfHeightPieces = mStage.getNumberOfVerticalPieces();

    // Get Timer Layout
    final RelativeLayout timerLayout = (RelativeLayout) findViewById(R.id.timer_layout);

    // Initial CountDownTextView
    mCountDownView = new CountDownTextView(PlayActivity.this, PlayActivity.this, countDownTime);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.addRule(RelativeLayout.CENTER_VERTICAL);

    // Add CountDown View into Main Layout
    timerLayout.addView(mCountDownView, params);

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

    int screenWidth = dimension.widthPixels;

    // Search image file
    File dir = getApplication().getFilesDir();
    File[] foundFiles =
        dir.listFiles(
            new FilenameFilter() {
              @Override
              public boolean accept(File dir, String filename) {
                return filename.startsWith(mStage.getImageID() + "-");
              }
            });
    if (foundFiles.length > 0) {
      mImageFile = foundFiles[0];

      // Sample Picture
      Bitmap picture = loadBitmap(mImageFile);

      mGameBoard = (TileBoardView) findViewById(R.id.game_board);
      mGameBoard.setBackgroundColor(Color.parseColor("#000000"));
      mGameBoard.setTileBoardViewListener(PlayActivity.this);
      mGameBoard.playWithImage(picture, numberOfWidthPieces, numberOfHeightPieces, screenWidth);
    }
  }
Exemplo n.º 25
0
 void setStatusBarVisibility(boolean visible) {
   if (!visible) statusBar.setText("");
   RelativeLayout.LayoutParams lp =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.MATCH_PARENT,
           visible ? RelativeLayout.LayoutParams.WRAP_CONTENT : 0);
   lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
   lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
   mainLayout.updateViewLayout(statusBar, lp);
 }
Exemplo n.º 26
0
  private void init() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      setLayerType(LAYER_TYPE_SOFTWARE, null);
    } else {
      setDrawingCacheEnabled(true);
    }

    boolean hasShot =
        getContext()
            .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE)
            .getBoolean("hasShot" + getConfigOptions().showcaseId, false);
    if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) {
      // The showcase has already been shot once, so we don't need to do anything
      setVisibility(View.GONE);
      isRedundant = true;
      return;
    }
    showcase = getContext().getResources().getDrawable(R.drawable.cling);

    showcaseRadius = metricScale * INNER_CIRCLE_RADIUS;
    PorterDuffXfermode mBlender = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY);
    setOnTouchListener(this);

    mPaintTitle = new Paint();
    mPaintTitle.setColor(titleTextColor);
    mPaintTitle.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY);
    mPaintTitle.setTextSize(24 * metricScale);
    mPaintTitle.setAntiAlias(true);

    mPaintDetail = new TextPaint();
    mPaintDetail.setColor(detailTextColor);
    mPaintDetail.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY);
    mPaintDetail.setTextSize(16 * metricScale);
    mPaintDetail.setAntiAlias(true);

    mEraser = new Paint();
    mEraser.setColor(0xFFFFFF);
    mEraser.setAlpha(0);
    mEraser.setXfermode(mBlender);
    mEraser.setAntiAlias(true);

    if (!mOptions.noButton && mEndButton.getParent() == null) {
      RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams();
      lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      int margin = ((Number) (metricScale * 12)).intValue();
      lps.setMargins(margin, margin, margin, margin);
      lps.height = LayoutParams.WRAP_CONTENT;
      lps.width = LayoutParams.WRAP_CONTENT;
      mEndButton.setLayoutParams(lps);
      mEndButton.setText(buttonText != null ? buttonText : getResources().getString(R.string.ok));
      if (!hasCustomClickListener) mEndButton.setOnClickListener(this);
      addView(mEndButton);
    }
  }
Exemplo n.º 27
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.round_view);

    Round toDisplay = (Round) getIntent().getSerializableExtra("round");
    if (toDisplay.holeByHole) {
      Button viewScorecard = new Button(getApplicationContext());
      viewScorecard.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO make a scorecard view
            }
          });

      RelativeLayout.LayoutParams ourRulez =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      ourRulez.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      ourRulez.addRule(RelativeLayout.CENTER_HORIZONTAL);
      ((RelativeLayout) findViewById(R.id.round_view_relative_layout))
          .addView(viewScorecard, ourRulez);
    }

    ((TextView) findViewById(R.id.round_view_course_name))
        .setText(toDisplay.getCourse().getName() + " " + toDisplay.getTeeBox().getTeeBoxName());

    ((TextView) findViewById(R.id.round_view_score))
        .setText(Integer.toString(toDisplay.getScore()));

    ((TextView) findViewById(R.id.round_view_fairways_hit))
        .setText(
            (((toDisplay.getFwysHit() == -1) ? "N/A" : Integer.toString(toDisplay.getFwysHit()))));

    ((TextView) findViewById(R.id.round_view_greens_hit))
        .setText(
            (toDisplay.getGreensHit() == -1 ? "N/A" : Integer.toString(toDisplay.getGreensHit())));

    ((TextView) findViewById(R.id.round_view_putts))
        .setText(
            (String) (toDisplay.getPutts() == -1 ? "N/A" : Integer.toString(toDisplay.getPutts())));

    ((TextView) findViewById(R.id.round_view_avg_drive))
        .setText(
            (String)
                (toDisplay.getAvgDrive() == 0 ? "N/A" : Double.toString(toDisplay.getAvgDrive())));

    // ((TextView)
    // findViewById(R.id.round_view_slope_rating)).setText((String)(toDisplay.getCourse().getSlopeRating() == -1 ? "N/A" : Integer.toString(toDisplay.getCourse().getSlopeRating())));

    // ((TextView) findViewById(R.id.round_view_course_rating)).setText((String)
    // (toDisplay.getCourse().getCourseRating() == -1 ? "N/A" :
    // Double.toString(toDisplay.getCourse().getCourseRating())));

  }
 void addScoreCounter() {
   int size = (int) (Metrics.squareButtonSize * Metrics.squareButtonScale);
   scoreCounter = new ScoreCounter(activity, size * 32 / 10, size);
   scoreCounter.setVisibility(View.GONE);
   scoreCounter.setScore(prefs.getScore());
   RelativeLayout.LayoutParams lp =
       new RelativeLayout.LayoutParams(
           ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
   lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
   layout.addView(scoreCounter.getView(), lp);
 }
 public void alignUnderView(View v) {
   if (rlpUnderView == null) {
     rlpUnderView =
         new RelativeLayout.LayoutParams(
             ViewGroup.LayoutParams.FILL_PARENT,
             (int) (Metrics.squareButtonSize * Metrics.squareButtonScale));
     rlpUnderView.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
     rlpUnderView.setMargins(Metrics.screenMargin, Metrics.screenMargin, Metrics.screenMargin, 0);
   }
   rlpUnderView.addRule(RelativeLayout.BELOW, v.getId());
   layout.setLayoutParams(rlpUnderView);
 }
Exemplo n.º 30
0
 private void initLogo() {
   nameLP = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   nameLP.addRule(CENTER_HORIZONTAL);
   nameLP.addRule(BELOW, ID_LOGO);
   name = new TextView(mContext);
   name.setId(ID_NAME);
   name.setLayoutParams(nameLP);
   name.setText("宁宁猫浏览器");
   name.setTextColor(Color.WHITE);
   name.setTextSize(getIntScaleX(20));
   this.addView(name);
 }