导航菜单

页面标题

页面副标题

Mint v5.7.3 - MyFirebaseMessagingService.java 源代码

正在查看: Mint v5.7.3 应用的 MyFirebaseMessagingService.java JAVA 源代码文件

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


package com.htmedia.mint.notification;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.TextUtils;
import android.widget.RemoteViews;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import com.appsflyer.AppsFlyerLib;
import com.bumptech.glide.Glide;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.google.firebase.perf.FirebasePerformance;
import com.htmedia.mint.AppController;
import com.htmedia.mint.R;
import com.htmedia.mint.ui.activity.SplashActivity;
import com.htmedia.mint.ui.activity.WebViewActivityWithHeader;
import com.htmedia.mint.utils.f0;
import com.htmedia.mint.utils.h0;
import com.htmedia.mint.utils.o0;
import com.htmedia.mint.utils.o1;
import com.htmedia.mint.utils.q;
import f6.h;
import f6.i;
import f6.l;
import io.piano.android.cxense.model.PerformanceEvent;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.json.JSONObject;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    class a extends r0.c<Bitmap> {
        final Map a;

        a(Map map) {
            this.a = map;
        }

        public void onLoadCleared(@Nullable Drawable drawable) {
        }

        public void onLoadFailed(@Nullable Drawable drawable) {
        }

        public void onResourceReady(@NonNull Bitmap bitmap, @Nullable s0.b bVar) {
            MyFirebaseMessagingService.this.l(this.a, bitmap);
        }
    }

    class b implements Runnable {
        final String a;
        final r0.c b;

        b(String str, r0.c cVar) {
            this.a = str;
            this.b = cVar;
        }

        @Override
        public void run() {
            Glide.u(MyFirebaseMessagingService.this).b().w0(this.a).n0(this.b);
        }
    }

    class c implements Runnable {
        final String a;

        c(String str) {
            this.a = str;
        }

        @Override
        public void run() {
            try {
                Thread.sleep(5000L);
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("notificationId", this.a);
                jSONObject.put("applicationId", "57c00a2ccaf48e2831750343");
                f6.c.a(FirebasePerformance.HttpMethod.PUT, "http://push1.hindustantimes.com/notification/receive", jSONObject, l.k(MyFirebaseMessagingService.this, "accessEndPoint"));
            } catch (Exception e) {
                o0.g(e, getClass().getSimpleName());
            }
        }
    }

    private String d(String str) {
        return str.contains("<span class='webrupee'>") ? str.replace("<span", "<font face=\"lato_black\"").replace("</span>", "</font>") : str;
    }

    private Intent e(String str, String str2, String str3) {
        Intent intent = new Intent(this, (Class<?>) SplashActivity.class);
        f0.s(this, intent);
        intent.addFlags(67108864);
        intent.putExtra("urlkey", str2);
        intent.putExtra("keylaunchMode", q.m.e.ordinal());
        if (!TextUtils.isEmpty(str)) {
            intent.putExtra("notification_Id", str);
        }
        return intent;
    }

    private void f(Map<String, String> map) {
        String str = map.get("imageURL");
        if (str == null || str.trim().equalsIgnoreCase("")) {
            l(map, null);
            return;
        }
        if (str.contains(" ")) {
            str = str.replaceAll(" ", "%20");
        }
        try {
            new Handler(Looper.getMainLooper()).post(new b(str, new a(map)));
        } catch (Exception unused) {
        }
    }

    private String h(String str, Map<String, String> map) {
        return map.containsKey(str) ? map.get(str) : "";
    }

    private void j(String str) {
        new Thread(new c(str)).start();
    }

    private void k(String str) {
        new i(new WeakReference(this), str).execute(new Void[0]);
    }

    public void l(Map<String, String> map, Bitmap bitmap) {
        String h = h("alert", map);
        String h2 = h("notification_id", map);
        String h3 = h("target_uri", map);
        String h7 = h("title", map);
        String h8 = h("imageURL", map);
        String h9 = h("message", map);
        String h10 = h(PerformanceEvent.TYPE, map);
        o1.a("MyFirebaseMsgService", "ALERT: " + h);
        o1.a("MyFirebaseMsgService", "NOTIFICATION_ID: " + h2);
        o1.a("MyFirebaseMsgService", "TARGET_URI: " + h3);
        o1.a("MyFirebaseMsgService", "TITLE: " + h7);
        o1.a("MyFirebaseMsgService", "IMAGE URL: " + h8);
        if (l.k(this, "notification_Id").trim().equalsIgnoreCase(h2)) {
            return;
        }
        m(h, h10, h2, h7, h9, h3, bitmap);
    }

    int g() {
        SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        int i = defaultSharedPreferences.getInt("notification_counter", 0) + 1;
        defaultSharedPreferences.edit().putInt("notification_counter", i).commit();
        return i;
    }

    public void i(Map<String, String> map) {
        if (map.containsKey("imageURL")) {
            f(map);
        } else {
            l(map, null);
        }
    }

    public void m(String str, String str2, String str3, String str4, String str5, String str6, Bitmap bitmap) {
        Intent e;
        f0.U2(str6, this, true);
        AppController.j().E();
        l.m(this, "notification_Id", str3);
        j(str3);
        if (!TextUtils.isEmpty(str2) && str2.trim().equalsIgnoreCase("External") && !TextUtils.isEmpty(str6)) {
            e = new Intent("android.intent.action.VIEW");
            e.setData(Uri.parse(str6));
        } else if (TextUtils.isEmpty(str2) || !str2.trim().equalsIgnoreCase("webview") || TextUtils.isEmpty(str6)) {
            e = e(str3, str6, str4);
        } else {
            e = new Intent(this, (Class<?>) WebViewActivityWithHeader.class);
            e.addFlags(67108864);
            e.putExtra("isNotification", q.m.e.ordinal());
            e.putExtra("url", str6);
        }
        PendingIntent e2 = h0.e(this, g(), e);
        String string = getResources().getString(R.string.default_notification_channel_id);
        Uri defaultUri = RingtoneManager.getDefaultUri(2);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, string);
        builder.setSmallIcon(R.drawable.notification_image_mint);
        builder.setColor(getResources().getColor(R.color.orange1));
        String d = d(str);
        builder.setContentText(Html.fromHtml(d));
        builder.setSound(defaultUri);
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.custom_expanded);
        RemoteViews remoteViews2 = new RemoteViews(getPackageName(), R.layout.notification_small);
        remoteViews2.setTextViewText(R.id.notification_title, d);
        remoteViews.setTextViewText(R.id.notificationExpandedTitle, d);
        if (bitmap != null) {
            remoteViews.setImageViewBitmap(2131428732, bitmap);
            remoteViews.setTextViewText(R.id.txtTime, new SimpleDateFormat("hh:mm a").format(new Date(System.currentTimeMillis())));
        } else {
            remoteViews.setViewVisibility(R.id.txtTime, 8);
        }
        builder.setCustomContentView(remoteViews2);
        builder.setCustomBigContentView(remoteViews);
        builder.setContentIntent(e2);
        builder.setAutoCancel(true);
        builder.setDefaults(-1);
        builder.setPriority(1);
        builder.setStyle(new NotificationCompat.DecoratedCustomViewStyle());
        NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
        notificationManager.createNotificationChannel(new NotificationChannel(string, getResources().getString(2131951702), 4));
        try {
            notificationManager.notify(g(), builder.build());
        } catch (Exception e3) {
            e3.printStackTrace();
            o0.g(e3, getClass().getSimpleName());
        }
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        o1.a("MyFirebaseMsgService", "Message From: " + remoteMessage.getFrom());
        Map<String, String> data = remoteMessage.getData();
        if (data != null && data.size() > 0) {
            o1.a("MyFirebaseMsgService", "Message data payload: " + remoteMessage.getData());
            if (!data.containsKey("source") || !"webengage".equals(data.get("source"))) {
                if (kd.b.e().h(remoteMessage.getData())) {
                    new h(this, remoteMessage.getData()).n();
                } else {
                    i(data);
                }
            }
        }
        if (remoteMessage.getNotification() != null) {
            o1.a("MyFirebaseMsgService", "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }
    }

    @Override
    public void onNewToken(String str) {
        super.onNewToken(str);
        o1.a("MyFirebaseMsgService", "onComplete: On New Token " + str);
        AppsFlyerLib.getInstance().updateServerUninstallToken(getApplicationContext(), str);
        ec.a.d().f(getApplicationContext(), str);
        k(str);
    }
}