TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c

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


package com.tencent.biz.anonymous;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.text.TextUtils;
import com.tencent.biz.webviewplugin.ReportPlugin;
import com.tencent.mobileqq.activity.qwallet.PasswdRedBagDBHelper;
import com.tencent.mobileqq.app.QQAppInterface;
import com.tencent.mobileqq.data.MessageRecord;
import com.tencent.qphone.base.util.QLog;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;
public class AnonymousChatHelper {
    public static AnonymousChatHelper f3444a = null;
    public static final String f3445a = "http://pub.idqqimg.com/pc/group/anony/portrait/img/";
    public static final String f3446b = "http://qqweb.qq.com/m/business/anonymoustalk/index.html?_wv=5123&_bid=227";
    public static final String f3447c = "anonymous";
    public AnonymousReport f3448a;
    public AnonymousStatusListener f3449a;
    public HashMap f3450a = new HashMap();
    public boolean f3451a;
    public static final int f82237a = Color.rgb(64, 64, 65);
    public static final int f82238b = Color.rgb(166, 166, 166);
    public static final int f82239c = Color.argb(255, 255, 255, 255);
    public static final int d = Color.argb(154, 255, 255, 255);
    public static final int e = Color.rgb(19, 19, 19);

    public interface AnonymousStatusListener {
        void a(String str, String str2);
    }

    public static AnonymousChatHelper a() {
        if (f3444a == null) {
            f3444a = new AnonymousChatHelper();
        }
        return f3444a;
    }

    public void a(boolean z, String str) {
        if (this.f3450a.containsKey(str)) {
            ((AnonymousInfo) this.f3450a.get(str)).f3457a = z;
        } else {
            this.f3450a.put(str, new AnonymousInfo(z));
        }
    }

    public boolean m897a(String str) {
        if (this.f3450a.containsKey(str)) {
            return ((AnonymousInfo) this.f3450a.get(str)).f3457a;
        }
        return false;
    }

    public AnonymousInfo a(String str) {
        return (AnonymousInfo) this.f3450a.get(str);
    }

    public void a(String str, long j, int i, String str2, int i2, String str3) {
        if (!TextUtils.isEmpty(str)) {
            if (QLog.isColorLevel()) {
                QLog.d("AnonymousUpdate", 2, "nickName=" + str2 + ", vipBubbleId=" + j + ", headId=" + i);
            }
            if (this.f3450a.containsKey(str)) {
                AnonymousInfo anonymousInfo = (AnonymousInfo) this.f3450a.get(str);
                anonymousInfo.f82243a = i;
                if (str2 != null && !str2.equals(anonymousInfo.f3456a) && this.f3449a != null) {
                    this.f3449a.a(str, str2);
                }
                anonymousInfo.f3456a = str2;
                anonymousInfo.f3454a = j;
                anonymousInfo.f82244b = i2;
                anonymousInfo.f3458b = str3;
                this.f3450a.put(str, anonymousInfo);
                return;
            }
            AnonymousInfo anonymousInfo2 = new AnonymousInfo(false);
            anonymousInfo2.f82243a = i;
            anonymousInfo2.f3456a = str2;
            anonymousInfo2.f3454a = j;
            anonymousInfo2.f82244b = i2;
            anonymousInfo2.f3458b = str3;
            this.f3450a.put(str, anonymousInfo2);
        }
    }

    public void m895a() {
        this.f3450a.clear();
    }

    public void m896a(MessageRecord messageRecord) {
        if (this.f3451a) {
            if (messageRecord.longMsgCount == messageRecord.longMsgIndex + 1 || messageRecord.longMsgCount == 0) {
                this.f3451a = false;
            }
        } else if (m897a(messageRecord.frienduin)) {
            AnonymousInfo a2 = a(messageRecord.frienduin);
            messageRecord.vipBubbleID = a2.f3454a;
            messageRecord.extLong |= 3;
            messageRecord.saveExtInfoToExtStr("anonymous", a(2, a2.f3458b, a2.f3456a, a2.f82243a, a2.f82244b));
        }
    }

