APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:лукистрелы
版本号:4.7.5
包名称:com.itrack.lukistrely492503

MD5 校验值:f251013a2aaff35392a018e97a7e0052

反编译源代码说明

DesignShareManager.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.itrack.mobifitnessdemo.utils.share;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;
import androidx.core.app.ShareCompat$IntentBuilder;
import androidx.fragment.app.FragmentActivity;
import com.itrack.lukistrely492503.R;
import com.itrack.mobifitnessdemo.activity.BaseShareActivity;
import com.itrack.mobifitnessdemo.android.job.PointsJobService;
import com.itrack.mobifitnessdemo.domain.model.dto.PointsCode;
import com.itrack.mobifitnessdemo.domain.model.preferences.FranchisePrefs;
import com.itrack.mobifitnessdemo.domain.model.utils.SpellingResHelper;
import com.itrack.mobifitnessdemo.snackbar.Snackbar;
import com.itrack.mobifitnessdemo.ui.dialog.SingleChoiceBottomSheetDialogFragment;
import com.itrack.mobifitnessdemo.utils.FileUtils;
import com.itrack.mobifitnessdemo.utils.IntentUtils;
import com.itrack.mobifitnessdemo.utils.StringExtentionsKt;
import com.itrack.mobifitnessdemo.utils.TimeUtils;
import com.itrack.mobifitnessdemo.utils.share.FacebookShareController;
import com.itrack.mobifitnessdemo.utils.share.ShareContentProvider;
import com.itrack.mobifitnessdemo.utils.share.ShareManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import kotlin.Unit;
import kotlin.collections.ArraysKt___ArraysKt;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;
import kotlin.text.StringsKt__StringsKt;

public final class DesignShareManager implements ShareResultCallback, FacebookShareController.FacebookShareListener {
    public static final Companion Companion = new Companion(null);
    private static final String INSTAGRAM_PACKAGE_NAME = "com.instagram.android";
    private static final String ODNOKLASSNIKI_PACKAGE_NAME = "ru.ok.android";
    private static final int REQUEST_CAMERA = 42;
    private static final int REQUEST_GALLERY_FILE = 43;
    private static final int REQUEST_SHARE_TWITTER = 41;
    private static final int REQUEST_SHARE_VK = 40;
    private static final String TELEGRAM_PACKAGE_NAME = "org.telegram.messenger";
    private final FragmentActivity activity;
    private final ShareManager.DetailsProvider detailsProvider;
    private FacebookShareController facebookShareController;

    public DesignShareManager(FragmentActivity activity, ShareManager.DetailsProvider detailsProvider) {
        Intrinsics.checkNotNullParameter(activity, "activity");
        Intrinsics.checkNotNullParameter(detailsProvider, "detailsProvider");
        this.activity = activity;
        this.detailsProvider = detailsProvider;
    }

    public DesignShareManager(FragmentActivity fragmentActivity, ShareManager.DetailsProvider detailsProvider, int i, DefaultConstructorMarker defaultConstructorMarker) {
        this(fragmentActivity, detailsProvider);
        if ((i & 2) != 0) {
            Intrinsics.checkNotNull(fragmentActivity, "null cannot be cast to non-null type com.itrack.mobifitnessdemo.utils.share.ShareManager.DetailsProvider");
            detailsProvider = (ShareManager.DetailsProvider) fragmentActivity;
        }
    }

    public final void startSharing(@ShareManager.Type int i, Object source) {
        Intrinsics.checkNotNullParameter(source, "source");
        switch (this.detailsProvider.provideShareType()) {
            case 1:
                shareNews(i, (ShareContentProvider.NewsContent) source);
                return;
            case 2:
                shareVideo(i, (ShareContentProvider.VideoContent) source);
                return;
            case 3:
                shareSchedule(i, (ShareContentProvider.ScheduleContent) source);
                return;
            case 4:
                shareTrainer(i, (ShareContentProvider.TrainerContent) source);
                return;
            case 5:
                shareClub(i, (ShareContentProvider.ClubContent) source);
                return;
            case 6:
                sharePoints(i, (ShareContentProvider.PromoCodeContent) source);
                return;
            case 7:
                shareFranchise(i);
                return;
            default:
                Toast.makeText(this.activity, "Such source is not supported", 0).show();
                return;
        }
    }

