酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319

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


package com.kugou.android.app.flexowebview;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.View;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.kugou.android.common.delegate.DelegateFragment;
import com.kugou.android.lite.R;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.player.manager.Initiator;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.utils.bv;
import com.kugou.common.utils.bz;
import com.kugou.framework.share.common.ShareUtils;
import com.kugou.svplayer.worklog.WorkLog;
import com.tencent.open.SocialConstants;
import java.net.URI;
import java.net.URISyntaxException;
import org.json.JSONException;
import org.json.JSONObject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class KugouWebUtils {
    public static void openWebFragment(String str, String str2) {
        openWebFragment(str, str2, true);
    }

    public static void a(DelegateFragment delegateFragment, String str, String str2) {
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_playing_bar", true);
        delegateFragment.startFragment(KGFelxoWebFragment.class, bundle);
    }

    public static void openWebFragment(String str, String str2, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_playing_bar", z);
        openWebFragment(bundle);
    }

    public static void openWebFragment(String str, String str2, boolean z, int i) {
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_playing_bar", z);
        bundle.putInt("extra_from", i);
        openWebFragment(bundle);
    }

    public static void openWebFragment(String str, String str2, Boolean bool, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_playing_bar", bool.booleanValue());
        bundle.putBoolean("is_proxy", z);
        openWebFragment(bundle);
    }

    public static void openWebFragment(String str, String str2, String str3) {
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putString(DelegateFragment.KEY_IDENTIFIER, str3);
        openWebFragment(bundle);
    }

    public static void openWebFragment(Bundle bundle) {
        com.kugou.common.base.g.a((Class<? extends Fragment>) KGFelxoWebFragment.class, bundle);
    }

    public static void startWebActivity(Context context, String str, String str2) {
        startWebActivity(context, str, str2, false);
    }

    public static void startWebActivity(Context context, Bundle bundle) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        context.startActivity(intent);
    }

    public static void startWebActivity(Context context, String str, String str2, boolean z) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("sendDestoryMsg", z);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startWebActivity(Context context, String str, String str2, Boolean bool) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("can_back_web", bool.booleanValue());
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void a(Context context, String str, String str2) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        bundle.putBoolean("from_colleager_indentify", true);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startWebActivity(Context context, String str, String str2, Boolean bool, boolean z) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("can_back_web", bool.booleanValue());
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        bundle.putBoolean("is_proxy", z);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startWebActivityCanNoSwipe(Context context, String str, String str2, boolean z, boolean z2, boolean z3) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("can_back_web", z);
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        bundle.putBoolean("is_proxy", z2);
        bundle.putBoolean("canSwipe", z3);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startAccountWebActivity(Context context, String str, String str2, boolean z) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebForAccountActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        bundle.putBoolean("extra_login_suc_can_jump_h5", z);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void openMobileHasBindedAccountHelp(Context context) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebForAccountActivity.class);
        Bundle bundle = new Bundle();
        String b2 = com.kugou.common.config.c.a().b(com.kugou.common.config.a.tX);
        if (TextUtils.isEmpty(b2)) {
            b2 = "http://m.kugou.com/webapp/account/static/help_binding_4.html";
        }
        bundle.putString("web_title", context.getString(R.string.a69));
        bundle.putString("web_url", b2);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startWebActivity(Context context, String str, String str2, String str3, boolean z) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("is_proxy", z);
        if (!TextUtils.isEmpty(str3)) {
            bundle.putString(SocialConstants.PARAM_SOURCE, str3);
        }
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startWebActivity(Context context, String str, String str2, String str3) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        if (!TextUtils.isEmpty(str3)) {
            bundle.putString(SocialConstants.PARAM_SOURCE, str3);
        }
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startWebActivity(Context context, String str, boolean z) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_url", str);
        bundle.putBoolean("extra_full_page", z);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startAppealWebActivity(Context context, String str, String str2) {
        Intent intent = new Intent(context, (Class<?>) KGFlexoWebNoSwipeActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", str);
        bundle.putString("web_url", str2);
        bundle.putBoolean("felxo_fragment_has_menu", false);
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        bundle.putBoolean("extra_from_account_appeal", true);
        bundle.putBoolean("canSwipe", false);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static boolean startRemoveBindingActivity(Activity activity) {
        if (!br.Q(activity)) {
            bv.b(activity, R.string.aat);
            return false;
        }
        if (!com.kugou.common.environment.a.o()) {
            br.T(activity);
            return false;
        }
        Intent intent = new Intent(activity, (Class<?>) KGFlexoWebNoSwipeActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("web_title", "解除手机绑定申诉");
        String b2 = com.kugou.common.config.c.a().b(com.kugou.android.app.a.a.pW);
        if (TextUtils.isEmpty(b2)) {
            b2 = "http://m.kugou.com/webapp/removeBinding/static/index.html";
        }
        bundle.putString("web_url", b2);
        bundle.putBoolean("felxo_fragment_has_menu", false);
        bundle.putBoolean("felxo_fragment_has_title_menu", false);
        bundle.putBoolean("extra_from_account_appeal", true);
        bundle.putBoolean("canSwipe", false);
        intent.putExtras(bundle);
        activity.startActivity(intent);
        return true;
    }

    public static boolean isHttpOrHttpsScheme(String str) {
        String scheme;
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        try {
            String[] split = str.split("[?]");
            if (split != null && split.length > 0) {
                str = split[0];
            }
            scheme = new URI(str).getScheme();
        } catch (URISyntaxException e2) {
            as.e(e2);
        }
        if (TextUtils.isEmpty(scheme)) {
            return false;
        }
        if (as.f54365e) {
            StringBuilder sb = new StringBuilder();
            sb.append("scheme = ");
            sb.append(TextUtils.isEmpty(scheme) ? "" : scheme);
            as.b("BLUE", sb.toString());
        }
        if ("http".equalsIgnoreCase(scheme)) {
            return true;
        }
        return "https".equalsIgnoreCase(scheme);
    }

    @SuppressLint({"NewApi"})
    public static String getPath(Context context, Uri uri) {
        Uri uri2 = null;
        if ((Build.VERSION.SDK_INT >= 19) && DocumentsContract.isDocumentUri(context, uri)) {
            if (isExternalStorageDocument(uri)) {
                String[] split = DocumentsContract.getDocumentId(uri).split(WorkLog.SEPARATOR_KEY_VALUE);
                if ("primary".equalsIgnoreCase(split[0])) {
                    return Environment.getExternalStorageDirectory() + "/" + split[1];
                }
            } else {
                if (isDownloadsDocument(uri)) {
                    return getDataColumn(context, ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(DocumentsContract.getDocumentId(uri)).longValue()), null, null);
                }
                if (isMediaDocument(uri)) {
                    String[] split2 = DocumentsContract.getDocumentId(uri).split(WorkLog.SEPARATOR_KEY_VALUE);
                    String str = split2[0];
                    if ("image".equals(str)) {
                        uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                    } else if ("video".equals(str)) {
                        uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
                    } else if ("audio".equals(str)) {
                        uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
                    }
                    return getDataColumn(context, uri2, "_id=?", new String[]{split2[1]});
                }
            }
        } else {
            if (RemoteMessageConst.Notification.CONTENT.equalsIgnoreCase(uri.getScheme())) {
                return getDataColumn(context, uri, null, null);
            }
            if ("file".equalsIgnoreCase(uri.getScheme())) {
                return uri.getPath();
            }
        }
        return null;
    }

    public static String getDataColumn(Context context, Uri uri, String str, String[] strArr) {
        Cursor cursor;
        try {
            cursor = context.getContentResolver().query(uri, new String[]{"_data"}, str, strArr, null);
            if (cursor != null) {
                try {
                    try {
                        if (cursor.moveToFirst()) {
                            String string = cursor.getString(cursor.getColumnIndexOrThrow("_data"));
                            cursor.close();
                            return string;
                        }
                    } catch (Exception e2) {
                        e = e2;
                        as.e(e);
                    }
                } catch (Throwable th) {
                    th = th;
                    if (cursor != null) {
                        cursor.close();
                    }
                    throw th;
                }
            }
        } catch (Exception e3) {
            e = e3;
            cursor = null;
        } catch (Throwable th2) {
            th = th2;
            cursor = null;
            if (cursor != null) {
            }
            throw th;
        }
    }

    public static boolean isExternalStorageDocument(Uri uri) {
        return "com.android.externalstorage.documents".equals(uri.getAuthority());
    }

    public static boolean isDownloadsDocument(Uri uri) {
        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
    }

    public static boolean isMediaDocument(Uri uri) {
        return "com.android.providers.media.documents".equals(uri.getAuthority());
    }

    public static void a(final String str, final com.kugou.common.web.d dVar, final boolean z) {
        try {
            final String string = new JSONObject(str).getString("AndroidCallback");
            if (!br.Q(KGCommonApplication.getContext())) {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("status", 0);
                jSONObject.put("errno", 0);
                jSONObject.put("errMsg", "无网络");
                jSONObject.put("data", "");
                dVar.loadUrl("javascript:" + string + "(" + bz.a(jSONObject.toString()) + ")");
            } else {
                rx.e.a("").b(Schedulers.io()).d(new rx.b.e<String, String>() {
                    @Override
                    public String call(String str2) {
                        return new mobileCallProtocol().a(str, z);
                    }
                }).a(AndroidSchedulers.mainThread()).b(new rx.b.b<String>() {
                    @Override
                    public void call(String str2) {
                        String a2 = bz.a(str2);
                        com.kugou.common.web.d.this.loadUrl("javascript:" + string + "(" + a2 + ")");
                    }
                });
            }
        } catch (JSONException e2) {
            as.e(e2);
        }
    }

    public static void b(final String str, final com.kugou.common.web.d dVar, final boolean z) {
        try {
            final String string = new JSONObject(str).getString("AndroidCallback");
            if (!br.Q(KGCommonApplication.getContext())) {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("status", 0);
                jSONObject.put("errno", 0);
                jSONObject.put("errMsg", "无网络");
                jSONObject.put("data", "");
                String str2 = "javascript:" + string + "('" + bz.a(bz.a(jSONObject.toString())) + "','" + bz.a("#") + "')";
                dVar.loadUrl(str2);
                if (as.f54365e) {
                    as.f("JSBridge", "ackerror=" + str2);
                }
            } else {
                rx.e.a("").b(Schedulers.io()).d(new rx.b.e<String, String>() {
                    @Override
                    public String call(String str3) {
                        return new mobileCallProtocol().a(str, z);
                    }
                }).a(AndroidSchedulers.mainThread()).b(new rx.b.b<String>() {
                    @Override
                    public void call(String str3) {
                        String a2 = bz.a("#");
                        String str4 = "javascript:" + string + "('" + bz.a(bz.a(str3)) + "','" + a2 + "')";
                        dVar.loadUrl(str4);
                        if (as.f54365e) {
                            as.f("JSBridge", "ackresult=" + str4);
                        }
                    }
                });
            }
        } catch (JSONException e2) {
            as.e(e2);
        }
    }

    public static boolean a(DelegateFragment delegateFragment, String str) {
        if (!str.startsWith("tel:")) {
            return false;
        }
        delegateFragment.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
        return true;
    }

    public static void shareFromWeb(Activity activity, com.kugou.common.web.b bVar, Context context, Initiator initiator, String str, String str2, com.kugou.common.event.d dVar, View view, com.kugou.common.event.m mVar) {
        ShareUtils.a(activity, bVar, context, initiator, str, str2, dVar, view, mVar);
    }
}