Merge branch 'master' into Setup

This commit is contained in:
Ekamo-11 2024-06-11 15:55:12 +09:00
commit 86e77532dc
4 changed files with 144 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

@ -0,0 +1,66 @@
package com.example.oplogy;
import android.util.Log;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.Timestamp;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
import java.util.List;
import java.util.Map;
public class FirestoreReception {
private FirebaseFirestore db;
public FirestoreReception() {
db = FirebaseFirestore.getInstance();
}
//ClassIdを引数にデータの作成を行う
public void getDocumentsByClassId(int classId) {
CollectionReference collectionRef = db.collection("QuestionnaireForms");
// classIdが引数のものを取得する
collectionRef.whereEqualTo("classId", classId).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
// データの取得に成功した場合
for (QueryDocumentSnapshot document : task.getResult()) {
Map<String, Object> data = document.getData();
// デバッグ用のログ出力
Log.d("FirestoreReception", "Document ID: " + document.getId());
Log.d("FirestoreReception", "Data: " + data);
// ここでデータを取得し必要に応じて処理を行います
// String parentName = (String) data.get("patronName");
// String childName = (String) data.get("childName");
// String studentId = (String) data.get("studentNumber");
//// Timestamp address = (Timestamp) data.get("address");
// List<Timestamp> firstDay = (List<Timestamp>) data.get("firstDay");
// List<Timestamp> secondDay = (List<Timestamp>) data.get("secondDay");
// List<Timestamp> thirdDay = (List<Timestamp>) data.get("thirdDay");
//
// // 取得したデータを使って必要な処理を行う
// Log.d("FirestoreReception", "ParentName: " + parentName);
// Log.d("FirestoreReception", "ChildName: " + childName);
// Log.d("FirestoreReception", "StudentNumber: " + studentId);
//// Log.d("FirestoreReception", "Address: " + address.toDate());
// Log.d("FirestoreReception", "First Day: " + firstDay);
// Log.d("FirestoreReception", "Second Day: " + secondDay);
// Log.d("FirestoreReception", "Third Day: " + thirdDay);
}
} else {
Log.w("FirestoreReception", "Error getting documents.", task.getException());
}
}
});
}
}

View File

@ -1,13 +1,19 @@
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;
import com.google.firebase.firestore.FirebaseFirestore;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
@ -28,6 +34,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private int previousRoot = 0; //元の画像のインデックス
// 提出状況のTextViewとImageView
private TextView submission;
//firestoreの受信関連
private FirebaseFirestore db;
private FirestoreReception firestoreReception;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -51,6 +63,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
submission = findViewById(R.id.submission);
submission.setOnClickListener(this);
// firestoreの受信関連
db = FirebaseFirestore.getInstance();
firestoreReception = new FirestoreReception();
firestoreReception.getDocumentsByClassId(100);
}
@ -61,8 +81,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 +102,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();
}
}