    @Override
    public String onActivityResult(int i, int i2, Intent intent) {
        String onActivityResult;
        Uri data;
        if (42 == i) {
            Uri tempImageUri = FileUtils.getTempImageUri(this.activity);
            if (tempImageUri == null) {
                return null;
            }
            launchInstagram(tempImageUri);
        } else if (i == 43) {
            if (intent == null || (data = intent.getData()) == null) {
                return null;
            }
            launchInstagram(data);
        } else if (40 == i && i2 == -1) {
            Snackbar.with(this.activity).message(R.string.shared_successfully_message).show();
            if (!isBonusesEnabled()) {
                return null;
            }
            BaseShareActivity.Companion companion = BaseShareActivity.Companion;
            if (companion.shouldGivePoints(intent)) {
                String resultPointsCode = companion.getResultPointsCode(intent);
                return resultPointsCode == null ? PointsCode.CODE_SHARE_TO_VK : resultPointsCode;
            }
        } else if (41 == i && i2 == -1) {
            Snackbar.with(this.activity).message(R.string.shared_successfully_message).show();
            if (!isBonusesEnabled()) {
                return null;
            }
            BaseShareActivity.Companion companion2 = BaseShareActivity.Companion;
            if (companion2.shouldGivePoints(intent)) {
                String resultPointsCode2 = companion2.getResultPointsCode(intent);
                return resultPointsCode2 == null ? PointsCode.CODE_SHARE_TO_TWITTER : resultPointsCode2;
            }
        } else {
            FacebookShareController facebookShareController = this.facebookShareController;
            if (facebookShareController == null || (onActivityResult = facebookShareController.onActivityResult(i, i2, intent)) == null) {
                return null;
            }
            this.facebookShareController = null;
            return onActivityResult;
        }
        return null;
    }

    private final boolean isBonusesEnabled() {
        return this.detailsProvider.provideFranchisePrefs().getFeatures().isBonusesEnabled();
    }

    private final void sharePoints(@ShareManager.Type int i, ShareContentProvider.PromoCodeContent promoCodeContent) {
        String str = promoCodeContent.getBody() + '\n' + promoCodeContent.getPromoCodeImageUrl();
        String promoCodeImageUrl = promoCodeContent.getPromoCodeImageUrl();
        Uri parse = promoCodeImageUrl != null ? Uri.parse(promoCodeImageUrl) : null;
        switch (i) {
            case 0:
                sendToVk$default(this, str, null, null, null, null, 30, null);
                return;
            case 1:
                sendToFacebook$default(this, promoCodeContent.getFacebookShareUrl(), promoCodeContent.getBody() + '\n' + promoCodeContent.getPromoCodeImageUrl(), null, parse, null, 20, null);
                return;
            case 2:
                sendToTwitter$default(this, str, null, parse, null, null, 26, null);
                return;
            case 3:
                if (parse != null) {
                    launchInstagram(parse);
                    return;
                } else {
                    sendToInstagram();
                    return;
                }
            case 4:
                sendToEmail(null, str, parse);
                return;
            case 5:
                sendToSms(str);
                return;
            case 6:
            default:
                return;
            case 7:
                sendToOdnoklassniki(str, parse);
                return;
            case 8:
                sendToTelegram(str, parse);
                return;
        }
    }

    private final void shareTrainer(@ShareManager.Type int i, ShareContentProvider.TrainerContent trainerContent) {
        String vkUrl;
        boolean isBlank;
        if (i == 0) {
            vkUrl = trainerContent.getVkUrl();
        } else if (i == 1) {
            vkUrl = trainerContent.getFacebookUrl();
        } else if (i == 3) {
            vkUrl = trainerContent.getInstagramUrl();
        } else if (i == 7) {
            vkUrl = trainerContent.getOdnoklassnikiUrl();
        } else if (i != 8) {
            return;
        } else {
            vkUrl = trainerContent.getTelegramUrl();
        }
        isBlank = StringsKt__StringsJVMKt.isBlank(vkUrl);
        if (!isBlank) {
            sendToSocialPage(vkUrl);
        }
    }

