package com.overlook.android.fing.ui.internet; import android.annotation.SuppressLint; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.appcompat.app.g; import com.huawei.hms.support.api.entity.common.CommonConstant; import com.huawei.hms.support.api.push.pushselfshow.prepare.NotificationIconUtil; import com.overlook.android.fing.R; import com.overlook.android.fing.engine.l.u; import com.overlook.android.fing.engine.model.internet.IspInfo; import com.overlook.android.fing.engine.model.internet.UserRating; import com.overlook.android.fing.vl.components.IconView; import com.overlook.android.fing.vl.components.MainButton; import com.overlook.android.fing.vl.components.TextView; import e.a.a.a.a; import e.f.a.a.b.f.f0; import e.f.a.a.b.j.j; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Collections; import java.util.Objects; import java.util.Random; /* compiled from: TwitterRatingHelper */ public class z4 { /* renamed from: a reason: collision with root package name */ private IspInfo f16917a; private UserRating b; /* renamed from: c reason: collision with root package name */ private String[][] f16918c = {new String[]{"🤢", "🤯", "😡", "🤬", "😤", "💩", "💔"}, new String[]{"😢", "😠", "☹️", "👎"}, new String[]{"🤔", "😐", "😑", "😶"}, new String[]{"👍", "👏", "⭐"}, new String[]{"😍", "😻", "🤩", "🤗", "❤️"}}; public z4(IspInfo ispInfo, UserRating userRating) { this.f16917a = ispInfo; this.b = userRating; } public void a(Context context, g gVar, View view) { String str; j.x("User_Rating_Share", Collections.singletonMap("Type", "Twitter")); String e2 = this.f16917a.e() != null ? this.f16917a.e() : this.f16917a.j(); try { e2 = URLEncoder.encode(e2.replaceAll(" ", "%20"), "UTF-8"); } catch (UnsupportedEncodingException unused) { } StringBuilder H = a.H("https://internet.fing.com/provider/", e2, NotificationIconUtil.SPLIT_CHAR); H.append(this.f16917a.d()); H.append("?utm_source=mobile_app%26utm_medium=twitter_share%26utm_campaign=dropdetect"); String string = context.getString(R.string.twitter_message_with_link2, this.f16917a.j(), u.b(this.f16917a.d()), H.toString()); StringBuilder E = a.E("%23fing %23internet %23"); E.append(this.f16917a.j().replace(" ", "")); String sb = E.toString(); int max = Math.max(0, (int) (Math.ceil((double) (Math.max(0.0f, Math.min((float) this.b.d(), 100.0f)) / (100.0f / ((float) this.f16918c.length)))) - 1.0d)); String str2 = this.f16918c[max][new Random().nextInt(this.f16918c[max].length)]; if (TextUtils.isEmpty(this.b.a())) { str = context.getString(R.string.twitter_message, str2, this.f16917a.m()); } else { str = context.getString(R.string.twitter_message_with_comment, str2, this.f16917a.m(), this.b.a()); } StringBuilder sb2 = new StringBuilder(); sb2.append(str); sb2.append("\n\n"); sb2.append(string); sb2.append("\n\n"); sb2.append(sb); String z = a.z(sb2, "\n\n", "via @fingapp @outagedetect"); if (z.length() > 270 && !TextUtils.isEmpty(this.b.a())) { try { str = context.getString(R.string.twitter_message_with_comment, str2, this.f16917a.m(), this.b.a().substring(0, str.length() - ((z.length() - 270) - 1)) + "…"); } catch (IndexOutOfBoundsException unused2) { } } StringBuilder sb3 = new StringBuilder(); sb3.append(str); sb3.append("%0A%0A"); sb3.append(string); sb3.append("%0A%0A"); sb3.append(sb); sb3.append("%0A%0A"); sb3.append("via @fingapp @outagedetect"); try { context.startActivity(new Intent(CommonConstant.ACTION.HWID_SCHEME_URL, Uri.parse("https://twitter.com/intent/tweet" + "?text=" + ((CharSequence) sb3) + "&related=fingapp%3AFing%20internet,outagedetect%3AOutageInternet%20Internet"))); j.x("User_Rating_Share_Success", Collections.singletonMap("Type", "Twitter")); } catch (ActivityNotFoundException unused3) { j.x("User_Rating_Share_Fail", Collections.singletonMap("Type", "Twitter")); } gVar.dismiss(); } @SuppressLint({"InflateParams"}) public void b(Context context) { IspInfo ispInfo; if (context != null && (ispInfo = this.f16917a) != null && !TextUtils.isEmpty(ispInfo.m())) { View inflate = LayoutInflater.from(context).inflate(R.layout.dialog_send_tweet, (ViewGroup) null); IconView iconView = (IconView) inflate.findViewById(R.id.logo); int i2 = androidx.core.content.a.b; iconView.setImageDrawable(context.getDrawable(R.drawable.done_96)); e.e.a.a.a.a.j0(iconView, androidx.core.content.a.b(context, R.color.green100)); IconView iconView2 = (IconView) inflate.findViewById(R.id.close_button); int b2 = androidx.core.content.a.b(context, R.color.text50); Objects.requireNonNull(iconView2); e.e.a.a.a.a.j0(iconView2, b2); TextView textView = (TextView) inflate.findViewById(R.id.not_now); MainButton mainButton = (MainButton) inflate.findViewById(R.id.tweet_button); mainButton.f(androidx.core.content.a.b(context, R.color.green100)); mainButton.setBackgroundColor(androidx.core.content.a.b(context, R.color.green100)); mainButton.k(androidx.core.content.a.b(context, 17170443)); mainButton.p(androidx.core.content.a.b(context, 17170443)); mainButton.n(R.string.minternetspeed_twitter_action); f0 f0Var = new f0(context); f0Var.d(true); f0Var.s(inflate); f0Var.F(new j4(this, textView, iconView2, mainButton, context)); try { f0Var.M(); } catch (Exception unused) { } } } }