导航菜单

页面标题

页面副标题

Namma Yatri v3.3.7 - OverlayMessagingService.java 源代码

正在查看: Namma Yatri v3.3.7 应用的 OverlayMessagingService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package in.juspay.mobility.app;

import android.app.Service;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.swmansion.reanimated.layoutReanimation.Snapshot;
import in.juspay.hypersdk.core.PaymentConstants;
import in.juspay.mobility.app.MyFirebaseMessagingService;
import in.juspay.mobility.app.RemoteConfigs.MobilityRemoteConfigs;
import in.juspay.mobility.common.services.MobilityAPIResponse;
import in.juspay.mobility.common.services.MobilityCallAPI;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
import java.util.TimeZone;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class OverlayMessagingService extends Service {
    private static MobilityRemoteConfigs remoteConfigs = new MobilityRemoteConfigs(false, true);
    private JSONArray actions;
    private JSONArray actions2;
    private CountDownTimer countDownTimer;
    private String currency;
    private double editLat;
    private double editlon;
    private String endPoint;
    private String lang;
    private String link;
    private View messageView;
    private String method;
    private String reqBody;
    private JSONArray secondaryActions;
    private JSONArray secondaryActions2;
    private String supportPhoneNumber;
    private String toastMessage;
    private WindowManager windowManager;

    public void lambda$setDataToMediaView$0(String str, View view) {
        openLink(str);
        stopSelf();
    }

    public void lambda$setViewListeners$1(String str, View view) {
        for (int i = 0; i < this.actions2.length(); i++) {
            try {
                if (this.actions2.getJSONObject(i) != null) {
                    performAction2(this.actions2.getJSONObject(i), str);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (this.actions2.length() == 0) {
            for (int i2 = 0; i2 < this.actions.length(); i2++) {
                performAction(String.valueOf(this.actions.get(i2)), str);
            }
        }
        CountDownTimer countDownTimer = this.countDownTimer;
        if (countDownTimer != null) {
            countDownTimer.cancel();
        }
        stopSelf();
    }

    public void lambda$setViewListeners$2(String str, View view) {
        for (int i = 0; i < this.secondaryActions2.length(); i++) {
            try {
                if (this.secondaryActions2.getJSONObject(i) != null) {
                    performAction2(this.secondaryActions2.getJSONObject(i), str);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (this.secondaryActions2.length() == 0) {
            for (int i2 = 0; i2 < this.secondaryActions.length(); i2++) {
                performAction(String.valueOf(this.secondaryActions.get(i2)), str);
            }
        }
        stopSelf();
    }

    public void performDependentAction(JSONArray jSONArray, String str) {
        if (jSONArray != null) {
            try {
                if (jSONArray.length() > 0) {
                    for (int i = 0; i < jSONArray.length(); i++) {
                        performAction2(jSONArray.getJSONObject(i), str);
                    }
                }
            } catch (Exception e) {
                System.out.println("Exception in performDependentAction: " + e);
            }
        }
    }

    private void setDataToViews(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            TextView textView = (TextView) this.messageView.findViewById(R.id.title);
            FrameLayout frameLayout = (FrameLayout) this.messageView.findViewById(R.id.update_loc_details_component);
            TextView textView2 = (TextView) this.messageView.findViewById(R.id.description);
            ImageView imageView = (ImageView) this.messageView.findViewById(R.id.image);
            LinearLayout linearLayout = (LinearLayout) this.messageView.findViewById(R.id.button_view);
            MaterialButton findViewById = this.messageView.findViewById(R.id.button_ok);
            TextView textView3 = (TextView) this.messageView.findViewById(R.id.button_cancel);
            ImageView imageView2 = (ImageView) this.messageView.findViewById(R.id.cancel_button_image);
            TextView textView4 = (TextView) this.messageView.findViewById(R.id.button_cancel_right);
            textView.setText(jSONObject.has("title") ? jSONObject.getString("title") : "");
            findViewById.setText(jSONObject.has("okButtonText") ? jSONObject.getString("okButtonText") : "Cancel");
            textView3.setText(jSONObject.has("cancelButtonText") ? jSONObject.getString("cancelButtonText") : "Ok");
            textView2.setText(jSONObject.has("description") ? jSONObject.getString("description") : "");
            this.link = jSONObject.has("link") ? jSONObject.getString("link") : null;
            this.endPoint = jSONObject.has("endPoint") ? jSONObject.getString("endPoint") : null;
            this.method = jSONObject.has("method") ? jSONObject.getString("method") : null;
            this.reqBody = jSONObject.has("reqBody") ? jSONObject.getString("reqBody") : null;
            this.actions = jSONObject.has("actions") ? jSONObject.getJSONArray("actions") : new JSONArray();
            this.actions2 = jSONObject.has("actions2") ? jSONObject.getJSONArray("actions2") : new JSONArray();
            this.secondaryActions = jSONObject.has("secondaryActions") ? jSONObject.getJSONArray("secondaryActions") : new JSONArray();
            this.secondaryActions2 = jSONObject.has("secondaryActions2") ? jSONObject.getJSONArray("secondaryActions2") : new JSONArray();
            this.toastMessage = jSONObject.optString("toastMessage", null);
            this.supportPhoneNumber = jSONObject.optString("contactSupportNumber", null);
            this.editLat = jSONObject.has("editlat") ? jSONObject.getDouble("editlat") : 0.0d;
            this.editlon = jSONObject.has("editlon") ? jSONObject.getDouble("editlon") : 0.0d;
            com.bumptech.glide.b.t(this).v(jSONObject.getString("imageUrl")).A0(imageView);
            boolean z = jSONObject.has("titleVisibility") && jSONObject.getBoolean("titleVisibility");
            boolean has = jSONObject.has("updateLocDetails");
            if (has) {
                SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(getString(R.string.preference_file_key), 0);
                SharedPreferences.Editor edit = sharedPreferences.edit();
                this.currency = sharedPreferences.getString("CURRENCY", "₹");
                this.lang = sharedPreferences.getString("LANGUAGE_KEY", "ENGLISH");
                edit.putString("CALL_REFRESH", "true").apply();
            }
            boolean z2 = jSONObject.has("descriptionVisibility") && jSONObject.getBoolean("descriptionVisibility");
            boolean z3 = jSONObject.has("buttonOkVisibility") && jSONObject.getBoolean("buttonOkVisibility");
            boolean z4 = jSONObject.has("buttonCancelVisibility") && jSONObject.getBoolean("buttonCancelVisibility");
            boolean z5 = jSONObject.has("buttonLayoutVisibility") && jSONObject.getBoolean("buttonLayoutVisibility");
            boolean z6 = jSONObject.has("imageVisibility") && jSONObject.getBoolean("imageVisibility");
            textView.setVisibility(z ? 0 : 8);
            frameLayout.setVisibility(has ? 0 : 8);
            textView2.setVisibility(z2 ? 0 : 8);
            linearLayout.setVisibility(z5 ? 0 : 8);
            findViewById.setVisibility(z3 ? 0 : 8);
            textView3.setVisibility(z4 ? 0 : 8);
            imageView.setVisibility(z6 ? 0 : 8);
            try {
                setDataToMediaView(jSONObject);
            } catch (Exception e) {
                FirebaseCrashlytics.getInstance().recordException(new Exception("Error in SetDataToView " + e));
                String message = e.getMessage();
                Objects.requireNonNull(message);
                RideRequestUtils.firebaseLogEventWithParams("exception_in_construct_media_view", "CONSTRUCT_MEDIA_VIEW", message.substring(0, 40), this);
            }
            if (this.supportPhoneNumber != null) {
                textView4.setVisibility(0);
                imageView2.setVisibility(0);
                JSONArray jSONArray = this.secondaryActions;
                this.secondaryActions = jSONArray != null ? jSONArray.put("CALL_SUPPORT") : new JSONArray("CALL_SUPPORT");
                textView3.setText(R.string.need_help);
            }
            if (has) {
                setDataToLocationDetailsComponent(jSONObject);
            }
        } catch (Exception e2) {
            FirebaseCrashlytics.getInstance().recordException(new Exception("Error in ConstructView " + e2));
            RideRequestUtils.firebaseLogEventWithParams("exception_construct_view", "CONSTRUCT_VIEW", String.valueOf(e2), this);
            stopSelf();
        }
    }

    private void setViewListeners(View view, final String str) {
        view.findViewById(R.id.button_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                OverlayMessagingService.this.lambda$setViewListeners$1(str, view2);
            }
        });
        view.findViewById(R.id.secondary_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                OverlayMessagingService.this.lambda$setViewListeners$2(str, view2);
            }
        });
    }

    private void updateViewFromMlTranslation(TextView textView, String str, Context context) {
        new TranslatorMLKit("en", this.lang, context).translateStringInTextView(str, textView);
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        if (Settings.canDrawOverlays(this)) {
            super.onCreate();
        }
    }

    @Override
    public void onDestroy() {
        View view;
        super.onDestroy();
        WindowManager windowManager = this.windowManager;
        if (windowManager == null || (view = this.messageView) == null) {
            return;
        }
        windowManager.removeView(view);
        this.messageView = null;
    }

    @Override
    public int onStartCommand(Intent intent, int i, int i2) {
        String stringExtra = (intent == null || !intent.hasExtra(PaymentConstants.PAYLOAD)) ? null : intent.getStringExtra(PaymentConstants.PAYLOAD);
        if (Settings.canDrawOverlays(this) && stringExtra != null) {
            int i3 = Build.VERSION.SDK_INT >= 26 ? 2038 : 2002;
            if (this.windowManager != null) {
                setDataToViews(stringExtra);
                return 1;
            }
            this.windowManager = (WindowManager) getSystemService("window");
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-1, -1, i3, 2097154, -2);
            layoutParams.dimAmount = 0.6f;
            layoutParams.gravity = 17;
            layoutParams.screenOrientation = 1;
            View inflate = LayoutInflater.from(getApplicationContext()).inflate(R.layout.message_overlay, (ViewGroup) null);
            this.messageView = inflate;
            setViewListeners(inflate, stringExtra);
            this.windowManager.addView(this.messageView, layoutParams);
            setDataToViews(stringExtra);
        }
        return 1;
    }

    public void openLink(String str) {
        if (str != null) {
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
            intent.addFlags(268435456);
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException unused) {
                Toast.makeText(this, getResources().getString(Utils.getResIdentifier(getApplicationContext(), "no_enabled_browser", "string")), 1).show();
                RideRequestUtils.firebaseLogEventWithParams("exception_in_open_link_no_activity", "OPEN_LINK", "ActivityNotFoundException", this);
            } catch (Exception e) {
                String message = e.getMessage();
                Objects.requireNonNull(message);
                RideRequestUtils.firebaseLogEventWithParams("exception_in_open_link", "OPEN_LINK", message.substring(0, 40), this);
            }
        }
    }

    public void openNavigation(double d, double d2) {
        try {
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("google.navigation:q=" + d + "," + d2));
            intent.setFlags(268435456);
            intent.setPackage("com.google.android.apps.maps");
            startActivity(intent);
        } catch (Exception e) {
            String message = e.getMessage();
            Objects.requireNonNull(message);
            RideRequestUtils.firebaseLogEventWithParams("exception_in_open_navigation", "OPEN_NAVIGATION", message.substring(0, 40), this);
            e.printStackTrace();
        }
    }

    public void performAction(String str, String str2) {
        str.hashCode();
        switch (str) {
            case "OPEN_SUBSCRIPTION":
                Intent launchIntentForPackage = getApplicationContext().getPackageManager().getLaunchIntentForPackage(getApplicationContext().getPackageName());
                launchIntentForPackage.putExtra("notification_type", "PAYMENT_MODE_MANUAL");
                launchIntentForPackage.putExtra("entity_ids", "");
                launchIntentForPackage.putExtra("entity_type", "");
                launchIntentForPackage.addFlags(268435456);
                startActivity(launchIntentForPackage);
                Utils.logEvent("ny_driver_overlay_join_now", getApplicationContext());
                break;
            case "EDIT_LOCATION":
                try {
                    JSONObject jSONObject = new JSONObject(str2);
                    openNavigation(Double.parseDouble(jSONObject.optString("lat", "0.0")), Double.parseDouble(jSONObject.optString("lon", "0.0")));
                    break;
                } catch (Exception e) {
                    System.out.println(e.toString());
                    break;
                }
            case "CALL_SUPPORT":
                try {
                    Intent intent = new Intent("android.intent.action.DIAL");
                    intent.setData(Uri.parse("tel:" + this.supportPhoneNumber));
                    intent.addFlags(268435456);
                    startActivity(intent);
                    break;
                } catch (Exception e2) {
                    System.out.println(e2.toString());
                    break;
                }
            case "NAVIGATE":
                openNavigation(this.editLat, this.editlon);
                break;
            case "SET_DRIVER_ONLINE":
                RideRequestUtils.updateDriverStatus(Boolean.TRUE, "ONLINE", this, Boolean.FALSE);
                RideRequestUtils.restartLocationService(this);
                break;
            case "OPEN_LINK":
                openLink(this.link);
                break;
            case "OPEN_APP":
                RideRequestUtils.openApplication(this);
                break;
            case "CALL_API":
                try {
                    if (this.endPoint != null && this.reqBody != null && this.method != null) {
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                final MobilityAPIResponse callAPI = MobilityCallAPI.getInstance(OverlayMessagingService.this.getApplicationContext()).callAPI(OverlayMessagingService.this.endPoint, MobilityCallAPI.getBaseHeaders(OverlayMessagingService.this), OverlayMessagingService.this.reqBody, OverlayMessagingService.this.method);
                                new Handler(Looper.getMainLooper()).post(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (OverlayMessagingService.this.toastMessage == null || callAPI.getStatusCode() != 200) {
                                            return;
                                        }
                                        OverlayMessagingService overlayMessagingService = OverlayMessagingService.this;
                                        Toast.makeText(overlayMessagingService, overlayMessagingService.toastMessage, 0).show();
                                    }
                                });
                            }
                        }).start();
                        break;
                    }
                } catch (Exception e3) {
                    System.out.println("Error : " + e3);
                    break;
                }
                break;
        }
        stopSelf();
    }

    public void performAction2(JSONObject jSONObject, final String str) {
        JSONObject jSONObject2;
        char c;
        try {
            jSONObject2 = jSONObject.has("primaryAction") ? jSONObject.getJSONObject("primaryAction") : null;
        } catch (Exception e) {
            RideRequestUtils.firebaseLogEventWithParams("exception_perform_action", "PERFORM_ACTION", String.valueOf(e), this);
        }
        if (jSONObject2 != null) {
            String optString = jSONObject2.optString("actionName", "");
            JSONObject jSONObject3 = jSONObject2.has("actionDetails") ? jSONObject2.getJSONObject("actionDetails") : null;
            JSONArray jSONArray = jSONObject.has("dependentActions") ? jSONObject.getJSONArray("dependentActions") : null;
            switch (optString.hashCode()) {
                case -1932749582:
                    if (optString.equals("OPEN_SUBSCRIPTION")) {
                        c = 5;
                        break;
                    }
                    c = 65535;
                    break;
                case -1758755254:
                    if (optString.equals("EDIT_LOCATION")) {
                        c = 7;
                        break;
                    }
                    c = 65535;
                    break;
                case -1535383858:
                    if (optString.equals("CALL_SUPPORT")) {
                        c = 6;
                        break;
                    }
                    c = 65535;
                    break;
                case -1409845903:
                    if (optString.equals("NAVIGATE")) {
                        c = 1;
                        break;
                    }
                    c = 65535;
                    break;
                case 25695501:
                    if (optString.equals("SET_DRIVER_ONLINE")) {
                        c = 0;
                        break;
                    }
                    c = 65535;
                    break;
                case 67281103:
                    if (optString.equals("OPEN_LINK")) {
                        c = 2;
                        break;
                    }
                    c = 65535;
                    break;
                case 279254668:
                    if (optString.equals("OPEN_APP")) {
                        c = 4;
                        break;
                    }
                    c = 65535;
                    break;
                case 611270809:
                    if (optString.equals(MyFirebaseMessagingService.NotificationTypes.CALL_API)) {
                        c = 3;
                        break;
                    }
                    c = 65535;
                    break;
                default:
                    c = 65535;
                    break;
            }
            switch (c) {
                case 0:
                    RideRequestUtils.updateDriverStatus(Boolean.TRUE, "ONLINE", this, Boolean.FALSE);
                    RideRequestUtils.restartLocationService(this);
                    performDependentAction(jSONArray, str);
                    stopSelf();
                    break;
                case 1:
                    openNavigation(jSONObject3.optDouble("lat", 0.0d), jSONObject3.optDouble("long", 0.0d));
                    performDependentAction(jSONArray, str);
                    stopSelf();
                    break;
                case 2:
                    openLink(jSONObject3.optString("link", null));
                    performDependentAction(jSONArray, str);
                    stopSelf();
                    break;
                case 3:
                    try {
                        final String optString2 = jSONObject3.optString("endPoint", null);
                        final String optString3 = jSONObject3.optString("reqBody", null);
                        final String optString4 = jSONObject3.optString("method", null);
                        if (optString2 != null && optString3 != null && optString4 != null) {
                            final JSONArray jSONArray2 = jSONArray;
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    final MobilityAPIResponse callAPI = MobilityCallAPI.getInstance(OverlayMessagingService.this.getApplicationContext()).callAPI(optString2, MobilityCallAPI.getBaseHeaders(OverlayMessagingService.this), optString3, optString4);
                                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                                        @Override
                                        public void run() {
                                            if (callAPI.getStatusCode() != 200) {
                                                RideRequestUtils.firebaseLogEventWithParams("failure_call_api", MyFirebaseMessagingService.NotificationTypes.CALL_API, String.valueOf(callAPI), OverlayMessagingService.this.getApplicationContext());
                                                OverlayMessagingService.this.toastMessage = "Something went Wrong.";
                                                OverlayMessagingService overlayMessagingService = OverlayMessagingService.this;
                                                Toast.makeText(overlayMessagingService, overlayMessagingService.toastMessage, 0).show();
                                                return;
                                            }
                                            if (OverlayMessagingService.this.toastMessage != null) {
                                                OverlayMessagingService overlayMessagingService2 = OverlayMessagingService.this;
                                                Toast.makeText(overlayMessagingService2, overlayMessagingService2.toastMessage, 0).show();
                                            }
                                            AnonymousClass3 anonymousClass3 = AnonymousClass3.this;
                                            OverlayMessagingService.this.performDependentAction(jSONArray2, str);
                                        }
                                    });
                                }
                            }).start();
                        }
                    } catch (Exception e2) {
                        RideRequestUtils.firebaseLogEventWithParams("exception_call_api", MyFirebaseMessagingService.NotificationTypes.CALL_API, String.valueOf(e2), this);
                    }
                    stopSelf();
                    break;
                case 4:
                    RideRequestUtils.openApplication(this);
                    performDependentAction(jSONArray, str);
                    stopSelf();
                    break;
                case 5:
                    Intent launchIntentForPackage = getApplicationContext().getPackageManager().getLaunchIntentForPackage(getApplicationContext().getPackageName());
                    launchIntentForPackage.putExtra("notification_type", "PAYMENT_MODE_MANUAL");
                    launchIntentForPackage.putExtra("entity_ids", "");
                    launchIntentForPackage.putExtra("entity_type", "");
                    launchIntentForPackage.addFlags(268435456);
                    startActivity(launchIntentForPackage);
                    Utils.logEvent("ny_driver_overlay_join_now", getApplicationContext());
                    performDependentAction(jSONArray, str);
                    stopSelf();
                    break;
                case 6:
                    try {
                        String optString5 = jSONObject3.optString("contactSupportNumber", "");
                        Intent intent = new Intent("android.intent.action.DIAL");
                        intent.setData(Uri.parse("tel:" + optString5));
                        intent.addFlags(268435456);
                        startActivity(intent);
                        performDependentAction(jSONArray, str);
                    } catch (Exception e3) {
                        System.out.println("Error : " + e3);
                    }
                    stopSelf();
                    break;
                case 7:
                    try {
                        JSONObject jSONObject4 = new JSONObject(str);
                        openNavigation(Double.parseDouble(jSONObject4.optString("lat", "0.0")), Double.parseDouble(jSONObject4.optString("lon", "0.0")));
                    } catch (Exception e4) {
                        System.out.println(e4.toString());
                    }
                    stopSelf();
                    break;
                default:
                    stopSelf();
                    break;
            }
        }
    }

    public void setDataToLocationDetailsComponent(JSONObject jSONObject) throws JSONException {
        String str;
        int i;
        String str2;
        String str3;
        String str4;
        String string;
        int i2;
        int i3;
        String string2;
        int i4;
        JSONObject jSONObject2 = jSONObject.getJSONObject("updateLocDetails");
        JSONObject jSONObject3 = jSONObject2.has("destination") ? jSONObject2.getJSONObject("destination") : null;
        if (jSONObject3 != null) {
            double optDouble = jSONObject3.optDouble("lat", 0.0d);
            double optDouble2 = jSONObject3.optDouble("lon", 0.0d);
            String optString = (jSONObject3.has("address") ? jSONObject3.getJSONObject("address") : null).optString("fullAddress", "");
            String pinCodeFromRR = RideRequestUtils.getPinCodeFromRR(optDouble, optDouble2, this);
            TextView textView = (TextView) this.messageView.findViewById(R.id.new_drop);
            updateViewFromMlTranslation(textView, "Drop: " + optString, getApplicationContext());
            TextView textView2 = (TextView) this.messageView.findViewById(R.id.pin_code);
            textView2.setText(pinCodeFromRR);
            textView2.setVisibility(0);
            textView.setVisibility(0);
            ((LinearLayout) this.messageView.findViewById(R.id.drop_layout)).setVisibility(0);
        }
        double optDouble3 = jSONObject2.optDouble("newEstimatedDistance", 0.0d);
        double d = optDouble3 / 1000.0d;
        double optDouble4 = jSONObject2.optDouble("newEstimatedFare", 0.0d);
        double optDouble5 = jSONObject2.optDouble("oldEstimatedDistance", 0.0d);
        double optDouble6 = jSONObject2.optDouble("oldEstimatedFare", 0.0d);
        TextView textView3 = (TextView) this.messageView.findViewById(R.id.new_fare_val);
        textView3.setText(this.currency + " " + String.format(Locale.getDefault(), "%.1f", Double.valueOf(optDouble4)));
        textView3.setVisibility(0);
        double d2 = optDouble4 - optDouble6;
        ImageView imageView = (ImageView) this.messageView.findViewById(R.id.fare_diff_indicator_arrow);
        MaterialCardView findViewById = this.messageView.findViewById(R.id.fare_diff_indicator);
        TextView textView4 = (TextView) this.messageView.findViewById(R.id.fare_diff_indicator_val);
        String string3 = remoteConfigs.hasKey("update_loc_details") ? remoteConfigs.getString("update_loc_details") : null;
        String str5 = "#A7A7A7";
        String str6 = "#53BB6F";
        if (string3 != null) {
            JSONObject jSONObject4 = new JSONObject(string3);
            String optString2 = jSONObject4.optString("distDiffColorPositive", "#53BB6F");
            String optString3 = jSONObject4.optString("distDiffColorNegative", "#E55454");
            str2 = optString2;
            str4 = jSONObject4.optString("distDiffColorNeutral", "#A7A7A7");
            str6 = jSONObject4.optString("fareDiffColorPositive", "#53BB6F");
            String optString4 = jSONObject4.optString("fareDiffColorNegative", "#E55454");
            str5 = jSONObject4.optString("fareDiffColorNeutral", "#A7A7A7");
            str = optString3;
            i = jSONObject4.optInt("minTimeToShowPopupInMS", 50000);
            str3 = optString4;
        } else {
            str = "#E55454";
            i = 50000;
            str2 = "#53BB6F";
            str3 = str;
            str4 = "#A7A7A7";
        }
        int i5 = R.drawable.ny_ic_down_arrow_white;
        if (d2 < 0.0d) {
            string = this.currency + " " + String.format(Locale.getDefault(), "%.1f", Double.valueOf(optDouble6 - optDouble4));
            i2 = i5;
            i3 = 0;
        } else if (d2 > 0.0d) {
            int i6 = R.drawable.ny_ic_up_arrow_white;
            string = this.currency + " " + String.format(Locale.getDefault(), "%.1f", Double.valueOf(d2));
            i3 = 0;
            String str7 = str6;
            i2 = i6;
            str3 = str7;
        } else {
            string = getString(R.string.no_change);
            i2 = i5;
            str3 = str5;
            i3 = 8;
        }
        findViewById.setCardBackgroundColor(Color.parseColor(str3));
        imageView.setVisibility(i3);
        imageView.setImageDrawable(getDrawable(i2));
        textView4.setText(string);
        ((TextView) this.messageView.findViewById(R.id.new_dist_val)).setText(String.format(Locale.getDefault(), "%.1f", Double.valueOf(d)) + " km");
        double d3 = optDouble3 - optDouble5;
        ImageView imageView2 = (ImageView) this.messageView.findViewById(R.id.dist_diff_indicator_arrow);
        TextView textView5 = (TextView) this.messageView.findViewById(R.id.dist_diff_indicator_val);
        MaterialCardView findViewById2 = this.messageView.findViewById(R.id.dist_diff_indicator);
        if (d3 < 0.0d) {
            i5 = R.drawable.ny_ic_down_arrow_white;
            string2 = String.format(Locale.getDefault(), "%.1f", Double.valueOf((optDouble5 - optDouble3) / 1000.0d)) + " km";
        } else {
            if (d3 <= 0.0d) {
                string2 = getString(R.string.no_change);
                str = str4;
                i4 = 8;
                imageView2.setImageDrawable(getDrawable(i5));
                imageView2.setVisibility(i4);
                findViewById2.setCardBackgroundColor(Color.parseColor(str));
                textView5.setText(string2);
                new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", new Locale("en", "us")).setTimeZone(TimeZone.getTimeZone("UTC"));
                int min = Math.min((RideRequestUtils.calculateExpireTimer(jSONObject2.optString("validTill", ""), r0.format(new Date())) - 5) * 1000, i);
                final LinearProgressIndicator findViewById3 = this.messageView.findViewById(R.id.progress_indicator_overlay);
                CountDownTimer countDownTimer = new CountDownTimer(min, 1000L) {
                    @Override
                    public void onFinish() {
                        OverlayMessagingService.this.stopSelf();
                    }

                    @Override
                    public void onTick(long j) {
                        int i7 = (int) (j / 1000);
                        findViewById3.o(i7 * 2, true);
                        if (i7 <= 8) {
                            findViewById3.setIndicatorColor(new int[]{OverlayMessagingService.this.getColor(R.color.red900)});
                        } else {
                            findViewById3.setIndicatorColor(new int[]{OverlayMessagingService.this.getColor(R.color.green900)});
                        }
                    }
                };
                this.countDownTimer = countDownTimer;
                countDownTimer.start();
            }
            i5 = R.drawable.ny_ic_up_arrow_white;
            string2 = String.format(Locale.getDefault(), "%.1f", Double.valueOf(d3 / 1000.0d)) + " km";
            str = str2;
        }
        i4 = 0;
        imageView2.setImageDrawable(getDrawable(i5));
        imageView2.setVisibility(i4);
        findViewById2.setCardBackgroundColor(Color.parseColor(str));
        textView5.setText(string2);
        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", new Locale("en", "us")).setTimeZone(TimeZone.getTimeZone("UTC"));
        long min2 = Math.min((RideRequestUtils.calculateExpireTimer(jSONObject2.optString("validTill", ""), r0.format(new Date())) - 5) * 1000, i);
        final LinearProgressIndicator findViewById32 = this.messageView.findViewById(R.id.progress_indicator_overlay);
        CountDownTimer countDownTimer2 = new CountDownTimer(min2, 1000L) {
            @Override
            public void onFinish() {
                OverlayMessagingService.this.stopSelf();
            }

            @Override
            public void onTick(long j) {
                int i7 = (int) (j / 1000);
                findViewById32.o(i7 * 2, true);
                if (i7 <= 8) {
                    findViewById32.setIndicatorColor(new int[]{OverlayMessagingService.this.getColor(R.color.red900)});
                } else {
                    findViewById32.setIndicatorColor(new int[]{OverlayMessagingService.this.getColor(R.color.green900)});
                }
            }
        };
        this.countDownTimer = countDownTimer2;
        countDownTimer2.start();
    }

    public void setDataToMediaView(JSONObject jSONObject) throws JSONException {
        LinearLayout linearLayout = (LinearLayout) this.messageView.findViewById(R.id.dynamic_views);
        linearLayout.removeAllViews();
        JSONArray jSONArray = jSONObject.has("socialMediaLinks") ? jSONObject.getJSONArray("socialMediaLinks") : null;
        if (jSONArray != null) {
            for (int i = 0; i < jSONArray.length(); i++) {
                LinearLayout linearLayout2 = new LinearLayout(this);
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                int i2 = jSONObject2.has(Snapshot.HEIGHT) ? jSONObject2.getInt(Snapshot.HEIGHT) : 0;
                int i3 = jSONObject2.has(Snapshot.WIDTH) ? jSONObject2.getInt(Snapshot.HEIGHT) : 0;
                int i4 = 8;
                if (jSONObject2.has("prefixImage")) {
                    ImageView imageView = new ImageView(this);
                    com.bumptech.glide.b.t(this).v(jSONObject2.getString("prefixImage")).A0(imageView);
                    imageView.setLayoutParams(new LinearLayout.LayoutParams(i3, i2));
                    imageView.setVisibility((!jSONObject2.has("prefixImage") || jSONObject2.getString("prefixImage").length() == 0) ? 8 : 0);
                    linearLayout2.addView(imageView);
                }
                TextView textView = new TextView(this);
                textView.setText(jSONObject2.has("linkText") ? jSONObject2.getString("linkText") : "");
                textView.setTextColor(jSONObject2.has("linkTextColor") ? jSONObject2.getInt("linkTextColor") : getResources().getColor(R.color.blue800, null));
                if (!jSONObject2.has("isTextUnderlined") || jSONObject2.getBoolean("isTextUnderlined")) {
                    textView.setPaintFlags(textView.getPaintFlags() | 8);
                }
                textView.setVisibility((!jSONObject2.has("linkText") || jSONObject2.getString("linkText").length() == 0) ? 8 : 0);
                textView.setPadding(10, 0, 10, 0);
                linearLayout2.addView(textView);
                if (jSONObject2.has("suffixImage")) {
                    ImageView imageView2 = new ImageView(this);
                    com.bumptech.glide.b.t(this).v(jSONObject2.getString("suffixImage")).A0(imageView2);
                    imageView2.setLayoutParams(new LinearLayout.LayoutParams(i3, i2));
                    if (jSONObject2.has("suffixImage") && jSONObject2.getString("suffixImage").length() != 0) {
                        i4 = 0;
                    }
                    imageView2.setVisibility(i4);
                    linearLayout2.addView(imageView2);
                }
                linearLayout2.setGravity(17);
                final String string = jSONObject2.has("link") ? jSONObject2.getString("link") : null;
                if (string != null) {
                    linearLayout2.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            OverlayMessagingService.this.lambda$setDataToMediaView$0(string, view);
                        }
                    });
                }
                linearLayout.addView(linearLayout2);
            }
        }
    }
}