QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

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


package com.tencent.mtt.file.tencentdocument;

import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.utils.UrlUtils;
import com.tencent.library.BuildConfig;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.account.AccountConst;
import com.tencent.mtt.base.account.AccountInfo;
import com.tencent.mtt.base.account.gateway.viewmodel.QueryBindVm;
import com.tencent.mtt.browser.file.stat.DocEventOnlineExtraBuilder;
import com.tencent.mtt.browser.utils.FileLog;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.external.reader.dex.base.ReaderConfig;
import com.tencent.mtt.file.page.homepage.tab.card.doc.DocUtils;
import com.tencent.mtt.file.page.homepage.tab.card.doc.manager.TxDocInfo;
import com.tencent.mtt.file.page.statistics.FileKeyEvent;
import com.tencent.mtt.file.tencentdocument.stat.ReporterFromCreate;
import com.tencent.mtt.file.tencentdocument.stat.ReporterFromHome;
import com.tencent.mtt.file.tencentdocument.stat.ReporterFromTransform;
import com.tencent.mtt.file.tencentdocument.upload.TDUploader;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.view.toast.MttToaster;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Unit;
import kotlin.jvm.functions.Function2;
import tencent.doc.opensdk.b;
import tencent.doc.opensdk.b.a;
import tencent.doc.opensdk.b.b.c;
import tencent.doc.opensdk.c.e;
import tencent.doc.opensdk.log.LogLevel;
import tencent.doc.opensdk.openapi.f.b.c;

public class TxDocument {

