commit
1e954780cc
11
app/src/main/java/com/example/oplogy/AppDatabase.java
Normal file
11
app/src/main/java/com/example/oplogy/AppDatabase.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package com.example.oplogy;
|
||||||
|
import androidx.room.Database;
|
||||||
|
import androidx.room.RoomDatabase;
|
||||||
|
import androidx.room.TypeConverters;
|
||||||
|
|
||||||
|
@Database(entities = {QuestionnaireForm.class}, version = 1)
|
||||||
|
@TypeConverters({Converters.class})
|
||||||
|
public abstract class AppDatabase extends RoomDatabase {
|
||||||
|
// データベースにアクセスするためのメソッドを提供する
|
||||||
|
public abstract QuestionnaireFormDao questionnaireFormDao();
|
||||||
|
}
|
39
app/src/main/java/com/example/oplogy/Converters.java
Normal file
39
app/src/main/java/com/example/oplogy/Converters.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package com.example.oplogy;
|
||||||
|
import androidx.room.TypeConverter;
|
||||||
|
|
||||||
|
import com.google.firebase.Timestamp;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class Converters {
|
||||||
|
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.JAPAN);
|
||||||
|
|
||||||
|
|
||||||
|
// タイムスタンプを文字列(yyyy-mm-dd,日時)に変換
|
||||||
|
@TypeConverter
|
||||||
|
public static List<String> fromTimestampList(List<Timestamp> timestamps) {
|
||||||
|
List<String> strings = new ArrayList<>();
|
||||||
|
for (Timestamp timestamp : timestamps) {
|
||||||
|
strings.add(format.format(timestamp.toDate()));
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeConverter
|
||||||
|
public static List<Timestamp> toTimestampList(List<String> strings) {
|
||||||
|
List<Timestamp> timestamps = new ArrayList<>();
|
||||||
|
for (String string : strings) {
|
||||||
|
try {
|
||||||
|
Date date = format.parse(string);
|
||||||
|
timestamps.add(new Timestamp(date));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return timestamps;
|
||||||
|
}
|
||||||
|
}
|
20
app/src/main/java/com/example/oplogy/QuestionnaireForm.java
Normal file
20
app/src/main/java/com/example/oplogy/QuestionnaireForm.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package com.example.oplogy;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class QuestionnaireForm {
|
||||||
|
//主キー
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
public int id;
|
||||||
|
|
||||||
|
//その他フィールド
|
||||||
|
public int classId;
|
||||||
|
public String patronName;
|
||||||
|
public String address;
|
||||||
|
public String firstDay;
|
||||||
|
public int studentNumber;
|
||||||
|
public String childName;
|
||||||
|
public String thirdDay;
|
||||||
|
public String secondDay;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.example.oplogy;
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface QuestionnaireFormDao {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM QuestionnaireForm")
|
||||||
|
List<QuestionnaireForm> getAll();
|
||||||
|
|
||||||
|
// このメソッドは、QuestionnaireFormのリストを受け取り、それらをデータベースに挿入します。
|
||||||
|
@Insert
|
||||||
|
void insertAll(QuestionnaireForm... questionnaireForms);
|
||||||
|
}
|
|
@ -1,14 +1,164 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.TimePickerDialog;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
public class SetUpActivity extends AppCompatActivity {
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
public class SetUpActivity extends FragmentActivity
|
||||||
|
implements TimePickerDialog.OnTimeSetListener {
|
||||||
|
|
||||||
|
String teacherName;
|
||||||
|
String startPoint;
|
||||||
|
String startTime;
|
||||||
|
String endTime;
|
||||||
|
String intervalTime;
|
||||||
|
String startBreakTime;
|
||||||
|
String endBreakTime;
|
||||||
|
int totalStudent;
|
||||||
|
private TextView setTeacherName;
|
||||||
|
private TextView setStartPoint;
|
||||||
|
private TextView setStartTime;
|
||||||
|
private TextView setEndTime;
|
||||||
|
private TextView setStartBreakTime;
|
||||||
|
private TextView setEndBreakTime;
|
||||||
|
private TextView setTotalStudent;
|
||||||
|
private int isStartTimeSelected;
|
||||||
|
|
||||||
|
String stringHourOfDay;
|
||||||
|
String stringMinute;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Button startTimeSetButton;
|
||||||
|
Button endTimeSetButton;
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_set_up);
|
setContentView(R.layout.activity_set_up);
|
||||||
|
|
||||||
|
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
||||||
|
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
||||||
|
|
||||||
|
setStartTime = findViewById(R.id.startTime); //開始時刻
|
||||||
|
setStartTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG); //下線を引く
|
||||||
|
setEndTime = findViewById(R.id.endTime); //終了時刻
|
||||||
|
setEndTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
|
||||||
|
RadioButton setTenMinute = findViewById(R.id.tenMinute); //訪問間隔(10分)
|
||||||
|
RadioButton setFifteenMinute = findViewById(R.id.fifteenMinute); //訪問間隔(15分)
|
||||||
|
RadioButton setThirtyMinute = findViewById(R.id.thirtyMinute); //訪問間隔(30分)
|
||||||
|
|
||||||
|
setStartBreakTime = findViewById(R.id.startBreakTime); //休憩開始時刻
|
||||||
|
setStartBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
setEndBreakTime = findViewById(R.id.endBreakTime); //休憩終了時刻
|
||||||
|
setEndBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
|
||||||
|
setTotalStudent = findViewById(R.id.totalStudent); //クラスの人数
|
||||||
|
|
||||||
|
startTimeSetButton = findViewById(R.id.startTimeSetButton); //開始時刻を設定するためのボタン
|
||||||
|
endTimeSetButton = findViewById(R.id.endTimeSetButton); //終了時刻を設定するためのボタン
|
||||||
|
|
||||||
|
Button setUp = findViewById(R.id.setUpButton); //画面下の設定ボタン
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setUp.setOnClickListener(view -> {
|
||||||
|
|
||||||
|
teacherName = setTeacherName.getText().toString(); //各変数に値を挿入
|
||||||
|
Log.d(TAG, "Teacher Name: " + teacherName);
|
||||||
|
startPoint = setStartPoint.getText().toString();
|
||||||
|
Log.d(TAG, "Start Point: " + startPoint);
|
||||||
|
Log.d(TAG, "Start Time" + startTime);
|
||||||
|
Log.d(TAG, "End Time" + endTime);
|
||||||
|
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
||||||
|
intervalTime = "10";
|
||||||
|
} else if (setFifteenMinute.isChecked()) {
|
||||||
|
intervalTime = "15";
|
||||||
|
} else if (setThirtyMinute.isChecked()) {
|
||||||
|
intervalTime = "30";
|
||||||
|
} else {
|
||||||
|
intervalTime = "0";
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Interval Time" + intervalTime);
|
||||||
|
Log.d(TAG, "Start Break Time" + startBreakTime);
|
||||||
|
Log.d(TAG, "End Break Time" + endBreakTime);
|
||||||
|
totalStudent = Integer.parseInt(setTotalStudent.getText().toString());
|
||||||
|
Log.d(TAG, "Total Student" + totalStudent);
|
||||||
|
Log.d(TAG, "onClick: できてるよ");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
startTimeSetButton.setOnClickListener(v -> {
|
||||||
|
isStartTimeSelected = 1; //ボタンの判別
|
||||||
|
showTimePickerDialog(); //TimePeckerの表示
|
||||||
|
});
|
||||||
|
|
||||||
|
endTimeSetButton.setOnClickListener(v -> {
|
||||||
|
isStartTimeSelected = 2;
|
||||||
|
showTimePickerDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
setStartBreakTime.setOnClickListener(v -> {
|
||||||
|
isStartTimeSelected = 3;
|
||||||
|
showTimePickerDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
setEndBreakTime.setOnClickListener(v -> {
|
||||||
|
isStartTimeSelected = 4;
|
||||||
|
showTimePickerDialog();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint({"DefaultLocale", "SetTextI18n"})
|
||||||
|
@Override
|
||||||
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||||
|
String str = String.format(Locale.US, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
||||||
|
|
||||||
|
if (isStartTimeSelected == 1) { //押した場所を判定して、押したほうにだけ挿入する
|
||||||
|
stringHourOfDay = String.format("%02d", hourOfDay); //時を取得
|
||||||
|
stringMinute = String.format("%02d", minute); //分を取得
|
||||||
|
startTime = stringHourOfDay + stringMinute; //時と分を結合し四桁の文字列に
|
||||||
|
setStartTime.setText(" " + str + " "); //画面に出力
|
||||||
|
|
||||||
|
} else if (isStartTimeSelected == 2) {
|
||||||
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
|
stringMinute = String.format("%02d", minute);
|
||||||
|
endTime = stringHourOfDay + stringMinute;
|
||||||
|
setEndTime.setText(" " + str + " ");
|
||||||
|
|
||||||
|
} else if (isStartTimeSelected == 3) {
|
||||||
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
|
stringMinute = String.format("%02d", minute);
|
||||||
|
startBreakTime =stringHourOfDay + stringMinute;
|
||||||
|
setStartBreakTime.setText(" " + str + " ");
|
||||||
|
|
||||||
|
} else if (isStartTimeSelected == 4) {
|
||||||
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
|
stringMinute = String.format("%02d", minute);
|
||||||
|
endBreakTime = stringHourOfDay + stringMinute;
|
||||||
|
setEndBreakTime.setText(" " + str + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void showTimePickerDialog() { // Dialogを表示する
|
||||||
|
DialogFragment newFragment = new com.example.oplogy.TimePick();
|
||||||
|
newFragment.show(getSupportFragmentManager(), "timePicker");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,164 +0,0 @@
|
||||||
package com.example.oplogy;
|
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.TimePickerDialog;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.TimePicker;
|
|
||||||
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
|
|
||||||
public class SetUpActivity extends FragmentActivity
|
|
||||||
implements TimePickerDialog.OnTimeSetListener {
|
|
||||||
|
|
||||||
String teacherName;
|
|
||||||
String startPoint;
|
|
||||||
String startTime;
|
|
||||||
String endTime;
|
|
||||||
String intervalTime;
|
|
||||||
String startBreakTime;
|
|
||||||
String endBreakTime;
|
|
||||||
int totalStudent;
|
|
||||||
private TextView setTeacherName;
|
|
||||||
private TextView setStartPoint;
|
|
||||||
private TextView setStartTime;
|
|
||||||
private TextView setEndTime;
|
|
||||||
private TextView setStartBreakTime;
|
|
||||||
private TextView setEndBreakTime;
|
|
||||||
private TextView setTotalStudent;
|
|
||||||
private int isStartTimeSelected;
|
|
||||||
|
|
||||||
String stringHourOfDay;
|
|
||||||
String stringMinute;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Button startTimeSetButton;
|
|
||||||
Button endTimeSetButton;
|
|
||||||
@SuppressLint("MissingInflatedId")
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_set_up);
|
|
||||||
|
|
||||||
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
|
||||||
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
|
||||||
|
|
||||||
setStartTime = findViewById(R.id.startTime); //開始時刻
|
|
||||||
setStartTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG); //下線を引く
|
|
||||||
setEndTime = findViewById(R.id.endTime); //終了時刻
|
|
||||||
setEndTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
|
||||||
|
|
||||||
RadioButton setTenMinute = findViewById(R.id.tenMinute); //訪問間隔(10分)
|
|
||||||
RadioButton setFifteenMinute = findViewById(R.id.fifteenMinute); //訪問間隔(15分)
|
|
||||||
RadioButton setThirtyMinute = findViewById(R.id.thirtyMinute); //訪問間隔(30分)
|
|
||||||
|
|
||||||
setStartBreakTime = findViewById(R.id.startBreakTime); //休憩開始時刻
|
|
||||||
setStartBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
|
||||||
setEndBreakTime = findViewById(R.id.endBreakTime); //休憩終了時刻
|
|
||||||
setEndBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
|
||||||
|
|
||||||
setTotalStudent = findViewById(R.id.totalStudent); //クラスの人数
|
|
||||||
|
|
||||||
startTimeSetButton = findViewById(R.id.startTimeSetButton); //開始時刻を設定するためのボタン
|
|
||||||
endTimeSetButton = findViewById(R.id.endTimeSetButton); //終了時刻を設定するためのボタン
|
|
||||||
|
|
||||||
Button setUp = findViewById(R.id.setUpButton); //画面下の設定ボタン
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setUp.setOnClickListener(view -> {
|
|
||||||
|
|
||||||
teacherName = setTeacherName.getText().toString(); //各変数に値を挿入
|
|
||||||
Log.d(TAG, "Teacher Name: " + teacherName);
|
|
||||||
startPoint = setStartPoint.getText().toString();
|
|
||||||
Log.d(TAG, "Start Point: " + startPoint);
|
|
||||||
Log.d(TAG, "Start Time" + startTime);
|
|
||||||
Log.d(TAG, "End Time" + endTime);
|
|
||||||
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
|
||||||
intervalTime = "10";
|
|
||||||
} else if (setFifteenMinute.isChecked()) {
|
|
||||||
intervalTime = "15";
|
|
||||||
} else if (setThirtyMinute.isChecked()) {
|
|
||||||
intervalTime = "30";
|
|
||||||
} else {
|
|
||||||
intervalTime = "0";
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Interval Time" + intervalTime);
|
|
||||||
Log.d(TAG, "Start Break Time" + startBreakTime);
|
|
||||||
Log.d(TAG, "End Break Time" + endBreakTime);
|
|
||||||
totalStudent = Integer.parseInt(setTotalStudent.getText().toString());
|
|
||||||
Log.d(TAG, "Total Student" + totalStudent);
|
|
||||||
Log.d(TAG, "onClick: できてるよ");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
startTimeSetButton.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 1; //ボタンの判別
|
|
||||||
showTimePickerDialog(); //TimePeckerの表示
|
|
||||||
});
|
|
||||||
|
|
||||||
endTimeSetButton.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 2;
|
|
||||||
showTimePickerDialog();
|
|
||||||
});
|
|
||||||
|
|
||||||
setStartBreakTime.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 3;
|
|
||||||
showTimePickerDialog();
|
|
||||||
});
|
|
||||||
|
|
||||||
setEndBreakTime.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 4;
|
|
||||||
showTimePickerDialog();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint({"DefaultLocale", "SetTextI18n"})
|
|
||||||
@Override
|
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
|
||||||
String str = String.format(Locale.US, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
|
||||||
|
|
||||||
if (isStartTimeSelected == 1) { //押した場所を判定して、押したほうにだけ挿入する
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay); //時を取得
|
|
||||||
stringMinute = String.format("%02d", minute); //分を取得
|
|
||||||
startTime = stringHourOfDay + stringMinute; //時と分を結合し四桁の文字列に
|
|
||||||
setStartTime.setText(" " + str + " "); //画面に出力
|
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 2) {
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
|
||||||
stringMinute = String.format("%02d", minute);
|
|
||||||
endTime = stringHourOfDay + stringMinute;
|
|
||||||
setEndTime.setText(" " + str + " ");
|
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 3) {
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
|
||||||
stringMinute = String.format("%02d", minute);
|
|
||||||
startBreakTime =stringHourOfDay + stringMinute;
|
|
||||||
setStartBreakTime.setText(" " + str + " ");
|
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 4) {
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
|
||||||
stringMinute = String.format("%02d", minute);
|
|
||||||
endBreakTime = stringHourOfDay + stringMinute;
|
|
||||||
setEndBreakTime.setText(" " + str + " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void showTimePickerDialog() { // Dialogを表示する
|
|
||||||
DialogFragment newFragment = new com.example.oplogy.TimePick();
|
|
||||||
newFragment.show(getSupportFragmentManager(), "timePicker");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user