入力した情報を変数に入れる機能を作成しました、後はRoomに受け渡すだけです
This commit is contained in:
parent
efbd0703be
commit
1e15a0626a
|
@ -6,14 +6,18 @@ import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,98 +28,153 @@ public class SetUpActivity extends FragmentActivity
|
||||||
String startPoint;
|
String startPoint;
|
||||||
String startTime;
|
String startTime;
|
||||||
String endTime;
|
String endTime;
|
||||||
String breakTime;
|
String intervalTime;
|
||||||
|
String startBreakTime;
|
||||||
|
String endBreakTime;
|
||||||
int totalStudent;
|
int totalStudent;
|
||||||
private TextView setTeacherName;
|
private TextView setTeacherName;
|
||||||
private TextView setStartPoint;
|
private TextView setStartPoint;
|
||||||
private TextView setStartTime;
|
private TextView setStartTime;
|
||||||
private TextView setEndTime;
|
private TextView setEndTime;
|
||||||
private TextView setBreakTime;
|
private TextView setStartBreakTime;
|
||||||
private RadioButton setTenMinute;
|
private TextView setEndBreakTime;
|
||||||
private RadioButton setFifteenMinute;
|
|
||||||
private RadioButton setThirtyMinute;
|
|
||||||
private TextView setTotalStudent;
|
private TextView setTotalStudent;
|
||||||
private Button setUp;
|
private int isStartTimeSelected;
|
||||||
private boolean isStartTimeSelected = true; // デフォルトはstartTimeを選択
|
|
||||||
|
|
||||||
String startHourOfDay;
|
String stringHourOfDay;
|
||||||
String startMinute;
|
String stringMinute;
|
||||||
String endHourOfDay;
|
|
||||||
String endMinute;
|
|
||||||
|
|
||||||
|
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);
|
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
||||||
setStartPoint = findViewById(R.id.startPoint);
|
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
||||||
setStartTime = findViewById(R.id.startTime);
|
|
||||||
setEndTime = findViewById(R.id.endTime);
|
setStartTime = findViewById(R.id.startTime); //開始時刻
|
||||||
setBreakTime = findViewById(R.id.breakTime);
|
setStartTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG); //下線を引く
|
||||||
setTenMinute = findViewById(R.id.tenMinute);
|
setEndTime = findViewById(R.id.endTime); //終了時刻
|
||||||
setFifteenMinute = findViewById(R.id.fifteenMinute);
|
setEndTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||||
setThirtyMinute = findViewById(R.id.thirtyMinute);
|
|
||||||
setTotalStudent = findViewById(R.id.totalStudent);
|
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 = findViewById(R.id.setUpButton);
|
|
||||||
|
|
||||||
|
|
||||||
setUp.setOnClickListener(new View.OnClickListener() {
|
setUp.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
|
||||||
teacherName = setTeacherName.getText().toString();
|
teacherName = setTeacherName.getText().toString(); //各変数に値を挿入
|
||||||
Log.d(TAG, "Teacher Name: " + teacherName);
|
Log.d(TAG, "Teacher Name: " + teacherName);
|
||||||
startPoint = setStartPoint.getText().toString();
|
startPoint = setStartPoint.getText().toString();
|
||||||
Log.d(TAG, "Start Point: " + startPoint);
|
Log.d(TAG, "Start Point: " + startPoint);
|
||||||
startTime = startHourOfDay + startMinute;
|
Log.d(TAG, "Start Time" + startTime);
|
||||||
Log.d(TAG, "Start Time: " + startTime);
|
Log.d(TAG, "End Time" + endTime);
|
||||||
endTime = endHourOfDay + endMinute;
|
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
||||||
Log.d(TAG, "End Time: " + endTime);
|
intervalTime = "10";
|
||||||
breakTime = setBreakTime.getText().toString();
|
} else if (setFifteenMinute.isChecked()) {
|
||||||
Log.d(TAG, "Break Time: " + breakTime);
|
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());
|
totalStudent = Integer.parseInt(setTotalStudent.getText().toString());
|
||||||
|
Log.d(TAG, "Total Student" + totalStudent);
|
||||||
Log.d(TAG, "onClick: できてるよ");
|
Log.d(TAG, "onClick: できてるよ");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setStartTime.setOnClickListener(new View.OnClickListener() {
|
startTimeSetButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
isStartTimeSelected = true;
|
isStartTimeSelected = 1; //ボタンの判別
|
||||||
|
showTimePickerDialog(); //TimePeckerの表示
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
endTimeSetButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
isStartTimeSelected = 2;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setEndTime.setOnClickListener(new View.OnClickListener() {
|
setStartBreakTime.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
isStartTimeSelected = false;
|
isStartTimeSelected = 3;
|
||||||
|
showTimePickerDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setEndBreakTime.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
isStartTimeSelected = 4;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint({"DefaultLocale", "SetTextI18n"})
|
||||||
@Override
|
@Override
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||||
String str = String.format(Locale.US, "%d:%d", hourOfDay, minute); // Textviewに保存する形式を設定
|
String str = String.format(Locale.US, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
||||||
|
|
||||||
if (isStartTimeSelected) { //押した場所を判定して、押したほうにだけ挿入する
|
if (isStartTimeSelected == 1) { //押した場所を判定して、押したほうにだけ挿入する
|
||||||
startHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDay = String.format("%02d", hourOfDay); //時を取得
|
||||||
startMinute = String.format("%02d", minute);
|
stringMinute = String.format("%02d", minute); //分を取得
|
||||||
setStartTime.setText(str);
|
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 {
|
} else if (isStartTimeSelected == 3) {
|
||||||
endHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
endMinute = String.format("%02d", minute);
|
stringMinute = String.format("%02d", minute);
|
||||||
setEndTime.setText(str);
|
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を表示する
|
private void showTimePickerDialog() { // Dialogを表示する
|
||||||
DialogFragment newFragment = new TimePick();
|
DialogFragment newFragment = new TimePick();
|
||||||
newFragment.show(getSupportFragmentManager(), "timePicker");
|
newFragment.show(getSupportFragmentManager(), "timePicker");
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/toMain"
|
android:id="@+id/toMain"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left"
|
android:layout_gravity="left"
|
||||||
|
android:paddingStart="20dp"
|
||||||
android:text="🔙"
|
android:text="🔙"
|
||||||
android:textSize="50dp"
|
android:textSize="50dp"
|
||||||
tools:ignore="RtlCompat" />
|
tools:ignore="RtlCompat" />
|
||||||
|
@ -85,14 +86,26 @@
|
||||||
android:text="@string/startTime"
|
android:text="@string/startTime"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/startTime"
|
android:id="@+id/startTime"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:text=" "
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:textAlignment="center"
|
||||||
android:autofillHints=""
|
android:autofillHints=""
|
||||||
android:inputType=""
|
android:inputType=""
|
||||||
tools:ignore="LabelFor"/>
|
tools:ignore="LabelFor"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/startTimeSetButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="65dp"
|
||||||
|
android:layout_marginEnd="65dp"
|
||||||
|
android:text="@string/timeSet"
|
||||||
|
tools:ignore="DuplicateIds" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -108,14 +121,25 @@
|
||||||
android:text="@string/endTime"
|
android:text="@string/endTime"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/endTime"
|
android:id="@+id/endTime"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:text=" "
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:textAlignment="center"
|
||||||
android:autofillHints=""
|
android:autofillHints=""
|
||||||
android:inputType=""
|
android:inputType=""
|
||||||
tools:ignore="LabelFor"/>
|
tools:ignore="LabelFor"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/endTimeSetButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/timeSet"
|
||||||
|
android:layout_marginStart="65dp"
|
||||||
|
android:layout_marginEnd="65dp"
|
||||||
|
tools:ignore="DuplicateIds" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -172,25 +196,51 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="10dp"
|
android:weightSum="10"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="90sp"
|
android:layout_width="90sp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/breakTime"
|
android:gravity="center"
|
||||||
android:gravity="center"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/breakTime" />
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/breakTime"
|
android:id="@+id/startBreakTime"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="例)30分➝30 1時間半➝90"
|
android:hint=" から "
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:textAlignment="center"
|
||||||
android:autofillHints=""
|
android:autofillHints=""
|
||||||
|
android:layout_weight="4"
|
||||||
android:inputType=""
|
android:inputType=""
|
||||||
tools:ignore="LabelFor"/>
|
tools:ignore="LabelFor"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="~"
|
||||||
|
android:textSize="30dp"
|
||||||
|
android:paddingStart="30dp"
|
||||||
|
android:paddingEnd="30dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/endBreakTime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:hint=" まで "
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:layout_weight="4"
|
||||||
|
android:inputType=""
|
||||||
|
tools:ignore="LabelFor"/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -10,4 +10,5 @@
|
||||||
<string name="intervalTime">訪問間隔</string>
|
<string name="intervalTime">訪問間隔</string>
|
||||||
<string name="breakTime">休憩時間</string>
|
<string name="breakTime">休憩時間</string>
|
||||||
<string name="totalStudent">生徒の人数</string>
|
<string name="totalStudent">生徒の人数</string>
|
||||||
|
<string name="timeSet">時刻設定</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user