public AddMemberCell(Context context) {
    super(context);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.addmember);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(
        imageView,
        LayoutHelper.createFrame(
            48,
            48,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 68,
            8,
            LocaleController.isRTL ? 68 : 0,
            0));

    SimpleTextView textView = new SimpleTextView(context);
    textView.setTextColor(0xff212121);
    textView.setTextSize(17);
    textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(
        textView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            20,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 28 : 129,
            22.5f,
            LocaleController.isRTL ? 129 : 28,
            0));
  }
Example #2
0
  public TextDetailCell(Context context) {
    super(context);

    textView = new MyTextView(context);
    textView.setTextColor(0xff212121);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(
        textView,
        LayoutHelper.createFrame(
            LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT,
            LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT,
            LocaleController.isRTL ? 16 : 71,
            10,
            LocaleController.isRTL ? 71 : 16,
            0));

    valueTextView = new MyTextView(context);
    valueTextView.setTextColor(0xff8a8a8a);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(
        valueTextView,
        LayoutHelper.createFrame(
            LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT,
            LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT,
            LocaleController.isRTL ? 16 : 71,
            35,
            LocaleController.isRTL ? 71 : 16,
            0));

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(
        imageView,
        LayoutHelper.createFrame(
            LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL,
            LocaleController.isRTL ? 0 : 16,
            0,
            LocaleController.isRTL ? 16 : 0,
            0));
  }
Example #3
0
  public StickerCell(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    imageView.setAspectFit(true);
    addView(imageView, LayoutHelper.createFrame(66, 66, Gravity.CENTER_HORIZONTAL, 0, 5, 0, 0));
  }
