示例#1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_voo);

    Controle controle = new Controle();
    // capturando a msg do intent

    Intent intent = getIntent();
    String destino = intent.getStringExtra(MainActivity.DESTINO);
    String origem = intent.getStringExtra(MainActivity.ORIGEM);

    TreeSet<Voo> lista = controle.listarVoos(origem, destino);

    // texto da View
    TextView textView = (TextView) findViewById(R.id.txt_lista_voo);
    String message = "";

    for (Voo voo : lista) {
      message += voo.getNome() + "" + voo.getSituacao() + "\n";
    }

    if (message.length() == 0) {

      message = "Voo não encontrado";

      textView.setLines(3);
    } else {
      textView.setLines(lista.size());
    }

    textView.setText(message);
  }
  public DrawerProfileCell(Context context) {
    super(context);
    setBackgroundColor(0xff4c84b5);

    shadowView = new ImageView(context);
    shadowView.setVisibility(INVISIBLE);
    shadowView.setScaleType(ImageView.ScaleType.FIT_XY);
    shadowView.setImageResource(R.drawable.bottom_shadow);
    addView(
        shadowView,
        LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, Gravity.LEFT | Gravity.BOTTOM));

    avatarImageView = new BackupImageView(context);
    avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
    addView(
        avatarImageView,
        LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setGravity(Gravity.LEFT);
    addView(
        nameTextView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            Gravity.LEFT | Gravity.BOTTOM,
            16,
            0,
            16,
            28));

    phoneTextView = new TextView(context);
    phoneTextView.setTextColor(0xffc2e5ff);
    phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    phoneTextView.setLines(1);
    phoneTextView.setMaxLines(1);
    phoneTextView.setSingleLine(true);
    phoneTextView.setGravity(Gravity.LEFT);
    addView(
        phoneTextView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            Gravity.LEFT | Gravity.BOTTOM,
            16,
            0,
            16,
            9));
  }
示例#3
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));
  }
    public AttachButton(Context context) {
      super(context);

      imageView = new ImageView(context);
      imageView.setScaleType(ImageView.ScaleType.CENTER);
      addView(imageView, LayoutHelper.createFrame(64, 64, Gravity.CENTER_HORIZONTAL | Gravity.TOP));

      textView = new TextView(context);
      textView.setLines(1);
      textView.setSingleLine(true);
      textView.setGravity(Gravity.CENTER_HORIZONTAL);
      textView.setEllipsize(TextUtils.TruncateAt.END);
      textView.setTextColor(0xff757575);
      textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
      addView(
          textView,
          LayoutHelper.createFrame(
              LayoutHelper.MATCH_PARENT,
              LayoutHelper.WRAP_CONTENT,
              Gravity.LEFT | Gravity.TOP,
              0,
              64,
              0,
              0));
    }
示例#5
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));
  }
 /** {@inheritDoc} */
 @Override
 public void setLines(int lines) {
   super.setLines(lines);
   if (mHelper != null) {
     mHelper.setMaxLines(lines);
   }
 }
 /**
  * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
  *
  * @param view the text view to be configured
  */
 protected void configureTextView(TextView view) {
   view.setTextColor(textColor);
   view.setGravity(Gravity.CENTER);
   view.setTextSize(textSize);
   view.setLines(1);
   view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
 }
 /**
  * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
  *
  * @param view the text view to be configured
  */
 protected void configureTextView(TextView view) {
   // view.setTextColor(textColor);
   view.setGravity(Gravity.CENTER);
   view.setTextSize(textSize);
   view.setLines(1);
   view.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
   view.setPadding(0, 10, 0, 10);
 }
示例#9
0
        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
          if (!data.moveToFirst()) {
            return;
          }

          String bookTitle =
              data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.TITLE));
          bookTitleTextView.setText(bookTitle);

          String bookSubTitle =
              data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.SUBTITLE));
          if (bookSubTitle != null && bookSubTitle.trim().length() > 0) {
            bookSubTitleTextView.setText(bookSubTitle);
          } else {
            bookSubTitleTextView.setVisibility(View.GONE);
          }

          String authors =
              data.getString(data.getColumnIndex(AlexandriaContract.AuthorEntry.AUTHOR));
          if (authors != null && authors.trim().length() > 0) {
            String[] authorsArr = authors.split(",");
            authorsTextView.setLines(authorsArr.length);
            authorsTextView.setText(authors.replace(",", "\n"));
            authorsTitleTextView.setVisibility(View.VISIBLE);
          } else {
            authorsTitleTextView.setVisibility(View.GONE);
            authorsTextView.setVisibility(View.GONE);
          }

          String imgUrl =
              data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.IMAGE_URL));
          if (Patterns.WEB_URL.matcher(imgUrl).matches()) {
            Glide.with(getActivity())
                .load(imgUrl)
                .asBitmap()
                .placeholder(R.drawable.ic_launcher)
                // .error(R.drawable.ic_launcher)
                .into(bookCoverImageView);
            bookCoverImageView.setVisibility(View.VISIBLE);
          } else {
            bookCoverImageView.setVisibility(View.GONE);
          }

          String categories =
              data.getString(data.getColumnIndex(AlexandriaContract.CategoryEntry.CATEGORY));
          if (categories != null && categories.trim().length() > 0) {
            categoriesTitleTextView.setVisibility(View.VISIBLE);
            categoriesTextView.setText(categories);
          } else {
            categoriesTitleTextView.setVisibility(View.GONE);
            categoriesTextView.setVisibility(View.GONE);
          }
          mLinearLayoutFooter.setVisibility(View.VISIBLE);
          saveButton.setVisibility(View.VISIBLE);
          deleteButton.setVisibility(View.VISIBLE);
        }
 protected void configureTextView(TextView view) {
   textLP = new LayoutParams(LayoutParams.MATCH_PARENT, DisplayUtil.dip2px(context, 50));
   view.setTextColor(textColor);
   view.setGravity(Gravity.CENTER);
   view.setTextSize(textSize);
   view.setLines(1);
   view.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
   view.setLayoutParams(textLP);
   view.getHeight();
 }
