org.telegram.ui.ActionBar.Theme Java Examples

The following examples show how to use org.telegram.ui.ActionBar.Theme. 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: JoinSheetUserCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public JoinSheetUserCell(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    nameTextView.setMaxLines(1);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 65, 6, 0));
}
 
Example #2
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    TLRPC.FileLocation photo = null;
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(photo, "50_50", avatarDrawable);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #3
Source File: PhotoPickerActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
    ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();

    themeDescriptions.add(new ThemeDescription(sizeNotifierFrameLayout, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_dialogBackground));

    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_dialogBackground));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_dialogTextBlack));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_dialogTextBlack));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_dialogButtonSelector));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_dialogTextBlack));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_chat_messagePanelHint));
    themeDescriptions.add(new ThemeDescription(searchItem != null ? searchItem.getSearchField() : null, ThemeDescription.FLAG_CURSORCOLOR, null, null, null, null, Theme.key_dialogTextBlack));

    themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_dialogBackground));

    themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, null, new Drawable[]{Theme.chat_attachEmptyDrawable}, null, Theme.key_chat_attachEmptyImage));
    themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, null, null, null, Theme.key_chat_attachPhotoBackground));

    return themeDescriptions;
}
 
Example #4
Source File: DialogCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public DialogCell(Context context, boolean needCheck)
{
    super(context);

    Theme.createDialogsResources(context);
    avatarImage.setRoundRadius(AndroidUtilities.dp(26));

    if (needCheck)
    {
        checkBox = new GroupCreateCheckBox(context);
        checkBox.setVisibility(VISIBLE);
        addView(checkBox);
    }

    statusBG = new GradientDrawable();
    statusBG.setCornerRadius(AndroidUtilities.dp(16));
}
 
Example #5
Source File: WallpapersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
    WallpaperCell wallpaperCell = (WallpaperCell) viewHolder.itemView;
    if (i == 0) {
        wallpaperCell.setWallpaper(null, !Theme.hasWallpaperFromTheme() || overrideThemeWallpaper ? selectedBackground : -2, null, false);
    } else {
        if (Theme.hasWallpaperFromTheme()) {
            if (i == 1) {
                wallpaperCell.setWallpaper(null, overrideThemeWallpaper ? -1 : -2, themedWallpaper, true);
                return;
            } else {
                i -= 2;
            }
        } else {
            i--;
        }
        wallpaperCell.setWallpaper(wallPapers.get(i), !Theme.hasWallpaperFromTheme() || overrideThemeWallpaper ? selectedBackground : -2, null, false);
    }
}
 
Example #6
Source File: TextCheckBoxCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public TextCheckBoxCell(Context context, boolean dialog) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(dialog ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
    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);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 66 : 21, 0, LocaleController.isRTL ? 21 : 66, 0));

    checkBox = new CheckBoxSquare(context, dialog);
    checkBox.setDuplicateParentStateEnabled(false);
    checkBox.setFocusable(false);
    checkBox.setFocusableInTouchMode(false);
    checkBox.setClickable(false);
    addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0));
}
 
Example #7
Source File: PhotoPickerSearchActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
    ArrayList<ThemeDescription> arrayList = new ArrayList<>();

    arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_dialogBackground));
    arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_dialogBackground));
    arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_dialogTextBlack));
    arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_dialogTextBlack));
    arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_dialogButtonSelector));
    arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_dialogTextBlack));
    arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_chat_messagePanelHint));
    arrayList.add(new ThemeDescription(searchItem.getSearchField(), ThemeDescription.FLAG_CURSORCOLOR, null, null, null, null, Theme.key_dialogTextBlack));

    arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{TextView.class}, null, null, null, Theme.key_chat_attachActiveTab));
    arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{TextView.class}, null, null, null, Theme.key_chat_attachUnactiveTab));
    arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip.getTabsContainer(), ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{TextView.class}, null, null, null, Theme.key_dialogButtonSelector));
    arrayList.add(new ThemeDescription(null, 0, null, null, new Drawable[]{scrollSlidingTextTabStrip.getSelectorDrawable()}, null, Theme.key_chat_attachActiveTab));

    arrayList.addAll(imagesSearch.getThemeDescriptions());
    arrayList.addAll(gifsSearch.getThemeDescriptions());

    return arrayList;
}
 
