Esempio n. 1
0
  public void updatePhotosButton() {
    int count = photoAttachAdapter.getSelectedPhotos().size();
    if (count == 0) {
      sendPhotosButton.imageView.setPadding(0, AndroidUtilities.dp(4), 0, 0);
      sendPhotosButton.imageView.setBackgroundResource(R.drawable.attach_hide_states);
      sendPhotosButton.imageView.setImageResource(R.drawable.attach_hide2);
      sendPhotosButton.textView.setText("");
    } else {
      sendPhotosButton.imageView.setPadding(AndroidUtilities.dp(2), 0, 0, 0);
      sendPhotosButton.imageView.setBackgroundResource(R.drawable.attach_send_states);
      sendPhotosButton.imageView.setImageResource(R.drawable.attach_send2);
      sendPhotosButton.textView.setText(
          LocaleController.formatString(
              "SendItems", R.string.SendItems, String.format("(%d)", count)));
    }

    if (Build.VERSION.SDK_INT >= 23
        && getContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
      progressView.setText(
          LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
      progressView.setTextSize(16);
    } else {
      progressView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
      progressView.setTextSize(20);
    }
  }
 public void updatePhotosButton() {
   int count = photoAttachAdapter.getSelectedPhotos().size();
   if (count == 0) {
     sendPhotosButton.imageView.setPadding(0, AndroidUtilities.dp(4), 0, 0);
     sendPhotosButton.imageView.setBackgroundResource(R.drawable.attach_hide_states);
     sendPhotosButton.imageView.setImageResource(R.drawable.attach_hide2);
     sendPhotosButton.textView.setText("");
   } else {
     sendPhotosButton.imageView.setPadding(AndroidUtilities.dp(2), 0, 0, 0);
     sendPhotosButton.imageView.setBackgroundResource(R.drawable.attach_send_states);
     sendPhotosButton.imageView.setImageResource(R.drawable.attach_send2);
     sendPhotosButton.textView.setText(
         LocaleController.formatString(
             "SendItems", R.string.SendItems, String.format("(%d)", count)));
   }
 }
  @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;
  }