示例#1
0
  protected void init() {
    super.init();

    checkResources(getContext());

    clockIconPaint = new Paint();
    clockIconPaint.setStyle(Paint.Style.STROKE);
    clockIconPaint.setColor(0xff12C000);
    clockIconPaint.setStrokeWidth(getPx(1));
    clockIconPaint.setAntiAlias(true);
    clockIconPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    statePending = getResources().getDrawable(R.drawable.st_bubble_ic_clock);
    stateSent = getResources().getDrawable(R.drawable.st_bubble_ic_check);
    stateHalfCheck = getResources().getDrawable(R.drawable.st_bubble_ic_halfcheck);
    stateFailure = getResources().getDrawable(R.drawable.st_bubble_ic_warning);
  }
示例#2
0
  private static void checkResources(Context context) {
    if (!isLoaded) {
      TelegramApplication application = (TelegramApplication) context.getApplicationContext();
      IS_LARGE =
          application.getUserSettings().getDialogItemSize() == UserSettings.DIALOG_SIZE_LARGE;

      avatarPaint = new Paint();

      if (FontController.USE_SUBPIXEL) {
        titlePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        titlePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }

      titlePaint.setColor(0xff222222);
      if (IS_LARGE) {
        titlePaint.setTextSize(sp(20f));
        titlePaint.setTypeface(FontController.loadTypeface(context, "medium"));
      } else {
        titlePaint.setTextSize(sp(18f));
        titlePaint.setTypeface(FontController.loadTypeface(context, "medium"));
      }

      if (FontController.USE_SUBPIXEL) {
        titleHighlightPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        titleHighlightPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      titleHighlightPaint.setColor(0xff006FC8);
      if (IS_LARGE) {
        titleHighlightPaint.setTextSize(sp(20f));
        titleHighlightPaint.setTypeface(FontController.loadTypeface(context, "medium"));
      } else {
        titleHighlightPaint.setTextSize(sp(18f));
        titleHighlightPaint.setTypeface(FontController.loadTypeface(context, "medium"));
      }

      if (FontController.USE_SUBPIXEL) {
        titleEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        titleEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      titleEncryptedPaint.setColor(0xff368c3e);
      if (IS_LARGE) {
        titleEncryptedPaint.setTextSize(sp(20f));
        titleEncryptedPaint.setTypeface(FontController.loadTypeface(context, "medium"));
      } else {
        titleEncryptedPaint.setTextSize(sp(18f));
        titleEncryptedPaint.setTypeface(FontController.loadTypeface(context, "medium"));
      }

      if (FontController.USE_SUBPIXEL) {
        unreadClockPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        unreadClockPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      unreadClockPaint.setColor(UNREAD_TIME_COLOR);
      unreadClockPaint.setTextSize(sp(14));
      unreadClockPaint.setTypeface(FontController.loadTypeface(context, "regular"));

      if (FontController.USE_SUBPIXEL) {
        readClockPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        readClockPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      readClockPaint.setColor(READ_TIME_COLOR);
      readClockPaint.setTextSize(sp(14));
      readClockPaint.setTypeface(FontController.loadTypeface(context, "regular"));

      if (FontController.USE_SUBPIXEL) {
        bodyPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        bodyPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      bodyPaint.setColor(READ_COLOR);
      bodyPaint.setTextSize(sp(17f));
      bodyPaint.setTypeface(FontController.loadTypeface(context, "regular"));

      if (FontController.USE_SUBPIXEL) {
        bodyUnreadPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        bodyUnreadPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      bodyUnreadPaint.setColor(UNREAD_COLOR);
      bodyUnreadPaint.setTextSize(sp(17f));
      bodyUnreadPaint.setTypeface(FontController.loadTypeface(context, "regular"));

      if (FontController.USE_SUBPIXEL) {
        bodyHighlightPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        bodyHighlightPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      bodyHighlightPaint.setColor(HIGHLIGHT_COLOR);
      bodyHighlightPaint.setTextSize(sp(17f));
      bodyHighlightPaint.setTypeface(FontController.loadTypeface(context, "regular"));

      if (FontController.USE_SUBPIXEL) {
        typingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        typingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      typingPaint.setColor(0xff006FC8);
      typingPaint.setTextSize(sp(16f));
      typingPaint.setTypeface(FontController.loadTypeface(context, "regular"));

      if (FontController.USE_SUBPIXEL) {
        counterTitlePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        counterTitlePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      counterTitlePaint.setColor(0xffffffff);
      if (IS_LARGE) {
        counterTitlePaint.setTextSize(sp(15.5f));
      } else {
        counterTitlePaint.setTextSize(sp(14f));
      }
      counterTitlePaint.setTypeface(FontController.loadTypeface(context, "regular"));

      counterPaint = new Paint();
      counterPaint.setColor(0xff8fc478);
      counterPaint.setAntiAlias(true);

      placeholderPaint = new Paint();
      placeholderPaint.setAntiAlias(true);

      if (FontController.USE_SUBPIXEL) {
        placeholderTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
      } else {
        placeholderTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
      }
      placeholderTextPaint.setColor(0xffffffff);
      placeholderTextPaint.setTextSize(px(28f));
      placeholderTextPaint.setTypeface(FontController.loadTypeface(context, "regular"));
      placeholderTextPaint.setTextAlign(Paint.Align.CENTER);

      isLoaded = true;
    }
  }