diff --git a/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java b/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java index 79cca26..bb12093 100644 --- a/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java @@ -1,5 +1,6 @@ package org.ntlab.irisclient; +import android.content.DialogInterface; import android.content.ClipData; import android.content.ClipDescription; import android.content.ClipboardManager; @@ -17,6 +18,7 @@ import com.google.android.material.snackbar.Snackbar; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; @@ -48,6 +50,33 @@ String belongs; Boolean isMaster; + private void homeButton(RoomViewModel roomViewModel){ + String strTitle = "ホーム画面に戻ってよろしいですか?"; + String strMessage = "退出すると部屋は削除されます"; + + AlertDialog.Builder builder; + builder = new AlertDialog.Builder(this); + builder.setMessage(strMessage); + builder.setTitle(strTitle); + builder.setPositiveButton("ok", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + roomViewModel.ownerLeaving(roomId , myName); + + Intent i = new Intent(OwnerRoomActivity.this, MainActivity.class); + startActivity(i); + } + }); + builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + builder.create(); + builder.show(); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -102,6 +131,7 @@ Button blueMasterButton = (Button) findViewById(R.id.beBlueMaster); Button blueSpyButton = (Button) findViewById(R.id.beBlueSpy); ImageButton copyButton = (ImageButton) findViewById(R.id.copyButton); + ImageButton homeButton = (ImageButton) findViewById(R.id.homeButton); //OwnerRoom専用ボタン Button randomButton = (Button) findViewById(R.id.random); @@ -172,6 +202,13 @@ } }); + //ホームボタン + homeButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + homeButton(roomViewModel); + } + }); + //--------------------------------------------------------------- //settings情報 String s = "設定\\nお絵描き";