<commit_before>package com.crescentflare.unilayout.views;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * UniLayout view: a view with simple text
 * Extends TextView, currently it's just an alias to have the same name as the iOS class
 */
public class UniTextView extends TextView
{
    // ---
    // Initialization
    // ---

    public UniTextView(Context context)
    {
        this(context, (AttributeSet)null);
    }

    public UniTextView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        init(attrs);
    }

    public UniTextView(Context context, AttributeSet attrs, int defStyleAttr)
    {
        this(context, attrs);
    }

    public UniTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
    {
        this(context, attrs);
    }

    private void init(AttributeSet attrs)
    {
    }
}<commit_msg>Added a workaround to re-measure the text view for text alignment<commit_after>package com.crescentflare.unilayout.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.TextView;

import com.crescentflare.unilayout.helpers.UniLayoutParams;

/**
 * UniLayout view: a view with simple text
 * Extends TextView, includes a workaround to get text alignment to work with minimum width
 */
public class UniTextView extends TextView
{
    // ---
    // Initialization
    // ---

    public UniTextView(Context context)
    {
        this(context, (AttributeSet)null);
    }

    public UniTextView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        init(attrs);
    }

    public UniTextView(Context context, AttributeSet attrs, int defStyleAttr)
    {
        this(context, attrs);
    }

    public UniTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
    {
        this(context, attrs);
    }

    private void init(AttributeSet attrs)
    {
    }


    // ---
    // Override measure to work with minimum width and alignment
    // ---

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
    {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        ViewGroup.LayoutParams layoutParams = getLayoutParams();
        if (layoutParams instanceof UniLayoutParams)
        {
            UniLayoutParams uniLayoutParams = (UniLayoutParams)layoutParams;
            int specMode = MeasureSpec.getMode(widthMeasureSpec);
            if (specMode != MeasureSpec.EXACTLY && getMeasuredWidth() < uniLayoutParams.minWidth)
            {
                int limitWidth = uniLayoutParams.minWidth;
                if (specMode == MeasureSpec.AT_MOST)
                {
                    limitWidth = Math.min(limitWidth, MeasureSpec.getSize(widthMeasureSpec));
                }
                super.onMeasure(MeasureSpec.makeMeasureSpec(limitWidth, MeasureSpec.EXACTLY), heightMeasureSpec);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08745874587458746, 'fraction_numerical': 0.0, 'mean_word_length': 2.6783980582524274, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '3961765', 'n_tokens_mistral': 845, 'n_tokens_neox': 811, 'n_words': 208}