Java Code Examples for org.telegram.ui.ActionBar.SimpleTextView#setTag()

The following examples show how to use org.telegram.ui.ActionBar.SimpleTextView#setTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterCreateActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void setTextLeft(View cell) {
    if (cell instanceof PollEditTextCell) {
        PollEditTextCell textCell = (PollEditTextCell) cell;
        int left = MAX_NAME_LENGTH - (newFilterName != null ? newFilterName.length() : 0);
        if (left <= MAX_NAME_LENGTH - MAX_NAME_LENGTH * 0.7f) {
            textCell.setText2(String.format("%d", left));
            SimpleTextView textView = textCell.getTextView2();
            String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
            textView.setTextColor(Theme.getColor(key));
            textView.setTag(key);
            textView.setAlpha(((PollEditTextCell) cell).getTextView().isFocused() || left < 0 ? 1.0f : 0.0f);
        } else {
            textCell.setText2("");
        }
    }
}
 
Example 2
Source File: FilterCreateActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void setTextLeft(View cell) {
    if (cell instanceof PollEditTextCell) {
        PollEditTextCell textCell = (PollEditTextCell) cell;
        int left = MAX_NAME_LENGTH - (newFilterName != null ? newFilterName.length() : 0);
        if (left <= MAX_NAME_LENGTH - MAX_NAME_LENGTH * 0.7f) {
            textCell.setText2(String.format("%d", left));
            SimpleTextView textView = textCell.getTextView2();
            String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
            textView.setTextColor(Theme.getColor(key));
            textView.setTag(key);
            textView.setAlpha(((PollEditTextCell) cell).getTextView().isFocused() || left < 0 ? 1.0f : 0.0f);
        } else {
            textCell.setText2("");
        }
    }
}
 
Example 3
Source File: ChatRightsEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void setTextLeft(View cell) {
    if (cell instanceof HeaderCell) {
        HeaderCell headerCell = (HeaderCell) cell;
        int left = MAX_RANK_LENGTH - (currentRank != null ? currentRank.codePointCount(0, currentRank.length()) : 0);
        if (left <= MAX_RANK_LENGTH - MAX_RANK_LENGTH * 0.7f) {
            headerCell.setText2(String.format("%d", left));
            SimpleTextView textView = headerCell.getTextView2();
            String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
            textView.setTextColor(Theme.getColor(key));
            textView.setTag(key);
        } else {
            headerCell.setText2("");
        }
    }
}
 
Example 4
Source File: FiltersSetupActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public TextCell(Context context) {
    super(context);

    textView = new SimpleTextView(context);
    textView.setTextSize(16);
    textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText2));
    textView.setTag(Theme.key_windowBackgroundWhiteBlueText2);
    addView(textView);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView);
}
 
Example 5
Source File: PollCreateActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void setTextLeft(View cell, int index) {
    if (!(cell instanceof PollEditTextCell)) {
        return;
    }
    PollEditTextCell textCell = (PollEditTextCell) cell;
    int max;
    int left;
    if (index == questionRow) {
        max = ChatAttachAlertPollLayout.MAX_QUESTION_LENGTH;
        left = ChatAttachAlertPollLayout.MAX_QUESTION_LENGTH - (questionString != null ? questionString.length() : 0);
    } else if (index == solutionRow) {
        max = ChatAttachAlertPollLayout.MAX_SOLUTION_LENGTH;
        left = ChatAttachAlertPollLayout.MAX_SOLUTION_LENGTH - (solutionString != null ? solutionString.length() : 0);
    } else if (index >= answerStartRow && index < answerStartRow + answersCount) {
        index -= answerStartRow;
        max = ChatAttachAlertPollLayout.MAX_ANSWER_LENGTH;
        left = ChatAttachAlertPollLayout.MAX_ANSWER_LENGTH - (answers[index] != null ? answers[index].length() : 0);
    } else {
        return;
    }
    if (left <= max - max * 0.7f) {
        textCell.setText2(String.format("%d", left));
        SimpleTextView textView = textCell.getTextView2();
        String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
        textView.setTextColor(Theme.getColor(key));
        textView.setTag(key);
    } else {
        textCell.setText2("");
    }
}
 