    public static final boolean f64793a = FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_FILETAB_NEW_865996243);

    private static volatile TDLogin f64794b;

    private static volatile TDUploader f64795c;

    private final List<ITxDocChangeListener> f64796d;
    private final List<ITxDocRefreshListener> e;
    private final TransformProgressView f;

    public interface ITxDocChangeListener {
        void a(Integer num, List<TxDocInfo> list);
    }

    public interface ITxDocRefreshListener {
        void t();
    }

    public static class Wrapper {

        private static final TxDocument f64819a = new TxDocument();

        private Wrapper() {
        }
    }

    private TxDocument() {
        this.f64796d = new ArrayList();
        this.e = new ArrayList();
        this.f = new TransformProgressView();
        FileLog.a("TxDocLog", "腾讯文档初始化");
        b.a().b().a(f64793a);
        b.a().a(new a("qqbrowser", "201e35ec06be1f5a0526", AccountConst.QQ_CONNECT_APPID, AccountConst.WX_APPID, "tencent://com.tencent.mtt/TxDocumentAuth", "com.tencent.mtt"), (Application) ContextHolder.getAppContext());
        b.a().a(new tencent.doc.opensdk.log.a() {
            @Override
            public void a(LogLevel logLevel, String str) {
                if (str != null && str.length() > 500) {
                    str = str.substring(0, 500);
                }
                FileLog.a("TxDocLog", str);
            }
        });
        c b2 = tencent.doc.opensdk.oauth.b.a().b();
        if (b2 != null) {
            tencent.doc.opensdk.openapi.a.a().a(b2.d(), b2.g());
        }
        if (a()) {
            String string = ContextHolder.getAppContext().getString(R.string.bou);
            if (!TextUtils.isEmpty(string)) {
                MttToaster.show("腾讯文档测试环境:" + string, 0);
            }
            b.a().a(string);
        }
    }

    public Bundle a(String str, String str2, Bundle bundle) {
        Bundle bundle2 = new Bundle();
        bundle2.putString("prePageUrl", str);
        Bundle bundle3 = new Bundle();
        bundle2.putBundle("prePageExtra", bundle3);
        bundle3.putString("dstUrl", str2);
        bundle3.putBoolean("isDelayLoad", true);
        if (bundle != null) {
            bundle3.putBundle("prePageParams", bundle);
        }
        return bundle2;
    }

    public UrlParams a(String str, String str2, String str3) {
        return new UrlParams(UrlUtils.addParamsToUrl(UrlUtils.addParamsToUrl(str, "callFrom=" + str2), "callerName=" + str3));
    }

    private Runnable a(final String str, final String str2, final String str3, final Bundle bundle) {
        return new Runnable() {
            @Override
            public void run() {
                UrlParams a2 = TxDocument.this.a("qb://filesdk/txdocs", str2, str3);
                Bundle bundle2 = bundle;
                if (bundle2 == null) {
                    bundle2 = new Bundle();
                }
                bundle2.putString("dstUrl", TxDocument.this.a(str));
                a2.a(bundle2);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(a2);
            }
        };
    }

    public String a(String str) {
        try {
            return String.format("https://docs.qq.com/oauth/v2/util/jump?access_token=%s&target=%s", f64793a ? tencent.doc.opensdk.openapi.a.a().b() : TXDocumentAccount.getInstance().a(), URLEncoder.encode(str, "utf-8"));
        } catch (UnsupportedEncodingException unused) {
            return str;
        }
    }

    public void a(String str, final String str2, final String str3, final TransformCallBack transformCallBack) {
        this.f.b();
        tencent.doc.opensdk.openapi.a.a().a(str, "/", new UploadCallBackProxy(new tencent.doc.opensdk.openapi.b.a.a() {
            @Override
            public void a() {
                Logs.c("TxDocument", "文档开始转化: ");
            }

            @Override
            public void a(float f, float f2) {
            }

            @Override
            public void a(String str4) {
                MttToaster.show("文档转化失败", 1);
                Logs.c("TxDocument", "文档转化失败: " + str4);
                TxDocument.this.f.a();
                transformCallBack.b();
            }

            @Override
            public void a(tencent.doc.opensdk.b.c.a.b bVar) {
                Logs.c("TxDocument", "文档转化成功: " + bVar.e());
                TxDocument.this.f.a();
                TxDocument.this.a(bVar, str2, str3);
                transformCallBack.a();
            }
        }));
    }

    static boolean a() {
        return false;
    }

    public static TxDocument b() {
        return Wrapper.f64819a;
    }

    public TxDocInfo a(c.a aVar) {
        TxDocInfo txDocInfo = new TxDocInfo();
        txDocInfo.id = aVar.a();
        txDocInfo.title = aVar.b();
        txDocInfo.type = aVar.c();
        txDocInfo.url = aVar.d();
        txDocInfo.isOwner = true;
        return txDocInfo;
    }

    public void a(Context context) {
        Bundle bundle = new Bundle();
        bundle.putString("title", "消息通知");
        a(context, "https://docs.qq.com/tim/docs/components/Notifications.html", "", "", bundle);
    }

    public void a(Context context, Runnable runnable) {
        TXDocumentAccount.getInstance().a(context, new ReporterFromCreate(), runnable);
    }

    public void a(Context context, final String str, final String str2) {
        TXDocumentAccount.getInstance().a(context, new ReporterFromHome(), new Runnable() {
            @Override
            public void run() {
                UrlParams a2 = TxDocument.this.a("qb://filesdk/txdocs", str, str2);
                Bundle bundle = new Bundle();
                bundle.putString("dstUrl", TxDocument.this.a("https://docs.qq.com/desktop/m/?adtag=qqbrowser_file_android"));
                a2.a(bundle);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(a2);
            }
        });
    }

    public void a(Context context, String str, String str2, String str3) {
        a(context, str, str2, str3, (Bundle) null);
    }

    public void a(Context context, String str, String str2, String str3, Bundle bundle) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        if (!str.contains("adtag=qqbrowser_file_android")) {
            str = UrlUtils.addParamsToUrl(str, "adtag=qqbrowser_file_android");
        }
        FileLog.a("TxDocLog", "open TxDoc Url: " + str);
        TXDocumentAccount.getInstance().a(context, new ReporterFromHome(), a(str, str2, str3, bundle));
    }

    public void a(Context context, e eVar) {
        AccountForTxDoc.a(context, (QueryBindVm) null, eVar);
    }

    public void a(TxDocInfo txDocInfo, Bundle bundle, String str, String str2) {
        ReaderConfig.KVPairs a2 = ReaderConfig.a("qdoc_type", "2");
        a2.a("qdoc_login_status", DocUtils.e());
        DocEventOnlineExtraBuilder docEventOnlineExtraBuilder = new DocEventOnlineExtraBuilder(a2.a());
        docEventOnlineExtraBuilder.c(txDocInfo.title);
        docEventOnlineExtraBuilder.d(txDocInfo.isOwner ? "1" : "2");
        FileKeyEvent fileKeyEvent = new FileKeyEvent("doc_exposed");
        fileKeyEvent.f = DocEventOnlineExtraBuilder.e(txDocInfo.type);
        fileKeyEvent.a(docEventOnlineExtraBuilder.b());
        String addParamsToUrl = UrlUtils.addParamsToUrl(UrlUtils.addParamsToUrl(UrlUtils.addParamsToUrl(UrlUtils.addParamsToUrl(UrlUtils.addParamsToUrl("qb://filesdk/txdocs/start", "dstUrl=" + txDocInfo.url), "callFrom=" + str), "callerName=" + str2), "name=" + txDocInfo.title), "ext=" + txDocInfo.type);
        StringBuilder sb = new StringBuilder();
        sb.append("owner=");
        sb.append(txDocInfo.isOwner ? 1 : 2);
        String addParamsToUrl2 = UrlUtils.addParamsToUrl(UrlUtils.addParamsToUrl(addParamsToUrl, sb.toString()), "id=" + txDocInfo.id);
        if (bundle != null && FeatureToggle.a(qb.file.BuildConfig.FEATURE_TOGGLE_869355601) && bundle.containsKey("switch_from")) {
            addParamsToUrl2 = UrlUtils.addParamsToUrl(addParamsToUrl2, "switch_from=" + bundle.getString("switch_from", ""));
        }
        UrlParams urlParams = new UrlParams(addParamsToUrl2);
        urlParams.j = true;
        ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(urlParams);
    }

    public void a(TxDocInfo txDocInfo, String str, String str2) {
        a(txDocInfo, (Bundle) null, str, str2);
    }

    public void a(ITxDocChangeListener iTxDocChangeListener) {
        if (this.f64796d.contains(iTxDocChangeListener)) {
            return;
        }
        this.f64796d.add(iTxDocChangeListener);
    }

    public void a(ITxDocRefreshListener iTxDocRefreshListener) {
        if (this.e.contains(iTxDocRefreshListener)) {
            return;
        }
        this.e.add(iTxDocRefreshListener);
    }

    public void a(final String str, Context context, final String str2, final String str3, final TransformCallBack transformCallBack) {
        TXDocumentAccount.getInstance().a(context, new ReporterFromTransform(), new Runnable() {
            @Override
            public void run() {
                TxDocument.this.a(str, str2, str3, transformCallBack);
            }
        });
    }

    public void a(List<TxDocInfo> list) {
        Iterator<ITxDocChangeListener> it = this.f64796d.iterator();
        while (it.hasNext()) {
            it.next().a(2, list);
        }
    }

    public void a(tencent.doc.opensdk.b.c.a.b bVar, String str, String str2) {
        if (TextUtils.isEmpty(bVar.d()) || TextUtils.isEmpty(bVar.e())) {
            return;
        }
        UrlParams a2 = a("qb://filesdk/txdocs", str, str2);
        Bundle bundle = new Bundle();
        bundle.putString("dstUrl", a(String.format("https://docs.qq.com/scenario/share.html?id=%s&from=invite", bVar.d())));
        bundle.putBundle("prePageParams", a(a2.f46351a, a(bVar.e()), a(a2.f46351a, a("https://docs.qq.com/desktop/m/?adtag=qqbrowser_file_android"), (Bundle) null)));
        a2.a(bundle);
        ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(a2);
    }

    public void a(c.a aVar, Bundle bundle, String str, String str2) {
        a(a(aVar), bundle, str, str2);
    }

    public void b(Context context) {
        a(context, "https://docs.qq.com/mall/topic/10029?from_page=qqbrowser_file_android", "", "");
    }

    public void b(Context context, final String str, final String str2) {
        TXDocumentAccount.getInstance().a(context, new ReporterFromCreate(), new Runnable() {
            @Override
            public void run() {
                UrlParams a2 = TxDocument.this.a("qb://filesdk/txdocs", str, str2);
                Bundle bundle = new Bundle();
                bundle.putString("title", "新建在线文档");
                bundle.putString("dstUrl", TxDocument.this.a("https://docs.qq.com/desktop/m/templates_list.html?padtype=0&_wv=2&_wwv=512&adtag=qqbrowser_file_android"));
                if (!TxDocument.f64793a) {
                    bundle.putBundle("prePageParams", TxDocument.this.a(a2.f46351a, TxDocument.this.a("https://docs.qq.com/desktop/m/?adtag=qqbrowser_file_android"), (Bundle) null));
                }
                a2.a(bundle);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(a2);
            }
        });
    }

    public void b(final Context context, final e eVar) {
        AccountForTxDoc.a(new Function2<Integer, AccountInfo, Unit>() {
            @Override
            public Unit invoke(Integer num, AccountInfo accountInfo) {
                AccountForTxDoc.a(context, accountInfo, eVar);
                return Unit.INSTANCE;
            }
        });
    }

    public void b(ITxDocChangeListener iTxDocChangeListener) {
        this.f64796d.remove(iTxDocChangeListener);
    }

    public void b(ITxDocRefreshListener iTxDocRefreshListener) {
        this.e.remove(iTxDocRefreshListener);
    }

    public void b(List<TxDocInfo> list) {
        Iterator<ITxDocChangeListener> it = this.f64796d.iterator();
        while (it.hasNext()) {
            it.next().a(3, list);
        }
    }

    public void c() {
        Iterator<ITxDocRefreshListener> it = this.e.iterator();
        while (it.hasNext()) {
            it.next().t();
        }
    }

    public void c(List<TxDocInfo> list) {
        Iterator<ITxDocChangeListener> it = this.f64796d.iterator();
        while (it.hasNext()) {
            it.next().a(1, list);
        }
    }

    public TxDocOpenApi d() {
        return new TxDocOpenApi();
    }

    public TDLogin e() {
        if (f64794b == null) {
            synchronized (TDLogin.class) {
                if (f64794b == null) {
                    f64794b = new TDLogin();
                }
            }
        }
        return f64794b;
    }

    public TDUploader f() {
        if (f64795c == null) {
            synchronized (TDUploader.class) {
                if (f64795c == null) {
                    f64795c = new TDUploader();
                }
            }
        }
        return f64795c;
    }

    public boolean g() {
        boolean z = !tencent.doc.opensdk.openapi.a.a().d();
        FileLog.a("TxDocLog", "TxDocument::isLogin() -- result: " + z);
        return z;
    }

    public void h() {
        FileLog.a("TxDocLog", "TxDocument::logout()");
        TXDocumentAccount.getInstance().d();
    }
}