示例#11
0
 public void initialize() {
   TextView mTextView = new TextView(mContext);
   LinearLayout.LayoutParams param =
       new LinearLayout.LayoutParams(
           LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
   mTextView.setLayoutParams(param);
   mTextView.setGravity(Gravity.CENTER | Gravity.CENTER);
   mTextView.setLines(6);
   mTextView.setText("Burst");
   mTextView.setTextColor(Color.BLACK);
   // mTextView.setTypeface(Typeface.BOLD);
   mLayout.addView(mTextView);
 }
 /**
  * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
  *
  * @param view the text view to be configured
  */
 protected void configureTextView(TextView view) {
   if (itemResourceId == TEXT_VIEW_ITEM_RESOURCE) {
     view.setTextColor(textColor);
     view.setGravity(Gravity.CENTER);
     view.setTextSize(textSize);
     view.setLines(1);
   }
   if (textTypeface != null) {
     view.setTypeface(textTypeface);
   } else {
     view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
   }
 }
示例#13
0
  @Override
  public void onLoadFinished(android.support.v4.content.Loader<Cursor> loader, Cursor data) {
    if (!data.moveToFirst()) {
      return;
    }

    String bookTitle = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.TITLE));
    ((TextView) rootView.findViewById(R.id.bookTitle)).setText(bookTitle);

    String bookSubTitle =
        data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.SUBTITLE));
    ((TextView) rootView.findViewById(R.id.bookSubTitle)).setText(bookSubTitle);

    TextView authorsView = (TextView) rootView.findViewById(R.id.authors);
    String authors = data.getString(data.getColumnIndex(AlexandriaContract.AuthorEntry.AUTHOR));
    if (authors != null) {
      String[] authorsArr = authors.split(",");
      authorsView.setLines(authorsArr.length);
      authorsView.setText(authors.replace(",", "\n"));
    } else {
      authorsView.setLines(1);
      authorsView.setText("");
    }

    String imgUrl = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.IMAGE_URL));
    if (Patterns.WEB_URL.matcher(imgUrl).matches()) {
      new DownloadImage((ImageView) rootView.findViewById(R.id.bookCover)).execute(imgUrl);
      rootView.findViewById(R.id.bookCover).setVisibility(View.VISIBLE);
    }

    String categories =
        data.getString(data.getColumnIndex(AlexandriaContract.CategoryEntry.CATEGORY));
    ((TextView) rootView.findViewById(R.id.categories)).setText(categories);

    rootView.findViewById(R.id.save_button).setVisibility(View.VISIBLE);
    rootView.findViewById(R.id.delete_button).setVisibility(View.VISIBLE);
  }
示例#14
0
  @Override
  public LinearLayout prepareLayout(Context c) {
    LinearLayout layout = new LinearLayout(c);
    layout.setOrientation(LinearLayout.VERTICAL);

    TextView questionText = new TextView(c);
    questionText.setText(this.getQuestion().replace("|", "\n"));
    // questionText.setTextAppearance(c, R.attr.textAppearanceLarge);
    questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    questionText.setLines(4);

    LinearLayout.LayoutParams layoutq =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutq.setMargins(10, 15, 0, 0);

    questionText.setLayoutParams(layoutq);

    EditText editText = new EditText(c);
    editText.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void afterTextChanged(Editable arg0) {
            selectedText = arg0.toString();
          }

          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          @Override
          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}
        });

    LinearLayout.LayoutParams layoutp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutp.setMargins(0, 40, 0, 0);
    editText.setLayoutParams(layoutp);

    layout.addView(questionText);
    layout.addView(editText);

    return layout;
  }
示例#15
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   KeyValueBean bean = datas.get(position);
   if (convertView == null) {
     TextView tv = new TextView(context);
     tv.setText(bean.key);
     AbsListView.LayoutParams params =
         new AbsListView.LayoutParams(
             AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT);
     tv.setLayoutParams(params);
     tv.setPadding(
         DensityUtil.dip2px(context, 6),
         DensityUtil.dip2px(context, 6),
         DensityUtil.dip2px(context, 6),
         DensityUtil.dip2px(context, 6));
     tv.setGravity(Gravity.CENTER_VERTICAL);
     tv.setLines(1);
     //			tv.setEllipsize(TruncateAt.END);
     convertView = tv;
   } else {
     ((TextView) convertView).setText(bean.key);
   }
   return convertView;
 }
