android.widget.ImageView#setColorFilter ( )源码实例Demo

下面列出了android.widget.ImageView#setColorFilter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Camera-Roll-Android-App   文件: FileHolder.java
public void setSelected(boolean selected) {
    Context context = itemView.getContext();

    Settings s = Settings.getInstance(itemView.getContext());
    Theme theme = s.getThemeInstance(context);

    int color = selected ?
            theme.getAccentColor(context)
            : ContextCompat.getColor(context, android.R.color.transparent);
    itemView.setBackgroundColor(color);

    TextView textView = itemView.findViewById(R.id.text);
    textView.setTextColor(selected ? theme.getAccentTextColor(context)
            : theme.getTextColorPrimary(context));

    ImageView folderIndicator = itemView.findViewById(R.id.folder_indicator);
    folderIndicator.setColorFilter(selected ? theme.getAccentTextColor(context)
            : theme.getTextColorSecondary(context), PorterDuff.Mode.SRC_IN);
}
 
源代码2 项目: TelePlus-Android   文件: ThemeTypeCell.java
public ThemeTypeCell(Context context) {
    super(context);

    setWillNotDraw(false);

    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, LocaleController.isRTL ? 23 + 48 : 17, 0, LocaleController.isRTL ? 17 : 23, 0));

    checkImage = new ImageView(context);
    checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
    checkImage.setImageResource(R.drawable.sticker_added);
    addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 23, 0, 23, 0));
}
 
private void bindOneImage(int position, ImageView monsterImageView, Integer monsterId, boolean alreadyIgnored) {
	MyLog.entry("position = " + position);

	monsterImageView.clearColorFilter();

	if (monsterId != null && mTaskFragment.getMonsterInfoHelper() != null) {
		monsterImageView.setVisibility(View.VISIBLE);
		try {
			final MonsterInfoModel monsterInfo = mTaskFragment.getMonsterInfoHelper().getMonsterInfo(monsterId);
			mImageHelper.fillImage(monsterImageView, monsterInfo);

			if (!alreadyIgnored) {
				monsterImageView.setColorFilter(Color.parseColor("#99000000"), PorterDuff.Mode.DARKEN);
			}
		} catch (UnknownMonsterException e) {
			Picasso.with(getContext())
					.load(R.drawable.no_monster_image)
					.into(monsterImageView);
		}
	} else {
		MyLog.debug("no monster at " + position + ", ignored");
		monsterImageView.setVisibility(View.INVISIBLE);
	}
	MyLog.exit();
}
 
源代码4 项目: Telegram-FOSS   文件: AdminedChannelCell.java
public AdminedChannelCell(Context context, View.OnClickListener onClickListener) {
    super(context);

    avatarDrawable = new AvatarDrawable();

    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
    addView(avatarImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 12, LocaleController.isRTL ? 12 : 0, 0));

    nameTextView = new SimpleTextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(17);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 62 : 73, 15.5f, LocaleController.isRTL ? 73 : 62, 0));

    statusTextView = new SimpleTextView(context);
    statusTextView.setTextSize(14);
    statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
    statusTextView.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
    statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(statusTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 62 : 73, 38.5f, LocaleController.isRTL ? 73 : 62, 0));

    deleteButton = new ImageView(context);
    deleteButton.setScaleType(ImageView.ScaleType.CENTER);
    deleteButton.setImageResource(R.drawable.msg_panel_clear);
    deleteButton.setOnClickListener(onClickListener);
    deleteButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText), PorterDuff.Mode.MULTIPLY));
    addView(deleteButton, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 7 : 0, 12, LocaleController.isRTL ? 0 : 7, 0));
}
 
源代码5 项目: 365browser   文件: InfoBarControlLayout.java
/**
 * Adds an icon with a descriptive message to the layout.
 *
 * -----------------------------------------------------
 * | ICON | PRIMARY MESSAGE SECONDARY MESSAGE          |
 * -----------------------------------------------------
 * If an icon is not provided, the ImageView that would normally show it is hidden.
 *
 * @param iconResourceId   ID of the drawable to use for the icon.
 * @param iconColorId      ID of the tint color for the icon, or 0 for default.
 * @param primaryMessage   Message to display for the toggle.
 * @param secondaryMessage Additional descriptive text for the toggle.  May be null.
 */