Example #8
Source File: SettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #9
Source File: CameraScanActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
    ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
    if (currentType == TYPE_QR) {
        return themeDescriptions;
    }

    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));

    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarWhiteSelector));

    themeDescriptions.add(new ThemeDescription(titleTextView, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
    themeDescriptions.add(new ThemeDescription(descriptionText, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));

    return themeDescriptions;
}
 
Example #10
Source File: ChatUnreadCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public ChatUnreadCell(Context context) {
    super(context);

    backgroundLayout = new FrameLayout(context);
    backgroundLayout.setBackgroundResource(R.drawable.newmsg_divider);
    backgroundLayout.getBackground().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_unreadMessagesStartBackground), PorterDuff.Mode.MULTIPLY));
    addView(backgroundLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 27, Gravity.LEFT | Gravity.TOP, 0, 7, 0, 0));

    imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.ic_ab_new);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_unreadMessagesStartArrowIcon), PorterDuff.Mode.MULTIPLY));
    imageView.setPadding(0, AndroidUtilities.dp(2), 0, 0);
    backgroundLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    textView = new TextView(context);
    textView.setPadding(0, 0, 0, AndroidUtilities.dp(1));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setTextColor(Theme.getColor(Theme.key_chat_unreadMessagesStartText));
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
}
 
Example #11
Source File: ChangeUsernameActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ThemeDescription[] getThemeDescriptions()
{
    return new ThemeDescription[]{
            new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite),

            new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault),
            new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon),
            new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle),
            new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector),

            new ThemeDescription(firstNameField, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
            new ThemeDescription(firstNameField, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText),
            new ThemeDescription(firstNameField, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputField),
            new ThemeDescription(firstNameField, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated),

            new ThemeDescription(helpTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText8),

            new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteRedText4),
            new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteGreenText),
            new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText8),
    };
}
 
Example #12
Source File: BotHelpCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    int x = (canvas.getWidth() - width) / 2;
    int y = AndroidUtilities.dp(4);
    Theme.chat_msgInMediaShadowDrawable.setBounds(x, y, width + x, height + y);
    Theme.chat_msgInMediaShadowDrawable.draw(canvas);
    Theme.chat_msgInMediaDrawable.setBounds(x, y, width + x, height + y);
    Theme.chat_msgInMediaDrawable.draw(canvas);
    Theme.chat_msgTextPaint.setColor(Theme.getColor(Theme.key_chat_messageTextIn));
    Theme.chat_msgTextPaint.linkColor = Theme.getColor(Theme.key_chat_messageLinkIn);
    canvas.save();
    canvas.translate(textX = AndroidUtilities.dp(2 + 9) + x, textY = AndroidUtilities.dp(2 + 9) + y);
    if (pressedLink != null) {
        canvas.drawPath(urlPath, Theme.chat_urlPaint);
    }
    if (textLayout != null) {
        textLayout.draw(canvas);
    }
    canvas.restore();
}
 
Example #13
Source File: SlidingTabView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void addTextTab(final int position, String title)
{
    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(0xffffffff);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    tab.setTypeface(Typeface.DEFAULT_BOLD);
    tab.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, 0));

    tab.setOnClickListener(v -> didSelectTab(position));
    addView(tab);
    LayoutParams layoutParams = (LayoutParams) tab.getLayoutParams();
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.width = 0;
    layoutParams.weight = 50;
    tab.setLayoutParams(layoutParams);

    tabCount++;
}
 
Example #14
Source File: DialogCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public DialogCell(Context context, boolean needCheck, boolean forceThreeLines) {
    super(context);

    Theme.createDialogsResources(context);
    avatarImage.setRoundRadius(AndroidUtilities.dp(28));
    thumbImage.setRoundRadius(AndroidUtilities.dp(2));
    useForceThreeLines = forceThreeLines;

    if (needCheck) {
        checkBox = new CheckBox2(context, 21);
        checkBox.setColor(null, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck);
        checkBox.setDrawUnchecked(false);
        checkBox.setDrawBackgroundAsArc(3);
        addView(checkBox);
    }
}
 