Example #4
0
  public TextColorCell(Context context) {
    super(context);

    if (paint == null) {
      paint = new Paint();
      paint.setColor(0xffd9d9d9);
      paint.setStrokeWidth(1);
    }

    colorDrawable = getResources().getDrawable(R.drawable.switch_to_on2);

    textView = new MyTextView(context);
    textView.setTextColor(0xff212121);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(
        (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(
        textView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            17,
            0,
            17,
            0));
  }
    public AlbumView(Context context) {
      super(context);

      imageView = new BackupImageView(context);
      addView(
          imageView,
          LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

      LinearLayout linearLayout = new LinearLayout(context);
      linearLayout.setOrientation(LinearLayout.HORIZONTAL);
      linearLayout.setBackgroundColor(0x7f000000);
      addView(
          linearLayout,
          LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28, Gravity.LEFT | Gravity.BOTTOM));

      nameTextView = new TextView(context);
      nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
      nameTextView.setTextColor(0xffffffff);
      nameTextView.setSingleLine(true);
      nameTextView.setEllipsize(TextUtils.TruncateAt.END);
      nameTextView.setMaxLines(1);
      nameTextView.setGravity(Gravity.CENTER_VERTICAL);
      linearLayout.addView(
          nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));

      countTextView = new TextView(context);
      countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
      countTextView.setTextColor(0xffaaaaaa);
      countTextView.setSingleLine(true);
      countTextView.setEllipsize(TextUtils.TruncateAt.END);
      countTextView.setMaxLines(1);
      countTextView.setGravity(Gravity.CENTER_VERTICAL);
      linearLayout.addView(
          countTextView,
          LayoutHelper.createLinear(
              LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));

      selector = new View(context);
      selector.setBackgroundResource(R.drawable.list_selector);
      addView(
          selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    }
    public ActionBarPopupWindowLayout(Context context) {
      super(context);

      if (backgroundDrawable == null) {
        backgroundDrawable = getResources().getDrawable(R.drawable.popup_fixed);
      }

      setPadding(
          AndroidUtilities.dp(8),
          AndroidUtilities.dp(8),
          AndroidUtilities.dp(8),
          AndroidUtilities.dp(8));
      setWillNotDraw(false);

      try {
        scrollView = new ScrollView(context);
        scrollView.setVerticalScrollBarEnabled(false);
        addView(
            scrollView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
      } catch (Throwable e) {
        FileLog.e("tmessages", e);
      }

      linearLayout = new LinearLayout(context);
      linearLayout.setOrientation(LinearLayout.VERTICAL);
      if (scrollView != null) {
        scrollView.addView(
            linearLayout,
            new ScrollView.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      } else {
        addView(
            linearLayout,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
      }
    }
Example #7
0
  @Override
  public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Stickers", R.string.Stickers));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            }
          }
        });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(0xfff0f0f0);

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    frameLayout.addView(
        listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i >= stickersStartRow && i < stickersEndRow && getParentActivity() != null) {
              final TLRPC.TL_messages_stickerSet stickerSet = StickersQuery.getStickerSets().get(i);
              ArrayList<TLRPC.Document> stickers = stickerSet.documents;
              if (stickers == null || stickers.isEmpty()) {
                return;
              }
              StickersAlert alert = new StickersAlert(getParentActivity(), stickerSet);
              alert.setButton(
                  AlertDialog.BUTTON_NEGATIVE,
                  LocaleController.getString("Close", R.string.Close),
                  (Message) null);
              if ((stickerSet.set.flags & 4) == 0) {
                alert.setButton(
                    AlertDialog.BUTTON_NEUTRAL,
                    LocaleController.getString("StickersRemove", R.string.StickersRemove),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        StickersQuery.removeStickersSet(getParentActivity(), stickerSet.set, 0);
                      }
                    });
              }
              setVisibleDialog(alert);
              alert.show();
            }
          }
        });

    return fragmentView;
  }
  @Override
  public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            }
          }
        });

    fragmentView = new LinearLayout(context);
    LinearLayout linearLayout = (LinearLayout) fragmentView;
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setWeightSum(100);
    linearLayout.setBackgroundColor(0xfff0f0f0);
    fragmentView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setPadding(
        AndroidUtilities.dp(20),
        AndroidUtilities.dp(20),
        AndroidUtilities.dp(20),
        AndroidUtilities.dp(20));
    linearLayout.addView(
        frameLayout,
        LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    ImageView identiconView = new ImageView(context);
    identiconView.setScaleType(ImageView.ScaleType.FIT_XY);
    frameLayout.addView(
        identiconView,
        LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundColor(0xffffffff);
    frameLayout.setPadding(
        AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10));
    linearLayout.addView(
        frameLayout,
        LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    TextView textView = new TextView(context);
    textView.setTextColor(0xff7f7f7f);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLinksClickable(true);
    textView.setClickable(true);
    textView.setMovementMethod(new LinkMovementMethodMy());
    // textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(0xff316f9f);
    textView.setGravity(Gravity.CENTER);
    frameLayout.addView(
        textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
    if (encryptedChat != null) {
      IdenticonDrawable drawable = new IdenticonDrawable();
      identiconView.setImageDrawable(drawable);
      drawable.setEncryptedChat(encryptedChat);
      TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
      SpannableStringBuilder hash = new SpannableStringBuilder();
      if (encryptedChat.key_hash.length > 16) {
        String hex = Utilities.bytesToHex(encryptedChat.key_hash);
        for (int a = 0; a < 32; a++) {
          if (a != 0) {
            if (a % 8 == 0) {
              hash.append('\n');
            } else if (a % 4 == 0) {
              hash.append(' ');
            }
          }
          hash.append(hex.substring(a * 2, a * 2 + 2));
          hash.append(' ');
        }
        hash.append("\n\n");
      }
      hash.append(
          AndroidUtilities.replaceTags(
              LocaleController.formatString(
                  "EncryptionKeyDescription",
                  R.string.EncryptionKeyDescription,
                  user.first_name,
                  user.first_name)));
      final String url = "telegram.org";
      int index = hash.toString().indexOf(url);
      if (index != -1) {
        hash.setSpan(
            new URLSpanReplacement(
                LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)),
            index,
            index + url.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
      textView.setText(hash);
    }

    return fragmentView;
  }