package com.ayuget.redface.ui.view;

import android.content.Context;
import android.os.Build;
import android.text.Html;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;

import com.ayuget.redface.R;
import com.ayuget.redface.ui.misc.UiUtils;
import com.ayuget.redface.util.HTMLUtils;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class ProfileDetailsItemView extends RelativeLayout {

	@InjectView(R.id.detail_icon)
	ImageView detailIconView;

	@InjectView(R.id.main_text)
	TextView mainTextView;

	@InjectView(R.id.secondary_text)
	TextView secondaryTextView;

	private final String value;

	private final int labelRes;

	private final int icon;

	public ProfileDetailsItemView(Context context, String value, int labelRes, int icon) {
		super(context);
		this.value = value;
		this.labelRes = labelRes;
		this.icon = icon;
		initialize();
	}

	private void initialize() {
		inflate(getContext(), R.layout.item_profile_detail, this);
		ButterKnife.inject(this);

		detailIconView.setImageDrawable(getContext().getResources().getDrawable(icon));
		mainTextView.setText(value);

		mainTextView.setText(HTMLUtils.unescapeHTML(value));
		secondaryTextView.setText(getContext().getString(labelRes));

		UiUtils.setDrawableColor(detailIconView.getDrawable(), UiUtils.getReplyToolbarIconsColor(getContext()));
	}

	public static com.ayuget.redface.ui.view.ProfileDetailsItemView.Builder from(Context context) {
		return new com.ayuget.redface.ui.view.ProfileDetailsItemView.Builder(context);
	}

	public static class Builder {
		private final Context context;

		private String value;

		private int labelRes;

		private int icon;

		private Builder(Context context) {
			this.context = context;
		}

		public com.ayuget.redface.ui.view.ProfileDetailsItemView.Builder withValue(String value) {
			this.value = value;
			return this;
		}

		public com.ayuget.redface.ui.view.ProfileDetailsItemView.Builder withLabel(@StringRes int labelRes) {
			this.labelRes = labelRes;
			return this;
		}

		public com.ayuget.redface.ui.view.ProfileDetailsItemView.Builder withIcon(@DrawableRes int drawableRes) {
			this.icon = drawableRes;
			return this;
		}

		public com.ayuget.redface.ui.view.ProfileDetailsItemView build() {
			return new com.ayuget.redface.ui.view.ProfileDetailsItemView(context, value, labelRes, icon);
		}
	}
}

@@ -81,42 +81,38 @@
 oid.
-os.Build;%0Aimport android.text.Html
+text.method.LinkMovementMethod
 ;%0Aim
@@ -1193,16 +1193,17 @@
 icon));%0A
+%0A
 %09%09mainTe
@@ -1221,16 +1221,39 @@
 ext(
+HTMLUtils.unescapeHTML(
 value)
+)
 ;
-%0A
 %0A%09%09m
@@ -1271,44 +1271,98 @@
 .set
-Text(HTMLUtils.unescapeHTML(val
+MovementMethod(LinkMovementMethod.getInstance());%0A%09%09mainTextView.setLinksClickable(tr
 ue)
-)
 ;
+%0A
 %0A%09%09s

Make links in profile signature clickable