Example 6
Source File: ChatAttachAlertPollLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void setTextLeft(View cell, int index) {
    if (!(cell instanceof PollEditTextCell)) {
        return;
    }
    PollEditTextCell textCell = (PollEditTextCell) cell;
    int max;
    int left;
    if (index == questionRow) {
        max = MAX_QUESTION_LENGTH;
        left = MAX_QUESTION_LENGTH - (questionString != null ? questionString.length() : 0);
    } else if (index == solutionRow) {
        max = MAX_SOLUTION_LENGTH;
        left = MAX_SOLUTION_LENGTH - (solutionString != null ? solutionString.length() : 0);
    } else if (index >= answerStartRow && index < answerStartRow + answersCount) {
        index -= answerStartRow;
        max = MAX_ANSWER_LENGTH;
        left = MAX_ANSWER_LENGTH - (answers[index] != null ? answers[index].length() : 0);
    } else {
        return;
    }
    if (left <= max - max * 0.7f) {
        textCell.setText2(String.format("%d", left));
        SimpleTextView textView = textCell.getTextView2();
        String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
        textView.setTextColor(Theme.getColor(key));
        textView.setTag(key);
    } else {
        textCell.setText2("");
    }
}
 
Example 7
Source File: ChatRightsEditActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void setTextLeft(View cell) {
    if (cell instanceof HeaderCell) {
        HeaderCell headerCell = (HeaderCell) cell;
        int left = MAX_RANK_LENGTH - (currentRank != null ? currentRank.codePointCount(0, currentRank.length()) : 0);
        if (left <= MAX_RANK_LENGTH - MAX_RANK_LENGTH * 0.7f) {
            headerCell.setText2(String.format("%d", left));
            SimpleTextView textView = headerCell.getTextView2();
            String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
            textView.setTextColor(Theme.getColor(key));
            textView.setTag(key);
        } else {
            headerCell.setText2("");
        }
    }
}
 
Example 8
Source File: FiltersSetupActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public TextCell(Context context) {
    super(context);

    textView = new SimpleTextView(context);
    textView.setTextSize(16);
    textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText2));
    textView.setTag(Theme.key_windowBackgroundWhiteBlueText2);
    addView(textView);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView);
}
 
Example 9
Source File: PollCreateActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void setTextLeft(View cell, int index) {
    if (!(cell instanceof PollEditTextCell)) {
        return;
    }
    PollEditTextCell textCell = (PollEditTextCell) cell;
    int max;
    int left;
    if (index == questionRow) {
        max = ChatAttachAlertPollLayout.MAX_QUESTION_LENGTH;
        left = ChatAttachAlertPollLayout.MAX_QUESTION_LENGTH - (questionString != null ? questionString.length() : 0);
    } else if (index == solutionRow) {
        max = ChatAttachAlertPollLayout.MAX_SOLUTION_LENGTH;
        left = ChatAttachAlertPollLayout.MAX_SOLUTION_LENGTH - (solutionString != null ? solutionString.length() : 0);
    } else if (index >= answerStartRow && index < answerStartRow + answersCount) {
        index -= answerStartRow;
        max = ChatAttachAlertPollLayout.MAX_ANSWER_LENGTH;
        left = ChatAttachAlertPollLayout.MAX_ANSWER_LENGTH - (answers[index] != null ? answers[index].length() : 0);
    } else {
        return;
    }
    if (left <= max - max * 0.7f) {
        textCell.setText2(String.format("%d", left));
        SimpleTextView textView = textCell.getTextView2();
        String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
        textView.setTextColor(Theme.getColor(key));
        textView.setTag(key);
    } else {
        textCell.setText2("");
    }
}
 
Example 10
Source File: ChatAttachAlertPollLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void setTextLeft(View cell, int index) {
    if (!(cell instanceof PollEditTextCell)) {
        return;
    }
    PollEditTextCell textCell = (PollEditTextCell) cell;
    int max;
    int left;
    if (index == questionRow) {
        max = MAX_QUESTION_LENGTH;
        left = MAX_QUESTION_LENGTH - (questionString != null ? questionString.length() : 0);
    } else if (index == solutionRow) {
        max = MAX_SOLUTION_LENGTH;
        left = MAX_SOLUTION_LENGTH - (solutionString != null ? solutionString.length() : 0);
    } else if (index >= answerStartRow && index < answerStartRow + answersCount) {
        index -= answerStartRow;
        max = MAX_ANSWER_LENGTH;
        left = MAX_ANSWER_LENGTH - (answers[index] != null ? answers[index].length() : 0);
    } else {
        return;
    }
    if (left <= max - max * 0.7f) {
        textCell.setText2(String.format("%d", left));
        SimpleTextView textView = textCell.getTextView2();
        String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
        textView.setTextColor(Theme.getColor(key));
        textView.setTag(key);
    } else {
        textCell.setText2("");
    }
}
 