    private final void shareClub(@ShareManager.Type int i, ShareContentProvider.ClubContent clubContent) {
        String vkUrl;
        boolean isBlank;
        if (i == 0) {
            vkUrl = clubContent.getVkUrl();
        } else if (i == 1) {
            vkUrl = clubContent.getFacebookUrl();
        } else if (i == 2) {
            vkUrl = clubContent.getTwitterUrl();
        } else if (i == 3) {
            vkUrl = clubContent.getInstagramUrl();
        } else if (i == 7) {
            vkUrl = clubContent.getOdnoklassnikiUrl();
        } else if (i != 8) {
            return;
        } else {
            vkUrl = clubContent.getTelegramUrl();
        }
        isBlank = StringsKt__StringsJVMKt.isBlank(vkUrl);
        if (!isBlank) {
            sendToSocialPage(vkUrl);
        }
    }

    private final void shareFranchise(@ShareManager.Type int i) {
        String str;
        List listOfNotNull;
        String joinToString$default;
        List listOfNotNull2;
        String joinToString$default2;
        FranchisePrefs provideFranchisePrefs = this.detailsProvider.provideFranchisePrefs();
        if (i == 0) {
            String vkTag = provideFranchisePrefs.getVkTag();
            String str2 = vkTag == null ? "" : vkTag;
            String siteUrl = provideFranchisePrefs.getSiteUrl();
            str = siteUrl != null ? siteUrl : "";
            sendToVk$default(this, str2, str, null, PointsCode.CODE_SHARE_TO_VK, getShareSearchForPoint(str2, str), 4, null);
            return;
        }
        if (i == 1) {
            String facebookUrl = provideFranchisePrefs.getFacebookUrl();
            if (facebookUrl == null) {
                facebookUrl = provideFranchisePrefs.getSiteUrl();
            }
            sendToFacebook$default(this, facebookUrl, provideFranchisePrefs.getFacebookTag(), null, null, PointsCode.CODE_SHARE_TO_FACEBOOK, 12, null);
            return;
        }
        if (i == 2) {
            String twitterTag = provideFranchisePrefs.getTwitterTag();
            String str3 = twitterTag == null ? "" : twitterTag;
            String siteUrl2 = provideFranchisePrefs.getSiteUrl();
            str = siteUrl2 != null ? siteUrl2 : "";
            sendToTwitter$default(this, str3, str, null, PointsCode.CODE_SHARE_TO_TWITTER, getShareSearchForPoint(str3, str), 4, null);
            return;
        }
        if (i == 3) {
            sendToInstagram();
            return;
        }
        if (i == 7) {
            listOfNotNull = CollectionsKt__CollectionsKt.listOfNotNull((Object[]) new String[]{provideFranchisePrefs.getOdnoklassnikiTag(), provideFranchisePrefs.getFranchiseTitle(), provideFranchisePrefs.getSiteUrl(), provideFranchisePrefs.getOdnoklassnikiUrl()});
            joinToString$default = CollectionsKt___CollectionsKt.joinToString$default(listOfNotNull, "\n", null, null, 0, null, null, 62, null);
            sendToOdnoklassniki$default(this, joinToString$default, null, 2, null);
        } else {
            if (i != 8) {
                return;
            }
            listOfNotNull2 = CollectionsKt__CollectionsKt.listOfNotNull((Object[]) new String[]{provideFranchisePrefs.getTelegramTag(), provideFranchisePrefs.getFranchiseTitle(), provideFranchisePrefs.getSiteUrl(), provideFranchisePrefs.getTelegramUrl()});
            joinToString$default2 = CollectionsKt___CollectionsKt.joinToString$default(listOfNotNull2, "\n", null, null, 0, null, null, 62, null);
            sendToTelegram$default(this, joinToString$default2, null, 2, null);
        }
    }