示例#16
0
  public View generateView(final Context ctx) {
    if (idType.equals(Constantes.DIV)) {
      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.HORIZONTAL);

      LinearLayout.LayoutParams pTEXT =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      LinearLayout.LayoutParams pSEPARADOR =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      pTEXT.weight = 4;
      pSEPARADOR.weight = 1;
      pSEPARADOR.setMargins(20, 4, 0, 4);

      EditText left = new EditText(ctx);
      left.setLayoutParams(pTEXT);
      left.setBackgroundResource(R.drawable.fondo_edittext);
      left.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);

      EditText right = new EditText(ctx);
      right.setLayoutParams(pTEXT);
      right.setBackgroundResource(R.drawable.fondo_edittext);
      right.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);

      TextView separador = new TextView(ctx);
      separador.setLayoutParams(pSEPARADOR);

      left.setInputType(InputType.TYPE_CLASS_NUMBER);
      right.setInputType(InputType.TYPE_CLASS_NUMBER);

      separador.setText("/");
      separador.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
      editTexts = new ArrayList<>();
      editTexts.add(left);
      editTexts.add(right);

      ((LinearLayout) view).addView(left);
      ((LinearLayout) view).addView(separador);
      ((LinearLayout) view).addView(right);
    }
    if (idType.equals(Constantes.DATE)) {
      final Calendar myCalendar = Calendar.getInstance();
      final EditText fecha = new EditText(ctx);
      fecha.setBackgroundResource(R.drawable.fondo_edittext);
      fecha.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
      fecha.setEnabled(false);
      fecha.setGravity(Gravity.CENTER_VERTICAL);

      ImageButton pick = new ImageButton(ctx);
      pick.setBackgroundResource(R.drawable.button_gray);
      pick.setImageResource(R.drawable.ic_calendarwhite);

      LinearLayout.LayoutParams pButton =
          new LinearLayout.LayoutParams(
              0,
              (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_DIP, 48, ctx.getResources().getDisplayMetrics()));
      LinearLayout.LayoutParams pText =
          new LinearLayout.LayoutParams(
              0,
              (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_DIP, 48, ctx.getResources().getDisplayMetrics()));
      pButton.weight = 1;
      pText.weight = 4;
      pText.leftMargin =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 10, ctx.getResources().getDisplayMetrics());

      final DatePickerDialog.OnDateSetListener date =
          new DatePickerDialog.OnDateSetListener() {

            @Override
            public void onDateSet(DatePicker picker, int year, int monthOfYear, int dayOfMonth) {
              // TODO Auto-generated method stub
              myCalendar.set(Calendar.YEAR, year);
              myCalendar.set(Calendar.MONTH, monthOfYear);
              myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
              String myFormat = "yyyy/MM/dd"; // In which you need put here
              SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);

              fecha.setText(sdf.format(myCalendar.getTime()));
            }
          };

      pick.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              new DatePickerDialog(
                      ctx,
                      date,
                      myCalendar.get(Calendar.YEAR),
                      myCalendar.get(Calendar.MONTH),
                      myCalendar.get(Calendar.DAY_OF_MONTH))
                  .show();
            }
          });

      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.HORIZONTAL);
      ((LinearLayout) view).setGravity(Gravity.CENTER_VERTICAL);

      fecha.setLayoutParams(pText);
      pick.setLayoutParams(pButton);

      editTexts = new ArrayList<>();
      editTexts.add(fecha);

      ((LinearLayout) view).addView(pick);
      ((LinearLayout) view).addView(fecha);
    }
    if (idType.equals(Constantes.RADIO)) {
      view = new RadioGroup(ctx);
      for (VALUE v : values) {
        RadioButton b = new RadioButton(ctx);
        b.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        b.setText(v.getNameValue());
        ((RadioGroup) view).addView(b);
      }
      LinearLayout.LayoutParams p =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      p.leftMargin =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 10, ctx.getResources().getDisplayMetrics());
      ((RadioGroup) view).setGravity(Gravity.LEFT);
      view.setLayoutParams(p);
      ((RadioGroup) view).setOrientation(LinearLayout.HORIZONTAL);
      if (values.size() > 2) ((RadioGroup) view).setOrientation(LinearLayout.VERTICAL);
    }
    if (idType.equals(Constantes.CHECK)) {
      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.VERTICAL);
      checkBoxes = new ArrayList<>();
      int count = 0;

      LinearLayout tmp;
      tmp = new LinearLayout(ctx);
      tmp.setOrientation(LinearLayout.HORIZONTAL);
      for (VALUE v : values) {
        CheckBox c = new CheckBox(ctx);
        c.setText(v.getNameValue());
        c.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        checkBoxes.add(c);
        if (count == 0) {
          tmp.addView(c);
          count++;
          if (checkBoxes.size() == values.size()) {
            ((LinearLayout) view).addView(tmp);
          }
        } else if (count == 1) {
          tmp.addView(c);
          ((LinearLayout) view).addView(tmp);
          tmp = new LinearLayout(ctx);
          tmp.setOrientation(LinearLayout.HORIZONTAL);
          count = 0;
        }
      }
      /*view = new LinearLayout(ctx);
      ((LinearLayout)view).setOrientation(LinearLayout.VERTICAL);
      checkBoxes = new ArrayList<>();
      int count = 0;
      for (VALUE v : values) {
          CheckBox c = new CheckBox(ctx);
          c.setText(v.getNameValue());
          c.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
          checkBoxes.add(c);
          if(values.size() >= 3) {
              LinearLayout tmp = new LinearLayout(ctx);
              tmp.setOrientation(LinearLayout.HORIZONTAL);
              if (count < 2) {
                  tmp.addView(c);
                  count++;
              } else {
                  ((LinearLayout) view).addView(tmp);
                  count = 0;
              }
          }else{
              ((LinearLayout) view).addView(c);
          }
      }*/
    }
    if (idType.equals(Constantes.TEXT) || idType.equals(Constantes.NUM)) {
      view = new EditText(ctx);
      ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
      view.setBackgroundResource(R.drawable.fondo_edittext);
      view.setPadding(10, 5, 10, 5);

      if (idType.equals(Constantes.NUM)) {
        ((TextView) view)
            .setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
      }
      if (idType.equals(Constantes.TEXT)) {
        ((TextView) view).setLines(4);
        ((TextView) view).setGravity(Gravity.LEFT | Gravity.TOP);
      }
    }
    if (idType.equals(Constantes.PHOTO)) {
      LinearLayout.LayoutParams left =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      LinearLayout.LayoutParams right =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      left.weight = 3;
      right.weight = 2;
      buttons = new ArrayList<>();
      Button take = new Button(ctx);
      Button show = new Button(ctx);

      take.setText("Tomar Foto");
      take.setLayoutParams(left);
      take.setBackgroundResource(R.drawable.custom_button_blue_left);
      take.setTextColor(Color.WHITE);
      show.setText("Ver");
      show.setLayoutParams(right);
      show.setBackgroundResource(R.drawable.custom_button_blue_right);
      show.setTextColor(Color.WHITE);
      show.setEnabled(false);

      buttons.add(take);
      buttons.add(show);

      view = new LinearLayout(ctx);
      ((LinearLayout) view).setOrientation(LinearLayout.HORIZONTAL);
      // ((LinearLayout)view).addView(take);
      // ((LinearLayout)view).addView(show);
    }

    return view;
  }
  @Override
  public View createView(Context context) {
    if (!receiverRegistered) {
      receiverRegistered = true;
      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
      filter.addAction(Intent.ACTION_MEDIA_CHECKING);
      filter.addAction(Intent.ACTION_MEDIA_EJECT);
      filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
      filter.addAction(Intent.ACTION_MEDIA_NOFS);
      filter.addAction(Intent.ACTION_MEDIA_REMOVED);
      filter.addAction(Intent.ACTION_MEDIA_SHARED);
      filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
      filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
      filter.addDataScheme("file");
      ApplicationLoader.applicationContext.registerReceiver(receiver, filter);
    }

    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            } else if (id == -2) {
              selectedFiles.clear();
              actionBar.hideActionMode();
              listView.invalidateViews();
            } else if (id == done) {
              if (delegate != null) {
                ArrayList<String> files = new ArrayList<>();
                files.addAll(selectedFiles.keySet());
                delegate.didSelectFiles(DocumentSelectActivity.this, files);
              }
            }
          }
        });
    selectedFiles.clear();
    actionModeViews.clear();

    final ActionBarMenu actionMode = actionBar.createActionMode();
    actionModeViews.add(
        actionMode.addItem(
            -2,
            R.drawable.ic_ab_back_grey,
            R.drawable.bar_selector_mode,
            null,
            AndroidUtilities.dp(54)));

    selectedMessagesCountTextView = new TextView(actionMode.getContext());
    selectedMessagesCountTextView.setTextSize(18);
    selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    selectedMessagesCountTextView.setTextColor(0xff737373);
    selectedMessagesCountTextView.setSingleLine(true);
    selectedMessagesCountTextView.setLines(1);
    selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
    selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2));
    selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
    selectedMessagesCountTextView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    actionMode.addView(selectedMessagesCountTextView);
    LinearLayout.LayoutParams layoutParams =
        (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
    layoutParams.weight = 1;
    layoutParams.width = 0;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    selectedMessagesCountTextView.setLayoutParams(layoutParams);

    actionModeViews.add(
        actionMode.addItem(
            done,
            R.drawable.ic_ab_done_gray,
            R.drawable.bar_selector_mode,
            null,
            AndroidUtilities.dp(54)));

    fragmentView =
        getParentActivity()
            .getLayoutInflater()
            .inflate(R.layout.document_select_layout, null, false);
    listAdapter = new ListAdapter(context);
    emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
    emptyView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    listView = (ListView) fragmentView.findViewById(R.id.listView);
    listView.setEmptyView(emptyView);
    listView.setAdapter(listAdapter);

    listView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            scrolling = scrollState != SCROLL_STATE_IDLE;
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int i, long id) {
            if (actionBar.isActionModeShowed() || i < 0 || i >= items.size()) {
              return false;
            }
            ListItem item = items.get(i);
            File file = item.file;
            if (file != null && !file.isDirectory()) {
              if (!file.canRead()) {
                showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
                return false;
              }
              if (sizeLimit != 0) {
                if (file.length() > sizeLimit) {
                  showErrorBox(
                      LocaleController.formatString(
                          "FileUploadLimit",
                          R.string.FileUploadLimit,
                          AndroidUtilities.formatFileSize(sizeLimit)));
                  return false;
                }
              }
              if (file.length() == 0) {
                return false;
              }
              selectedFiles.put(file.toString(), item);
              selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
              if (Build.VERSION.SDK_INT >= 11) {
                AnimatorSetProxy animatorSet = new AnimatorSetProxy();
                ArrayList<Object> animators = new ArrayList<>();
                for (int a = 0; a < actionModeViews.size(); a++) {
                  View view2 = actionModeViews.get(a);
                  AndroidUtilities.clearDrawableAnimation(view2);
                  if (a < 1) {
                    animators.add(
                        ObjectAnimatorProxy.ofFloat(
                            view2, "translationX", -AndroidUtilities.dp(56), 0));
                  } else {
                    animators.add(ObjectAnimatorProxy.ofFloat(view2, "scaleY", 0.1f, 1.0f));
                  }
                }
                animatorSet.playTogether(animators);
                animatorSet.setDuration(250);
                animatorSet.start();
              }
              scrolling = false;
              if (view instanceof SharedDocumentCell) {
                ((SharedDocumentCell) view).setChecked(true, true);
              }
              actionBar.showActionMode();
            }
            return true;
          }
        });

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i < 0 || i >= items.size()) {
              return;
            }
            ListItem item = items.get(i);
            File file = item.file;
            if (file == null) {
              if (item.icon == R.drawable.ic_storage_gallery) {
                if (delegate != null) {
                  delegate.startDocumentSelectActivity();
                }
                finishFragment(false);
              } else {
                HistoryEntry he = history.remove(history.size() - 1);
                actionBar.setTitle(he.title);
                if (he.dir != null) {
                  listFiles(he.dir);
                } else {
                  listRoots();
                }
                listView.setSelectionFromTop(he.scrollItem, he.scrollOffset);
              }
            } else if (file.isDirectory()) {
              HistoryEntry he = new HistoryEntry();
              he.scrollItem = listView.getFirstVisiblePosition();
              he.scrollOffset = listView.getChildAt(0).getTop();
              he.dir = currentDir;
              he.title = actionBar.getTitle();
              history.add(he);
              if (!listFiles(file)) {
                history.remove(he);
                return;
              }
              actionBar.setTitle(item.title);
              listView.setSelection(0);
            } else {
              if (!file.canRead()) {
                showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
                file = new File("/mnt/sdcard");
              }
              if (sizeLimit != 0) {
                if (file.length() > sizeLimit) {
                  showErrorBox(
                      LocaleController.formatString(
                          "FileUploadLimit",
                          R.string.FileUploadLimit,
                          AndroidUtilities.formatFileSize(sizeLimit)));
                  return;
                }
              }
              if (file.length() == 0) {
                return;
              }
              if (actionBar.isActionModeShowed()) {
                if (selectedFiles.containsKey(file.toString())) {
                  selectedFiles.remove(file.toString());
                } else {
                  selectedFiles.put(file.toString(), item);
                }
                if (selectedFiles.isEmpty()) {
                  actionBar.hideActionMode();
                } else {
                  selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
                }
                scrolling = false;
                if (view instanceof SharedDocumentCell) {
                  ((SharedDocumentCell) view)
                      .setChecked(selectedFiles.containsKey(item.file.toString()), true);
                }
              } else {
                if (delegate != null) {
                  ArrayList<String> files = new ArrayList<>();
                  files.add(file.getAbsolutePath());
                  delegate.didSelectFiles(DocumentSelectActivity.this, files);
                }
              }
            }
          }
        });

    listRoots();

    return fragmentView;
  }
