package com.exquisite.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.exquisite.activity.KeyBoardSettingsActivity;
import com.exquisite.activity.WebActivity;
import com.exquisite.R;
import com.exquisite.databinding.FragmentPageTwoBinding;

public class SettingFragment extends Fragment {
    FragmentPageTwoBinding binding;

    @SuppressLint("MissingInflatedId")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = FragmentPageTwoBinding.inflate(getLayoutInflater());

        initEvent();
        return binding.getRoot();
    }

    private void initEvent() {

        binding.versionText.setText("1.0.8");
        binding.keyboardSetting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(getActivity(), KeyBoardSettingsActivity.class);
                startActivity(intent1);
            }
        });

        binding.share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("text/plain");
                share.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name);
                String text = getString(R.string.share_title);
                text = text + "\n https://play.google.com/store/apps/details?id=" + "com.key.keyboardskins";
                share.putExtra(Intent.EXTRA_TEXT, text);
                startActivity(Intent.createChooser(share, "choose one"));
            }
        });

        binding.rate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "https://play.google.com/store/apps/details?id=com.key.keyboardskins";
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
            }
        });

        binding.privacy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2 = new Intent(requireContext(), WebActivity.class);
                startActivity(intent2);
            }
        });

    }

}