Java Code Examples for com.pluscubed.logcat.helper.PreferenceHelper#getTextSizePreference()

The following examples show how to use com.pluscubed.logcat.helper.PreferenceHelper#getTextSizePreference() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogLineAdapter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(LogLineViewHolder holder, int position) {
    Context context = holder.itemView.getContext();

    LogLine logLine;
    try {
        logLine = getItem(position);
    } catch (IndexOutOfBoundsException ignore) {
        // XXX hack - I sometimes get array index out of bounds exceptions here
        // no idea how to solve it, so this is the best I can do
        //TODO: Fix
        logLine = LogLine.newLogLine("", PreferenceHelper.getExpandedByDefaultPreference(context));
    }

    holder.logLine = logLine;

    holder.binding.logLevelText.setText(logLine.getProcessIdText());
    holder.binding.logLevelText.setBackgroundColor(LogLineAdapterUtil.getBackgroundColorForLogLevel(context, logLine.getLogLevel()));
    holder.binding.logLevelText.setTextColor(LogLineAdapterUtil.getForegroundColorForLogLevel(context, logLine.getLogLevel()));
    holder.binding.logLevelText.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE);

    int textColor = PreferenceHelper.getColorScheme(context).getForegroundColor(context);
    float textSize = PreferenceHelper.getTextSizePreference(context);

    //OUTPUT TEXT VIEW
    holder.binding.logOutputText.setSingleLine(!logLine.isExpanded());
    holder.binding.logOutputText.setText(logLine.getLogOutput());
    holder.binding.logOutputText.setTextColor(textColor);


    //TAG TEXT VIEW
    holder.binding.tagText.setSingleLine(!logLine.isExpanded());
    holder.binding.tagText.setText(logLine.getTag());
    holder.binding.tagText.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE);


    //TEXT SIZE
    holder.binding.tagText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    holder.binding.logOutputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    holder.binding.logLevelText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

    //EXPANDED INFO
    boolean extraInfoIsVisible = logLine.isExpanded()
            && PreferenceHelper.getShowTimestampAndPidPreference(context)
            && logLine.getProcessId() != -1; // -1 marks lines like 'beginning of /dev/log...'

    holder.binding.pidText.setVisibility(extraInfoIsVisible ? View.VISIBLE : View.GONE);
    holder.binding.timestampText.setVisibility(extraInfoIsVisible ? View.VISIBLE : View.GONE);

    if (extraInfoIsVisible) {

        holder.binding.pidText.setTextColor(textColor);
        holder.binding.timestampText.setTextColor(textColor);

        holder.binding.pidText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        holder.binding.timestampText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

        holder.binding.pidText.setText(logLine.getProcessId() != -1 ? Integer.toString(logLine.getProcessId()) : null);
        holder.binding.timestampText.setText(logLine.getTimestamp());
    }

    holder.binding.tagText.setTextColor(LogLineAdapterUtil.getOrCreateTagColor(context, logLine.getTag()));

    // if this is a "partially selected" log, change the color to orange or whatever

    int selectedBackground = logLine.isHighlighted()
            ? PreferenceHelper.getColorScheme(context).getSelectedColor(context)
            : ContextCompat.getColor(context,android.R.color.transparent);
    holder.itemView.setBackgroundColor(selectedBackground);
}
 