Example #15
Source File: DocumentObject.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public ThemeDocument(TLRPC.TL_themeSettings settings) {
    themeSettings = settings;
    baseTheme = Theme.getTheme(Theme.getBaseThemeKey(settings));
    accent = baseTheme.createNewAccent(settings);
    if (themeSettings.wallpaper instanceof TLRPC.TL_wallPaper) {
        TLRPC.TL_wallPaper object = (TLRPC.TL_wallPaper) themeSettings.wallpaper;
        wallpaper = object.document;
        id = wallpaper.id;
        access_hash = wallpaper.access_hash;
        file_reference = wallpaper.file_reference;
        user_id = wallpaper.user_id;
        date = wallpaper.date;
        file_name = wallpaper.file_name;
        mime_type = wallpaper.mime_type;
        size = wallpaper.size;
        thumbs = wallpaper.thumbs;
        version = wallpaper.version;
        dc_id = wallpaper.dc_id;
        key = wallpaper.key;
        iv = wallpaper.iv;
        attributes = wallpaper.attributes;
    } else {
        id = Integer.MIN_VALUE;
        dc_id = Integer.MIN_VALUE;
    }
}
 
Example #16
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static Dialog createSingleChoiceDialog(Activity parentActivity, final String[] options, final String title, final int selected, final DialogInterface.OnClickListener listener) {
    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    for (int a = 0; a < options.length; a++) {
        RadioColorCell cell = new RadioColorCell(parentActivity);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(options[a], selected == a);
        linearLayout.addView(cell);
        cell.setOnClickListener(v -> {
            int sel = (Integer) v.getTag();
            builder.getDismissRunnable().run();
            listener.onClick(null, sel);
        });
    }

    builder.setTitle(title);
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder.create();
}
 
Example #17
Source File: RadioCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public RadioCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    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));

    radioButton = new RadioButton(context);
    radioButton.setSize(AndroidUtilities.dp(20));
    radioButton.setColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_radioBackgroundChecked));
    addView(radioButton, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, (LocaleController.isRTL ? 18 : 0), 13, (LocaleController.isRTL ? 0 : 18), 0));
}
 
Example #18
Source File: ThemeSetUrlActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void setCheckText(String text, String colorKey) {
    if (TextUtils.isEmpty(text)) {
        checkInfoCell.setVisibility(View.GONE);
        if (creatingNewTheme) {
            helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(getParentActivity(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
        } else {
            helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(getParentActivity(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
        }
    } else {
        checkInfoCell.setVisibility(View.VISIBLE);
        checkInfoCell.setText(text);
        checkInfoCell.setTag(colorKey);
        checkInfoCell.setTextColor(colorKey);
        if (creatingNewTheme) {
            helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(getParentActivity(), R.drawable.greydivider_top, Theme.key_windowBackgroundGrayShadow));
        } else {
            helpInfoCell.setBackgroundDrawable(null);
        }
    }
}
 
Example #19
Source File: SharedAudioCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (titleLayout != null) {
        canvas.save();
        canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), titleY);
        titleLayout.draw(canvas);
        canvas.restore();
    }

    if (descriptionLayout != null) {
        Theme.chat_contextResult_descriptionTextPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
        canvas.save();
        canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), descriptionY);
        descriptionLayout.draw(canvas);
        canvas.restore();
    }

    radialProgress.setProgressColor(Theme.getColor(buttonPressed ? Theme.key_chat_inAudioSelectedProgress : Theme.key_chat_inAudioProgress));
    radialProgress.draw(canvas);

    if (needDivider) {
        canvas.drawLine(AndroidUtilities.dp(72), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, Theme.dividerPaint);
    }
}
 
Example #20
Source File: BotKeyboardView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setButtons(TLRPC.TL_replyKeyboardMarkup buttons) {
    botButtons = buttons;
    container.removeAllViews();
    buttonViews.clear();
    scrollView.scrollTo(0, 0);

    if (buttons != null && botButtons.rows.size() != 0) {
        isFullSize = !buttons.resize;
        buttonHeight = !isFullSize ? 42 : (int) Math.max(42, (panelHeight - AndroidUtilities.dp(30) - (botButtons.rows.size() - 1) * AndroidUtilities.dp(10)) / botButtons.rows.size() / AndroidUtilities.density);
        for (int a = 0; a < buttons.rows.size(); a++) {
            TLRPC.TL_keyboardButtonRow row = buttons.rows.get(a);

            LinearLayout layout = new LinearLayout(getContext());
            layout.setOrientation(LinearLayout.HORIZONTAL);
            container.addView(layout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, buttonHeight, 15, a == 0 ? 15 : 10, 15, a == buttons.rows.size() - 1 ? 15 : 0));

            float weight = 1.0f / row.buttons.size();
            for (int b = 0; b < row.buttons.size(); b++) {
                TLRPC.KeyboardButton button = row.buttons.get(b);
                TextView textView = new TextView(getContext());
                textView.setTag(button);
                textView.setTextColor(Theme.getColor(Theme.key_chat_botKeyboardButtonText));
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
                textView.setGravity(Gravity.CENTER);
                textView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_chat_botKeyboardButtonBackground), Theme.getColor(Theme.key_chat_botKeyboardButtonBackgroundPressed)));
                textView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
                textView.setText(Emoji.replaceEmoji(button.text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
                layout.addView(textView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, weight, 0, 0, b != row.buttons.size() - 1 ? 10 : 0, 0));
                textView.setOnClickListener(v -> delegate.didPressedButton((TLRPC.KeyboardButton) v.getTag()));
                buttonViews.add(textView);
            }
        }
    }
}
 
