Chomp v9.11版本的 MD5 值为:86ab69d1e20ec410efefb0967588d151

以下内容为反编译后的 Utils.java 源代码,内容仅作参考


package com.uservoice.uservoicesdk.ui;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.util.TypedValue;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
import com.uservoice.uservoicesdk.activity.TopicActivity;
import com.uservoice.uservoicesdk.dialog.ArticleDialogFragment;
import com.uservoice.uservoicesdk.dialog.SuggestionDialogFragment;
import com.uservoice.uservoicesdk.model.Article;
import com.uservoice.uservoicesdk.model.BaseModel;
import com.uservoice.uservoicesdk.model.Suggestion;
import com.uservoice.uservoicesdk.model.Topic;
import java.util.Locale;
import r4.r0;
import r4.s0;
public class Utils {
    @SuppressLint({"SetJavaScriptEnabled"})
    public static void displayArticle(WebView webView, Article article, Context context) {
        String str;
        if (isDarkTheme(context)) {
            webView.setBackgroundColor(-16777216);
            str = "iframe, img { max-width: 100%; }body { background-color: #000000; color: #F6F6F6; } a { color: #0099FF; }";
        } else {
            str = "iframe, img { max-width: 100%; }";
        }
        String format = String.format("<html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"\"/><style>%s</style></head><body class=\"typeset\" style=\"font-family: sans-serif; margin: 1em\"><h3>%s</h3>%s</body></html>", str, article.getTitle(), article.getHtml());
        webView.setWebChromeClient(new WebChromeClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
        webView.loadUrl(String.format("data:text/html;charset=utf-8,%s", Uri.encode(format)));
    }

    public static void displayInstantAnswer(View view, BaseModel baseModel) {
        TextView textView = (TextView) view.findViewById(s0.uv_title);
        TextView textView2 = (TextView) view.findViewById(s0.uv_detail);
        View findViewById = view.findViewById(s0.uv_suggestion_details);
        ImageView imageView = (ImageView) view.findViewById(s0.uv_icon);
        if (baseModel instanceof Article) {
            Article article = (Article) baseModel;
            imageView.setImageResource(r0.uv_article);
            textView.setText(article.getTitle());
            if (article.getTopicName() != null) {
                textView2.setVisibility(0);
                textView2.setText(article.getTopicName());
            } else {
                textView2.setVisibility(8);
            }
            findViewById.setVisibility(8);
        } else if (baseModel instanceof Suggestion) {
            Suggestion suggestion = (Suggestion) baseModel;
            imageView.setImageResource(r0.uv_idea);
            textView.setText(suggestion.getTitle());
            textView2.setVisibility(0);
            textView2.setText(suggestion.getForumName());
            if (suggestion.getStatus() == null) {
                findViewById.setVisibility(8);
                return;
            }
            View findViewById2 = findViewById.findViewById(s0.uv_suggestion_status_color);
            TextView textView3 = (TextView) findViewById.findViewById(s0.uv_suggestion_status);
            int parseColor = Color.parseColor(suggestion.getStatusColor());
            findViewById.setVisibility(0);
            textView3.setText(suggestion.getStatus().toUpperCase(Locale.getDefault()));
            textView3.setTextColor(parseColor);
            findViewById2.setBackgroundColor(parseColor);
        }
    }

    @SuppressLint({"DefaultLocale"})
    public static String getQuantityString(View view, int i10, int i11) {
        return String.format("%,d %s", Integer.valueOf(i11), view.getContext().getResources().getQuantityString(i10, i11));
    }

    public static boolean isDarkTheme(Context context) {
        TypedValue typedValue = new TypedValue();
        float[] fArr = new float[3];
        context.getTheme().resolveAttribute(16842806, typedValue, true);
        Color.colorToHSV(context.getResources().getColor(typedValue.resourceId), fArr);
        return fArr[2] > 0.5f;
    }

    public static void showModel(FragmentActivity fragmentActivity, BaseModel baseModel) {
        showModel(fragmentActivity, baseModel, null);
    }

    public static void showModel(FragmentActivity fragmentActivity, BaseModel baseModel, String str) {
        if (baseModel instanceof Article) {
            new ArticleDialogFragment((Article) baseModel, str).show(fragmentActivity.getSupportFragmentManager(), "ArticleDialogFragment");
        } else if (baseModel instanceof Suggestion) {
            new SuggestionDialogFragment((Suggestion) baseModel, str).show(fragmentActivity.getSupportFragmentManager(), "SuggestionDialogFragment");
        } else if (baseModel instanceof Topic) {
            Intent intent = new Intent(fragmentActivity, TopicActivity.class);
            intent.putExtra("topic", (Topic) baseModel);
            fragmentActivity.startActivity(intent);
        }
    }
}