Example 11
Source File: ChatAvatarContainer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public ChatAvatarContainer(Context context, ChatActivity chatActivity, boolean needTime) {
    super(context);
    parentFragment = chatActivity;

    if (parentFragment != null) {
        sharedMediaPreloader = new SharedMediaLayout.SharedMediaPreloader(chatActivity);
    }

    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    addView(avatarImageView);
    if (parentFragment != null && !parentFragment.isInScheduleMode()) {
        avatarImageView.setOnClickListener(v -> openProfile(true));
    }

    titleTextView = new SimpleTextView(context);
    titleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
    titleTextView.setTextSize(18);
    titleTextView.setGravity(Gravity.LEFT);
    titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    titleTextView.setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
    addView(titleTextView);

    subtitleTextView = new SimpleTextView(context);
    subtitleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle));
    subtitleTextView.setTag(Theme.key_actionBarDefaultSubtitle);
    subtitleTextView.setTextSize(14);
    subtitleTextView.setGravity(Gravity.LEFT);
    addView(subtitleTextView);

    if (needTime) {
        timeItem = new ImageView(context);
        timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5));
        timeItem.setScaleType(ImageView.ScaleType.CENTER);
        timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context));
        addView(timeItem);
        timeItem.setOnClickListener(v -> parentFragment.showDialog(AlertsCreator.createTTLAlert(getContext(), parentFragment.getCurrentEncryptedChat()).create()));
        timeItem.setContentDescription(LocaleController.getString("SetTimer", R.string.SetTimer));
    }

    if (parentFragment != null && !parentFragment.isInScheduleMode()) {
        setOnClickListener(v -> openProfile(false));

        TLRPC.Chat chat = parentFragment.getCurrentChat();
        statusDrawables[0] = new TypingDotsDrawable();
        statusDrawables[1] = new RecordStatusDrawable();
        statusDrawables[2] = new SendingFileDrawable();
        statusDrawables[3] = new PlayingGameDrawable();
        statusDrawables[4] = new RoundStatusDrawable();
        for (int a = 0; a < statusDrawables.length; a++) {
            statusDrawables[a].setIsChat(chat != null);
        }
    }
}
 
Example 12
Source File: ChatAvatarContainer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public ChatAvatarContainer(Context context, ChatActivity chatActivity, boolean needTime) {
    super(context);
    parentFragment = chatActivity;

    if (parentFragment != null) {
        sharedMediaPreloader = new SharedMediaLayout.SharedMediaPreloader(chatActivity);
    }

    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    addView(avatarImageView);
    if (parentFragment != null && !parentFragment.isInScheduleMode()) {
        avatarImageView.setOnClickListener(v -> openProfile(true));
    }

    titleTextView = new SimpleTextView(context);
    titleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
    titleTextView.setTextSize(18);
    titleTextView.setGravity(Gravity.LEFT);
    titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    titleTextView.setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
    addView(titleTextView);

    subtitleTextView = new SimpleTextView(context);
    subtitleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle));
    subtitleTextView.setTag(Theme.key_actionBarDefaultSubtitle);
    subtitleTextView.setTextSize(14);
    subtitleTextView.setGravity(Gravity.LEFT);
    addView(subtitleTextView);

    if (needTime) {
        timeItem = new ImageView(context);
        timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5));
        timeItem.setScaleType(ImageView.ScaleType.CENTER);
        timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context));
        addView(timeItem);
        timeItem.setOnClickListener(v -> parentFragment.showDialog(AlertsCreator.createTTLAlert(getContext(), parentFragment.getCurrentEncryptedChat()).create()));
        timeItem.setContentDescription(LocaleController.getString("SetTimer", R.string.SetTimer));
    }

    if (parentFragment != null && !parentFragment.isInScheduleMode()) {
        setOnClickListener(v -> openProfile(false));

        TLRPC.Chat chat = parentFragment.getCurrentChat();
        statusDrawables[0] = new TypingDotsDrawable();
        statusDrawables[1] = new RecordStatusDrawable();
        statusDrawables[2] = new SendingFileDrawable();
        statusDrawables[3] = new PlayingGameDrawable();
        statusDrawables[4] = new RoundStatusDrawable();
        for (int a = 0; a < statusDrawables.length; a++) {
            statusDrawables[a].setIsChat(chat != null);
        }
    }
}