public View addIcon(int iconResourceId, int iconColorId, CharSequence primaryMessage,
        CharSequence secondaryMessage) {
    LinearLayout layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_icon_with_description, this, false);
    addView(layout, new ControlLayoutParams());

    ImageView iconView = (ImageView) layout.findViewById(R.id.control_icon);
    iconView.setImageResource(iconResourceId);
    if (iconColorId != 0) {
        iconView.setColorFilter(ApiCompatibilityUtils.getColor(getResources(), iconColorId));
    }

    // The primary message text is always displayed.
    TextView primaryView = (TextView) layout.findViewById(R.id.control_message);
    primaryView.setText(primaryMessage);

    // The secondary message text is optional.
    TextView secondaryView =
            (TextView) layout.findViewById(R.id.control_secondary_message);
    if (secondaryMessage == null) {
        layout.removeView(secondaryView);
    } else {
        secondaryView.setText(secondaryMessage);
    }

    return layout;
}
 
源代码6 项目: droidddle   文件: NavigationDrawerFragment.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) {
    if (isSeparator(itemId)) {
        // not applicable
        return;
    }

    ImageView iconView = (ImageView) view.findViewById(R.id.icon);
    TextView titleView = (TextView) view.findViewById(R.id.title);

    // configure its appearance according to whether or not it's selected
    titleView.setTextColor(selected ? mTintColor : mDrawerTextColor);
    iconView.setColorFilter(selected ? mTintColor : mDrawerIconTint);
}
 
源代码7 项目: Telegram-FOSS   文件: ProxyListActivity.java
public TextDetailProxyCell(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.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 56 : 21), 10, (LocaleController.isRTL ? 21 : 56), 0));

    valueTextView = new TextView(context);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setCompoundDrawablePadding(AndroidUtilities.dp(6));
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    valueTextView.setPadding(0, 0, 0, 0);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 56 : 21), 35, (LocaleController.isRTL ? 21 : 56), 0));

    checkImageView = new ImageView(context);
    checkImageView.setImageResource(R.drawable.profile_info);
    checkImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3), PorterDuff.Mode.MULTIPLY));
    checkImageView.setScaleType(ImageView.ScaleType.CENTER);
    checkImageView.setContentDescription(LocaleController.getString("Edit", R.string.Edit));
    addView(checkImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 8, 8, 8, 0));
    checkImageView.setOnClickListener(v -> presentFragment(new ProxySettingsActivity(currentInfo)));

    setWillNotDraw(false);
}
 
源代码8 项目: TelePlus-Android   文件: ManageChatUserCell.java
public ManageChatUserCell(Context context, int padding, boolean needOption) {
    super(context);

    statusColor = Theme.getColor(Theme.key_windowBackgroundWhiteGrayText);
    statusOnlineColor = Theme.getColor(Theme.key_windowBackgroundWhiteBlueText);

    avatarDrawable = new AvatarDrawable();

    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
    addView(avatarImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 7 + padding, 8, LocaleController.isRTL ? 7 + padding : 0, 0));

    nameTextView = new SimpleTextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(17);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 + 18 : (68 + padding), 11.5f, LocaleController.isRTL ? (68 + padding) : 28 + 18, 0));

    statusTextView = new SimpleTextView(context);
    statusTextView.setTextSize(14);
    statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(statusTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : (68 + padding), 34.5f, LocaleController.isRTL ? (68 + padding) : 28, 0));

    if (needOption) {
        optionsButton = new ImageView(context);
        optionsButton.setFocusable(false);
        optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
        optionsButton.setImageResource(R.drawable.ic_ab_other);
        optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
        optionsButton.setScaleType(ImageView.ScaleType.CENTER);
        addView(optionsButton, LayoutHelper.createFrame(48, 64, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP));
        optionsButton.setOnClickListener(v -> delegate.onOptionsButtonCheck(ManageChatUserCell.this, true));
    }
}
 
源代码9 项目: Telegram-FOSS   文件: TextSettingsCell.java
public TextSettingsCell(Context context, int padding) {
    super(context);

    textView = new TextView(context);
    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);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, 0, padding, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText));
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 0, padding, 0));

    valueImageView = new ImageView(context);
    valueImageView.setScaleType(ImageView.ScaleType.CENTER);
    valueImageView.setVisibility(INVISIBLE);
    valueImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
    addView(valueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, padding, 0, padding, 0));
}
 
