导航菜单

页面标题

页面副标题

FileWipe Pro v3.0.0 - Intents.java 源代码

正在查看: FileWipe Pro v3.0.0 应用的 Intents.java JAVA 源代码文件

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


package com.tradplus.ads.common.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.tradplus.ads.common.Preconditions;
import com.tradplus.ads.common.TPBrowser;
import com.tradplus.ads.common.UrlAction;
import com.tradplus.ads.exceptions.IntentNotResolvableException;
import com.tradplus.ads.exceptions.UrlParseException;
import com.tradplus.crosspro.manager.CPClickController;
import j0.a;

public class Intents {
    private Intents() {
    }

    @Deprecated
    public static boolean canHandleApplicationUrl(Context context, Uri uri) {
        return false;
    }

    public static boolean deviceCanHandleIntent(Context context, Intent intent) {
        return false;
    }

    public static Uri getPlayStoreUri(Intent intent) {
        Preconditions.checkNotNull(intent);
        return Uri.parse("market://details?id=" + intent.getPackage());
    }

    public static Intent getStartActivityIntent(Context context, Class cls, Bundle bundle) {
        Intent intent = new Intent(context, (Class<?>) cls);
        if (!(context instanceof Activity)) {
            intent.addFlags(268435456);
        }
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        return intent;
    }

    public static Intent intentForNativeBrowserScheme(Uri uri) {
        Preconditions.checkNotNull(uri);
        if (!UrlAction.OPEN_NATIVE_BROWSER.shouldTryHandlingUrl(uri)) {
            throw new UrlParseException("URL does not have tpnativebrowser:// scheme.");
        }
        if (!"navigate".equals(uri.getHost())) {
            throw new UrlParseException("URL missing 'navigate' host parameter.");
        }
        try {
            String queryParameter = uri.getQueryParameter("url");
            if (queryParameter != null) {
                return new Intent("android.intent.action.VIEW", Uri.parse(queryParameter));
            }
            throw new UrlParseException("URL missing 'url' query parameter.");
        } catch (UnsupportedOperationException unused) {
            LogUtil.show("Could not handle url: " + uri);
            throw new UrlParseException("Passed-in URL did not create a hierarchical URI.");
        }
    }

    public static Intent intentForShareTweet(Uri uri) {
        if (!UrlAction.HANDLE_SHARE_TWEET.shouldTryHandlingUrl(uri)) {
            throw new UrlParseException("URL does not have tpshare://tweet? format.");
        }
        try {
            String queryParameter = uri.getQueryParameter("screen_name");
            String queryParameter2 = uri.getQueryParameter("tweet_id");
            if (TextUtils.isEmpty(queryParameter)) {
                throw new UrlParseException("URL missing non-empty 'screen_name' query parameter.");
            }
            if (TextUtils.isEmpty(queryParameter2)) {
                throw new UrlParseException("URL missing non-empty 'tweet_id' query parameter.");
            }
            String h = a.h("Check out @", queryParameter, "'s Tweet: ", a.h("https://twitter.com/", queryParameter, "/status/", queryParameter2));
            Intent intent = new Intent("android.intent.action.SEND");
            intent.setType("text/plain");
            intent.putExtra("android.intent.extra.SUBJECT", h);
            intent.putExtra("android.intent.extra.TEXT", h);
            return intent;
        } catch (UnsupportedOperationException unused) {
            LogUtil.show("Could not handle url: " + uri);
            throw new UrlParseException("Passed-in URL did not create a hierarchical URI.");
        }
    }

    public static void launchActionViewIntent(Context context, Uri uri, String str) {
        Preconditions.checkNotNull(context);
        Preconditions.checkNotNull(uri);
        Intent intent = new Intent("android.intent.action.VIEW", uri);
        if (!(context instanceof Activity)) {
            intent.addFlags(268435456);
        }
        launchIntentForUserClick(context, intent, str);
    }

    public static void launchApplicationIntent(Context context, Intent intent) {
        Preconditions.checkNotNull(context);
        Preconditions.checkNotNull(intent);
        if (deviceCanHandleIntent(context, intent)) {
            String str = "Unable to open intent: " + intent;
            if (!(context instanceof Activity)) {
                intent.addFlags(268435456);
            }
            launchIntentForUserClick(context, intent, str);
            return;
        }
        String stringExtra = intent.getStringExtra("browser_fallback_url");
        if (TextUtils.isEmpty(stringExtra)) {
            if (!CPClickController.SCHEME_MARKET.equalsIgnoreCase(intent.getScheme())) {
                launchApplicationUrl(context, getPlayStoreUri(intent));
                return;
            } else {
                throw new IntentNotResolvableException("Device could not handle neither intent nor market url.\nIntent: " + intent.toString());
            }
        }
        Uri parse = Uri.parse(stringExtra);
        String scheme = parse.getScheme();
        if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) {
            showTPBrowserForUrl(context, parse, null);
        } else {
            launchApplicationUrl(context, parse);
        }
    }

    public static void launchApplicationUrl(Context context, Uri uri) {
        Intent intent = new Intent("android.intent.action.VIEW", uri);
        Preconditions.checkNotNull(context);
        Preconditions.checkNotNull(uri);
        if (deviceCanHandleIntent(context, intent)) {
            launchApplicationIntent(context, intent);
            return;
        }
        throw new IntentNotResolvableException("Could not handle application specific action: " + uri + "\n\tYou may be running in the emulator or another device which does not have the required application.");
    }

    public static void launchIntentForUserClick(Context context, Intent intent, String str) {
        Preconditions.NoThrow.checkNotNull(context);
        Preconditions.NoThrow.checkNotNull(intent);
        try {
            startActivity(context, intent);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static void showTPBrowserForUrl(Context context, Uri uri, String str) {
        Preconditions.checkNotNull(context);
        Preconditions.checkNotNull(uri);
        LogUtil.show("Final URI to show in browser: " + uri);
        Bundle bundle = new Bundle();
        bundle.putString("URL", uri.toString());
        if (!TextUtils.isEmpty(str)) {
            bundle.putString("tp-dsp-creative-id", str);
        }
        launchIntentForUserClick(context, getStartActivityIntent(context, TPBrowser.class, bundle), "Could not show TPBrowser for url: " + uri + "\n\tPerhaps you forgot to declare TPBrowser in your Android manifest file.");
    }

    public static void startActivity(Context context, Intent intent) {
        Preconditions.checkNotNull(context);
        Preconditions.checkNotNull(intent);
        if (!(context instanceof Activity)) {
            intent.addFlags(268435456);
        }
        try {
            context.startActivity(intent);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Deprecated
    public static boolean canHandleApplicationUrl(Context context, Uri uri, boolean z) {
        return false;
    }
}