    private final void shareVideo(@ShareManager.Type int i, ShareContentProvider.VideoContent videoContent) {
        String str;
        int lastIndexOf$default;
        FranchisePrefs provideFranchisePrefs = this.detailsProvider.provideFranchisePrefs();
        if (i == 0) {
            String vkTag = provideFranchisePrefs.getVkTag();
            str = vkTag != null ? vkTag : "";
            sendToVk$default(this, getShareMessage(videoContent, str), null, null, PointsCode.CODE_SHARE_TO_VK_VIDEO, getShareSearchForPoint(videoContent.getUrl(), str), 6, null);
            return;
        }
        String str2 = null;
        if (i == 1) {
            String videoUrl = videoContent.getVideoUrl();
            if (videoUrl != null) {
                if (!(videoUrl.length() == 0)) {
                    lastIndexOf$default = StringsKt__StringsKt.lastIndexOf$default((CharSequence) videoUrl, "/", 0, false, 6, (Object) null);
                    videoUrl = videoUrl.substring(lastIndexOf$default + 1);
                    Intrinsics.checkNotNullExpressionValue(videoUrl, "this as java.lang.String).substring(startIndex)");
                }
                str2 = this.activity.getString(R.string.facebook_video_share_url_template, videoUrl);
            }
            sendToFacebook$default(this, str2, null, videoContent.getTitle(), null, PointsCode.CODE_SHARE_TO_FACEBOOK_VIDEO, 10, null);
            return;
        }
        if (i == 2) {
            String twitterTag = provideFranchisePrefs.getTwitterTag();
            str = twitterTag != null ? twitterTag : "";
            sendToTwitter$default(this, getShareMessage(videoContent, str), null, null, PointsCode.CODE_SHARE_TO_TWITTER_VIDEO, getShareSearchForPoint(videoContent.getUrl(), str), 6, null);
        } else {
            if (i == 4) {
                sendToEmail$default(this, videoContent.getTitle(), this.activity.getString(R.string.share_video_email_message_template, videoContent.getUrl()), null, 4, null);
                return;
            }
            if (i == 5) {
                String string = this.activity.getString(R.string.share_video_email_message_template, videoContent.getUrl());
                Intrinsics.checkNotNullExpressionValue(string, "activity.getString(R.str…age_template, source.url)");
                sendToSms(string);
            } else if (i == 7) {
                sendToOdnoklassniki$default(this, getShareMessage(videoContent, provideFranchisePrefs.getOdnoklassnikiTag()), null, 2, null);
            } else {
                if (i != 8) {
                    return;
                }
                sendToTelegram$default(this, getShareMessage(videoContent, provideFranchisePrefs.getTelegramTag()), null, 2, null);
            }
        }
    }

    public static String getShareMessage$default(DesignShareManager designShareManager, ShareContentProvider.VideoContent videoContent, String str, int i, Object obj) {
        if ((i & 1) != 0) {
            str = null;
        }
        return designShareManager.getShareMessage(videoContent, str);
    }

    private final String getShareMessage(ShareContentProvider.VideoContent videoContent, String str) {
        String takeIfNotBlank;
        List listOfNotNull;
        String joinToString$default;
        String[] strArr = new String[3];
        strArr[0] = StringExtentionsKt.takeIfNotBlank(str);
        strArr[1] = StringExtentionsKt.takeIfNotBlank(videoContent.getTitle());
        String url = videoContent.getUrl();
        if (url == null || (takeIfNotBlank = StringExtentionsKt.takeIfNotBlank(url)) == null) {
            String videoUrl = videoContent.getVideoUrl();
            takeIfNotBlank = videoUrl != null ? StringExtentionsKt.takeIfNotBlank(videoUrl) : null;
        }
        strArr[2] = takeIfNotBlank;
        listOfNotNull = CollectionsKt__CollectionsKt.listOfNotNull((Object[]) strArr);
        joinToString$default = CollectionsKt___CollectionsKt.joinToString$default(listOfNotNull, "\n", null, null, 0, null, null, 62, null);
        return joinToString$default;
    }

    private final void shareSchedule(@ShareManager.Type int i, ShareContentProvider.ScheduleContent scheduleContent) {
        FranchisePrefs provideFranchisePrefs = this.detailsProvider.provideFranchisePrefs();
        if (i == 0) {
            String vkTag = provideFranchisePrefs.getVkTag();
            sendToVk$default(this, getShareMessageText(scheduleContent, vkTag), null, null, PointsCode.CODE_SHARE_TO_VK_WORKOUT, getShareSearchForPoint(vkTag), 6, null);
            return;
        }
        if (i == 1) {
            String facebookUrl = provideFranchisePrefs.getFacebookUrl();
            if (facebookUrl == null) {
                facebookUrl = provideFranchisePrefs.getSiteUrl();
            }
            sendToFacebook$default(this, facebookUrl, getShareMessageText(scheduleContent, provideFranchisePrefs.getFacebookTag()), scheduleContent.getWorkoutTitle(), null, PointsCode.CODE_SHARE_TO_FACEBOOK_WORKOUT, 8, null);
            return;
        }
        if (i == 2) {
            String twitterTag = provideFranchisePrefs.getTwitterTag();
            sendToTwitter$default(this, getShareMessageText(scheduleContent, twitterTag), null, null, "twitter_activity", getShareSearchForPoint(twitterTag), 6, null);
            return;
        }
        if (i == 4) {
            sendToEmail$default(this, getSpellingHelper().getString(R.string.share_email_schedule_item_title), getShareMessageText$default(this, scheduleContent, null, 1, null), null, 4, null);
            return;
        }
        if (i == 5) {
            sendToSms(getSmsMessage(scheduleContent));
        } else if (i == 7) {
            sendToOdnoklassniki$default(this, getShareMessageText(scheduleContent, provideFranchisePrefs.getOdnoklassnikiTag()), null, 2, null);
        } else {
            if (i != 8) {
                return;
            }
            sendToTelegram$default(this, getShareMessageText(scheduleContent, provideFranchisePrefs.getTelegramTag()), null, 2, null);
        }
    }

