导航菜单

页面标题

页面副标题

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

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

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


package in.juspay.mobility.app;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.material.button.MaterialButton;
import in.juspay.hypersdk.core.PaymentConstants;
import java.util.ArrayList;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONObject;

public class MessageOverlayService extends Service implements View.OnClickListener {
    private static final ArrayList<SendMessageCallBack> sendMessageCallBacks = new ArrayList<>();
    Context context;
    private View overlayView;
    private View stopDetectedOverlayView;
    private WindowManager windowManager;
    String LOG_TAG = "MessageOverlay";
    LinearLayout messageSheetHeader = null;
    TextView messageTextView = null;
    TextView TimestampView = null;
    TextView headerTextView = null;
    TextView bodyTextView = null;
    LinearLayout stopDetectedSuggestion1View = null;
    LinearLayout stopDetectedSuggestion2View = null;
    LinearLayout stopDetectedSuggestion3View = null;
    TextView stopSuggestion1TextView = null;
    TextView stopSuggestion2TextView = null;
    TextView stopSuggestion3TextView = null;
    TextView quickChatsTextView = null;
    ImageView stopSuggestion1ImageView = null;
    ImageView stopSuggestion2ImageView = null;
    ImageView stopSuggestion3ImageView = null;
    ImageView headerSuffixImage = null;
    TextView suggestion1SentTextView = null;
    TextView suggestion2SentTextView = null;
    TextView suggestion3SentTextView = null;
    MaterialButton gotItButtonView = null;
    MaterialButton suggestion1View = null;
    MaterialButton suggestion2View = null;
    MaterialButton suggestion3View = null;
    Suggestions suggestions = null;
    boolean stopDetectedOverlay = false;

    public interface SendMessageCallBack {
        void sendMessage(String str);
    }

    public static void deRegisterSendMessageCallBack(SendMessageCallBack sendMessageCallBack) {
        sendMessageCallBacks.remove(sendMessageCallBack);
    }

