datePicker #30
|
@ -5,8 +5,9 @@
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
<option name="gradleJvm" value="JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -35,11 +37,23 @@ public class CreateRoot {
|
||||||
|
|
||||||
boolean secondDuplicates;
|
boolean secondDuplicates;
|
||||||
|
|
||||||
String testdata[] = {"20240604", "20240605", "20240606"};
|
// String testdata[] = {"20240604", "20240605", "20240606"};
|
||||||
|
String[] testdata;
|
||||||
|
|
||||||
|
|
||||||
public CreateRoot(AppCompatActivity activity) {
|
public CreateRoot(AppCompatActivity activity) {
|
||||||
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
|
SharedPreferences sharedPreferences= activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE);
|
||||||
|
String day1=sharedPreferences.getString("day1",null);
|
||||||
|
String day2=sharedPreferences.getString("day2",null);
|
||||||
|
String day3=sharedPreferences.getString("day3",null);
|
||||||
|
|
||||||
|
testdata= new String[]{day1, day2, day3};
|
||||||
|
|
||||||
|
for(String day:testdata){
|
||||||
|
Log.d("sharepre","day"+day);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean receiveData(List<MyDataClass> myDataList) {
|
public Boolean receiveData(List<MyDataClass> myDataList) {
|
||||||
|
|
|
@ -1,4 +1,35 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
public class DatePick {
|
import android.app.DatePickerDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class DatePick extends DialogFragment implements
|
||||||
|
DatePickerDialog.OnDateSetListener {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstantState) {
|
||||||
|
|
||||||
|
//デフォルトのタイムゾーンおよびロケールを使用してカレンダを取得
|
||||||
|
final Calendar c = Calendar.getInstance();
|
||||||
|
int year = c.get(Calendar.YEAR);
|
||||||
|
int month = c.get(Calendar.MONTH);
|
||||||
|
int day = c.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
|
return new DatePickerDialog(requireActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), year, month, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,17 @@ package com.example.oplogy;
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.media.Image;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -26,10 +29,13 @@ import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
|
||||||
public class SetUpActivity extends FragmentActivity
|
public class SetUpActivity extends FragmentActivity
|
||||||
implements TimePickerDialog.OnTimeSetListener {
|
implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
|
||||||
|
|
||||||
String teacherName;
|
String teacherName;
|
||||||
String startPoint;
|
String startPoint;
|
||||||
|
String firstDay;
|
||||||
|
String secondDay;
|
||||||
|
String thirdDay;
|
||||||
String startTime;
|
String startTime;
|
||||||
String endTime;
|
String endTime;
|
||||||
String intervalTime;
|
String intervalTime;
|
||||||
|
@ -43,8 +49,14 @@ public class SetUpActivity extends FragmentActivity
|
||||||
private TextView setStartBreakTime;
|
private TextView setStartBreakTime;
|
||||||
private TextView setEndBreakTime;
|
private TextView setEndBreakTime;
|
||||||
private TextView setTotalStudent;
|
private TextView setTotalStudent;
|
||||||
|
private int isDateSelected;
|
||||||
private int isStartTimeSelected;
|
private int isStartTimeSelected;
|
||||||
|
|
||||||
|
String stringYear;
|
||||||
|
String stringMonth;
|
||||||
|
String stringDayOfMonth;
|
||||||
|
|
||||||
|
|
||||||
String stringHourOfDay;
|
String stringHourOfDay;
|
||||||
String stringMinute;
|
String stringMinute;
|
||||||
|
|
||||||
|
@ -95,7 +107,6 @@ public class SetUpActivity extends FragmentActivity
|
||||||
Intent intent = new Intent(SetUpActivity.this,MainActivity.class); //main画面へ戻る処理
|
Intent intent = new Intent(SetUpActivity.this,MainActivity.class); //main画面へ戻る処理
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
//TODO:.SetUpの際に、classIdを挿入すること
|
|
||||||
|
|
||||||
setUp.setOnClickListener(view -> {
|
setUp.setOnClickListener(view -> {
|
||||||
|
|
||||||
|
@ -103,6 +114,9 @@ public class SetUpActivity extends FragmentActivity
|
||||||
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);
|
||||||
|
Log.d(TAG, "First Day:" + firstDay);
|
||||||
|
Log.d(TAG, "Second Day:" + secondDay);
|
||||||
|
Log.d(TAG, "Third Day:" + thirdDay);
|
||||||
Log.d(TAG, "Start Time" + startTime);
|
Log.d(TAG, "Start Time" + startTime);
|
||||||
Log.d(TAG, "End Time" + endTime);
|
Log.d(TAG, "End Time" + endTime);
|
||||||
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
||||||
|
@ -160,6 +174,15 @@ public class SetUpActivity extends FragmentActivity
|
||||||
setUpTableDao.insertAll(setUpTable);
|
setUpTableDao.insertAll(setUpTable);
|
||||||
runOnUiThread(() -> Toast.makeText(SetUpActivity.this, "登録しました", Toast.LENGTH_SHORT).show());
|
runOnUiThread(() -> Toast.makeText(SetUpActivity.this, "登録しました", Toast.LENGTH_SHORT).show());
|
||||||
}
|
}
|
||||||
|
//家庭訪問日を保存する共有プリファレンス
|
||||||
|
SharedPreferences sharedPreferences=getSharedPreferences("visitingDate",MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor= sharedPreferences.edit();
|
||||||
|
|
||||||
|
editor.putString("day1",firstDay);
|
||||||
|
editor.putString("day2",secondDay);
|
||||||
|
editor.putString("day3",thirdDay);
|
||||||
|
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -167,37 +190,37 @@ public class SetUpActivity extends FragmentActivity
|
||||||
});
|
});
|
||||||
|
|
||||||
setFirstDay.setOnClickListener(v ->{
|
setFirstDay.setOnClickListener(v ->{
|
||||||
isStartTimeSelected = 1;
|
isDateSelected = 1;
|
||||||
showTimePickerDialog();
|
showDatePickerDialog(); //DatePickerの表示
|
||||||
});
|
});
|
||||||
|
|
||||||
setSecondDay.setOnClickListener(v ->{
|
setSecondDay.setOnClickListener(v ->{
|
||||||
|
isDateSelected = 2;
|
||||||
|
showDatePickerDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
setThirdDay.setOnClickListener(v ->{
|
||||||
|
isDateSelected = 3;
|
||||||
|
showDatePickerDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
setStartTimeButton.setOnClickListener(v -> {
|
||||||
|
isStartTimeSelected = 1; //ボタンの判別
|
||||||
|
showTimePickerDialog(); //TimePickerの表示
|
||||||
|
});
|
||||||
|
|
||||||
|
setEndTimeButton.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 2;
|
isStartTimeSelected = 2;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
setThirdDay.setOnClickListener(v ->{
|
setStartBreakTime.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 3;
|
isStartTimeSelected = 3;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
setStartTimeButton.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 4; //ボタンの判別
|
|
||||||
showTimePickerDialog(); //TimePeckerの表示
|
|
||||||
});
|
|
||||||
|
|
||||||
setEndTimeButton.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 5;
|
|
||||||
showTimePickerDialog();
|
|
||||||
});
|
|
||||||
|
|
||||||
setStartBreakTime.setOnClickListener(v -> {
|
|
||||||
isStartTimeSelected = 6;
|
|
||||||
showTimePickerDialog();
|
|
||||||
});
|
|
||||||
|
|
||||||
setEndBreakTime.setOnClickListener(v -> {
|
setEndBreakTime.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 7;
|
isStartTimeSelected = 4;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -222,48 +245,59 @@ public class SetUpActivity extends FragmentActivity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDateSet(DatePicker datePicker, int year, int month, int dayOfMonth) { //Dateを成形する
|
||||||
|
// DatePickerDialogで選択された日付を処理する
|
||||||
|
String str = String.format(Locale.JAPAN, "%02d/%02d", month + 1, dayOfMonth); // TextViewに表示する日付の形式を設定
|
||||||
|
|
||||||
|
if (isDateSelected == 1) {
|
||||||
|
stringYear = String.valueOf(year); //年
|
||||||
|
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1); //月
|
||||||
|
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth); //日
|
||||||
|
firstDay = stringYear + stringMonth + stringDayOfMonth;
|
||||||
|
setFirstDay.setText(str);
|
||||||
|
} else if (isDateSelected == 2) {
|
||||||
|
stringYear = String.valueOf(year);
|
||||||
|
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1);
|
||||||
|
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
||||||
|
secondDay = stringYear + stringMonth + stringDayOfMonth;
|
||||||
|
setSecondDay.setText(str);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (isDateSelected == 3) {
|
||||||
|
stringYear = String.valueOf(year);
|
||||||
|
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1);
|
||||||
|
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
||||||
|
thirdDay = stringYear + stringMonth + stringDayOfMonth;
|
||||||
|
setThirdDay.setText(str);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint({"DefaultLocale", "SetTextI18n"})
|
@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, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
String str = String.format(Locale.JAPAN, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
||||||
|
|
||||||
if (isStartTimeSelected == 1) { //押した場所を判定して、押したほうにだけ挿入する
|
if (isStartTimeSelected == 1) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay); //時を取得
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute); //分を取得
|
stringMinute = String.format("%02d", minute);
|
||||||
startTime = stringHourOfDay + stringMinute; //時と分を結合し四桁の文字列に
|
startTime = stringHourOfDay + stringMinute;
|
||||||
setFirstDay.setText(str);
|
setStartTime.setText(str);
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 2) {
|
} else if (isStartTimeSelected == 2) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
|
||||||
stringMinute = String.format("%02d", minute);
|
|
||||||
endTime = stringHourOfDay + stringMinute;
|
|
||||||
setSecondDay.setText(str);
|
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 3) {
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
|
||||||
stringMinute = String.format("%02d", minute);
|
|
||||||
endTime = stringHourOfDay + stringMinute;
|
|
||||||
setThirdDay.setText(str);
|
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 4) {
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
|
||||||
stringMinute = String.format("%02d", minute);
|
|
||||||
endTime = stringHourOfDay + stringMinute;
|
|
||||||
setStartTime.setText(str);
|
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 5) {
|
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinute = String.format("%02d", minute);
|
||||||
endTime = stringHourOfDay + stringMinute;
|
endTime = stringHourOfDay + stringMinute;
|
||||||
setEndTime.setText(str);
|
setEndTime.setText(str);
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 6) {
|
} else if (isStartTimeSelected == 3) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinute = String.format("%02d", minute);
|
||||||
startBreakTime =stringHourOfDay + stringMinute;
|
startBreakTime =stringHourOfDay + stringMinute;
|
||||||
setStartBreakTime.setText(" " + str + " ");
|
setStartBreakTime.setText(" " + str + " ");
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 7) {
|
} else if (isStartTimeSelected == 4) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinute = String.format("%02d", minute);
|
||||||
endBreakTime = stringHourOfDay + stringMinute;
|
endBreakTime = stringHourOfDay + stringMinute;
|
||||||
|
@ -271,9 +305,14 @@ public class SetUpActivity extends FragmentActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showDatePickerDialog() {
|
||||||
|
DialogFragment newFragment = new DatePick();
|
||||||
|
newFragment.show(getSupportFragmentManager(), "datePicker");
|
||||||
|
}
|
||||||
|
|
||||||
private void showTimePickerDialog() { // Dialogを表示する
|
private void showTimePickerDialog() { // Dialogを表示する
|
||||||
DialogFragment newFragment = new TimePick();
|
DialogFragment newFragment = new TimePick();
|
||||||
newFragment.show(getSupportFragmentManager(), "timePicker");
|
newFragment.show(getSupportFragmentManager(), "timePicker");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application' version '8.0.2' apply false
|
id 'com.android.application' version '8.1.4' apply false
|
||||||
id 'com.android.library' version '8.0.2' apply false
|
id 'com.android.library' version '8.1.4' apply false
|
||||||
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
|
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user