package com.example.maposv2;

import android.content.Intent;
import android.graphics.BlurMaskFilter;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

public class FragmentPolicieSecond extends Fragment {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_policie2, container, false);
        setHasOptionsMenu(true);
        // Add function to call phone number
        Button buttonCall = view.findViewById(R.id.button_pol_volat_156);
        buttonCall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:156"));
                startActivity(intent);
            }
        });

        // Add function to open url for button 1
        Button buttonCall2 = view.findViewById(R.id.button_pol_volat_155);
        buttonCall2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:155"));
                startActivity(intent);
            }
        });

        // Add function to open url for button 2
        Button buttonCall3 = view.findViewById(R.id.button_pol_volat_150);
        buttonCall3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:150"));
                startActivity(intent);
            }
        });

        // Set background with blur effect
        /*FrameLayout frameLayout = view.findViewById(R.id.red_frame2);
        Paint paint = new Paint();
        paint.setMaskFilter(new BlurMaskFilter(16, BlurMaskFilter.Blur.NORMAL));
        int color = ContextCompat.getColor(requireContext(), android.R.color.white);
        paint.setColor(color);
        paint.setStyle(Paint.Style.FILL);
        frameLayout.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frameLayout.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
        frameLayout.getBackground().setAlpha(128);*/

        return view;
    }
    @Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        // hide the options menu in this fragment
        menu.findItem(R.id.action_settings).setVisible(false);
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public void onPrepareOptionsMenu(@NonNull Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.findItem(R.id.action_settings).setVisible(false);
    }
}