示例#18
0
 @Override
 public void setLines(final int lines) {
   super.setLines(lines);
   _maxLines = lines;
   reAdjust();
 }
示例#19
0
  public LinearLayout prepareLayout(Context c) {
    this.item = this.answers.get(0).getValue();
    this.min = Integer.parseInt(this.answers.get(1).getValue());
    this.max = Integer.parseInt(this.answers.get(2).getValue());
    if (result == -1) result = this.min;

    LinearLayout layout = new LinearLayout(c);
    layout.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    layout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout A_layout = new LinearLayout(c);
    A_layout.setOrientation(LinearLayout.VERTICAL);
    A_layout.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1));

    TextView questionText = new TextView(c);
    questionText.setText(getQuestion().replace("|", "\n"));
    questionText.setTextAppearance(c, android.R.attr.textAppearanceLarge);
    questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 22);
    questionText.setLines(4);

    counterText = new TextView(c);
    counterText.setText(result + " " + item);
    counterText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 22);

    LinearLayout.LayoutParams layoutt =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    layoutt.setMargins(10, 15, 10, 0);

    questionText.setLayoutParams(layoutt);
    counterText.setLayoutParams(layoutt);

    final NumberPickerMe np = new NumberPickerMe(c);
    np.setLayoutParams(layoutt);
    np.setMaxValue(max);
    np.setMinValue(min);
    np.setValue(result);

    answered = true;
    np.setOnValueChangedListener(
        new OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            // TODO Auto-generated method stub
            result = newVal;
            np.setValue(result);
            counterText.setText(result + " " + item);
          }
        });

    //		SeekBar sb = new SeekBar(c);
    //		sb.setMax(15);
    //		sb.setProgress(result);
    //		sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
    //			public void onProgressChanged(SeekBar seekBar, int progress,
    //					boolean fromUser) {
    //				if(fromUser){
    //					result = progress;
    //					counterText.setText(progress + " drinks");
    //					answered = true;
    //				}
    //			}
    //			public void onStartTrackingTouch(SeekBar seekBar) {		}
    //			public void onStopTrackingTouch(SeekBar seekBar)  {		}
    //		});

    layout.addView(questionText);

    A_layout.addView(counterText);
    A_layout.addView(np);
    layout.addView(A_layout);

    //		layout.addView(counterText);
    //		layout.addView(sb);
    //		layout.addView(np);

    return layout;
  }
