package com.prankapp.fartsounds.airhorn.ui;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.prankapp.fartsounds.airhorn.R;
import com.prankapp.fartsounds.airhorn.utilsfff.ImmUtils;

public class SettingActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ImmUtils.setStatusBar(this,false,false);
        ImageView imageView = findViewById(R.id.iv_back);
        RelativeLayout rl_about = findViewById(R.id.rl_about);
        RelativeLayout rl_feedback = findViewById(R.id.rl_feedback);
        RelativeLayout rl_yinsii = findViewById(R.id.rl_yinsii);
        RelativeLayout rl_yonghu = findViewById(R.id.rl_yonghu);
        rl_feedback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 参数2：设置BottomSheetDialog的主题样式；将背景设置为transparent，这样我们写的shape_bottom_sheet_dialog.xml才会起作用
                BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(SettingActivity.this, R.style.BottomSheetDialog);
                //不传第二个参数
                //BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);

                // 底部弹出的布局
                View bottomView = LayoutInflater.from(SettingActivity.this).inflate(R.layout.bottom_sheet_layout, null);
                TextView tvEmail = bottomView.findViewById(R.id.tv_email);
                TextView cancel = bottomView.findViewById(R.id.cancel);
                cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        bottomSheetDialog.cancel();
                    }
                });
                tvEmail.setText("google@email.com");
                bottomSheetDialog.setContentView(bottomView);
                //设置点击dialog外部不消失
                //bottomSheetDialog.setCanceledOnTouchOutside(false);
                bottomSheetDialog.show();
            }
        });
        rl_yinsii.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                Uri content_url = Uri.parse("https://prankapp.bitbucket.io/privacy.html");
                intent.setData(content_url);
                startActivity(intent);
            }
        });

        rl_yonghu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                Uri content_url = Uri.parse("https://wallpaperbox.bitbucket.io/privacy.html");
                intent.setData(content_url);
                startActivity(intent);
            }
        });

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        rl_about.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this,AboutHhdgActivity.class));
            }
        });
    }
}
