package com.SalmanDev.HtmlFormatTools;
import android.content.Context;
import android.util.Log;
import android.os.Bundle;
import android.os.Build;
import android.text.Html;
import android.view.View;
import android.widget.TextView;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
@DesignerComponent(version = 1, description = "Created by Salman Developer",
category = ComponentCategory.EXTENSION,
nonVisible = true, iconName = "https://img.icons8.com/fluent/16/000000/source-code.png")
@SimpleObject(external = true)
public class HtmlFormatTools extends AndroidNonvisibleComponent {
private ComponentContainer container;
private TextView textView;
public HtmlFormatTools(ComponentContainer container) {
super(container.$form());
this.container = container;
}
@SimpleFunction(description = "")
public void Register(AndroidViewComponent component) {
textView = (TextView) component.getView();
}
@SimpleProperty
public void HtmlText(String text) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
textView.setText(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY));
} else {
textView.setText(Html.fromHtml(text));
}
}
@SimpleProperty(category = PropertyCategory.APPEARANCE)
public String ComponentText() {
return textView.getText().toString();
}
}