示例#20
0
  static void populateEntryView(
      final View view,
      final Entry entry,
      final EntryManager entryManager,
      final UIHelper uiHelper) {
    final Resources resources = entryManager.getContext().getResources();

    // swipe
    final SwipeRelativeLayout swipeContainer =
        (SwipeRelativeLayout) view.findViewById(R.id.swipe_container);

    final View outterContainer = view.findViewById(R.id.outter_container);
    outterContainer.setPadding(0, 0, 0, 0);

    swipeContainer.setSwipeListener(
        new SwipeRelativeLayout.ISwipeListener() {

          private final int selectionFeedbackColor = resources.getColor(R.color.selection_feedback);

          public boolean swipeTopToBottom(final View v) {
            return false;
          }

          public boolean swipeRightToLeft(final View v) {

            view.setBackgroundColor(selectionFeedbackColor);
            entryManager.increaseUnreadLevel(entry);
            return true;
          }

          public boolean swipeLeftToRight(final View v) {

            view.setBackgroundColor(selectionFeedbackColor);
            entryManager.increaseReadLevel(entry);
            return true;
          }

          public boolean swipeBottomToTop(final View v) {
            return false;
          }

          public boolean onLongClick(final View v, final MotionEvent e) {
            return view.performLongClick();
          }

          public boolean onClick(final View v, final MotionEvent e) {
            return view.performClick();
          }
        });

    swipeContainer.setSwipeEnabeld(entryManager.isSwipeOnArticleDetailViewEnabled());
    swipeContainer.setBackgroundResource(R.drawable.article_header_background_thin);

    final TextView entryTitleView = (TextView) view.findViewById(R.id.entry_title);
    final TextView feedTitleView = (TextView) view.findViewById(R.id.feed_title);

    if (feedTitleView == null || entryTitleView == null) {
      Log.e(TAG, "feedTitleView or entryTitleView were null.");
      return;
    }

    if (entry == null) {
      Log.d(TAG, "entry was null");
      return;
    }

    if (entry.getFeedTitle() == null) {
      Log.e(TAG, "entry.getFeedTitle() was null.");
      return;
    }

    feedTitleView.setText(entry.getFeedTitle());
    entryTitleView.setText(entry.getTitle());

    if (entryManager.shouldTitlesBeEllipsized()) {
      entryTitleView.setEllipsize(TruncateAt.MIDDLE);
      entryTitleView.setLines(2);
    }

    // final int backgroundColor = resources.getColor(entry.isRead() ?
    // R.color.article_read_background
    // : R.color.article_unread_background);
    // final int textColor = resources.getColor(entry.isRead() ?
    // R.color.article_read_text
    // : R.color.article_unread_text);

    final TextView readIndicator = (TextView) view.findViewById(R.id.read_status_indicator);
    final int readIndicatorBackground =
        entryManager.isLightColorSchemeSelected()
            ? R.drawable.read_indicator
            : R.drawable.read_indicator_dark;
    final int pinnedIndicatorBackground =
        entryManager.isLightColorSchemeSelected()
            ? R.drawable.pinned_indicator
            : R.drawable.pinned_indicator_dark;

    int bgReadIndicator = -1;

    switch (entry.getReadState()) {
      case READ:
        bgReadIndicator = R.drawable.read_indicator_invisible;
        break;
      case UNREAD:
        bgReadIndicator = readIndicatorBackground;
        break;
      default:
        bgReadIndicator = pinnedIndicatorBackground;
    }

    readIndicator.setBackgroundResource(bgReadIndicator);

    // view.setBackgroundColor(backgroundColor);
    View container = view.findViewById(R.id.outter_container);
    if (entryManager.isLightColorSchemeSelected())
      container.setBackgroundColor(resources.getColor(R.color.article_read_background));
    else
      container.setBackgroundDrawable(
          resources.getDrawable(R.drawable.article_header_background_dark));

    // entryTitleView.setTextColor(textColor);
    // feedTitleView.setTextColor(textColor);

    //
    feedTitleView.setCompoundDrawablePadding(3);
    feedTitleView.setCompoundDrawablesWithIntrinsicBounds(
        resources.getDrawable(
            uiHelper.getArticleDownloadIndicatorDrawable(
                entry.getDownloaded(), entry.getDownloadPref(), resources)),
        null,
        null,
        null);

    // star check box
    final CheckBox starCheckBox = (CheckBox) view.findViewById(R.id.star_checkbox);
    starCheckBox.setVisibility(View.VISIBLE);
    starCheckBox.setChecked(entry.isStarred());
    starCheckBox.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(final View v) {
            entryManager.updateStarredState(entry, starCheckBox.isChecked());
          }
        });
    starCheckBox.requestFocus();

    if (false) {
      // changed
      final TextView changedView = (TextView) view.findViewById(R.id.article_changed);

      final boolean stateChanged = entry.isReadStatePending() || entry.isStarredStatePending();
      changedView.setText(stateChanged ? "*" : "");
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    classGuid = ConnectionsManager.getInstance().generateClassGuid();
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);

    typingDotsDrawable = new TypingDotsDrawable();
    recordStatusDrawable = new RecordStatusDrawable();

    SizeNotifierRelativeLayout contentView = new SizeNotifierRelativeLayout(this);
    setContentView(contentView);
    contentView.setBackgroundColor(0x99000000);

    RelativeLayout relativeLayout = new RelativeLayout(this);
    contentView.addView(relativeLayout);
    RelativeLayout.LayoutParams layoutParams3 =
        (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.MATCH_PARENT;
    relativeLayout.setLayoutParams(layoutParams3);

    RelativeLayout popupContainer = new RelativeLayout(this);
    popupContainer.setBackgroundColor(0xffffffff);
    relativeLayout.addView(popupContainer);
    layoutParams3 = (RelativeLayout.LayoutParams) popupContainer.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = AndroidUtilities.dp(240);
    layoutParams3.leftMargin = AndroidUtilities.dp(12);
    layoutParams3.rightMargin = AndroidUtilities.dp(12);
    layoutParams3.addRule(RelativeLayout.CENTER_IN_PARENT);
    popupContainer.setLayoutParams(layoutParams3);

    if (chatActivityEnterView != null) {
      chatActivityEnterView.onDestroy();
    }
    chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
    popupContainer.addView(chatActivityEnterView);
    layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    chatActivityEnterView.setLayoutParams(layoutParams3);
    chatActivityEnterView.setDelegate(
        new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
          @Override
          public void onMessageSend(String message) {
            if (currentMessageObject == null) {
              return;
            }
            if (currentMessageNum >= 0
                && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
              NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
            }
            MessagesController.getInstance()
                .markDialogAsRead(
                    currentMessageObject.getDialogId(),
                    currentMessageObject.getId(),
                    Math.max(0, currentMessageObject.getId()),
                    0,
                    currentMessageObject.messageOwner.date,
                    true,
                    true);
            currentMessageObject = null;
            getNewMessage();
          }

          @Override
          public void onTextChanged(CharSequence text, boolean big) {}

          @Override
          public void needSendTyping() {
            if (currentMessageObject != null) {
              MessagesController.getInstance()
                  .sendTyping(currentMessageObject.getDialogId(), 0, classGuid);
            }
          }

          @Override
          public void onAttachButtonHidden() {}

          @Override
          public void onAttachButtonShow() {}

          @Override
          public void onWindowSizeChanged(int size) {}
        });

    messageContainer = new FrameLayoutTouch(this);
    popupContainer.addView(messageContainer, 0);

    actionBar = new ActionBar(this);
    actionBar.setOccupyStatusBar(false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackgroundColor(0xff54759e);
    actionBar.setItemsBackground(R.drawable.bar_selector);
    popupContainer.addView(actionBar);
    ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    actionBar.setLayoutParams(layoutParams);

    ActionBarMenu menu = actionBar.createMenu();
    View view = menu.addItemResource(2, R.layout.popup_count_layout);
    countText = (TextView) view.findViewById(R.id.count_text);

    avatarContainer = new FrameLayoutFixed(this);
    avatarContainer.setBackgroundResource(R.drawable.bar_selector);
    avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
    actionBar.addView(avatarContainer);
    FrameLayout.LayoutParams layoutParams2 =
        (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
    layoutParams2.height = LayoutHelper.MATCH_PARENT;
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.rightMargin = AndroidUtilities.dp(48);
    layoutParams2.leftMargin = AndroidUtilities.dp(60);
    layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
    avatarContainer.setLayoutParams(layoutParams2);

    avatarImageView = new BackupImageView(this);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    avatarContainer.addView(avatarImageView);
    layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
    layoutParams2.width = AndroidUtilities.dp(42);
    layoutParams2.height = AndroidUtilities.dp(42);
    layoutParams2.topMargin = AndroidUtilities.dp(3);
    avatarImageView.setLayoutParams(layoutParams2);

    nameTextView = new TextView(this);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    avatarContainer.addView(nameTextView);
    layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(22);
    layoutParams2.gravity = Gravity.BOTTOM;
    nameTextView.setLayoutParams(layoutParams2);

    onlineTextView = new TextView(this);
    onlineTextView.setTextColor(0xffd7e8f7);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setLines(1);
    onlineTextView.setMaxLines(1);
    onlineTextView.setSingleLine(true);
    onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
    onlineTextView.setGravity(Gravity.LEFT);
    avatarContainer.addView(onlineTextView);
    layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(4);
    layoutParams2.gravity = Gravity.BOTTOM;
    onlineTextView.setLayoutParams(layoutParams2);

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              onFinish();
              finish();
            } else if (id == 1) {
              openCurrentMessage();
            } else if (id == 2) {
              switchToNextMessage();
            }
          }
        });

    PowerManager pm =
        (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
    wakeLock =
        pm.newWakeLock(
            PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
    wakeLock.setReferenceCounted(false);

    handleIntent(getIntent());
  }
  @SuppressWarnings("unchecked")
  @Override
  public View createView(Context context) {
    actionBar.setBackgroundColor(0xff333333);
    actionBar.setItemsBackground(R.drawable.bar_selector_picker);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              if (Build.VERSION.SDK_INT < 11) {
                listView.setAdapter(null);
                listView = null;
                listAdapter = null;
              }
              finishFragment();
            } else if (id == 1) {
              if (delegate != null) {
                finishFragment(false);
                delegate.startPhotoSelectActivity();
              }
            } else if (id == item_photos) {
              if (selectedMode == 0) {
                return;
              }
              selectedMode = 0;
              dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
              emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
              listAdapter.notifyDataSetChanged();
            } else if (id == item_video) {
              if (selectedMode == 1) {
                return;
              }
              selectedMode = 1;
              dropDown.setText(LocaleController.getString("PickerVideo", R.string.PickerVideo));
              emptyView.setText(LocaleController.getString("NoVideo", R.string.NoVideo));
              listAdapter.notifyDataSetChanged();
            }
          }
        });

    ActionBarMenu menu = actionBar.createMenu();
    menu.addItem(1, R.drawable.ic_ab_other);

    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(0xff000000);

    if (!singlePhoto) {
      selectedMode = 0;

      dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector_picker);
      dropDownContainer.setSubMenuOpenSide(1);
      dropDownContainer.addSubItem(
          item_photos, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0);
      dropDownContainer.addSubItem(
          item_video, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0);
      actionBar.addView(dropDownContainer);
      FrameLayout.LayoutParams layoutParams =
          (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
      layoutParams.height = LayoutHelper.MATCH_PARENT;
      layoutParams.width = LayoutHelper.WRAP_CONTENT;
      layoutParams.rightMargin = AndroidUtilities.dp(40);
      layoutParams.leftMargin =
          AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
      layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
      dropDownContainer.setLayoutParams(layoutParams);
      dropDownContainer.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              dropDownContainer.toggleSubMenu();
            }
          });

      dropDown = new TextView(context);
      dropDown.setGravity(Gravity.LEFT);
      dropDown.setSingleLine(true);
      dropDown.setLines(1);
      dropDown.setMaxLines(1);
      dropDown.setEllipsize(TextUtils.TruncateAt.END);
      dropDown.setTextColor(0xffffffff);
      dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
      dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
      dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
      dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
      dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
      dropDownContainer.addView(dropDown);
      layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
      layoutParams.width = LayoutHelper.WRAP_CONTENT;
      layoutParams.height = LayoutHelper.WRAP_CONTENT;
      layoutParams.leftMargin = AndroidUtilities.dp(16);
      layoutParams.gravity = Gravity.CENTER_VERTICAL;
      dropDown.setLayoutParams(layoutParams);
    } else {
      actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
    }

    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);

    pickerBottomLayout = new PickerBottomLayout(context);
    frameLayout.addView(pickerBottomLayout);
    layoutParams = (FrameLayout.LayoutParams) pickerBottomLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    layoutParams.gravity = Gravity.BOTTOM;
    pickerBottomLayout.setLayoutParams(layoutParams);
    pickerBottomLayout.cancelButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            finishFragment();
          }
        });
    pickerBottomLayout.doneButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            sendSelectedPhotos();
            finishFragment();
          }
        });

    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
      progressView.setVisibility(View.VISIBLE);
      listView.setEmptyView(null);
    } else {
      progressView.setVisibility(View.GONE);
      listView.setEmptyView(emptyView);
    }
    pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);

    return fragmentView;
  }
  public SharedDocumentCell(Context context) {
    super(context);

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

    TAG = MediaController.getInstance().generateObserverTag();

    placeholderImabeView = new ImageView(context);
    addView(
        placeholderImabeView,
        LayoutHelper.createFrame(
            40,
            40,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 12,
            8,
            LocaleController.isRTL ? 12 : 0,
            0));

    extTextView = new TextView(context);
    extTextView.setTextColor(0xffffffff);
    extTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    extTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    extTextView.setLines(1);
    extTextView.setMaxLines(1);
    extTextView.setSingleLine(true);
    extTextView.setGravity(Gravity.CENTER);
    extTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(
        extTextView,
        LayoutHelper.createFrame(
            32,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 16,
            22,
            LocaleController.isRTL ? 16 : 0,
            0));

    thumbImageView = new BackupImageView(context);
    addView(
        thumbImageView,
        LayoutHelper.createFrame(
            40,
            40,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 12,
            8,
            LocaleController.isRTL ? 12 : 0,
            0));
    thumbImageView
        .getImageReceiver()
        .setDelegate(
            new ImageReceiver.ImageReceiverDelegate() {
              @Override
              public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) {
                extTextView.setVisibility(set ? INVISIBLE : VISIBLE);
                placeholderImabeView.setVisibility(set ? INVISIBLE : VISIBLE);
              }
            });

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(
        (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(
        nameTextView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 8 : 72,
            5,
            LocaleController.isRTL ? 72 : 8,
            0));

    statusImageView = new ImageView(context);
    statusImageView.setVisibility(INVISIBLE);
    addView(
        statusImageView,
        LayoutHelper.createFrame(
            LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 8 : 72,
            35,
            LocaleController.isRTL ? 72 : 8,
            0));

    dateTextView = new TextView(context);
    dateTextView.setTextColor(0xff999999);
    dateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    dateTextView.setLines(1);
    dateTextView.setMaxLines(1);
    dateTextView.setSingleLine(true);
    dateTextView.setEllipsize(TextUtils.TruncateAt.END);
    dateTextView.setGravity(
        (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(
        dateTextView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 8 : 72,
            30,
            LocaleController.isRTL ? 72 : 8,
            0));

    progressView = new LineProgressView(context);
    addView(
        progressView,
        LayoutHelper.createFrame(
            LayoutHelper.MATCH_PARENT,
            2,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 72,
            54,
            LocaleController.isRTL ? 72 : 0,
            0));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setVisibility(INVISIBLE);
    addView(
        checkBox,
        LayoutHelper.createFrame(
            22,
            22,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
            LocaleController.isRTL ? 0 : 34,
            30,
            LocaleController.isRTL ? 34 : 0,
            0));
  }
 @Override
 public void setLines(int lines) {
   super.setLines(lines);
   mMaxLines = lines;
   reAdjust();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    classGuid = ConnectionsManager.getInstance().generateClassGuid();
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);

    typingDotsDrawable = new TypingDotsDrawable();
    recordStatusDrawable = new RecordStatusDrawable();

    SizeNotifierFrameLayout contentView =
        new SizeNotifierFrameLayout(this) {
          @Override
          protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int widthMode = MeasureSpec.getMode(widthMeasureSpec);
            int heightMode = MeasureSpec.getMode(heightMeasureSpec);
            int widthSize = MeasureSpec.getSize(widthMeasureSpec);
            int heightSize = MeasureSpec.getSize(heightMeasureSpec);

            setMeasuredDimension(widthSize, heightSize);

            int keyboardSize = getKeyboardHeight();

            if (keyboardSize <= AndroidUtilities.dp(20)) {
              heightSize -= chatActivityEnterView.getEmojiPadding();
            }

            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
              View child = getChildAt(i);
              if (child.getVisibility() == GONE) {
                continue;
              }
              if (chatActivityEnterView.isPopupView(child)) {
                child.measure(
                    MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(
                        child.getLayoutParams().height, MeasureSpec.EXACTLY));
              } else {
                child.measure(
                    MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(
                        Math.max(AndroidUtilities.dp(10), heightSize + AndroidUtilities.dp(2)),
                        MeasureSpec.EXACTLY));
              }
            }
          }

          @Override
          protected void onLayout(boolean changed, int l, int t, int r, int b) {
            final int count = getChildCount();

            int paddingBottom =
                getKeyboardHeight() <= AndroidUtilities.dp(20)
                    ? chatActivityEnterView.getEmojiPadding()
                    : 0;

            for (int i = 0; i < count; i++) {
              final View child = getChildAt(i);
              if (child.getVisibility() == GONE) {
                continue;
              }
              final LayoutParams lp = (LayoutParams) child.getLayoutParams();

              int width = child.getMeasuredWidth();
              int height = child.getMeasuredHeight();

              int childLeft;
              int childTop;

              int gravity = lp.gravity;
              if (gravity == -1) {
                gravity = Gravity.TOP | Gravity.LEFT;
              }

              final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
              final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;

              switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.CENTER_HORIZONTAL:
                  childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
                  break;
                case Gravity.RIGHT:
                  childLeft = r - width - lp.rightMargin;
                  break;
                case Gravity.LEFT:
                default:
                  childLeft = lp.leftMargin;
              }

              switch (verticalGravity) {
                case Gravity.TOP:
                  childTop = lp.topMargin;
                  break;
                case Gravity.CENTER_VERTICAL:
                  childTop =
                      ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
                  break;
                case Gravity.BOTTOM:
                  childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
                  break;
                default:
                  childTop = lp.topMargin;
              }
              if (chatActivityEnterView.isPopupView(child)) {
                childTop =
                    paddingBottom != 0 ? getMeasuredHeight() - paddingBottom : getMeasuredHeight();
              }
              child.layout(childLeft, childTop, childLeft + width, childTop + height);
            }

            notifyHeightChanged();
          }
        };
    setContentView(contentView);
    contentView.setBackgroundColor(0x99000000);

    RelativeLayout relativeLayout = new RelativeLayout(this);
    contentView.addView(
        relativeLayout,
        LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    RelativeLayout popupContainer = new RelativeLayout(this);
    popupContainer.setBackgroundColor(0xffffffff);
    relativeLayout.addView(
        popupContainer,
        LayoutHelper.createRelative(
            LayoutHelper.MATCH_PARENT, 240, 12, 0, 12, 0, RelativeLayout.CENTER_IN_PARENT));

    if (chatActivityEnterView != null) {
      chatActivityEnterView.onDestroy();
    }
    chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
    popupContainer.addView(
        chatActivityEnterView,
        LayoutHelper.createRelative(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            RelativeLayout.ALIGN_PARENT_BOTTOM));
    chatActivityEnterView.setDelegate(
        new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
          @Override
          public void onMessageSend(String message) {
            if (currentMessageObject == null) {
              return;
            }
            if (currentMessageNum >= 0
                && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
              NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
            }
            MessagesController.getInstance()
                .markDialogAsRead(
                    currentMessageObject.getDialogId(),
                    currentMessageObject.getId(),
                    Math.max(0, currentMessageObject.getId()),
                    0,
                    currentMessageObject.messageOwner.date,
                    true,
                    true);
            currentMessageObject = null;
            getNewMessage();
          }

          @Override
          public void onTextChanged(CharSequence text, boolean big) {}

          @Override
          public void needSendTyping() {
            if (currentMessageObject != null) {
              MessagesController.getInstance()
                  .sendTyping(currentMessageObject.getDialogId(), 0, classGuid);
            }
          }

          @Override
          public void onAttachButtonHidden() {}

          @Override
          public void onAttachButtonShow() {}

          @Override
          public void onWindowSizeChanged(int size) {}
        });

    messageContainer = new FrameLayoutTouch(this);
    popupContainer.addView(messageContainer, 0);

    actionBar = new ActionBar(this);
    actionBar.setOccupyStatusBar(false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackgroundColor(0xff54759e);
    actionBar.setItemsBackground(R.drawable.bar_selector);
    popupContainer.addView(actionBar);
    ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    actionBar.setLayoutParams(layoutParams);

    ActionBarMenu menu = actionBar.createMenu();
    View view = menu.addItemResource(2, R.layout.popup_count_layout);
    countText = (TextView) view.findViewById(R.id.count_text);

    avatarContainer = new FrameLayoutFixed(this);
    avatarContainer.setBackgroundResource(R.drawable.bar_selector);
    avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
    actionBar.addView(avatarContainer);
    FrameLayout.LayoutParams layoutParams2 =
        (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
    layoutParams2.height = LayoutHelper.MATCH_PARENT;
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.rightMargin = AndroidUtilities.dp(48);
    layoutParams2.leftMargin = AndroidUtilities.dp(60);
    layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
    avatarContainer.setLayoutParams(layoutParams2);

    avatarImageView = new BackupImageView(this);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    avatarContainer.addView(avatarImageView);
    layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
    layoutParams2.width = AndroidUtilities.dp(42);
    layoutParams2.height = AndroidUtilities.dp(42);
    layoutParams2.topMargin = AndroidUtilities.dp(3);
    avatarImageView.setLayoutParams(layoutParams2);

    nameTextView = new TextView(this);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    avatarContainer.addView(nameTextView);
    layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(22);
    layoutParams2.gravity = Gravity.BOTTOM;
    nameTextView.setLayoutParams(layoutParams2);

    onlineTextView = new TextView(this);
    onlineTextView.setTextColor(0xffd7e8f7);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setLines(1);
    onlineTextView.setMaxLines(1);
    onlineTextView.setSingleLine(true);
    onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
    onlineTextView.setGravity(Gravity.LEFT);
    avatarContainer.addView(onlineTextView);
    layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(4);
    layoutParams2.gravity = Gravity.BOTTOM;
    onlineTextView.setLayoutParams(layoutParams2);

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              onFinish();
              finish();
            } else if (id == 1) {
              openCurrentMessage();
            } else if (id == 2) {
              switchToNextMessage();
            }
          }
        });

    PowerManager pm =
        (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
    wakeLock =
        pm.newWakeLock(
            PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
    wakeLock.setReferenceCounted(false);

    handleIntent(getIntent());
  }