Example #21
Source File: ThemePreviewActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
    if (screenType == SCREEN_TYPE_ACCENT_COLOR) {
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
    }
    if (screenType != SCREEN_TYPE_PREVIEW || accent != null) {
        if (SharedConfig.getDevicePerfomanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
            int w = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
            int h = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
            imageFilter = (int) (w / AndroidUtilities.density) + "_" + (int) (h / AndroidUtilities.density) + "_f";
        } else {
            imageFilter = (int) (1080 / AndroidUtilities.density) + "_" + (int) (1920 / AndroidUtilities.density) + "_f";
        }
        maxWallpaperSize = Math.min(1920, Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y));

        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.wallpapersNeedReload);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.wallpapersDidLoad);
        TAG = DownloadController.getInstance(currentAccount).generateObserverTag();

        if (patterns == null) {
            patterns = new ArrayList<>();
            MessagesStorage.getInstance(currentAccount).getWallpapers();
        }
    } else {
        isMotion = Theme.isWallpaperMotion();
    }

    return super.onFragmentCreate();
}
 
Example #22
Source File: NotificationsCheckCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (needDivider) {
        canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
    }
    if (drawLine) {
        int x = LocaleController.isRTL ? AndroidUtilities.dp(76) : getMeasuredWidth() - AndroidUtilities.dp(76) - 1;
        int y = (getMeasuredHeight() - AndroidUtilities.dp(22)) / 2;
        canvas.drawRect(x, y, x + 2, y + AndroidUtilities.dp(22), Theme.dividerPaint);
    }
}
 
Example #23
Source File: AudioPlayerCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public AudioPlayerCell(Context context) {
    super(context);

    radialProgress = new RadialProgress2(this);
    radialProgress.setColors(Theme.key_chat_inLoader, Theme.key_chat_inLoaderSelected, Theme.key_chat_inMediaIcon, Theme.key_chat_inMediaIconSelected);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setFocusable(true);
}
 
Example #24
Source File: ChangePhoneHelpActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ThemeDescription[] getThemeDescriptions() {
    return new ThemeDescription[]{
            new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite),

            new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault),
            new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon),
            new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle),
            new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector),

            new ThemeDescription(textView1, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
            new ThemeDescription(textView2, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_changephoneinfo_changeText),
            new ThemeDescription(imageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_changephoneinfo_image),
    };
}
 
Example #25
Source File: FireworksEffect.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public FireworksEffect() {
    particlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    particlePaint.setStrokeWidth(AndroidUtilities.dp(1.5f));
    particlePaint.setColor(Theme.getColor(Theme.key_actionBarDefaultTitle) & 0xffe6e6e6);
    particlePaint.setStrokeCap(Paint.Cap.ROUND);
    particlePaint.setStyle(Paint.Style.STROKE);

    for (int a = 0; a < 20; a++) {
        freeParticles.add(new Particle());
    }
}
 
Example #26
Source File: SendLocationCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    LocationController.SharingLocationInfo currentInfo = LocationController.getInstance(currentAccount).getSharingLocationInfo(dialogId);
    if (currentInfo == null) {
        return;
    }
    int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    if (currentInfo.stopTime < currentTime) {
        return;
    }

    float progress = Math.abs(currentInfo.stopTime - currentTime) / (float) currentInfo.period;
    if (LocaleController.isRTL) {
        rect.set(AndroidUtilities.dp(13), AndroidUtilities.dp(18), AndroidUtilities.dp(43), AndroidUtilities.dp(48));
    } else {
        rect.set(getMeasuredWidth() - AndroidUtilities.dp(43), AndroidUtilities.dp(18), getMeasuredWidth() - AndroidUtilities.dp(13), AndroidUtilities.dp(48));
    }

    int color = Theme.getColor(Theme.key_location_liveLocationProgress);
    Theme.chat_radialProgress2Paint.setColor(color);
    Theme.chat_livePaint.setColor(color);

    canvas.drawArc(rect, -90, -360 * progress, false, Theme.chat_radialProgress2Paint);

    String text = LocaleController.formatLocationLeftTime(Math.abs(currentInfo.stopTime - currentTime));

    float size = Theme.chat_livePaint.measureText(text);

    canvas.drawText(text, rect.centerX() - size / 2, AndroidUtilities.dp(37), Theme.chat_livePaint);
}
 