    private final void shareNews(@ShareManager.Type int i, ShareContentProvider.NewsContent newsContent) {
        FranchisePrefs provideFranchisePrefs = this.detailsProvider.provideFranchisePrefs();
        String takeIfNotBlank = StringExtentionsKt.takeIfNotBlank(newsContent.getUrl());
        if (takeIfNotBlank == null && (takeIfNotBlank = provideFranchisePrefs.getSiteUrl()) == null) {
            takeIfNotBlank = "";
        }
        String str = takeIfNotBlank;
        Uri tempImageUri = FileUtils.getTempImageUri(this.activity);
        switch (i) {
            case 0:
                sendToVk(getShareMessage$default(this, newsContent, provideFranchisePrefs.getVkTag(), false, 2, null), newsContent.getUrl(), tempImageUri, PointsCode.CODE_SHARE_TO_VK_NEWS, getShareSearchForPoint(str, provideFranchisePrefs.getVkTag()));
                return;
            case 1:
                sendToFacebook(str, newsContent.getBody(), newsContent.getTitle(), tempImageUri, PointsCode.CODE_SHARE_TO_FACEBOOK_NEWS);
                return;
            case 2:
                sendToTwitter(getShareMessage$default(this, newsContent, provideFranchisePrefs.getTwitterTag(), false, 2, null), newsContent.getUrl(), tempImageUri, PointsCode.CODE_SHARE_TO_TWITTER_NEWS, getShareSearchForPoint(str, provideFranchisePrefs.getTwitterTag()));
                return;
            case 3:
                if (tempImageUri != null) {
                    launchInstagram(tempImageUri);
                    return;
                } else {
                    sendToInstagram();
                    return;
                }
            case 4:
                sendToEmail(newsContent.getTitle(), getShareMessage$default(this, newsContent, null, false, 1, null), tempImageUri);
                return;
            case 5:
                sendToSms(getShareMessage$default(this, newsContent, null, false, 3, null));
                return;
            case 6:
            default:
                return;
            case 7:
                sendToOdnoklassniki(getShareMessage$default(this, newsContent, provideFranchisePrefs.getOdnoklassnikiTag(), false, 2, null), tempImageUri);
                return;
            case 8:
                sendToTelegram(getShareMessage$default(this, newsContent, provideFranchisePrefs.getTelegramTag(), false, 2, null), tempImageUri);
                return;
        }
    }

