<commit_before>package com.xtremelabs.robolectric.shadows;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.TextWatcher;
import android.text.method.MovementMethod;
import android.text.method.TransformationMethod;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;

import java.util.ArrayList;
import java.util.List;

import static android.view.View.VISIBLE;
import static com.xtremelabs.robolectric.Robolectric.shadowOf_;

@SuppressWarnings({"UnusedDeclaration"})
@Implements(TextView.class)
public class ShadowTextView extends ShadowView {
    private CharSequence text = "";
    private CompoundDrawables compoundDrawablesImpl;
    private Integer textColorHexValue;
    private Integer hintColorHexValue;
    private float textSize = 14.0f;
    private boolean autoLinkPhoneNumbers;
    private int autoLinkMask;
    private CharSequence hintText;
    private int compoundDrawablePadding;
    private MovementMethod movementMethod;
    private boolean linksClickable;
    private int gravity;
    private TextView.OnEditorActionListener onEditorActionListener;
    private int imeOptions = EditorInfo.IME_NULL;
    private int textAppearanceId;
    private TransformationMethod transformationMethod;
    private int inputType;

    private List<TextWatcher> watchers = new ArrayList<TextWatcher>();
    
    @Override
    public void applyAttributes() {
        super.applyAttributes();
        applyTextAttribute();
        applyTextColorAttribute();
        applyHintAttribute();
        applyHintColorAttribute();
        applyCompoundDrawablesWithIntrinsicBoundsAttributes();
    }

    @Implementation(i18nSafe=false)
    public void setText(CharSequence text) {
    	sendBeforeTextChanged(text);
    	
    	if (text == null) {
            text = "";
        }
    	
    	CharSequence oldValue = this.text;
        this.text = text;
        
        sendOnTextChanged(oldValue);
        sendAfterTextChanged();
    }

    @Implementation
    public void setText(int textResourceId) {
    	sendBeforeTextChanged(text);
    	
    	CharSequence oldValue = this.text;
        this.text = getResources().getText(textResourceId);
        
    	sendOnTextChanged(oldValue);
        sendAfterTextChanged();
    }

    private void sendAfterTextChanged() {
		for (TextWatcher watcher : watchers) {
            watcher.afterTextChanged(new SpannableStringBuilder(getText()));
        }
	}<commit_msg>Add implementation of append-method to ShadowTextView<commit_after>package com.xtremelabs.robolectric.shadows;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.TextWatcher;
import android.text.method.MovementMethod;
import android.text.method.TransformationMethod;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;

import java.util.ArrayList;
import java.util.List;

import static android.view.View.VISIBLE;
import static com.xtremelabs.robolectric.Robolectric.shadowOf_;

@SuppressWarnings({"UnusedDeclaration"})
@Implements(TextView.class)
public class ShadowTextView extends ShadowView {
    private CharSequence text = "";
    private CompoundDrawables compoundDrawablesImpl;
    private Integer textColorHexValue;
    private Integer hintColorHexValue;
    private float textSize = 14.0f;
    private boolean autoLinkPhoneNumbers;
    private int autoLinkMask;
    private CharSequence hintText;
    private int compoundDrawablePadding;
    private MovementMethod movementMethod;
    private boolean linksClickable;
    private int gravity;
    private TextView.OnEditorActionListener onEditorActionListener;
    private int imeOptions = EditorInfo.IME_NULL;
    private int textAppearanceId;
    private TransformationMethod transformationMethod;
    private int inputType;

    private List<TextWatcher> watchers = new ArrayList<TextWatcher>();
    
    @Override
    public void applyAttributes() {
        super.applyAttributes();
        applyTextAttribute();
        applyTextColorAttribute();
        applyHintAttribute();
        applyHintColorAttribute();
        applyCompoundDrawablesWithIntrinsicBoundsAttributes();
    }

    @Implementation(i18nSafe=false)
    public void setText(CharSequence text) {
    	sendBeforeTextChanged(text);
    	
    	if (text == null) {
            text = "";
        }
    	
    	CharSequence oldValue = this.text;
        this.text = text;
        
        sendOnTextChanged(oldValue);
        sendAfterTextChanged();
    }
    
    @Implementation 
    public final void append(CharSequence text)  {
        CharSequence oldValue = this.text;
        StringBuffer sb = new StringBuffer(this.text);
        sb.append(text);
        this.text = sb.toString();
        
        sendBeforeTextChanged(this.text);
        sendOnTextChanged(oldValue);
        sendAfterTextChanged();
        
    }

    @Implementation
    public void setText(int textResourceId) {
    	sendBeforeTextChanged(text);
    	
    	CharSequence oldValue = this.text;
        this.text = getResources().getText(textResourceId);
        
    	sendOnTextChanged(oldValue);
        sendAfterTextChanged();
    }

    private void sendAfterTextChanged() {
		for (TextWatcher watcher : watchers) {
            watcher.afterTextChanged(new SpannableStringBuilder(getText()));
        }
	}
{'fraction_non_alphanumeric': 0.0791268758526603, 'fraction_numerical': 0.0017053206002728514, 'mean_word_length': 3.692, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4230935', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1567, 'n_words': 328}