源代码10 项目: Anti-recall   文件: SettingsFragment.java
private void addView(ViewGroup mainView, String content, String hint, boolean isChecked, View.OnClickListener onClickListener) {

        LayoutInflater inflater = getLayoutInflater();
        View view = inflater.inflate(R.layout.item_check_permission, mainView, false);
        LinearLayout llPermissioin = view.findViewById(R.id.ll_permission);
        TextView tvPermission = view.findViewById(R.id.tv_permission_content);
        ImageView ivChecked = view.findViewById(R.id.iv_checked);
        ImageView ivFix = view.findViewById(R.id.iv_fix);

        tvPermission.setText(content);
        if (hint != null) {
            TextView tvPermissionHint = new TextView(getContext());
            tvPermissionHint.setText(hint);
            llPermissioin.addView(tvPermissionHint);
        }
        if (isChecked) {
            ivChecked.setImageResource(R.drawable.ic_accept);
            ivChecked.setColorFilter(0xCC22DD22);
            ivFix.setVisibility(View.GONE);
        } else {
            ivChecked.setImageResource(R.drawable.ic_cancel);
            ivChecked.setColorFilter(0xAADD2222);
        }

        if (!isChecked)
            view.setOnClickListener(onClickListener);
        mainView.addView(view);
    }
 
源代码11 项目: InstaTag   文件: InstaTag.java
private void initViewWithId(Context context, TypedArray obtainStyledAttributes) {
    mContext = context;

    LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.tag_root, this);

    mRoot = findViewById(R.id.tag_root);
    mSquareImageView = findViewById(R.id.tag_image_view);
    mLikeImage = new ImageView(context);

    int likeColor, likeSrc, likeSize;
    if (obtainStyledAttributes != null) {
        likeColor = obtainStyledAttributes.getColor(R.styleable.InstaTag_likeColor,
                ContextCompat.getColor(context, R.color.colorAccent));
        likeSrc = obtainStyledAttributes.getResourceId(R.styleable.InstaTag_likeSrc,
                R.drawable.ic_like);
        likeSize = obtainStyledAttributes
                .getDimensionPixelSize(R.styleable.InstaTag_likeSize,
                        getResources().getDimensionPixelSize(R.dimen.dp150));
    } else {
        likeColor = ContextCompat.getColor(context, R.color.colorAccent);
        likeSrc = R.drawable.ic_like;
        likeSize = getResources().getDimensionPixelSize(R.dimen.dp150);
    }
    LayoutParams heartParams = new LayoutParams(likeSize, likeSize);
    heartParams.addRule(CENTER_IN_PARENT, TRUE);

    mLikeImage.setLayoutParams(heartParams);
    mLikeImage.setVisibility(GONE);
    mLikeImage.setImageResource(likeSrc);
    mLikeImage.setColorFilter(likeColor);

    setRootLayoutParams(mContext);
    mRoot.post(mSetRootHeightWidth);
    mRoot.setOnTouchListener(mOnTouchListener);
    mGestureDetector = new GestureDetector(mRoot.getContext(), mGestureListener);
}
 
源代码12 项目: nitroshare-android   文件: DirectoryAdapter.java
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    View view = super.getView(position, convertView, parent);
    File file = getItem(position);
    //noinspection ConstantConditions
    ((TextView) view.findViewById(android.R.id.text1)).setText(file.getName());
    ((TextView) view.findViewById(android.R.id.text2)).setText(
            file.isDirectory() ? getDirectorySummary(file) : getFileSummary(file)
    );
    ((TextView) view.findViewById(R.id.last_modified)).setText(
            DateUtils.getRelativeDateTimeString(
                    mContext,
                    file.lastModified(),
                    DateUtils.MINUTE_IN_MILLIS,
                    DateUtils.WEEK_IN_MILLIS,
                    0
            )
    );
    final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
    imageView.setColorFilter(mColor);
    Picasso.with(mContext)
            .load(file)
            .resizeDimen(R.dimen.explorer_icon_size, R.dimen.explorer_icon_size)
            .centerCrop()
            .placeholder(ContextCompat.getDrawable(
                    mContext, file.isDirectory() ? R.drawable.ic_folder : R.drawable.ic_file
            ))
            .into(imageView, new Callback() {
                @Override
                public void onSuccess() {
                    // Remove the tint once the image loads
                    imageView.setColorFilter(Color.argb(0, 0, 0, 0), PorterDuff.Mode.DST);
                }

                @Override
                public void onError() {
                }
            });
    View spacer = view.findViewById(R.id.spacer);
    CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox);
    if (mCheckboxes) {
        checkBox.setOnCheckedChangeListener(null);
        checkBox.setChecked(mChecked.indexOfKey(position) >= 0);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    mChecked.put(position, getItem(position));
                } else {
                    mChecked.remove(position);
                    if (mChecked.size() == 0) {
                        mListener.onAllItemsDeselected();
                    }
                }
            }
        });
        spacer.setVisibility(View.VISIBLE);
        checkBox.setVisibility(View.VISIBLE);
    } else {
        spacer.setVisibility(View.GONE);
        checkBox.setVisibility(View.GONE);
    }
    return view;
}
 