    public static String getShareMessage$default(DesignShareManager designShareManager, ShareContentProvider.NewsContent newsContent, String str, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            str = null;
        }
        if ((i & 2) != 0) {
            z = true;
        }
        return designShareManager.getShareMessage(newsContent, str, z);
    }

    private final String getShareMessage(ShareContentProvider.NewsContent newsContent, String str, boolean z) {
        List listOfNotNull;
        String joinToString$default;
        String[] strArr = new String[4];
        strArr[0] = StringExtentionsKt.takeIfNotBlank(str);
        strArr[1] = z ? StringExtentionsKt.takeIfNotBlank(newsContent.getTitle()) : null;
        strArr[2] = StringExtentionsKt.takeIfNotBlank(newsContent.getBody());
        String url = newsContent.getUrl();
        strArr[3] = url != null ? StringExtentionsKt.takeIfNotBlank(url) : null;
        listOfNotNull = CollectionsKt__CollectionsKt.listOfNotNull((Object[]) strArr);
        joinToString$default = CollectionsKt___CollectionsKt.joinToString$default(listOfNotNull, "\n", null, null, 0, null, null, 62, null);
        return joinToString$default;
    }

    private final String[] getShareSearchForPoint(String... strArr) {
        List listOfNotNull;
        boolean isBlank;
        listOfNotNull = CollectionsKt__CollectionsKt.listOfNotNull(Arrays.copyOf(strArr, strArr.length));
        ArrayList arrayList = new ArrayList();
        for (Object obj : listOfNotNull) {
            isBlank = StringsKt__StringsJVMKt.isBlank((String) obj);
            if (!isBlank) {
                arrayList.add(obj);
            }
        }
        Object[] array = arrayList.toArray(new String[0]);
        Intrinsics.checkNotNull(array, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
        return (String[]) array;
    }

    private final void sendToSocialPage(String str) {
        try {
            this.activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
        } catch (ActivityNotFoundException unused) {
            Toast.makeText(this.activity, R.string.webbrowser_not_found, 0).show();
        }
    }

    private final void sendToInstagram() {
        List list;
        SingleChoiceBottomSheetDialogFragment newInstance;
        String[] stringArray = this.activity.getResources().getStringArray(R.array.image_source);
        Intrinsics.checkNotNullExpressionValue(stringArray, "activity.resources.getSt…ray(R.array.image_source)");
        list = ArraysKt___ArraysKt.toList(stringArray);
        newInstance = SingleChoiceBottomSheetDialogFragment.Companion.newInstance((r12 & 1) != 0 ? 0 : 0, (r12 & 2) != 0 ? null : null, (r12 & 4) != 0 ? null : null, (r12 & 8) != 0 ? -1 : 0, list);
        newInstance.setOnChoiceHandler(new Function2<Integer, Integer, Unit>() {
            {
                super(2);
            }

            @Override
            public Unit invoke(Integer num, Integer num2) {
                invoke(num.intValue(), num2.intValue());
                return Unit.INSTANCE;
            }

            public final void invoke(int i, int i2) {
                if (i2 == 0) {
                    DesignShareManager.this.launchCamera();
                } else {
                    DesignShareManager.this.launchChoosePhoto();
                }
            }
        });
        newInstance.show(this.activity.getSupportFragmentManager(), (String) null);
    }

    private final void launchInstagram(Uri uri) {
        try {
            Intent intent = new Intent("android.intent.action.SEND").setType("image/*").putExtra("android.intent.extra.STREAM", uri).setPackage(INSTAGRAM_PACKAGE_NAME);
            Intrinsics.checkNotNullExpressionValue(intent, "Intent(Intent.ACTION_SEN…e(INSTAGRAM_PACKAGE_NAME)");
            this.activity.startActivity(Intent.createChooser(intent, ""));
        } catch (ActivityNotFoundException unused) {
            Toast.makeText(this.activity, R.string.instagram_is_no_installed, 1).show();
        }
    }

    public final void launchCamera() {
        Intent putExtra = new Intent("android.media.action.IMAGE_CAPTURE").putExtra("output", FileUtils.getTempImageUri(this.activity));
        Intrinsics.checkNotNullExpressionValue(putExtra, "Intent(MediaStore.ACTION…etTempImageUri(activity))");
        this.activity.startActivityForResult(putExtra, 42);
    }

    public final void launchChoosePhoto() {
        Intent type = new Intent("android.intent.action.GET_CONTENT").addCategory("android.intent.category.OPENABLE").setType("image/*");
        Intrinsics.checkNotNullExpressionValue(type, "Intent(Intent.ACTION_GET…      .setType(\"image/*\")");
        this.activity.startActivityForResult(type, 43);
    }

    public static void sendToTwitter$default(DesignShareManager designShareManager, String str, String str2, Uri uri, String str3, String[] strArr, int i, Object obj) {
        designShareManager.sendToTwitter(str, (i & 2) != 0 ? null : str2, (i & 4) != 0 ? null : uri, (i & 8) != 0 ? null : str3, (i & 16) != 0 ? null : strArr);
    }

    private final void sendToTwitter(String str, String str2, Uri uri, String str3, String[] strArr) {
        Toast.makeText(this.activity, "Twitter sharing is temporarily unavailable", 0).show();
    }

    public final Bundle getTwitterShareExtras(String str, String str2, Uri uri, String str3, String[] strArr) {
        BaseShareActivity.Companion companion = BaseShareActivity.Companion;
        return companion.applyDesign(companion.getTwitterIntentExtras(str, str2, uri, str3, (String[]) Arrays.copyOf(strArr, strArr.length)));
    }

    public static void sendToVk$default(DesignShareManager designShareManager, String str, String str2, Uri uri, String str3, String[] strArr, int i, Object obj) {
        designShareManager.sendToVk(str, (i & 2) != 0 ? null : str2, (i & 4) != 0 ? null : uri, (i & 8) != 0 ? null : str3, (i & 16) != 0 ? null : strArr);
    }

    private final void sendToVk(String str, String str2, Uri uri, String str3, String[] strArr) {
        if (strArr == null) {
            strArr = new String[0];
        }
        Intent putExtras = new Intent(this.activity, (Class<?>) BaseShareActivity.class).putExtras(getVkShareExtras(str, str2, uri, str3, strArr));
        Intrinsics.checkNotNullExpressionValue(putExtras, "Intent(activity, BaseSha…       .putExtras(extras)");
        this.activity.startActivityForResult(putExtras, 40);
    }

    public static void sendToFacebook$default(DesignShareManager designShareManager, String str, String str2, String str3, Uri uri, String str4, int i, Object obj) {
        if ((i & 1) != 0) {
            str = null;
        }
        if ((i & 2) != 0) {
            str2 = null;
        }
        if ((i & 4) != 0) {
            str3 = null;
        }
        if ((i & 8) != 0) {
            uri = null;
        }
        if ((i & 16) != 0) {
            str4 = null;
        }
        designShareManager.sendToFacebook(str, str2, str3, uri, str4);
    }

    private final void sendToFacebook(String str, String str2, String str3, Uri uri, String str4) {
        FacebookShareController facebookShareController = new FacebookShareController(this.activity, this, str4);
        facebookShareController.showShareDialog(str, str2, str3, uri);
        this.facebookShareController = facebookShareController;
    }

    @Override
    public void onFacebookShareSuccess(String str) {
        List<String> listOfNotNull;
        PointsJobService.Companion companion = PointsJobService.Companion;
        FragmentActivity fragmentActivity = this.activity;
        listOfNotNull = CollectionsKt__CollectionsKt.listOfNotNull(str);
        companion.scheduleJob(fragmentActivity, listOfNotNull);
    }

    public final Bundle getVkShareExtras(String str, String str2, Uri uri, String str3, String[] strArr) {
        BaseShareActivity.Companion companion = BaseShareActivity.Companion;
        return companion.applyDesign(companion.getVkIntentExtras(str, str2, uri, str3, (String[]) Arrays.copyOf(strArr, strArr.length)));
    }

    public static void sendToTelegram$default(DesignShareManager designShareManager, String str, Uri uri, int i, Object obj) {
        if ((i & 2) != 0) {
            uri = null;
        }
        designShareManager.sendToTelegram(str, uri);
    }

    private final void sendToTelegram(final String str, final Uri uri) {
        IntentUtils.openWithChooseIfNeeded$default(IntentUtils.INSTANCE, this.activity, new Function0<Intent>() {
            {
                super(0);
            }

            @Override
            public final Intent invoke() {
                FragmentActivity fragmentActivity;
                fragmentActivity = DesignShareManager.this.activity;
                Intent intent = new ShareCompat$IntentBuilder(fragmentActivity).setType("text/plain").setText(str).setStream(uri).getIntent().setPackage("org.telegram.messenger");
                Intrinsics.checkNotNullExpressionValue(intent, "IntentBuilder(activity)\n…ge(TELEGRAM_PACKAGE_NAME)");
                return intent;
            }
        }, null, null, 12, null);
    }

    public static void sendToOdnoklassniki$default(DesignShareManager designShareManager, String str, Uri uri, int i, Object obj) {
        if ((i & 2) != 0) {
            uri = null;
        }
        designShareManager.sendToOdnoklassniki(str, uri);
    }

    private final void sendToOdnoklassniki(final String str, final Uri uri) {
        IntentUtils.openWithChooseIfNeeded$default(IntentUtils.INSTANCE, this.activity, new Function0<Intent>() {
            {
                super(0);
            }

            @Override
            public final Intent invoke() {
                FragmentActivity fragmentActivity;
                fragmentActivity = DesignShareManager.this.activity;
                Intent intent = new ShareCompat$IntentBuilder(fragmentActivity).setType("text/plain").setText(str).setStream(uri).getIntent().setPackage("ru.ok.android");
                Intrinsics.checkNotNullExpressionValue(intent, "IntentBuilder(activity)\n…NOKLASSNIKI_PACKAGE_NAME)");
                return intent;
            }
        }, null, null, 12, null);
    }

    public static void sendToEmail$default(DesignShareManager designShareManager, String str, String str2, Uri uri, int i, Object obj) {
        if ((i & 4) != 0) {
            uri = null;
        }
        designShareManager.sendToEmail(str, str2, uri);
    }

    private final void sendToEmail(final String str, final String str2, final Uri uri) {
        IntentUtils.openWithChooseIfNeeded$default(IntentUtils.INSTANCE, this.activity, new Function0<Intent>() {
            {
                super(0);
            }

            @Override
            public final Intent invoke() {
                FragmentActivity fragmentActivity;
                fragmentActivity = DesignShareManager.this.activity;
                ShareCompat$IntentBuilder emailTo = new ShareCompat$IntentBuilder(fragmentActivity).setType("message/rfc822").setEmailTo(new String[0]);
                String str3 = str;
                if (str3 == null) {
                    str3 = "";
                }
                ShareCompat$IntentBuilder subject = emailTo.setSubject(str3);
                String str4 = str2;
                Intent intent = subject.setText(str4 != null ? str4 : "").setStream(uri).getIntent();
                Intrinsics.checkNotNullExpressionValue(intent, "IntentBuilder(activity)\n…                  .intent");
                return intent;
            }
        }, null, null, 12, null);
    }

    private final void sendToSms(String str) {
        try {
            Intent putExtra = new Intent("android.intent.action.VIEW").setData(Uri.parse("sms:")).putExtra("sms_body", str);
            Intrinsics.checkNotNullExpressionValue(putExtra, "Intent(Intent.ACTION_VIE…xtra(\"sms_body\", message)");
            this.activity.startActivity(putExtra);
        } catch (ActivityNotFoundException unused) {
            String string = this.activity.getString(R.string.sms_sender_not_found);
            Intrinsics.checkNotNullExpressionValue(string, "activity.getString(R.string.sms_sender_not_found)");
            Toast.makeText(this.activity, string, 0).show();
        }
    }

    private final String getSmsMessage(ShareContentProvider.ScheduleContent scheduleContent) {
        return getSpellingHelper().getString(R.string.share_email_schedule_item_title) + '\n' + getShareMessageText$default(this, scheduleContent, null, 1, null);
    }

    public static String getShareMessageText$default(DesignShareManager designShareManager, ShareContentProvider.ScheduleContent scheduleContent, String str, int i, Object obj) {
        if ((i & 1) != 0) {
            str = null;
        }
        return designShareManager.getShareMessageText(scheduleContent, str);
    }

    private final String getShareMessageText(ShareContentProvider.ScheduleContent scheduleContent, String str) {
        int i = scheduleContent.getDate().getDayOfWeek() == 2 ? R.string.share_workout_message_tuesday : R.string.share_workout_message;
        FragmentActivity fragmentActivity = this.activity;
        Object[] objArr = new Object[5];
        String abstractDateTime = scheduleContent.getDate().toString("EEEE dd/MM");
        Intrinsics.checkNotNullExpressionValue(abstractDateTime, "date.toString(\"EEEE dd/MM\")");
        String lowerCase = abstractDateTime.toLowerCase(Locale.ROOT);
        Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(Locale.ROOT)");
        objArr[0] = lowerCase;
        objArr[1] = TimeUtils.INSTANCE.formatScheduleTime(scheduleContent.getDate());
        objArr[2] = scheduleContent.getWorkoutTitle();
        objArr[3] = scheduleContent.getClubTitle();
        if (str == null) {
            str = "";
        }
        objArr[4] = str;
        String string = fragmentActivity.getString(i, objArr);
        Intrinsics.checkNotNullExpressionValue(string, "activity.getString(\n    …  hashTag ?: \"\"\n        )");
        return string;
    }

    private final SpellingResHelper getSpellingHelper() {
        return this.detailsProvider.provideSpellingHelper();
    }

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }
}