diff --git a/app/src/main/java/com/example/citrusclient/views/AccountColorDialogFragment.java b/app/src/main/java/com/example/citrusclient/views/AccountColorDialogFragment.java new file mode 100644 index 0000000..745261b --- /dev/null +++ b/app/src/main/java/com/example/citrusclient/views/AccountColorDialogFragment.java @@ -0,0 +1,69 @@ +package com.example.citrusclient.views; + +import android.app.Dialog; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import com.example.citrusclient.Citrus; +import com.example.citrusclient.R; +import android.widget.RadioButton; +import android.widget.RadioGroup; + + +public class AccountColorDialogFragment extends DialogFragment { + private Citrus citrus; + + SettingsFragment target2; //なにこれ + + AccountColorDialogFragment(SettingsFragment st) {target2=st;} + @NonNull //なにこれ + @Override + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { + // ダイアログを生成 + Dialog dialog = new Dialog(requireContext()); + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + dialog.setContentView(R.layout.fragment_account_color_dialog); + + RadioGroup rg = dialog.findViewById(R.id.radioGroupColors); + // ラジオグループのチェック状態変更リスナーを設定 + rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + // チェックされたラジオボタンのIDを取得 + RadioButton radioButton = group.findViewById(checkedId); + if (radioButton != null) { + int selectedId = radioButton.getId(); + // ここで選択されたラジオボタンのID(selectedId)を使用して処理を行う + if (selectedId == R.id.radioButtonShadow) { + target2.returnAccountColor("#D5D5D5"); + } else if (selectedId == R.id.radioButtonSprout) { + target2.returnAccountColor("#BEECAE"); + } else if (selectedId == R.id.radioButtonAqua) { + target2.returnAccountColor("#BEF7FF"); + } else if (selectedId == R.id.radioButtonLavender) { + target2.returnAccountColor("#D297FC"); + } else if (selectedId == R.id.radioButtonJasmine) { + target2.returnAccountColor("#FFFFFF"); + } else if (selectedId == R.id.radioButtonCitrus) { + target2.returnAccountColor("#FFFF99"); + } else if (selectedId == R.id.radioButtonSakura) { + target2.returnAccountColor("#FFECEF"); + } + + } + dismiss(); + } + }); + + return dialog; + } + } \ No newline at end of file