    private static JSONObject defaultStopSuggestions() {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("driverStopDetectedOverlay1BP", new JSONObject().put("en_us", "On my way, hold tight!").put("ta_in", "வந்துகொண்டு இருக்கிறேன், சற்று காத்திருங்கள்!").put("kn_in", "ಸರಿ ಬರುತ್ತಿದ್ದೇನೆ, ಸ್ವಲ್ಪ ಕಾಯಿರಿ").put("hi_in", "रास्ते में हूँ, थोड़ा इंतजार करें!").put("ml_in", "ഞാൻ വരുന്നു, കുറച്ച് സമയം കാത്തിരിക്കൂ!").put("bn_in", "রাস্তায় আছি, একটু অপেক্ষা করুন!").put("te_in", "మార్గ మధ్యంలో ఉన్నాను,కాసేపు ఆగండి"));
            jSONObject.put("driverStopDetectedOverlay2BP", new JSONObject().put("en_us", "Traffic ahead, few mins delay").put("ta_in", "போக்குவரத்து நெரிசலாக உள்ளது, சில நிமிடங்கள் தாமதமாகும்").put("kn_in", "ಟ್ರಾಫಿಕ್ ಇದೆ, ಸ್ವಲ್ಪ ಸಮಯ ತಡೆಯಿರಿ").put("hi_in", "आगे ट्रैफिक है, कुछ मिनट देरी होगी").put("ml_in", "ട്രാഫിക് ഉണ്ട്, കുറച്ച് നേരം വൈകും").put("bn_in", "সামনের দিকে ট্রাফিক আছে, কয়েক মিনিট দেরি").put("te_in", "ముందు ట్రాఫిక్ ఉంది, కొద్దిసేపు ఆలస్యం అవుతుంది."));
            jSONObject.put("driverStopDetectedOverlay3BP", new JSONObject().put("en_us", "Struggling with location, one sec!").put("ta_in", "இடத்தை கண்டுபிடிக்க சிரமமாக உள்ளது, ஒரு நொடி!").put("kn_in", "ಸ್ಥಳ ಸಿಗುವುದರಲ್ಲಿ ತೊಂದರೆ, ಒಂದು ಕ್ಷಣ!").put("hi_in", "स्थान ढूंढने में मुश्किल हो रही है, एक सेकंड!").put("ml_in", "ലൊക്കേഷൻ കണ്ടെത്താൻ ബുദ്ധിമുട്ടുന്നു, ഒരു സെക്കന്റ്!").put("bn_in", "লোকেশন খুঁজতে অসুবিধা হচ্ছে, এক সেকেন্ড!").put("te_in", "లొకేషన్ కనుగొనుటలో ఇబ్బందిఉంది, ఒక సెకండ్ ఆగండి!"));
            return jSONObject;
        } catch (Exception e) {
            android.util.Log.e("MessageOverlay", "Error in defaultStopSuggestions " + e);
            return null;
        }
    }

    private static JSONObject defaultSuggestions() {
        try {
            JSONObject jSONObject = new JSONObject("{\"ta_in\":\"சரி\",\"ml_in\":\"ഓക്കേ\",\"kn_in\":\"ಸರಿ\",\"hi_in\":\"ठीक है\",\"en_us\":\"Ok\",\"bn_in\":\"ঠিক আছে\",\"te_in\":\"సరే\"}");
            JSONObject jSONObject2 = new JSONObject("{\"en_us\":\"Yes\",\"ta_in\":\"ஆம்\",\"kn_in\":\"ಹೌದು\",\"hi_in\":\"हाँ\",\"ml_in\":\"അതെ\",\"bn_in\":\"হ্যাঁ\",\"te_in\":\"అవును\"}");
            JSONObject jSONObject3 = new JSONObject("{\"en_us\":\"5 mins\",\"ta_in\":\"5 mins\",\"kn_in\":\"5 mins\",\"hi_in\":\"5 mins\",\"ml_in\":\"5 mins\",\"bn_in\":\"5 mins\",\"te_in\":\"5 mins\"}");
            JSONObject jSONObject4 = new JSONObject("{\"en_us\":\"Yes\",\"ta_in\":\"ஆம்\",\"kn_in\":\"ಹೌದು\",\"hi_in\":\"हाँ\",\"ml_in\":\"അതെ\",\"bn_in\":\"হ্যাঁ\",\"te_in\":\"అవును\"}");
            JSONObject jSONObject5 = new JSONObject("{\"ta_in\":\"சரி\",\"ml_in\":\"ഓക്കേ\",\"kn_in\":\"ಸರಿ\",\"hi_in\":\"ठीक है\",\"en_us\":\"Ok\",\"bn_in\":\"ঠিক আছে\",\"te_in\":\"సరే\"}");
            JSONObject jSONObject6 = new JSONObject("{\"en_us\":\"5 mins\",\"ta_in\":\"5 mins\",\"kn_in\":\"5 mins\",\"hi_in\":\"5 mins\",\"ml_in\":\"5 mins\",\"bn_in\":\"5 mins\",\"te_in\":\"5 mins\"}");
            JSONObject jSONObject7 = new JSONObject();
            jSONObject7.put("dols1BP", jSONObject);
            jSONObject7.put("dols2BP", jSONObject2);
            jSONObject7.put("dols3BP", jSONObject3);
            jSONObject7.put("dols1AP", jSONObject4);
            jSONObject7.put("dols2AP", jSONObject5);
            jSONObject7.put("dols3AP", jSONObject6);
            return jSONObject7;
        } catch (Exception e) {
            android.util.Log.e("MessageOverlay", "Error in defaultSuggestions " + e);
            return null;
        }
    }

    private String getFallBackSuggestion(String str, String str2) {
        try {
            new JSONObject();
            JSONObject jSONObject = (this.stopDetectedOverlay ? defaultStopSuggestions() : defaultSuggestions()).getJSONObject(str);
            return jSONObject.has(str2.toLowerCase()) ? jSONObject.getString(str2.toLowerCase()) : jSONObject.getString("en_us");
        } catch (Exception e) {
            android.util.Log.e("MessageOverlay", "Error in getFallBackSuggestions " + e);
            return "";
        }
    }

    private Suggestions getFallBackSuggestions(Context context) {
        try {
            SharedPreferences sharedPreferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), 0);
            String string = sharedPreferences.getString("IS_DRIVER_AT_PICKUP", "null");
            String string2 = sharedPreferences.getString("LANGUAGE_KEY", "null");
            return this.stopDetectedOverlay ? new Suggestions(getFallBackSuggestion("driverStopDetectedOverlay1BP", string2), getFallBackSuggestion("driverStopDetectedOverlay2BP", string2), getFallBackSuggestion("driverStopDetectedOverlay3BP", string2)) : string.equals("true") ? new Suggestions(getFallBackSuggestion("dols1AP", string2), getFallBackSuggestion("dols2AP", string2), getFallBackSuggestion("dols3AP", string2)) : new Suggestions(getFallBackSuggestion("dols1BP", string2), getFallBackSuggestion("dols2BP", string2), getFallBackSuggestion("dols3BP", string2));
        } catch (Exception e) {
            android.util.Log.e("MessageOverlay", "Error in getFallBackSuggestions " + e);
            return null;
        }
    }

    private String getSuggestionFromKey(String str, String str2) {
        try {
            Context context = this.context;
            JSONObject jSONObject = new JSONObject(context.getSharedPreferences(context.getString(R.string.preference_file_key), 0).getString("SUGGESTIONS_DEFINITIONS", "null"));
            if (!jSONObject.has(str)) {
                return str;
            }
            JSONObject jSONObject2 = jSONObject.getJSONObject(str);
            return jSONObject2.has(str2.toLowerCase()) ? jSONObject2.getString(str2.toLowerCase()) : jSONObject2.getString("en_us");
        } catch (Exception e) {
            android.util.Log.e("MessageOverlay", "Error in getMessageFromKey : " + e);
            return "";
        }
    }

    public void lambda$sendMessage$0(SendMessageCallBack sendMessageCallBack, String str) {
        try {
            sendMessageCallBack.sendMessage(str);
        } catch (Exception e) {
            android.util.Log.e(this.LOG_TAG, "Error in sending a message" + e);
        }
    }

    public static void registerSendMessageCallBack(SendMessageCallBack sendMessageCallBack) {
        sendMessageCallBacks.add(sendMessageCallBack);
    }

    private void sendMessage(final SendMessageCallBack sendMessageCallBack, final String str) {
        new Thread(new Runnable() {
            @Override
            public final void run() {
                MessageOverlayService.this.lambda$sendMessage$0(sendMessageCallBack, str);
            }
        }).start();
    }

    private void sendMessageViewForStopsOverlay(int i) {
        ImageView imageView;
        TextView textView;
        ImageView imageView2;
        TextView textView2;
        ImageView imageView3;
        TextView textView3;
        this.stopDetectedSuggestion1View.setVisibility(8);
        this.stopDetectedSuggestion2View.setVisibility(8);
        this.stopDetectedSuggestion3View.setVisibility(8);
        this.stopDetectedSuggestion1View.setClickable(false);
        this.stopDetectedSuggestion2View.setClickable(false);
        this.stopDetectedSuggestion3View.setClickable(false);
        MaterialButton materialButton = this.gotItButtonView;
        if (materialButton != null) {
            materialButton.setText(R.string.okay_got_it_smallcase);
            this.gotItButtonView.setVisibility(0);
            this.gotItButtonView.setOnClickListener(this);
        }
        if (i == R.id.suggestion1 && (imageView3 = this.stopSuggestion1ImageView) != null && (textView3 = this.suggestion1SentTextView) != null) {
            setSentSuggestionImageAndText(this.stopDetectedSuggestion1View, R.drawable.ny_ic_check_green, imageView3, textView3);
            return;
        }
        if (i == R.id.suggestion2 && (imageView2 = this.stopSuggestion2ImageView) != null && (textView2 = this.suggestion2SentTextView) != null) {
            setSentSuggestionImageAndText(this.stopDetectedSuggestion2View, R.drawable.ny_ic_check_green, imageView2, textView2);
        } else {
            if (i != R.id.suggestion3 || (imageView = this.stopSuggestion3ImageView) == null || (textView = this.suggestion3SentTextView) == null) {
                return;
            }
            setSentSuggestionImageAndText(this.stopDetectedSuggestion3View, R.drawable.ny_ic_check_green, imageView, textView);
        }
    }

    private void setImageDimensions(ImageView imageView, int i, int i2) {
        ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
        layoutParams.width = i2;
        layoutParams.height = i;
        imageView.setLayoutParams(layoutParams);
    }

    private void setSentSuggestionImageAndText(LinearLayout linearLayout, int i, ImageView imageView, TextView textView) {
        linearLayout.setVisibility(0);
        textView.setVisibility(0);
        textView.setText(R.string.sent);
        imageView.setImageDrawable(getDrawable(i));
        setImageDimensions(imageView, 50, 50);
    }

    private void setStopSuggestionImageAndText(LinearLayout linearLayout, TextView textView, ImageView imageView, String str, Typeface typeface, TextView textView2) {
        textView.setText(str);
        imageView.setImageDrawable(getDrawable(R.drawable.ic_send_blue));
        textView2.setVisibility(8);
        textView.setTypeface(typeface);
        linearLayout.setVisibility(0);
        linearLayout.setOnClickListener(this);
    }

    private void showMessageOverlay(String str, String str2) {
        Typeface h;
        try {
            if (Settings.canDrawOverlays(this.context)) {
                int i = Build.VERSION.SDK_INT >= 26 ? 2038 : 2002;
                this.windowManager = (WindowManager) this.context.getSystemService("window");
                if (this.overlayView == null) {
                    this.overlayView = LayoutInflater.from(this.context).inflate(R.layout.message_sheet, (ViewGroup) null);
                }
                WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-1, -1, i, 8, -3);
                if (str != null && str2 != null && this.windowManager != null) {
                    DisplayMetrics displayMetrics = new DisplayMetrics();
                    this.windowManager.getDefaultDisplay().getMetrics(displayMetrics);
                    int i2 = displayMetrics.widthPixels;
                    this.messageSheetHeader = (LinearLayout) this.overlayView.findViewById(R.id.message_sheet_header);
                    this.messageTextView = (TextView) this.overlayView.findViewById(R.id.messageView);
                    this.TimestampView = (TextView) this.overlayView.findViewById(R.id.messageTimeView);
                    this.suggestion1View = this.overlayView.findViewById(R.id.suggestion1);
                    this.suggestion2View = this.overlayView.findViewById(R.id.suggestion2);
                    this.suggestion3View = this.overlayView.findViewById(R.id.suggestion3);
                    this.headerTextView = (TextView) this.overlayView.findViewById(R.id.HeaderTextView);
                    this.messageTextView.setText(str);
                    this.TimestampView.setText(str2);
                    this.headerTextView.setText(R.string.message_from_customer);
                    View view = this.overlayView;
                    if (view != null && !view.isAttachedToWindow()) {
                        this.windowManager.addView(this.overlayView, layoutParams);
                    }
                    this.messageTextView.setMaxWidth((int) (i2 * 0.7d));
                    this.overlayView.setVisibility(0);
                }
                LinearLayout linearLayout = this.messageSheetHeader;
                if (linearLayout != null) {
                    linearLayout.setOnClickListener(this);
                }
                this.suggestions = getDefaultSuggestions();
                Context context = this.context;
                String string = context.getSharedPreferences(context.getString(R.string.preference_file_key), 0).getString("LANGUAGE_KEY", "null");
                if (string.equals("KN_IN")) {
                    h = Typeface.createFromAsset(this.context.getAssets(), "fonts/NotoSansKannada-SemiBold.ttf");
                    this.headerTextView.setTypeface(h);
                } else {
                    h = androidx.core.content.res.h.h(this.context, R.font.plus_jakartasans_semibold);
                }
                Suggestions suggestions = this.suggestions;
                if (suggestions != null) {
                    String suggestionFromKey = getSuggestionFromKey(suggestions.s1, string);
                    String suggestionFromKey2 = getSuggestionFromKey(this.suggestions.s2, string);
                    String suggestionFromKey3 = getSuggestionFromKey(this.suggestions.s3, string);
                    if (suggestionFromKey.equals("")) {
                        suggestionFromKey = getFallBackSuggestion(this.suggestions.s1, string);
                    }
                    if (suggestionFromKey2.equals("")) {
                        suggestionFromKey2 = getFallBackSuggestion(this.suggestions.s2, string);
                    }
                    if (suggestionFromKey3.equals("")) {
                        suggestionFromKey3 = getFallBackSuggestion(this.suggestions.s3, string);
                    }
                    if (this.suggestion1View != null && !suggestionFromKey.equals("")) {
                        this.suggestion1View.setText(suggestionFromKey);
                        this.suggestion1View.setTypeface(h);
                        this.suggestion1View.setVisibility(0);
                        this.suggestion1View.setOnClickListener(this);
                    }
                    if (this.suggestion2View != null && !suggestionFromKey2.equals("")) {
                        this.suggestion2View.setText(suggestionFromKey2);
                        this.suggestion2View.setTypeface(h);
                        this.suggestion2View.setVisibility(0);
                        this.suggestion2View.setOnClickListener(this);
                    }
                    if (this.suggestion3View == null || suggestionFromKey3.equals("")) {
                        return;
                    }
                    this.suggestion3View.setText(suggestionFromKey3);
                    this.suggestion3View.setTypeface(h);
                    this.suggestion3View.setVisibility(0);
                    this.suggestion3View.setOnClickListener(this);
                }
            }
        } catch (Exception e) {
            android.util.Log.e(this.LOG_TAG, "Error in showMessageOverlay " + e);
        }
    }

    private void showStopDetectedOverlay(String str) {
        Typeface h;
        try {
            if (Settings.canDrawOverlays(this.context)) {
                int i = Build.VERSION.SDK_INT >= 26 ? 2038 : 2002;
                this.windowManager = (WindowManager) this.context.getSystemService("window");
                if (this.stopDetectedOverlayView == null) {
                    this.stopDetectedOverlayView = LayoutInflater.from(this.context).inflate(R.layout.stop_detected_message_sheet, (ViewGroup) null);
                }
                WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-1, -1, i, 8, -3);
                if (str != null && this.windowManager != null) {
                    this.windowManager.getDefaultDisplay().getMetrics(new DisplayMetrics());
                    this.messageSheetHeader = (LinearLayout) this.stopDetectedOverlayView.findViewById(R.id.stop_detected_message_sheet_header);
                    this.stopDetectedSuggestion1View = (LinearLayout) this.stopDetectedOverlayView.findViewById(R.id.suggestion1);
                    this.stopDetectedSuggestion2View = (LinearLayout) this.stopDetectedOverlayView.findViewById(R.id.suggestion2);
                    this.stopDetectedSuggestion3View = (LinearLayout) this.stopDetectedOverlayView.findViewById(R.id.suggestion3);
                    this.stopSuggestion1TextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.suggestion1_text);
                    this.stopSuggestion2TextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.suggestion2_text);
                    this.stopSuggestion3TextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.suggestion3_text);
                    this.stopSuggestion1ImageView = (ImageView) this.stopDetectedOverlayView.findViewById(R.id.suggestion1_image);
                    this.stopSuggestion2ImageView = (ImageView) this.stopDetectedOverlayView.findViewById(R.id.suggestion2_image);
                    this.stopSuggestion3ImageView = (ImageView) this.stopDetectedOverlayView.findViewById(R.id.suggestion3_image);
                    this.quickChatsTextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.quick_chats);
                    this.headerTextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.HeaderTextView);
                    this.bodyTextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.BodyTextView);
                    this.gotItButtonView = this.stopDetectedOverlayView.findViewById(R.id.got_it_button);
                    this.suggestion1SentTextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.suggestion1_sent_text);
                    this.suggestion2SentTextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.suggestion2_sent_text);
                    this.suggestion3SentTextView = (TextView) this.stopDetectedOverlayView.findViewById(R.id.suggestion3_sent_text);
                    ImageView imageView = (ImageView) this.stopDetectedOverlayView.findViewById(R.id.header_suffix_image);
                    this.headerSuffixImage = imageView;
                    if (imageView != null) {
                        imageView.setOnClickListener(this);
                    }
                    this.headerTextView.setText(R.string.customer_is_waiting);
                    this.bodyTextView.setText(R.string.please_start_moving_towards_the_pickup_location);
                    MaterialButton materialButton = this.gotItButtonView;
                    if (materialButton != null) {
                        materialButton.setVisibility(8);
                    }
                    View view = this.stopDetectedOverlayView;
                    if (view != null && !view.isAttachedToWindow()) {
                        this.windowManager.addView(this.stopDetectedOverlayView, layoutParams);
                    }
                    TextView textView = this.quickChatsTextView;
                    if (textView != null) {
                        textView.setText(R.string.quick_chats);
                    }
                    this.stopDetectedOverlayView.setVisibility(0);
                }
                Suggestions defaultSuggestions = getDefaultSuggestions();
                this.suggestions = defaultSuggestions;
                if (defaultSuggestions == null) {
                    this.suggestions = new Suggestions("driverStopDetectedOverlay1BP", "driverStopDetectedOverlay2BP", "driverStopDetectedOverlay3BP");
                }
                Context context = this.context;
                String string = context.getSharedPreferences(context.getString(R.string.preference_file_key), 0).getString("LANGUAGE_KEY", "null");
                if (string.equals("KN_IN")) {
                    h = Typeface.createFromAsset(this.context.getAssets(), "fonts/NotoSansKannada-SemiBold.ttf");
                    this.headerTextView.setTypeface(h);
                } else {
                    h = androidx.core.content.res.h.h(this.context, R.font.plus_jakartasans_semibold);
                }
                Suggestions suggestions = this.suggestions;
                if (suggestions != null) {
                    String suggestionFromKey = getSuggestionFromKey(suggestions.s1, string);
                    String suggestionFromKey2 = getSuggestionFromKey(this.suggestions.s2, string);
                    String suggestionFromKey3 = getSuggestionFromKey(this.suggestions.s3, string);
                    if (suggestionFromKey.equals("")) {
                        suggestionFromKey = getFallBackSuggestion(this.suggestions.s1, string);
                    }
                    String str2 = suggestionFromKey;
                    String fallBackSuggestion = suggestionFromKey2.equals("") ? getFallBackSuggestion(this.suggestions.s2, string) : suggestionFromKey2;
                    String fallBackSuggestion2 = suggestionFromKey3.equals("") ? getFallBackSuggestion(this.suggestions.s3, string) : suggestionFromKey3;
                    if (this.stopDetectedSuggestion1View != null && this.stopSuggestion1TextView != null && this.stopSuggestion1ImageView != null && this.suggestion1SentTextView != null && !str2.equals("")) {
                        setStopSuggestionImageAndText(this.stopDetectedSuggestion1View, this.stopSuggestion1TextView, this.stopSuggestion1ImageView, str2, h, this.suggestion1SentTextView);
                        setImageDimensions(this.stopSuggestion1ImageView, 64, 64);
                    }
                    if (this.stopDetectedSuggestion2View != null && this.stopSuggestion2TextView != null && this.stopSuggestion2ImageView != null && this.suggestion2SentTextView != null && !fallBackSuggestion.equals("")) {
                        setStopSuggestionImageAndText(this.stopDetectedSuggestion2View, this.stopSuggestion2TextView, this.stopSuggestion2ImageView, fallBackSuggestion, h, this.suggestion2SentTextView);
                        setImageDimensions(this.stopSuggestion2ImageView, 64, 64);
                    }
                    if (this.stopDetectedSuggestion3View == null || this.stopSuggestion3TextView == null || this.stopSuggestion3ImageView == null || this.suggestion3SentTextView == null || fallBackSuggestion2.equals("")) {
                        return;
                    }
                    setStopSuggestionImageAndText(this.stopDetectedSuggestion3View, this.stopSuggestion3TextView, this.stopSuggestion3ImageView, fallBackSuggestion2, h, this.suggestion3SentTextView);
                    setImageDimensions(this.stopSuggestion3ImageView, 64, 64);
                }
            }
        } catch (Exception e) {
            android.util.Log.e(this.LOG_TAG, "Error in showMessageOverlay " + e);
        }
    }

    private void startMainActivity() {
        Context context = this.context;
        SharedPreferences sharedPreferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), 0);
        if (sharedPreferences.getString(this.context.getResources().getString(R.string.REGISTERATION_TOKEN), "null").equals("null")) {
            return;
        }
        if (sharedPreferences.getString(this.context.getResources().getString(R.string.ACTIVITY_STATUS), "null").equals("onPause") || sharedPreferences.getString(this.context.getResources().getString(R.string.ACTIVITY_STATUS), "null").equals("onDestroy")) {
            Intent launchIntentForPackage = this.context.getPackageManager().getLaunchIntentForPackage(this.context.getPackageName());
            launchIntentForPackage.addFlags(268566528);
            try {
                this.context.startActivity(launchIntentForPackage);
            } catch (Exception e) {
                android.util.Log.e(this.LOG_TAG, "failed to start MainActivity" + e);
            }
        }
    }

    public Suggestions getDefaultSuggestions() {
        try {
            Context context = this.context;
            SharedPreferences sharedPreferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), 0);
            String string = sharedPreferences.getString("SUGGESTIONS", "null");
            String string2 = sharedPreferences.getString("IS_DRIVER_AT_PICKUP", "null");
            new JSONArray();
            JSONArray jSONArray = this.stopDetectedOverlay ? new JSONObject(string).getJSONArray("driverStopDetectedOverlayDefault") : string2.equals("true") ? new JSONObject(string).getJSONArray("driverOverlayDefaultAP") : new JSONObject(string).getJSONArray("driverOverlayDefaultBP");
            return new Suggestions(jSONArray.getString(0), jSONArray.getString(1), jSONArray.getString(2));
        } catch (Exception e) {
            android.util.Log.e("MessageOverlay", "Error in getDefaultSuggestions " + e);
            return getFallBackSuggestions(this.context);
        }
    }

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

    @Override
    public void onClick(View view) {
        int id2 = view.getId();
        if (id2 == R.id.message_sheet_header) {
            startMainActivity();
        } else if (id2 == R.id.suggestion1) {
            if (this.suggestions != null) {
                Iterator<SendMessageCallBack> it = sendMessageCallBacks.iterator();
                while (it.hasNext()) {
                    sendMessage(it.next(), this.suggestions.s1);
                }
            }
        } else if (id2 == R.id.suggestion2) {
            if (this.suggestions != null) {
                Iterator<SendMessageCallBack> it2 = sendMessageCallBacks.iterator();
                while (it2.hasNext()) {
                    sendMessage(it2.next(), this.suggestions.s2);
                }
            }
        } else if (id2 == R.id.suggestion3) {
            if (this.suggestions != null) {
                Iterator<SendMessageCallBack> it3 = sendMessageCallBacks.iterator();
                while (it3.hasNext()) {
                    sendMessage(it3.next(), this.suggestions.s3);
                }
            }
        } else if (id2 == R.id.header_suffix_image) {
            this.stopDetectedOverlayView.setVisibility(8);
        }
        if (this.stopDetectedOverlay) {
            this.stopDetectedOverlay = false;
            sendMessageViewForStopsOverlay(id2);
            return;
        }
        View view2 = this.overlayView;
        if (view2 != null) {
            view2.setVisibility(8);
        }
        View view3 = this.stopDetectedOverlayView;
        if (view3 != null) {
            view3.setVisibility(8);
        }
    }

    @Override
    public void onCreate() {
        this.context = getApplicationContext();
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        View view = this.overlayView;
        if (view != null) {
            view.setVisibility(8);
        }
        View view2 = this.stopDetectedOverlayView;
        if (view2 != null) {
            view2.setVisibility(8);
        }
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int i, int i2) {
        try {
            String stringExtra = intent.getStringExtra("message");
            String stringExtra2 = intent.getStringExtra(PaymentConstants.TIMESTAMP);
            boolean booleanExtra = intent.getBooleanExtra("isStopDetected", false);
            this.stopDetectedOverlay = booleanExtra;
            if (booleanExtra) {
                showStopDetectedOverlay(stringExtra2);
            } else {
                showMessageOverlay(stringExtra, stringExtra2);
            }
        } catch (Exception e) {
            android.util.Log.e("MessageOverlayService", "Error in onStartCommand : " + e);
        }
        return super.onStartCommand(intent, i, i2);
    }
}