    public class AnonymousInfo {
        public int f82243a;
        public long f3454a;
        public String f3456a;
        public boolean f3457a;
        public int f82244b;
        public String f3458b;

        public AnonymousInfo(boolean z) {
            this.f3457a = z;
        }
    }

    public void a(AnonymousStatusListener anonymousStatusListener) {
        this.f3449a = anonymousStatusListener;
    }

    public void b() {
        this.f3449a = null;
    }

    public class AnonymousReport {
        public String f3459a;
        public String f82246b;
        public String f82247c;

        public AnonymousReport() {
        }
    }

    public void a(String str, String str2, MessageRecord messageRecord) {
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2) && messageRecord != null) {
            String a2 = ReportPlugin.a(messageRecord);
            if (!TextUtils.isEmpty(a2)) {
                if (this.f3448a == null) {
                    this.f3448a = new AnonymousReport();
                }
                this.f3448a.f3459a = str;
                this.f3448a.f82246b = str2;
                this.f3448a.f82247c = a2;
            }
        }
    }

    public String a(String str, String str2) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || this.f3448a == null) {
            return null;
        }
        return this.f3448a.f82247c;
    }

    public static String a(int i) {
        return f3445a + i + ".png";
    }

    public static boolean a(Context context, QQAppInterface qQAppInterface) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("anonymous_chat", 0);
        if (sharedPreferences.getBoolean("first_enter_anonymous" + qQAppInterface.getCurrentAccountUin(), true)) {
            sharedPreferences.edit().putBoolean("first_enter_anonymous" + qQAppInterface.getCurrentAccountUin(), false).commit();
            return true;
        }
        return false;
    }

    public static boolean m894a(MessageRecord messageRecord) {
        return (messageRecord.extLong & 3) == 3;
    }

    public static boolean b(MessageRecord messageRecord) {
        return a(messageRecord).f82240a == 2;
    }

    public static String a(int i, String str, String str2, int i2, int i3) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("flags", i);
            jSONObject.put("an_id", str);
            jSONObject.put("an_nick", str2);
            jSONObject.put("head_protrait", i2);
            jSONObject.put(PasswdRedBagDBHelper.f, i3);
            return jSONObject.toString();
        } catch (JSONException e2) {
            if (QLog.isColorLevel()) {
                QLog.d("AnonymousChatHelper", 2, "getJsonStr JSONException:" + e2.toString());
            }
            e2.printStackTrace();
            return "";
        }
    }

    public static AnonymousExtInfo a(MessageRecord messageRecord) {
        String extInfoFromExtStr = messageRecord.getExtInfoFromExtStr("anonymous");
        AnonymousExtInfo anonymousExtInfo = new AnonymousExtInfo();
        try {
            JSONObject jSONObject = new JSONObject(extInfoFromExtStr);
            if (jSONObject.has("flags")) {
                anonymousExtInfo.f82240a = jSONObject.getInt("flags");
            }
            if (jSONObject.has("an_id")) {
                anonymousExtInfo.f3452a = jSONObject.getString("an_id");
            }
            if (jSONObject.has("an_nick")) {
                anonymousExtInfo.f3453b = jSONObject.getString("an_nick");
            }
            if (jSONObject.has("head_protrait")) {
                anonymousExtInfo.f82241b = jSONObject.getInt("head_protrait");
            }
            if (jSONObject.has(PasswdRedBagDBHelper.f)) {
                anonymousExtInfo.f82242c = jSONObject.getInt(PasswdRedBagDBHelper.f);
            }
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        return anonymousExtInfo;
    }

    public class AnonymousExtInfo {
        public int f82240a;
        public String f3452a;
        public int f82241b;
        public String f3453b;
        public int f82242c;

        public byte[] a() {
            if (TextUtils.isEmpty(this.f3452a)) {
                return null;
            }
            try {
                return this.f3452a.getBytes("ISO-8859-1");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                if (QLog.isColorLevel()) {
                    QLog.d("AnonymousChatHelper", 2, "getByteAnId UnsupportedEncodingException");
                    return null;
                }
                return null;
            }
        }
    }
}