Example 2
Source File: LogLineAdapter.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBindViewHolder(LogLineViewHolder holder, int position) {
    Context context = holder.itemView.getContext();

    LogLine logLine;
    try {
        logLine = getItem(position);
    } catch (IndexOutOfBoundsException ignore) {
        // XXX hack - I sometimes get array index out of bounds exceptions here
        // no idea how to solve it, so this is the best I can do
        //TODO: Fix
        logLine = LogLine.newLogLine("", PreferenceHelper.getExpandedByDefaultPreference(context));
    }

    holder.logLine = logLine;

    holder.binding.logLevelText.setText(logLine.getProcessIdText());
    holder.binding.logLevelText.setBackgroundColor(LogLineAdapterUtil.getBackgroundColorForLogLevel(context, logLine.getLogLevel()));
    holder.binding.logLevelText.setTextColor(LogLineAdapterUtil.getForegroundColorForLogLevel(context, logLine.getLogLevel()));
    holder.binding.logLevelText.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE);

    int textColor = PreferenceHelper.getColorScheme(context).getForegroundColor(context);
    float textSize = PreferenceHelper.getTextSizePreference(context);

    //OUTPUT TEXT VIEW
    holder.binding.logOutputText.setSingleLine(!logLine.isExpanded());
    holder.binding.logOutputText.setText(logLine.getLogOutput());
    holder.binding.logOutputText.setTextColor(textColor);


    //TAG TEXT VIEW
    holder.binding.tagText.setSingleLine(!logLine.isExpanded());
    holder.binding.tagText.setText(logLine.getTag());
    holder.binding.tagText.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE);


    //TEXT SIZE
    holder.binding.tagText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    holder.binding.logOutputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    holder.binding.logLevelText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

    //EXPANDED INFO
    boolean extraInfoIsVisible = logLine.isExpanded()
            && PreferenceHelper.getShowTimestampAndPidPreference(context)
            && logLine.getProcessId() != -1; // -1 marks lines like 'beginning of /dev/log...'

    holder.binding.pidText.setVisibility(extraInfoIsVisible ? View.VISIBLE : View.GONE);
    holder.binding.timestampText.setVisibility(extraInfoIsVisible ? View.VISIBLE : View.GONE);

    if (extraInfoIsVisible) {

        holder.binding.pidText.setTextColor(textColor);
        holder.binding.timestampText.setTextColor(textColor);

        holder.binding.pidText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        holder.binding.timestampText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

        holder.binding.pidText.setText(logLine.getProcessId() != -1 ? Integer.toString(logLine.getProcessId()) : null);
        holder.binding.timestampText.setText(logLine.getTimestamp());
    }

    holder.binding.tagText.setTextColor(LogLineAdapterUtil.getOrCreateTagColor(context, logLine.getTag()));

    // if this is a "partially selected" log, change the color to orange or whatever

    int selectedBackground = logLine.isHighlighted()
            ? PreferenceHelper.getColorScheme(context).getSelectedColor(context)
            : ContextCompat.getColor(context,android.R.color.transparent);
    holder.itemView.setBackgroundColor(selectedBackground);
}
 
Example 3
Source File: LogLineAdapter.java    From matlog with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBindViewHolder(LogLineViewHolder holder, int position) {
    Context context = holder.itemView.getContext();

    LogLine logLine;
    try {
        logLine = getItem(position);
    } catch (IndexOutOfBoundsException ignore) {
        // XXX hack - I sometimes get array index out of bounds exceptions here
        // no idea how to solve it, so this is the best I can do
        //TODO: Fix
        logLine = LogLine.newLogLine(
                "",
                PreferenceHelper.getExpandedByDefaultPreference(context),
                PreferenceHelper.getFilterPatternPreference(context)
        );
    }

    holder.logLine = logLine;

    TextView t = holder.itemView.findViewById(R.id.log_level_text);
    t.setText(logLine.getProcessIdText());
    t.setBackgroundColor(LogLineAdapterUtil.getBackgroundColorForLogLevel(context, logLine.getLogLevel()));
    t.setTextColor(LogLineAdapterUtil.getForegroundColorForLogLevel(context, logLine.getLogLevel()));
    t.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE);

    int textColor = PreferenceHelper.getColorScheme(context).getForegroundColor(context);
    float textSize = PreferenceHelper.getTextSizePreference(context);

    //OUTPUT TEXT VIEW
    TextView output = holder.itemView.findViewById(R.id.log_output_text);
    output.setSingleLine(!logLine.isExpanded());
    output.setText(logLine.getLogOutput());
    output.setTextColor(textColor);


    //TAG TEXT VIEW
    TextView tag = holder.itemView.findViewById(R.id.tag_text);
    tag.setSingleLine(!logLine.isExpanded());
    tag.setText(logLine.getTag());
    tag.setVisibility(logLine.getLogLevel() == -1 ? View.GONE : View.VISIBLE);


    //TEXT SIZE
    tag.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    output.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    t.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

    //EXPANDED INFO
    boolean extraInfoIsVisible = logLine.isExpanded()
            && PreferenceHelper.getShowTimestampAndPidPreference(context)
            && logLine.getProcessId() != -1; // -1 marks lines like 'beginning of /dev/log...'

    TextView pidText = holder.itemView.findViewById(R.id.pid_text);
    pidText.setVisibility(extraInfoIsVisible ? View.VISIBLE : View.GONE);
    TextView timestampText = holder.itemView.findViewById(R.id.timestamp_text);
    timestampText.setVisibility(extraInfoIsVisible ? View.VISIBLE : View.GONE);

    if (extraInfoIsVisible) {

        pidText.setTextColor(textColor);
        timestampText.setTextColor(textColor);

        pidText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        timestampText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

        pidText.setText(logLine.getProcessId() != -1 ? Integer.toString(logLine.getProcessId()) : null);
        timestampText.setText(logLine.getTimestamp());
    }

    tag.setTextColor(LogLineAdapterUtil.getOrCreateTagColor(context, logLine.getTag()));

    // if this is a "partially selected" log, change the color to orange or whatever

    int selectedBackground = logLine.isHighlighted()
            ? PreferenceHelper.getColorScheme(context).getSelectedColor(context)
            : ContextCompat.getColor(context,android.R.color.transparent);
    holder.itemView.setBackgroundColor(selectedBackground);
}