ダイアログの作成

uuidの作成
This commit is contained in:
it232115 2024-06-11 15:47:22 +09:00
parent 248666695e
commit 7d2ee567f3
3 changed files with 62 additions and 13 deletions

29
app/google-services.json Normal file
View File

@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "317219128586",
"project_id": "oplogy-b6971",
"storage_bucket": "oplogy-b6971.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:317219128586:android:c29583456e8fbd5f12a6f3",
"android_client_info": {
"package_name": "com.example.oplogy"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDaULi2TFHLiscR7DSZBCKS08d76Rtb49c"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@ -1,14 +1,12 @@
package com.example.oplogy;
import androidx.appcompat.app.AppCompatActivity;
import java.util.UUID;
import android.os.Bundle;
public class CreateUUID {
public class CreateUUID extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create_uuid);
public static String generateUUID() {
// UUIDを生成する処理
UUID uuid = UUID.randomUUID();
return uuid.toString();
}
}

View File

@ -1,13 +1,17 @@
package com.example.oplogy;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
@ -61,8 +65,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// ID作成のクリック処理
if(view == creatUUID){
imageUuid.setImageResource(R.drawable.ischecked_uuid);
Intent toCreateUUID = new Intent(MainActivity.this, CreateUUID.class);
startActivity(toCreateUUID);
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
}
// セットアップのクリック処理
@ -83,9 +86,28 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Intent toSubmission = new Intent(MainActivity.this,SubmissionActivity.class);
startActivity(toSubmission);
}
}
private void showUUIDYesNoDialog() {
//ダイアログの表示
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("クラスID");
builder.setMessage("あなたのクラスIDを表示しますか");
//YESのときは初回はUUIDを生成表示
//二回目以降は保存されたUUIDを表示
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String classId = CreateUUID.generateUUID();//classIDにuuidが入ってる
Toast.makeText(MainActivity.this, "クラスID: " + classId, Toast.LENGTH_SHORT).show();//テスト用
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d("DialogNO","DialogでNoが選ばれました");
}
});
builder.show();
}
}