源代码13 项目: base-imageloader   文件: MyAdapter.java
@Override
public void convert(final ViewHolder helper, final String item)
{
	//设置no_pic
	helper.setImageResource(R.id.id_item_image, R.drawable.pictures_no);
	//设置no_selected
			helper.setImageResource(R.id.id_item_select,
					R.drawable.picture_unselected);
	//设置图片
	helper.setImageByUrl(R.id.id_item_image, mDirPath + "/" + item);
	
	final ImageView mImageView = helper.getView(R.id.id_item_image);
	final ImageView mSelect = helper.getView(R.id.id_item_select);
	
	mImageView.setColorFilter(null);
	//设置ImageView的点击事件
	mImageView.setOnClickListener(new OnClickListener()
	{
		//选择,则将图片变暗,反之则反之
		@Override
		public void onClick(View v)
		{

			// 已经选择过该图片
			if (mSelectedImage.contains(mDirPath + "/" + item))
			{
				mSelectedImage.remove(mDirPath + "/" + item);
				mSelect.setImageResource(R.drawable.picture_unselected);
				mImageView.setColorFilter(null);
			} else
			// 未选择该图片
			{
				mSelectedImage.add(mDirPath + "/" + item);
				mSelect.setImageResource(R.drawable.pictures_selected);
				mImageView.setColorFilter(Color.parseColor("#77000000"));
			}

		}
	});
	
	/**
	 * 已经选择过的图片,显示出选择过的效果
	 */
	if (mSelectedImage.contains(mDirPath + "/" + item))
	{
		mSelect.setImageResource(R.drawable.pictures_selected);
		mImageView.setColorFilter(Color.parseColor("#77000000"));
	}

}
 
源代码14 项目: fdroidclient   文件: SwapWorkflowActivity.java
private void setUpFromWifi() {
    String scheme = Preferences.get().isLocalRepoHttpsEnabled() ? "https://" : "http://";

    // the fingerprint is not useful on the button label
    String buttonLabel = scheme + FDroidApp.ipAddressString + ":" + FDroidApp.port;
    TextView ipAddressView = container.findViewById(R.id.device_ip_address);
    if (ipAddressView != null) {
        ipAddressView.setText(buttonLabel);
    }

    String qrUriString = null;
    switch (currentView.getLayoutResId()) {
        case R.layout.swap_join_wifi:
            setUpJoinWifi();
            return;
        case R.layout.swap_send_fdroid:
            qrUriString = buttonLabel;
            break;
        case R.layout.swap_wifi_qr:
            Uri sharingUri = Utils.getSharingUri(FDroidApp.repo);
            StringBuilder qrUrlBuilder = new StringBuilder(scheme);
            qrUrlBuilder.append(sharingUri.getHost());
            if (sharingUri.getPort() != 80) {
                qrUrlBuilder.append(':');
                qrUrlBuilder.append(sharingUri.getPort());
            }
            qrUrlBuilder.append(sharingUri.getPath());
            boolean first = true;

            Set<String> names = sharingUri.getQueryParameterNames();
            for (String name : names) {
                if (!"ssid".equals(name)) {
                    if (first) {
                        qrUrlBuilder.append('?');
                        first = false;
                    } else {
                        qrUrlBuilder.append('&');
                    }
                    qrUrlBuilder.append(name.toUpperCase(Locale.ENGLISH));
                    qrUrlBuilder.append('=');
                    qrUrlBuilder.append(sharingUri.getQueryParameter(name).toUpperCase(Locale.ENGLISH));
                }
            }
            qrUriString = qrUrlBuilder.toString();
            break;
    }

    ImageView qrImage = container.findViewById(R.id.wifi_qr_code);
    if (qrUriString != null && qrImage != null) {
        Utils.debugLog(TAG, "Encoded swap URI in QR Code: " + qrUriString);
        new QrGenAsyncTask(SwapWorkflowActivity.this, R.id.wifi_qr_code).execute(qrUriString);

        // Replace all blacks with the background blue.
        qrImage.setColorFilter(new LightingColorFilter(0xffffffff, getResources().getColor(R.color.swap_blue)));

        final View qrWarningMessage = container.findViewById(R.id.warning_qr_scanner);
        if (CameraCharacteristicsChecker.getInstance(this).hasAutofocus()) {
            qrWarningMessage.setVisibility(View.GONE);
        } else {
            qrWarningMessage.setVisibility(View.VISIBLE);
        }
    }
}
 