Example #27
Source File: RadioButtonCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public RadioButtonCell(Context context, boolean dialog) {
    super(context);

    radioButton = new RadioButton(context);
    radioButton.setSize(AndroidUtilities.dp(20));
    if (dialog) {
        radioButton.setColor(Theme.getColor(Theme.key_dialogRadioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
    } else {
        radioButton.setColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_radioBackgroundChecked));
    }
    addView(radioButton, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 20), 10, (LocaleController.isRTL ? 20 : 0), 0));

    textView = new TextView(context);
    if (dialog) {
        textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    } else {
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    }
    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.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 23 : 61), 10, (LocaleController.isRTL ? 61 : 23), 0));

    valueTextView = new TextView(context);
    if (dialog) {
        valueTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2));
    } else {
        valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    }
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    valueTextView.setLines(0);
    valueTextView.setMaxLines(0);
    valueTextView.setSingleLine(false);
    valueTextView.setPadding(0, 0, 0, AndroidUtilities.dp(12));
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 61), 35, (LocaleController.isRTL ? 61 : 17), 0));
}
 
Example #28
Source File: FragmentContextView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void updatePlaybackButton() {
    if (playbackSpeedButton == null) {
        return;
    }
    float currentPlaybackSpeed = MediaController.getInstance().getPlaybackSpeed(isMusic);
    if (currentPlaybackSpeed > 1) {
        playbackSpeedButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_inappPlayerPlayPause), PorterDuff.Mode.MULTIPLY));
    } else {
        playbackSpeedButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_inappPlayerClose), PorterDuff.Mode.MULTIPLY));
    }
}
 
Example #29
Source File: TextSelectionHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void drawCaption(boolean isOut, StaticLayout captionLayout, Canvas canvas) {
    if (isDescription) {
        return;
    }
    if (isOut) {
        selectionPaint.setColor(Theme.getColor(Theme.key_chat_outTextSelectionHighlight));
    } else {
        selectionPaint.setColor(Theme.getColor(key_chat_inTextSelectionHighlight));
    }
    drawSelection(canvas, captionLayout, selectionStart, selectionEnd);
}
 
Example #30
Source File: PaymentFormActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updateSavePaymentField() {
    if (bottomCell[0] == null || sectionCell[2] == null) {
        return;
    }
    if ((paymentForm.password_missing || paymentForm.can_save_credentials) && (webView == null || webView != null && !webviewLoading)) {
        SpannableStringBuilder text = new SpannableStringBuilder(LocaleController.getString("PaymentCardSavePaymentInformationInfoLine1", R.string.PaymentCardSavePaymentInformationInfoLine1));
        if (paymentForm.password_missing) {
            loadPasswordInfo();
            text.append("\n");
            int len = text.length();
            String str2 = LocaleController.getString("PaymentCardSavePaymentInformationInfoLine2", R.string.PaymentCardSavePaymentInformationInfoLine2);
            int index1 = str2.indexOf('*');
            int index2 = str2.lastIndexOf('*');
            text.append(str2);
            if (index1 != -1 && index2 != -1) {
                index1 += len;
                index2 += len;
                bottomCell[0].getTextView().setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
                text.replace(index2, index2 + 1, "");
                text.replace(index1, index1 + 1, "");
                text.setSpan(new LinkSpan(), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        checkCell1.setEnabled(true);
        bottomCell[0].setText(text);
        checkCell1.setVisibility(View.VISIBLE);
        bottomCell[0].setVisibility(View.VISIBLE);
        sectionCell[2].setBackgroundDrawable(Theme.getThemedDrawable(sectionCell[2].getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
    } else {
        checkCell1.setVisibility(View.GONE);
        bottomCell[0].setVisibility(View.GONE);
        sectionCell[2].setBackgroundDrawable(Theme.getThemedDrawable(sectionCell[2].getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
    }
}