package com.atmob.voiceai.module.setting;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.atmob.app.lib.base.BaseViewModel;
import com.atmob.common.runtime.ActivityUtil;
import com.atmob.common.runtime.ContextUtil;
import com.atmob.voiceai.R;
import com.atmob.voiceai.data.consts.Constants;
import com.atmob.voiceai.module.subscription.SubscriptionPageActivity;
import com.atmob.voiceai.utils.AppUtil;
import com.atmob.voiceai.utils.CommonUtils;
import com.atmob.voiceai.utils.SystemUtil;
import com.atmob.voiceai.utils.ToastUtil;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class SettingViewModel extends BaseViewModel {


    private final MutableLiveData<String> versionName = new MutableLiveData<>();

    @Inject
    public SettingViewModel() {
        Context context = ContextUtil.getContext();
        versionName.setValue(context.getString(R.string.version_name, SystemUtil.getVersionName(context)));
    }

    public LiveData<String> getVersionName() {
        return versionName;
    }

    public void onSettingProClick() {
        SubscriptionPageActivity.start(ActivityUtil.getTopActivity());
    }

    public void onRateClick() {
        if (AppUtil.isAppExist(AppUtil.GooglePlay)) {
            AppUtil.launchGooglePlayDetail(ContextUtil.getContext().getPackageName());
        } else {
            ToastUtil.show(R.string.google_play_not_found, ToastUtil.LENGTH_SHORT);
        }
    }


    public void onSendEmailClick() {
        CommonUtils.sendEmail(ActivityUtil.getTopActivity(), "Voice AI", "", Constants.SEND_EMAIL_ADDRESS);
    }

    public void onPrivacyPolicyClick() {
        CommonUtils.startWeb(Constants.PRIVACY_POLICY);
    }

    public void onTermsOfServiceClick() {
        CommonUtils.startWeb(Constants.USER_AGREEMENT);
    }

}