源代码15 项目: Telegram   文件: StickerSetCell.java
public StickerSetCell(Context context, int option) {
    super(context);
    this.option = option;

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity(LayoutHelper.getAbsoluteGravityStart());
    addView(textView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, 71, 9, 46, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setGravity(LayoutHelper.getAbsoluteGravityStart());
    addView(valueTextView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, 71, 32, 46, 0));

    imageView = new BackupImageView(context);
    imageView.setAspectFit(true);
    imageView.setLayerNum(1);
    addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 13, 9, LocaleController.isRTL ? 13 : 0, 0));

    if (option == 2) {
        progressView = new RadialProgressView(getContext());
        progressView.setProgressColor(Theme.getColor(Theme.key_dialogProgressCircle));
        progressView.setSize(AndroidUtilities.dp(30));
        addView(progressView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 5, LocaleController.isRTL ? 12 : 0, 0));
    } else if (option != 0) {
        optionsButton = new ImageView(context);
        optionsButton.setFocusable(false);
        optionsButton.setScaleType(ImageView.ScaleType.CENTER);
        optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
        if (option == 1) {
            optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
            optionsButton.setImageResource(R.drawable.msg_actions);
            addView(optionsButton, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL));

            reorderButton = new ImageView(context);
            reorderButton.setAlpha(0f);
            reorderButton.setVisibility(GONE);
            reorderButton.setScaleType(ImageView.ScaleType.CENTER);
            reorderButton.setImageResource(R.drawable.list_reorder);
            reorderButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
            addView(reorderButton, LayoutHelper.createFrameRelatively(58, 58, Gravity.END));

            checkBox = new CheckBox2(context, 21);
            checkBox.setColor(null, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck);
            checkBox.setDrawUnchecked(false);
            checkBox.setDrawBackgroundAsArc(3);
            addView(checkBox, LayoutHelper.createFrameRelatively(24, 24, Gravity.START, 34, 30, 0, 0));
        } else if (option == 3) {
            optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
            optionsButton.setImageResource(R.drawable.sticker_added);
            addView(optionsButton, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, (LocaleController.isRTL ? 10 : 0), 9, (LocaleController.isRTL ? 0 : 10), 0));
        }
    }
}
 
源代码16 项目: AndroidIndicators   文件: ArgbIconicTabsEffect.java
@Override
public void applyTabEffect(ImageView imageView, float value, Status status) {


    int startA = (startInt >> 24) & 0xff;
    int startR = (startInt >> 16) & 0xff;
    int startG = (startInt >> 8) & 0xff;
    int startB = startInt & 0xff;

    int endA = (endInt >> 24) & 0xff;
    int endR = (endInt >> 16) & 0xff;
    int endG = (endInt >> 8) & 0xff;
    int endB = endInt & 0xff;

    int resultColor = (int) ((startA + (int) (value * (endA - startA))) << 24) |
            (int) ((startR + (int) (value * (endR - startR))) << 16) |
            (int) ((startG + (int) (value * (endG - startG))) << 8) |
            (int) ((startB + (int) (value * (endB - startB))));


    imageView.setColorFilter(resultColor, PorterDuff.Mode.MULTIPLY);


}
 
源代码17 项目: Stringlate   文件: ContextUtils.java
/**
 * Load an image into a {@link ImageView} and apply a color filter
 */
public static void setDrawableWithColorToImageView(ImageView imageView, @DrawableRes int drawableResId, @ColorRes int colorResId) {
    imageView.setImageResource(drawableResId);
    imageView.setColorFilter(ContextCompat.getColor(imageView.getContext(), colorResId));
}
 
源代码18 项目: Telegram   文件: UndoView.java
public UndoView(Context context, boolean top) {
    super(context);
    fromTop = top;

    infoTextView = new TextView(context);
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    infoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
    infoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    infoTextView.setMovementMethod(new LinkMovementMethodMy());
    addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 45, 13, 0, 0));

    subinfoTextView = new TextView(context);
    subinfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    subinfoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
    subinfoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    subinfoTextView.setHighlightColor(0);
    subinfoTextView.setSingleLine(true);
    subinfoTextView.setEllipsize(TextUtils.TruncateAt.END);
    subinfoTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
    addView(subinfoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 58, 27, 8, 0));

    leftImageView = new RLottieImageView(context);
    leftImageView.setScaleType(ImageView.ScaleType.CENTER);
    leftImageView.setLayerColor("info1.**", Theme.getColor(Theme.key_undo_background) | 0xff000000);
    leftImageView.setLayerColor("info2.**", Theme.getColor(Theme.key_undo_background) | 0xff000000);
    leftImageView.setLayerColor("luc12.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc11.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc10.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc9.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc8.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc7.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc6.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc5.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc4.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc3.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc2.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc1.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("Oval.**", Theme.getColor(Theme.key_undo_infoColor));
    addView(leftImageView, LayoutHelper.createFrame(54, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 3, 0, 0, 0));

    undoButton = new LinearLayout(context);
    undoButton.setOrientation(LinearLayout.HORIZONTAL);
    addView(undoButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 19, 0));
    undoButton.setOnClickListener(v -> {
        if (!canUndo()) {
            return;
        }
        hide(false, 1);
    });

    undoImageView = new ImageView(context);
    undoImageView.setImageResource(R.drawable.chats_undo);
    undoImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_cancelColor), PorterDuff.Mode.MULTIPLY));
    undoButton.addView(undoImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT));

    undoTextView = new TextView(context);
    undoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    undoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    undoTextView.setTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    undoTextView.setText(LocaleController.getString("Undo", R.string.Undo));
    undoButton.addView(undoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 6, 0, 0, 0));

    rect = new RectF(AndroidUtilities.dp(15), AndroidUtilities.dp(15), AndroidUtilities.dp(15 + 18), AndroidUtilities.dp(15 + 18));

    progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    progressPaint.setStyle(Paint.Style.STROKE);
    progressPaint.setStrokeWidth(AndroidUtilities.dp(2));
    progressPaint.setStrokeCap(Paint.Cap.ROUND);
    progressPaint.setColor(Theme.getColor(Theme.key_undo_infoColor));

    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(AndroidUtilities.dp(12));
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textPaint.setColor(Theme.getColor(Theme.key_undo_infoColor));

    setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_undo_background)));

    setOnTouchListener((v, event) -> true);

    setVisibility(INVISIBLE);
}
 
源代码19 项目: Telegram-FOSS   文件: FiltersSetupActivity.java
public FilterCell(Context context) {
    super(context);
    setWillNotDraw(false);

    moveImageView = new ImageView(context);
    moveImageView.setFocusable(false);
    moveImageView.setScaleType(ImageView.ScaleType.CENTER);
    moveImageView.setImageResource(R.drawable.list_reorder);
    moveImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
    moveImageView.setClickable(true);
    addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));

    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.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : 64, 14, LocaleController.isRTL ? 64 : 80, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setPadding(0, 0, 0, 0);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : 64, 35, LocaleController.isRTL ? 64 : 80, 0));
    valueTextView.setVisibility(GONE);

    optionsImageView = new ImageView(context);
    optionsImageView.setFocusable(false);
    optionsImageView.setScaleType(ImageView.ScaleType.CENTER);
    optionsImageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
    optionsImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
    optionsImageView.setImageResource(R.drawable.msg_actions);
    addView(optionsImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
}
 
源代码20 项目: spline   文件: LayerBindingAdapters.java
/**
 * Binding adapter for converting a color resource ID to a color int that can be set as the
 * tint of the passed ImageView
 * @param view
 * @param resId
 */
@BindingAdapter("android:tint")
public static void setImageTint(ImageView view, int resId) {
    int tintColor = view.getContext().getColor(resId);
    view.setColorFilter(tintColor);
}