Compare commits

...

45 Commits

Author SHA1 Message Date
301d097cd6 Merge pull request '本番環境移行' (#60) from 本番環境以降 into master
Reviewed-on: #60
2024-07-24 06:34:15 +00:00
nemukemo
7bfda687cd 粉砕玉砕大喝采 2024-07-24 15:32:54 +09:00
nemukemo
c61e41a8ae setupが落ちる原因を取り除く
FirestoreReceptionを本番用にしてい
uuidもreturn値を固定解除
2024-07-24 15:29:17 +09:00
422e105808 Merge pull request 'アイコンや設定画面を切り離しなど' (#59) from murakumo_Home画面をぶっ壊す into master コンフリ起きない万歳
Reviewed-on: #59
2024-07-19 01:45:37 +00:00
nemukemo
856e125612 webpども:アプリアイコンのため
SettingView:設定画面作成
main:設定情報を切り離した
その他:intentの調整
2024-07-19 10:44:32 +09:00
2c0bb36c68 Merge pull request '背景色消して○で表現できるようにした。すごい' (#58) from murakumo_Mapに○を into master
Reviewed-on: #58
2024-07-17 05:30:25 +00:00
b2f452c6fe Merge pull request '提出状況-1問題の解決' (#57) from murakumo_提出状況-1問題 into master
Reviewed-on: #57
2024-07-17 05:28:44 +00:00
nemukemo
1c1f366bf8 背景色消して○で表現できるようにした 2024-07-17 14:27:08 +09:00
nemukemo
bb4912f123 uuid:値をテストデータに固定中
main:各メソッドが何の処理をしているかのコメント追加
SubmissionActivity:nullチェックと謎のコード削除
SubmissionAdapter:色のセットなどをメソッド化
submission.xml:recyclerviewがマッチョペアレントだったから-1されるフレンズでした。てへぺろ
2024-07-17 12:23:41 +09:00
f28fd3c4ff Merge pull request 'murakumo_URLコピペボタンの作成完了' (#56) from murakumo_URLコピペボタン into master oh year
Reviewed-on: #56
2024-07-16 05:32:54 +00:00
nemukemo
d3c94b5a7b コンクリ解消 2024-07-16 14:31:50 +09:00
nemukemo
98f35c6555 Merge branch 'master' into murakumo_URLコピペボタン
# Conflicts:
#	app/src/main/java/com/example/oplogy/MainActivity.java
2024-07-16 14:30:59 +09:00
nemukemo
6f968f2b9b 再コミット 2024-07-16 14:26:37 +09:00
9c523c1047 Merge pull request 'NowLoading作成完了' (#54) from murakumo_NowLoading into master
Reviewed-on: #54
2024-07-16 05:20:05 +00:00
nemukemo
52a03156a2 NowLoading作成完了 2024-07-16 14:15:35 +09:00
nemukemo
e7a7838c2b コピペボタンの作成
レイアウトを調整する必要あり
2024-07-16 00:31:15 +09:00
65edd2e9f8 Merge pull request 'マップ表示のバグ修正' (#53) from murakumo_classIdが0になる問題 into master
Reviewed-on: #53
2024-07-15 04:17:56 +00:00
nemukemo
4e20d0006f マップ表示のバグ修正 2024-07-14 01:12:56 +09:00
2f2c99cf6f Merge pull request 'classIdの表示する時、0になる問題を解決' (#51) from murakumo_classIdが0になる問題 into master
Reviewed-on: #51
2024-07-12 01:16:34 +00:00
nemukemo
ecbb551c35 classIdの表示する時、0になる問題を解決 2024-07-12 10:15:21 +09:00
8f606dd30d Merge pull request '・重複時のダイアログに保護者の情報が表示されるように調整しました。' (#50) from api into master
Reviewed-on: #50
2024-07-10 07:31:26 +00:00
fe7752e758 Merge branch 'master' into api
# Conflicts:
#	app/src/main/java/com/example/oplogy/MainActivity.java
2024-07-10 16:21:05 +09:00
6a5eca8000 ・重複時のダイアログに保護者の情報が表示されるように調整しました。
・その他細かなバグを修正しました。
2024-07-10 16:13:24 +09:00
362b7b5544 プルリクエスト 'ID作成時に表示をダイアログに変更、セットアップが終了していない場合にtoast表示を行い遷移しないように変更' (#49) from last into master
Reviewed-on: #49
2024-07-10 07:09:15 +00:00
nemukemo
356021beae ID,セットアップが終わっていない場合にtoast表示を行う 2024-07-10 16:07:02 +09:00
nemukemo
d96f67b09b Merge remote-tracking branch 'origin/master'
# Conflicts:
#	app/src/main/java/com/example/oplogy/FirestoreReception.java
2024-07-09 19:51:59 +09:00
nemukemo
634547622a あとでろるばすりゅ 2024-07-09 19:49:58 +09:00
2245d5a5b3 Merge pull request 'api' (#48) from api into master
Reviewed-on: #48
2024-07-09 10:45:07 +00:00
02212be21e Merge remote-tracking branch 'origin/api' into api 2024-07-09 19:44:46 +09:00
0534bc75d4 小林最終提出 2024-07-09 19:44:12 +09:00
823fa8a2c4 Merge pull request 'api' (#47) from api into master
Reviewed-on: #47
2024-07-09 03:10:45 +00:00
470abcd53e 全ての変数名に型名がわかるように追記 2024-07-09 12:10:14 +09:00
0652ce505b ルート表示の成功
maps.javaへのコメントとコードの可読性向上
2024-07-09 11:32:19 +09:00
46a00a3337 Merge pull request '以下の機能を追加' (#46) from finishing into master
Reviewed-on: #46
2024-07-08 22:47:56 +00:00
c8af823a46 以下の機能を追加
・CreateScheduleの再作成
・CreateScheduleによって生成されたスケジュールの順番に並んだ実際の緯度経度、保護者情報のmapへのピン刺し&スクロールビューへの表示
・スクロールビューの要素数が増えるにつれて無尽蔵に画面を覆いつくしmapが見えなくなる不具合の修正
・スクロールビューをタッチすると対応したピンにカメラがフォーカスされる機能の追加
・スケジュールの順番に合わせてピン間のルートを表示する機能の追加(APIの問題により未完成)
・Maps.javaにおいてピンの色とスクロールビューの色が対応していないかつ5種類以上の色が使えない問題の修正(GooglemapApiのピンでは特定の10色しか使えないらしい)
2024-07-09 07:47:25 +09:00
bf24921cd7 Merge pull request '菊池' (#38) from AlsoMaps into master
Reviewed-on: #38
2024-07-08 07:58:12 +00:00
54da345315 Merge branch 'master' into AlsoMaps
# Conflicts:
#	app/src/main/java/com/example/oplogy/CreateRoot.java
2024-07-08 16:57:53 +09:00
bc3c802e03 菊池
複数の日を入れれるように書き直しました。
大きさは今後直せますが、取り敢えず今い作ったコードでちゃんと動くのか試してください。
大きさは変わり次第報告します
2024-07-08 15:32:50 +09:00
5599ff7b1d 菊池
取り敢えず3日分でテストしてみました。
別々の値で入れていますので、問題ないかと思います。
2024-07-08 13:06:53 +09:00
f3a3733e16 Merge pull request '作業kan' (#44) from murakumo_dao追加 into master
Reviewed-on: #44
2024-07-08 03:41:38 +00:00
nemukemo
69cbdf41f0 作業kan 2024-07-08 12:41:04 +09:00
819e15de6f Merge pull request '・セットアップに設定した初期地点の緯度経度化' (#42) from finishing into master
Reviewed-on: #42
2024-07-08 03:14:48 +00:00
ba9a53af02 ・セットアップに設定した初期地点の緯度経度化 2024-07-08 12:13:43 +09:00
20a5100a6a 菊池
新しいレイアウトを作りました。
2024-07-08 11:45:58 +09:00
1b6e22f677 菊池
ピンと色が一致するようになり、ピンをクリックと名前などが見えるように設定しました。
Main画面でUUID作成を押したときに、(Yes/No)を押してもチェックが消えなかったのでそこの訂正もしました。
そこの変更も確認お願いします。
2024-07-07 22:08:44 +09:00
51 changed files with 1357 additions and 828 deletions

View File

@ -51,4 +51,12 @@ dependencies {
def room_version = "2.4.1" def room_version = "2.4.1"
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version"
} }
//Map用の依存関係の追加
dependencies {
implementation 'com.google.android.gms:play-services-maps:18.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.google.code.gson:gson:2.8.9' // Gsonライブラリの追加
}

View File

@ -3,6 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
tools:ignore="CoarseFineLocation" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -15,6 +18,9 @@
android:theme="@style/Theme.Oplogy" android:theme="@style/Theme.Oplogy"
tools:ignore="ExtraText" tools:ignore="ExtraText"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".SettingView"
android:exported="false" />
<activity <activity
android:name=".SetUpActivity" android:name=".SetUpActivity"
android:exported="false" /> android:exported="false" />
@ -37,14 +43,11 @@
android:name=".Maps" android:name=".Maps"
android:exported="false" android:exported="false"
android:label="@string/title_activity_maps" /> android:label="@string/title_activity_maps" />
<activity
android:name=".TutorialActivity"
android:exported="false" />
<activity <activity
android:name=".SubmissionActivity" android:name=".SubmissionActivity"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".RootSearchActivity" android:name=".CreateUUID"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".DialogFragment" android:name=".DialogFragment"

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

View File

@ -1,5 +1,4 @@
package com.example.oplogy; package com.example.oplogy;
import androidx.room.TypeConverter; import androidx.room.TypeConverter;
import com.google.firebase.Timestamp; import com.google.firebase.Timestamp;
@ -17,11 +16,11 @@ public class Converters {
// タイムスタンプを文字列(yyyy-mm-dd,日時)に変換 // タイムスタンプを文字列(yyyy-mm-dd,日時)に変換
@TypeConverter @TypeConverter
public static List<String> fromTimestampList(List<Timestamp> timestamps) { public static List<String> fromTimestampList(List<Timestamp> timestamps) {
List<String> strings = new ArrayList<>(); List<String> stringsList = new ArrayList<>();
for (Timestamp timestamp : timestamps) { for (Timestamp timestamp : timestamps) {
strings.add(format.format(timestamp.toDate())); stringsList.add(format.format(timestamp.toDate()));
} }
return strings; return stringsList;
} }
@TypeConverter @TypeConverter

View File

@ -42,21 +42,22 @@ public class CreateSchedule {
private final AppDatabase db; private final AppDatabase db;
private int arraySizeInt; private int arraySizeInt;
boolean notSecondDuplicatesBoolean = true;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue) private boolean notSecondDuplicatesBoolean;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
String[] date; String[] homeVisitDaysString;
public CreateSchedule(AppCompatActivity activity) { public CreateSchedule(AppCompatActivity activity) {
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build(); this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
this.notSecondDuplicatesBoolean = true; // 初期値をtrueに設定する
SharedPreferences sharedPreferences = activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE);
String firstDay = sharedPreferences.getString("day1", null); String firstDay = sharedPreferences.getString("day1", null);
String secondDay = sharedPreferences.getString("day2", null); String secondDay = sharedPreferences.getString("day2", null);
String thirdDay = sharedPreferences.getString("day3", null); String thirdDay = sharedPreferences.getString("day3", null);
date = new String[]{firstDay, secondDay, thirdDay}; Log.d("createSchedule","day1"+firstDay+"day2"+secondDay+"thirdday"+thirdDay);
homeVisitDaysString = new String[]{firstDay, secondDay, thirdDay};
} }
//MainActivityからデータを受け取る //MainActivityからデータを受け取る
@ -102,26 +103,31 @@ public class CreateSchedule {
boolean notDuplicatesBoolean = createSchedule(myDataList, intervalArrayInt); boolean notDuplicatesBoolean = createSchedule(myDataList, intervalArrayInt);
//スケジュールの重複の確認 //スケジュールの重複の確認
if (!notDuplicatesBoolean) { if (notDuplicatesBoolean) {
//スケジュールを基準にソートする
sortSchedule(myDataList);
}else{
//第二希望日で同じ処理を行う //第二希望日で同じ処理を行う
Log.d("CreateSchedule", "第二希望"); Log.d("CreateSchedule", "第二希望");
secondSetData(myDataList); secondSetData(myDataList);
secondTimeZoneSort(myDataList); secondTimeZoneSort(myDataList);
notSecondDuplicatesBoolean = secondCreateSchedule(myDataList, intervalArrayInt); notSecondDuplicatesBoolean = secondCreateSchedule(myDataList, intervalArrayInt);
//スケジュールを基準にソートする
sortSchedule(myDataList);
} }
}); });
//重複がなければ開始地点の緯度経度を返す // 重複がなければ開始地点の緯度経度を返す
if (notSecondDuplicatesBoolean) { if (notSecondDuplicatesBoolean) {
//スケジュールを基準にソートする // 保護者の住所を緯度経度に変換する
sortSchedule(myDataList);
String startPointLatLngString = geocodeAddress(myDataList, context); String startPointLatLngString = geocodeAddress(myDataList, context);
Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString); Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString);
outPutLogSchedule(myDataList); outPutLogSchedule(myDataList);
return startPointLatLngString; return startPointLatLngString;
} else {
// 重複があるときは""を返す
Log.d("CreateSchedule", "重複によるエラー");
return "";
} }
//重複があるときは""を返す
Log.d("CreateSchedule", "重複によるエラー");
return "";
} }
@ -313,8 +319,8 @@ public class CreateSchedule {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
//家庭訪問の日目が保護者の第一希望日かを判定する //家庭訪問の日目が保護者の第一希望日かを判定する
//まだスケジュールを割り当てていない保護者かを判定する //まだスケジュールを割り当てていない保護者かを判定する
if (date[x].equals(myDataList.get(i).getStartDateString()) && myDataList.get(i).getSchedule() == 0) { if (homeVisitDaysString[x].equals(myDataList.get(i).getStartDateString()) && myDataList.get(i).getSchedule() == 0) {
checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getStartDateString()); checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getStartDateString(),homeVisitDaysString);
break; break;
} }
} }
@ -336,13 +342,14 @@ public class CreateSchedule {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
//家庭訪問の日目が保護者の第一希望日かを判定する //家庭訪問の日目が保護者の第一希望日かを判定する
//まだスケジュールを割り当てていない保護者かを判定する //まだスケジュールを割り当てていない保護者かを判定する
if (date[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) { if (homeVisitDaysString[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) {
checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getSecondDayStartDateString()); checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getSecondDayStartDateString(),homeVisitDaysString);
} }
} }
} }
} }
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
if (myDataList.get(i).getSchedule() == 0) {//重複により割り当てがされていない保護者がいないかの確認 if (myDataList.get(i).getSchedule() == 0) {//重複により割り当てがされていない保護者がいないかの確認
return false; return false;
@ -351,10 +358,12 @@ public class CreateSchedule {
return true; return true;
} }
private void checkSchedule(List<MyDataClass> myDataList, int[][][] intervalArrayInt, int i, int j, int x, String desiredDateString) { private void checkSchedule(List<MyDataClass> myDataList, int[][][] intervalArrayInt, int i, int j, int x, String desiredDateString, String[] homeVisitDaysString) {
//保護者の希望時間の開始と終了の間にまだ保護者の割り当てがされていないスケジュールの空き時間があるかの判定 //保護者の希望時間の開始と終了の間にまだ保護者の割り当てがされていないスケジュールの空き時間があるかの判定
if (intervalArrayInt[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArrayInt[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArrayInt[x][j][1] == 0) { if (intervalArrayInt[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArrayInt[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArrayInt[x][j][1] == 0) {
intervalArrayInt[x][j][1] += 1;//その時間が割り当て済みでありこと intervalArrayInt[x][j][1] += 1;//その時間が割り当て済みでありこと
myDataList.get(i).setScheduleDay(homeVisitDaysString[x]);
Log.d("CreateSchedule","getScheduleDay"+myDataList.get(i).getScheduleDay());
myDataList.get(i).setSchedule(Integer.parseInt(desiredDateString.substring(4, 8) + intervalArrayInt[x][j][0]));//スケジュールをmyDataListに入れる(:6041240(6月4日12時40分)) myDataList.get(i).setSchedule(Integer.parseInt(desiredDateString.substring(4, 8) + intervalArrayInt[x][j][0]));//スケジュールをmyDataListに入れる(:6041240(6月4日12時40分))
} }
} }
@ -382,8 +391,19 @@ public class CreateSchedule {
} }
//SetUpで設定した家庭訪問の開始地点を緯度経度に変換 //SetUpで設定した家庭訪問の開始地点を緯度経度に変換
String startPointLatLngString = String.valueOf(geocoder.getFromLocationName(startPointString, 1)); String startPointLatLngString = String.valueOf(geocoder.getFromLocationName(startPointString, 1));
Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString); String[] startPointLatLngArray = startPointLatLngString.split(",");
return startPointLatLngString; if (startPointLatLngArray.length >= 3) {
//[Address[addressLines=[0:"日本、〒510-8102 三重県三重郡朝日町小向852−1"],feature=,admin=三重県,sub-admin=三重郡,locality=朝日町,thoroughfare=null,postalCode=510-8102,countryCode=JP,countryName=日本,hasLatitude=true,latitude=35.0351632,hasLongitude=true,longitude=136.66538770000003,phone=null,url=null,extras=null]]
//というようになっているので配列の後ろから6番目が緯度4番目が経度
//不要なlatitude=とlongitude=を取り除く
String latitude = startPointLatLngArray[startPointLatLngArray.length - 6].trim().replace("latitude=", "");
String longitude = startPointLatLngArray[startPointLatLngArray.length - 4].trim().replace("longitude=", "");
Log.d("CreateSchedule", "Latitude: " + latitude + ", Longitude: " + longitude);
// 文字列を結合して形式を整える
startPointLatLngString = latitude + "," + longitude;
Log.d("CreateSchedule", "startPointLatLngString: " + startPointLatLngString);
return startPointLatLngString;
}
} catch (IOException e) { } catch (IOException e) {
Log.e("CreateSchedule", "緯度経度の取得に失敗: " + e); Log.e("CreateSchedule", "緯度経度の取得に失敗: " + e);
} }

View File

@ -5,12 +5,12 @@ import java.util.List;
public class CreateUUID { public class CreateUUID {
public static int generateUUID(List<Integer> classIdList ){ public static int generateUUID(List<Integer> classIdList) {
while (true){ while (true) {
int uuid = (int)(Math.random() * 1000000); int uuidInt = (int) (Math.random() * 1000000);
boolean isDuplicate = false; boolean isDuplicate = false;
for(int classId : classIdList){ for (int classIdInt : classIdList) {
if(classId==uuid){ if (classIdInt == uuidInt) {
//重複があればフラグを立てループを抜ける //重複があればフラグを立てループを抜ける
isDuplicate = true; isDuplicate = true;
break; break;
@ -20,10 +20,8 @@ public class CreateUUID {
if (!isDuplicate) { if (!isDuplicate) {
//firestoreに挿入処理 //firestoreに挿入処理
InsertClassIdforFirebase insertClassIdforFirebase = new InsertClassIdforFirebase(); InsertClassIdforFirebase insertClassIdforFirebase = new InsertClassIdforFirebase();
insertClassIdforFirebase.insertClassId(uuid); insertClassIdforFirebase.insertClassId(uuidInt);
//テスト用 return uuidInt;
uuid = 100;
return uuid;
} }
} }
} }

View File

@ -19,16 +19,16 @@ public class DatePick extends DialogFragment implements
//デフォルトのタイムゾーンおよびロケールを使用してカレンダを取得 //デフォルトのタイムゾーンおよびロケールを使用してカレンダを取得
final Calendar c = Calendar.getInstance(); final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR); int yearInt = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH); int monthInt = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH); int dayInt = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(requireActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), year, month, day); return new DatePickerDialog(requireActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), yearInt, monthInt, dayInt);
} }
@Override @Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) { public void onDateSet(DatePicker datePicker, int yearInt, int monthInt, int dayInt) {
} }
} }

View File

@ -1,8 +1,7 @@
package com.example.oplogy; package com.example.oplogy;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class DialogFragment extends AppCompatActivity { public class DialogFragment extends AppCompatActivity {

View File

@ -16,21 +16,20 @@ import java.util.Map;
public class FirestoreReception { public class FirestoreReception {
//firestoreから受け取ったデータを束ねるためのマップ
public List<MyDataClass> myDataList = new ArrayList<>();
private FirebaseFirestore db; private FirebaseFirestore db;
public FirestoreReception() { public FirestoreReception() {
db = FirebaseFirestore.getInstance(); db = FirebaseFirestore.getInstance();
} }
//firestoreから受け取ったデータを束ねるためのマップ
public List<MyDataClass> myDataList = new ArrayList<>();
//ClassIdを引数にデータの作成を行う //ClassIdを引数にデータの作成を行う
public void getDocumentsByClassId(int classId) { public void getDocumentsByClassId(int classId) {
myDataList.clear(); myDataList.clear();
CollectionReference collectionRef = db.collection("QuestionnaireForms"); CollectionReference collectionRef = db.collection("QuestionForm");
// classIdが引数のものを取得する
collectionRef.whereEqualTo("classId", classId).get() collectionRef.whereEqualTo("classId", classId).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override @Override

View File

@ -12,10 +12,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FirestoreReception_classIdDatabase { public class FirestoreReception_classIdDatabase {
private FirebaseFirestore db; private FirebaseFirestore db;
private List<Integer> classIdList = new ArrayList<>(); private List<Integer> classIdList= new ArrayList<>();
public FirestoreReception_classIdDatabase() { public FirestoreReception_classIdDatabase() {
db = FirebaseFirestore.getInstance(); db = FirebaseFirestore.getInstance();

View File

@ -1,59 +0,0 @@
package com.example.oplogy;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.util.Log;
import com.google.android.gms.maps.model.LatLng;
import com.google.firebase.Timestamp;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class GeoCoder {
private Context context;
public void processData(Map<String, Object> data, Context context) {
try {
this.context = context;
//家庭訪問先の住所
List<String> address = (List<String>) data.get("address");
//家庭訪問の第一希望日(配列0が希望時間帯のはじめ配列1がおわり)
List<Timestamp> firstDay = (List<Timestamp>) data.get("firstDay");
//出席番号
Long studentNumber = (Long) data.get("studentNumber");
// 住所を緯度経度に変換
LatLng latLng = geocodeAddress(address.get(0));
//デバッグ用ログ
Log.d("FirestoreReception", "address: " + address.get(0));
Log.d("FirestoreReception", "firstDay: " + firstDay.get(0));
Log.d("FirestoreReception", "firstDay: " + firstDay.get(1));
Log.d("FirestoreReception", "studentNumber: " + studentNumber);
Log.d("FirestoreReception", "latLng: " + latLng);
} catch (NullPointerException e) {
Log.e("NullPointerException", "getの中身がnull" + e);
}
}
private LatLng geocodeAddress(String address) {
try {
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocationName(address, 1);
if (addresses != null && !addresses.isEmpty()) {
Address addressResult = addresses.get(0);
double latitude = addressResult.getLatitude();
double longitude = addressResult.getLongitude();
return new LatLng(latitude, longitude);
}
} catch (IOException e) {
Log.e("GeocodingException", "Error geocoding address: " + address, e);
}
return null;
}
}

View File

@ -1,6 +1,6 @@
package com.example.oplogy; package com.example.oplogy;
import android.content.DialogInterface; import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
@ -21,59 +21,37 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
// ダイアログの宣言 // ダイアログの宣言
private AlertDialog alertDialog; private AlertDialog alertDialog;
// ID作成のTextViewとImageView // ID作成のTextViewとImageView
private TextView creatUUID;
private ImageView imageUuid;
// セットアップのTextViewとImageView
private TextView setUp;
private ImageView imageSetup;
// セットアップのTextViewとImageView
private TextView root; private TextView root;
private ImageView imageRoot; private ImageView imageRoot;
// 提出状況のTextViewとImageView // 提出状況のTextViewとImageView
private TextView submission; private TextView submission;
private ImageView imageSubmission; private ImageView imageSubmission;
private TextView SettingView;
private ImageView imageSettingView;
//firestoreの受信関連 //firestoreの受信関連
private FirebaseFirestore db; private FirebaseFirestore db;
private FirestoreReception firestoreReception; private FirestoreReception firestoreReception;
private FirestoreReception_classIdDatabase firestoreReception_classIdDatabase;
//取得するためのクラスID //取得するためのクラスID
private int classId; private int classId;
private final AppDatabase appDatabase = null;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
// ID作成用のインテント
creatUUID = findViewById(R.id.creatUUID);
creatUUID.setOnClickListener(this);
imageUuid = findViewById(R.id.imageUuid);
imageUuid.setOnClickListener(this);
// セットアップ用のインテント
setUp = findViewById(R.id.setUp);
setUp.setOnClickListener(this);
imageSetup = findViewById(R.id.imageSetup);
imageSetup.setOnClickListener(this);
// ルート作成用のインテント // ルート作成用のインテント
root = findViewById(R.id.root); root = findViewById(R.id.root);
root.setOnClickListener(this); root.setOnClickListener(this);
@ -86,6 +64,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
imageSubmission = findViewById(R.id.imageSubmission); imageSubmission = findViewById(R.id.imageSubmission);
imageSubmission.setOnClickListener(this); imageSubmission.setOnClickListener(this);
// 設定用のインテント
SettingView = findViewById(R.id.setting);
SettingView.setOnClickListener(this);
imageSettingView = findViewById(R.id.imageSetting);
imageSettingView.setOnClickListener(this);
// firestoreの受信関連 // firestoreの受信関連
db = FirebaseFirestore.getInstance(); db = FirebaseFirestore.getInstance();
firestoreReception = new FirestoreReception(); firestoreReception = new FirestoreReception();
@ -109,171 +93,108 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
// クリック処理 // クリック処理
@Override @Override
public void onClick(View view) { public void onClick(View view) {
// ID作成のクリック処理
if (view == creatUUID) {
imageUuid.setImageResource(R.drawable.ischecked_uuid);
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
}
if (view == imageUuid) {
imageUuid.setImageResource(R.drawable.ischecked_uuid);
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
}
// セットアップのクリック処理
if (view == setUp) {
imageSetup.setImageResource(R.drawable.ischecked_uuid);
Intent toSetup = new Intent(MainActivity.this, SetUpActivity.class);
toSetup.putExtra("classId", classId);
startActivity(toSetup);
finish(); // 画面遷移後元の状態に戻す
}
if (view == imageSetup) {
imageSetup.setImageResource(R.drawable.ischecked_uuid);
Intent toSetup = new Intent(MainActivity.this, SetUpActivity.class);
startActivity(toSetup);
finish(); // 画面遷移後元の状態に戻す
}
// ルート作成のクリック処理 // ルート作成のクリック処理
if (view == root) { if (view == root) {
imageRoot.setImageResource(R.drawable.pin); imageRoot.setImageResource(R.drawable.pin);
if (isClassIdSet()) { checkSetupAndCreateRoute(this::fetchDataAndCreateRoute);
isSetupExists(classId).thenAccept(setupExists -> {
if (setupExists) {
fetchDataAndCreateRoute();
} else {
runOnUiThread(() -> {
Toast.makeText(this, "セットアップが設定されていません", Toast.LENGTH_SHORT).show();
});
}
}).exceptionally(ex -> {
ex.printStackTrace();
runOnUiThread(() -> {
Toast.makeText(this, "エラーが発生しました", Toast.LENGTH_SHORT).show();
});
return null;
});
} else {
Toast.makeText(this, "クラスIDが設定されていません", Toast.LENGTH_SHORT).show();
}
} }
if (view == imageRoot) { if (view == imageRoot) {
imageRoot.setImageResource(R.drawable.pin); imageRoot.setImageResource(R.drawable.pin);
fetchDataAndCreateRoute(); checkSetupAndCreateRoute(this::fetchDataAndCreateRoute);
} }
// 提出状況のクリック処理 // 提出状況のクリック処理
if (view == submission) { if (view == submission) {
ArrayList<SubmissionStudent> submissionStudents = getSubmissionStudents(); checkSetupAndCreateRoute(() -> {
Intent toSubmission = new Intent(MainActivity.this, SubmissionActivity.class); ArrayList<SubmissionStudent> submissionStudents = getSubmissionStudents();
toSubmission.putParcelableArrayListExtra("submissionStudents", submissionStudents); Intent toSubmission = new Intent(MainActivity.this, SubmissionActivity.class);
startActivity(toSubmission); toSubmission.putParcelableArrayListExtra("submissionStudents", submissionStudents);
startActivity(toSubmission);
});
} }
if (view == imageSubmission) { if (view == imageSubmission) {
ArrayList<SubmissionStudent> submissionStudents = getSubmissionStudents(); checkSetupAndCreateRoute(() -> {
Intent toSubmission = new Intent(MainActivity.this, SubmissionActivity.class); ArrayList<SubmissionStudent> submissionStudents = getSubmissionStudents();
toSubmission.putParcelableArrayListExtra("submissionStudents", submissionStudents); Intent toSubmission = new Intent(MainActivity.this, SubmissionActivity.class);
startActivity(toSubmission); toSubmission.putParcelableArrayListExtra("submissionStudents", submissionStudents);
startActivity(toSubmission);
});
}
if (view == SettingView) {
Intent toSettingView = new Intent(MainActivity.this, SettingView.class);
startActivity(toSettingView);
}
if (view == imageSettingView) {
Intent toSettingView = new Intent(MainActivity.this, SettingView.class);
startActivity(toSettingView);
} }
} }
//IDに関する処理
private void showUUIDYesNoDialog() {
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
List<Integer> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
//ルート作成提出状況の遷移を行う前のチェックを行う処理
AlertDialog.Builder builder = new AlertDialog.Builder(this); private void checkSetupAndCreateRoute(Runnable onSetupComplete) {
builder.setTitle("クラスID"); if (isClassIdSet()) {
builder.setMessage("あなたのクラスIDを表示/もしくは新規で作成しますか?"); isSetupExists(classId).thenAccept(setupExists -> {
if (setupExists) {
builder.setPositiveButton("作成", new DialogInterface.OnClickListener() { runOnUiThread(onSetupComplete);
@Override } else {
public void onClick(DialogInterface dialog, int which) {
classId = CreateUUID.generateUUID(classIdList);
// 生成されたクラスIDを表示するメソッド
showClassIdDialog("生成されたクラスID",classId);
}
});
builder.setNegativeButton("表示", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//roomを扱うため非同期処理
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
// 現在のクラスIDを取得
int currentClassId = getCurrentClassIdFromRoom();
runOnUiThread(() -> { runOnUiThread(() -> {
// 現在のクラスIDを表示するダイアログ Toast.makeText(this, "先に設定画面で情報を入力してください", Toast.LENGTH_SHORT).show();
showClassIdDialog("現在のクラスID",currentClassId);
}); });
}
}).exceptionally(ex -> {
ex.printStackTrace();
runOnUiThread(() -> {
Toast.makeText(this, "エラーが発生しました", Toast.LENGTH_LONG).show();
}); });
executor.shutdown(); return null;
} });
}); } else {
Toast.makeText(this, "先に設定画面で情報を入力してください", Toast.LENGTH_SHORT).show();
alertDialog = builder.create(); }
alertDialog.show();
}
private int getCurrentClassIdFromRoom() {
AppDatabase db = getDatabaseInstance();
SetUpTableDao setUpTableDao = db.setUpTableDao();
// 現在のクラスIDを取得
return setUpTableDao.getClassId();
}
//クラスIDを表示するダイアログ
private void showClassIdDialog(String title, int classId) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(title);
builder.setMessage("クラスID: " + classId);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
} }
// クラスIDが設定されているかどうかを判定
private boolean isClassIdSet() { private boolean isClassIdSet() {
// classIdが0より大きい場合trueを返す // classIdが0より大きい場合trueを返す
return classId > 0; return classId > 0;
} }
// セットアップが存在するかどうかを判定
private CompletableFuture<Boolean> isSetupExists(int classId) { private CompletableFuture<Boolean> isSetupExists(int classId) {
final ExecutorService executorService = Executors.newSingleThreadExecutor(); final ExecutorService executorService = Executors.newSingleThreadExecutor();
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
AppDatabase db = getDatabaseInstance(); AppDatabase db = getDatabaseInstance();
SetUpTableDao setUpTableDao = db.setUpTableDao(); SetUpTableDao setUpTableDao = db.setUpTableDao();
//データベースの値を全取得
List<SetUpTable> checkData = setUpTableDao.getAll(); List<SetUpTable> checkData = setUpTableDao.getAll();
for (SetUpTable setUpTable : checkData) { for (SetUpTable setUpTable : checkData) {
//SetUpTableのclassIdと引数のclassIdが一致する場合trueを返す
if (setUpTable.classId == classId) { if (setUpTable.classId == classId) {
return true; return true;
} }
} }
return false; return false;
//処理完了時にexecutorServiceをシャットダウン
}, executorService).whenComplete((result, throwable) -> executorService.shutdown()); }, executorService).whenComplete((result, throwable) -> executorService.shutdown());
} }
//ルート作成の非同期処理 //ルート作成の非同期処理
private void fetchDataAndCreateRoute() { private void fetchDataAndCreateRoute() {
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> { executor.execute(() -> {
AppDatabase db = getDatabaseInstance(); SetUpTableDao setUpTableDao = db.setUpTableDao(); AppDatabase db = getDatabaseInstance();
int totalStudent = setUpTableDao.getTotalStudent(); SetUpTableDao setUpTableDao = db.setUpTableDao();
int myDataListSize = firestoreReception.getMyDataListSize(); int totalStudentInt = setUpTableDao.getTotalStudent();
int myDataListSizeInt = firestoreReception.getMyDataListSize();
//総生徒数と提出済みになっている生徒の数が一致するかの確認 //総生徒数と提出済みになっている生徒の数が一致するかの確認
runOnUiThread(() -> { runOnUiThread(() -> {
if (totalStudent != myDataListSize) { if (totalStudentInt != myDataListSizeInt) {
//未提出者がいることの警告ダイアログ //未提出者がいることの警告ダイアログ
showRouteCreationDialog(); showRouteCreationDialog();
} else { } else {
@ -286,6 +207,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// `fetchDataAndCreateRoute`メソッド内ではshutdownを呼び出さない // `fetchDataAndCreateRoute`メソッド内ではshutdownを呼び出さない
} }
// 未提出者がいることの警告ダイアログ
private void showRouteCreationDialog() { private void showRouteCreationDialog() {
new AlertDialog.Builder(MainActivity.this) new AlertDialog.Builder(MainActivity.this)
.setTitle("警告") .setTitle("警告")
@ -302,7 +224,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
.show(); .show();
} }
// ルート作成の非同期処理
private void createRoute(ExecutorService executor) { private void createRoute(ExecutorService executor) {
// ProgressDialogを作成
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.show();
executor.execute(() -> { executor.execute(() -> {
List<MyDataClass> myDataList = null; List<MyDataClass> myDataList = null;
while (myDataList == null) { while (myDataList == null) {
@ -311,6 +241,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Thread.sleep(3000); Thread.sleep(3000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
runOnUiThread(progressDialog::dismiss); // 進行状況ダイアログを閉じる
return; return;
} }
} }
@ -318,17 +249,29 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
//final宣言することによってスレッドセーフになる(ラムダ式内で使えるようにする) //final宣言することによってスレッドセーフになる(ラムダ式内で使えるようにする)
final List<MyDataClass> finalMyDataList = myDataList; final List<MyDataClass> finalMyDataList = myDataList;
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this); CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext()); String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext());
Boolean notDuplicatesBoolean = null;
for (int i = 0; i < myDataList.size(); i++) {
if (myDataList.get(i).getSchedule() == 0) {
notDuplicatesBoolean = false;
break;
} else {
notDuplicatesBoolean = true;
}
}
Boolean finalNotDuplicatesBoolean = notDuplicatesBoolean;
Log.d("MainActivity", "重複判定" + String.valueOf(finalNotDuplicatesBoolean));
runOnUiThread(() -> { runOnUiThread(() -> {
if ( !startPointLatLngString.equals("")) { progressDialog.dismiss(); // 進行状況ダイアログを閉じる
if (finalNotDuplicatesBoolean) {
Log.d("MainActivity", "スケジュール作成成功"); Log.d("MainActivity", "スケジュール作成成功");
saveMyDataList(finalMyDataList); saveMyDataList(finalMyDataList);
Intent toRoot = new Intent(MainActivity.this, Maps.class); Intent toRoot = new Intent(MainActivity.this, Maps.class);
toRoot.putExtra("startPointLatLngString", startPointLatLngString); toRoot.putExtra("startPointLatLngString", startPointLatLngString);
startActivity(toRoot); startActivity(toRoot);
} else { } else {
//保護者の重複による警告ダイアログ // 保護者の重複による警告ダイアログ
showErrorDialog(finalMyDataList); showErrorDialog(finalMyDataList);
} }
}); });
@ -337,6 +280,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
executor.shutdown(); executor.shutdown();
}); });
} }
// 作成したルートを(Mapに渡せるように)保存するメソッド
private void saveMyDataList(List<MyDataClass> myDataList) { private void saveMyDataList(List<MyDataClass> myDataList) {
// 共有プリファレンスのインスタンスを取得 // 共有プリファレンスのインスタンスを取得
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
@ -344,13 +289,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// MyDataListをJSON形式に変換 // MyDataListをJSON形式に変換
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(myDataList); String jsonString = gson.toJson(myDataList);
// JSON形式のデータを共有プリファレンスに保存 // JSON形式のデータを共有プリファレンスに保存
editor.putString("myDataList", json); editor.putString("myDataList", jsonString);
editor.apply(); editor.apply();
} }
// 保護者の重複による警告ダイアログ
private void showErrorDialog(List<MyDataClass> myDataList) { private void showErrorDialog(List<MyDataClass> myDataList) {
List<Integer> studentNumbers = new ArrayList<>(); List<Integer> studentNumbers = new ArrayList<>();
for (MyDataClass data : myDataList) { for (MyDataClass data : myDataList) {
@ -358,12 +304,22 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
studentNumbers.add(data.getStudentNumber()); studentNumbers.add(data.getStudentNumber());
} }
} }
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。調整してください。\n出席番号: "); StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。保護者に連絡して調整してください。\n\n");
for (int i = 0; i < studentNumbers.size(); i++) { for (int i = 0; i < studentNumbers.size(); i++) {
message.append(studentNumbers.get(i)); message.append("出席番号:" + studentNumbers.get(i));
if (i < studentNumbers.size() - 1) { message.append("\n保護者名:" + myDataList.get(i).getPatronName());
message.append(", "); message.append("\n第一希望 " + myDataList.get(i).getStartDateString().substring(4, 6) + "");
} message.append(myDataList.get(i).getStartDateString().substring(6, 8) + "");
message.append(" " + myDataList.get(i).getParentStartTimeString().substring(0, 2));
message.append(":" + myDataList.get(i).getParentStartTimeString().substring(2, 4));
message.append("" + myDataList.get(i).getParentEndTimeString().substring(0, 2));
message.append(":" + myDataList.get(i).getParentEndTimeString().substring(2, 4));
message.append("\n第二希望 " + myDataList.get(i).getSecondDayStartDateString().substring(4, 6) + "");
message.append(myDataList.get(i).getSecondDayStartDateString().substring(6, 8) + "");
message.append(" " + myDataList.get(i).getSecondDayParentStartTimeString().substring(0, 2));
message.append(":" + myDataList.get(i).getSecondDayParentStartTimeString().substring(2, 4));
message.append("" + myDataList.get(i).getSecondDayParentEndTimeString().substring(0, 2));
message.append(":" + myDataList.get(i).getSecondDayParentEndTimeString().substring(2, 4) + "\n\n");
} }
new AlertDialog.Builder(MainActivity.this) new AlertDialog.Builder(MainActivity.this)
.setTitle("警告") .setTitle("警告")
@ -374,15 +330,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
.show(); .show();
} }
// データベースのインスタンスを取得するメソッド
private AppDatabase getDatabaseInstance() { private AppDatabase getDatabaseInstance() {
return Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").fallbackToDestructiveMigration().build(); return Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
} }
//提出状況の取得 //提出状況の取得
private ArrayList<SubmissionStudent> getSubmissionStudents() { public ArrayList<SubmissionStudent> getSubmissionStudents() {
ArrayList<SubmissionStudent> submissionStudents = new ArrayList<>(); ArrayList<SubmissionStudent> submissionStudents = new ArrayList<>();
List<MyDataClass> myDataList = firestoreReception.getMyDataList(); List<MyDataClass> myDataList = firestoreReception.getMyDataList();
@ -390,40 +345,44 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
executor.execute(() -> { executor.execute(() -> {
// 1. Roomデータベースから全生徒数を取得 try {
AppDatabase db = getDatabaseInstance(); // 1. Roomデータベースから全生徒数を取得
SetUpTableDao setUpTableDao = db.setUpTableDao(); AppDatabase db = getDatabaseInstance();
int totalStudent = setUpTableDao.getTotalStudent(); SetUpTableDao setUpTableDao = db.setUpTableDao();
// 2. Firestoreから生徒番号のリストを取得 int totalStudentInt = setUpTableDao.getTotalStudent();
ArrayList<Integer> firestoreStudentNumbers = new ArrayList<>();
for (MyDataClass myData : myDataList) {
int studentNumber = myData.getStudentNumber();
firestoreStudentNumbers.add(studentNumber);
}
// 3. SubmissionStudentオブジェクトのリストを作成 // 2. Firestoreから生徒番号のリストを取得
for (int i = 1; i <= totalStudent; i++) { ArrayList<Integer> firestoreStudentNumbersList = new ArrayList<>();
boolean submitted = firestoreStudentNumbers.contains(i); for (MyDataClass myData : myDataList) {
submissionStudents.add(new SubmissionStudent(i, submitted)); int studentNumberInt = myData.getStudentNumber();
} firestoreStudentNumbersList.add(studentNumberInt);
}
// 4. データベース操作が完了したことを通知 // 3. SubmissionStudentオブジェクトのリストを作成
latch.countDown(); for (int i = 1; i <= totalStudentInt; i++) {
boolean submitted = firestoreStudentNumbersList.contains(i);
submissionStudents.add(new SubmissionStudent(i, submitted));
}
} catch (Exception e) {
e.printStackTrace(); // ログにエラーメッセージを出力
} finally {
// 4. データベース操作が完了したことを通知
latch.countDown();
}
}); });
try { try {
// データベース操作が完了するのを待つ latch.await(); // 非同期処理が完了するまで待機
latch.await();
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
executor.shutdown(); // ExecutorServiceをシャットダウン
} }
executor.shutdown();
// SubmissionStudentオブジェクトのリストを返す
return submissionStudents; return submissionStudents;
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();

View File

@ -1,73 +1,234 @@
package com.example.oplogy; package com.example.oplogy;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.webkit.WebSettings; import android.widget.AdapterView;
import android.webkit.WebView; import android.widget.ArrayAdapter;
import android.webkit.WebViewClient;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import com.example.oplogy.databinding.MapsBinding; import com.example.oplogy.databinding.MapsBinding;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class Maps extends FragmentActivity implements View.OnClickListener { public class Maps extends FragmentActivity implements OnMapReadyCallback, View.OnClickListener, GoogleMap.OnMarkerClickListener {
private WebView webView; //GoogleMapAPiで使用可能な色
private static final int[] COLORS = new int[]{Color.parseColor("#007FFF"), // HUE_AZURE
Color.parseColor("#0000FF"), // HUE_BLUE
Color.parseColor("#00FFFF"), // HUE_CYAN
Color.parseColor("#00FF00"), // HUE_GREEN
Color.parseColor("#FF00FF"), // HUE_MAGENTA
Color.parseColor("#FFA500"), // HUE_ORANGE
Color.parseColor("#FF0000"), // HUE_RED
Color.parseColor("#FF007F"), // HUE_ROSE
Color.parseColor("#8A2BE2"), // HUE_VIOLET
Color.parseColor("#FFFF00") // HUE_YELLOW
};
private final List<LatLng> latLngList = new ArrayList<>();
private final List<String> nameList = new ArrayList<>();
private final List<Integer> colorList = new ArrayList<>();
private final Map<String, Runnable> dateMap = new HashMap<>();
ImageView backMain; ImageView backMain;
private MapsBinding binding; private GoogleMap mMap;
private ArrayList<Parcelable> myDataList; private LinearLayout locationsName;
private int colorIndex = 0;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// バインディングの設定
binding = MapsBinding.inflate(getLayoutInflater()); com.example.oplogy.databinding.MapsBinding binding = MapsBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot()); setContentView(binding.getRoot());
// マップフラグメントの設定
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
// 各UI要素の設定
backMain = findViewById(R.id.BackMain); backMain = findViewById(R.id.BackMain);
backMain.setOnClickListener(this); backMain.setOnClickListener(this);
webView = findViewById(R.id.webView); locationsName = findViewById(R.id.locationsName);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
// startPointLatLngStringの取得 // スピナーの設定
String startPointLatLngString = getIntent().getStringExtra("startPointLatLngString"); String dateDataString = formatDate(getSharedPreferencesData(0)) + "/" + formatDate(getSharedPreferencesData(1)) + "/" + formatDate(getSharedPreferencesData(2));
//MyDataListの取得 ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item);
List<MyDataClass> myDataList = getMyDataList(); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
String[] dates = dateDataString.split("/");
for (String date : dates) {
adapter.add(date);
}
String latlngString = ""; // 各日付に対応するRunnableを設定する
for (int i = -1; i < myDataList.size(); i++) { for (int i = 0; i < 3; i++) {
if (i < 0) { int finalI = i;
//家庭訪問の開始地点の緯度経度 String dayString = getSharedPreferencesData(i);
latlngString += startPointLatLngString + "/"; String formattedDayString = formatDate(dayString);
} else { dateMap.put(formattedDayString, () -> loadMapAndNames(createlocationData(finalI), getscrollViewlData(finalI)));
//各家庭の緯度経度 }
String latlng = myDataList.get(i).getLatLngString();
int startIndex = latlng.indexOf("(") + 1; Spinner dateSpinner = findViewById(R.id.date);
int endIndex = latlng.indexOf(")"); dateSpinner.setAdapter(adapter);
String latlngOnly = latlng.substring(startIndex, endIndex);
latlngString += latlngOnly; // スピナーのアイテム選択リスナーを設定
if (i < myDataList.size() - 1) { dateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
latlngString += "/"; @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemString = (String) parent.getItemAtPosition(position);
Runnable mapLoader = dateMap.get(selectedItemString);
if (mapLoader != null) {
mapLoader.run();
} }
} }
@Override
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing
}
});
}
//ルート表示を押して最初に表示されるルート(3日間の家庭訪問における1日目)の設定
@Override
public void onMapReady(GoogleMap googleMap) {
//Google mapの定義
mMap = googleMap;
mMap.setOnMarkerClickListener(this);
//家庭訪問1日目のスケジュール順に緯度経度の情報をString型の変数に格納
//35.1711355,136.88552149999998/35.1696089,136.884084/35.1732838,136.88832890000003/...
String locationDataString = createlocationData(0);
//家庭訪問1日目のスケジュール順に住所や出席番号家庭訪問の開始時間の情報をString型の変数に格納
//開始地点/出席番号2番:鈴木次郎<453-0015 愛知県名古屋市中村区椿町6 地下1階5階> 06月04日12時00分/...
String scrollViewlDataString = getscrollViewlData(0);
loadMapAndNames(locationDataString, scrollViewlDataString);
}
//家庭訪問の日目が何月何日かを返すメソッド
private String getSharedPreferencesData(int i) {
SharedPreferences sharedPreferences = getSharedPreferences("visitingDate", MODE_PRIVATE);
// SetUpで設定した8桁の数字表記の家庭訪問日を日付表記に変更
String dayString;
if (i == 0) {
dayString = sharedPreferences.getString("day1", null);
} else if (i == 1) {
dayString = sharedPreferences.getString("day2", null);
} else {
dayString = sharedPreferences.getString("day3", null);
}
return dayString;
}
//家庭訪問の日付を8桁の整数表記から(2024070707月07日)表記に変更する
private String formatDate(String date) {
if (date == null || date.length() != 8) {
return "";
}
String monthString = date.substring(4, 6);
String dayString = date.substring(6, 8);
return monthString + "" + dayString + "";
}
//家庭訪問1日目のスケジュール順に緯度経度の情報をString型の変数に格納
private String createlocationData(int i) {
//家庭訪問の開始地点の緯度経度
String startPointLatLngString = getIntent().getStringExtra("startPointLatLngString");
List<MyDataClass> myDataList = getMyDataList();
//家庭訪問の緯度経度情報をまとめる変数
StringBuilder latlngString = new StringBuilder();
for (int y = -1; y < myDataList.size(); y++) {
if (y < 0) {
//家庭訪問の開始地点を追加
latlngString.append(startPointLatLngString);
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i))) {
if (latlngString.length() > 0) {
//区切りのスラッシュ
latlngString.append("/");
}
//mydataListから取り出した家庭訪問の各家庭の住所の緯度経度を追加
//この時点ではlongitude latitudeのような不要な文字があるのでformatLatLngメソッドで緯度経度だけのデータにする
latlngString.append(formatLatLng(myDataList.get(y)));
}
}
//各家庭の緯度経度をまとめたものを返す
return latlngString.toString();
}
//緯度と経度は(35.1711355,136.88552149999998)のように()の中に入っているのでそこだけを取り出す
private String formatLatLng(MyDataClass myData) {
String latlngString = myData.getLatLngString();
int startIndex = latlngString.indexOf("(") + 1;
int endIndex = latlngString.indexOf(")");
return latlngString.substring(startIndex, endIndex);
}
//ScrollViewにて表示するdataの作成メソッド
private String getscrollViewlData(int i) {
List<MyDataClass> myDataList = getMyDataList();
String homeVisitDataString = "";
for (int y = -1; y < myDataList.size(); y++) {
if (y < 0) {
//家庭訪問の開始地点
homeVisitDataString += "開始地点/";
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i)) && y + 1 < myDataList.size()) {
//出席番号:生徒の名前 <住所> 家庭訪問の開始時間+/
homeVisitDataString += "出席番号" + String.valueOf(myDataList.get(y).getStudentNumber()) + "番:" + myDataList.get(y).getChildName() + "<" + myDataList.get(y).getAddress().get(0) + "> " + formatSchedule(String.valueOf(myDataList.get(y).getSchedule())) + "/";
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i))) {
homeVisitDataString += "出席番号" + String.valueOf(myDataList.get(y).getStudentNumber()) + "番:" + myDataList.get(y).getChildName() + " <" + myDataList.get(y).getAddress().get(0) + "> " + formatSchedule(String.valueOf(myDataList.get(y).getSchedule()));
}
}
return homeVisitDataString;
}
//家庭訪問のscheduleを7桁の整数から(604120006月12日05時20分)に変換
private String formatSchedule(String schedule) {
Log.d("Maps", "schedule: " + schedule);
if (schedule.length() != 7) {
schedule = "0" + schedule;
String monthString = schedule.substring(0, 2);
String dayString = schedule.substring(2, 4);
String hourString = "0" + schedule.substring(4, 5);
String minuteString = schedule.substring(5, 7);
return monthString + "" + dayString + "" + hourString + "" + minuteString + "";
} else {
String monthString = "0" + schedule.substring(0, 1);
String dayString = schedule.substring(1, 3);
String hourString = schedule.substring(3, 5);
String minuteString = schedule.substring(5, 7);
return monthString + "" + dayString + "" + hourString + "" + minuteString + "";
} }
Log.d("Maps", "startPointLatLngString" + startPointLatLngString);
Log.d("Maps", "latlngString" + latlngString);
loadMapInWebView(latlngString);
} }
// 共有プリファレンスからMyDataListを取得するメソッド // 共有プリファレンスからMyDataListを取得するメソッド
@ -76,50 +237,268 @@ public class Maps extends FragmentActivity implements View.OnClickListener {
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
// 共有プリファレンスからJSON形式のデータを取得 // 共有プリファレンスからJSON形式のデータを取得
String json = sharedPreferences.getString("myDataList", ""); String jsonString = sharedPreferences.getString("myDataList", "");
// JSON形式のデータをMyDataListに変換 // JSON形式のデータをMyDataListに変換
Gson gson = new Gson(); Gson gson = new Gson();
Type type = new TypeToken<List<MyDataClass>>() { Type type = new TypeToken<List<MyDataClass>>() {
}.getType(); }.getType();
List<MyDataClass> myDataList = gson.fromJson(json, type); List<MyDataClass> myDataList = gson.fromJson(jsonString, type);
return myDataList; return myDataList;
} }
// WebViewの処理ですMapの中の処理をやっています
private void loadMapInWebView(String locations) {
// 区切ることで追加の地点を入れて最終地点にピンを打ってある状態です
String[] locArray = locations.split("/");
// URLで経路案内での表示をしています
StringBuilder urlBuilder = new StringBuilder("https://www.google.com/maps/dir/?api=1&travelmode=driving");
if (locArray.length > 0) { //mapやgetscrollViewlに値を渡すハブの役割のメソッド
urlBuilder.append("&origin=").append(locArray[0]); private void loadMapAndNames(String locationData, String nameData) {
try {
//mapに関するすべてのデータをリセット
latLngList.clear();
nameList.clear();
colorList.clear();
locationsName.removeAllViews();
mMap.clear();
if (locArray.length > 1) { // locationDataをスラッシュで分割して緯度経度リストを取得
urlBuilder.append("&destination=").append(locArray[locArray.length - 1]); String[] locArrayString = locationData.split("/");
// nameDataをスラッシュで分割して名前リストを取得
String[] nameArrayString = nameData.split("/");
if (locArray.length > 2) { for (int i = 0; i < locArrayString.length; i++) {
// 緯度経度をカンマで分割してLatLngオブジェクトを作成
String[] latLngString = locArrayString[i].split(",");
if (latLngString.length == 2) {
double latitudeDouble = Double.parseDouble(latLngString[0]);
double longitudeDouble = Double.parseDouble(latLngString[1]);
LatLng position = new LatLng(latitudeDouble, longitudeDouble);
latLngList.add(position);
// 名前リストから対応する名前を取得
String nameString = nameArrayString.length > i ? nameArrayString[i] : "Unknown";
nameList.add(nameString);
// 色リストから次の色を取得
int colorInt = getNextColor();
colorList.add(colorInt);
// 地図にピンを追加
addPinToMap(nameString, position, colorInt);
// スクロールビューに場所を追加
addLocationToScrollView(nameString, colorInt);
}
}
// 最初の位置にカメラを移動しルートを描画
if (!latLngList.isEmpty()) {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLngList.get(0), 17));
drawRoute(); // ルートを描画するメソッドを呼び出す
}
} catch (Exception e) {
Log.e("Maps", "エラーが発生しました。原因は以下", e);
}
}
// ルートを描画するメソッド
// Google マップの Directions API を使用してルート情報を取得しポリラインで描画
private void drawRoute() {
new Thread(() -> {
try {
StringBuilder urlBuilder = new StringBuilder("https://maps.googleapis.com/maps/api/directions/json?");
urlBuilder.append("origin=").append(latLngList.get(0).latitude).append(",").append(latLngList.get(0).longitude);
urlBuilder.append("&destination=").append(latLngList.get(latLngList.size() - 1).latitude).append(",").append(latLngList.get(latLngList.size() - 1).longitude);
if (latLngList.size() > 2) {
urlBuilder.append("&waypoints="); urlBuilder.append("&waypoints=");
for (int i = 1; i < locArray.length - 1; i++) { for (int i = 1; i < latLngList.size() - 1; i++) {
urlBuilder.append(locArray[i]); urlBuilder.append("via:").append(latLngList.get(i).latitude).append(",").append(latLngList.get(i).longitude);
if (i < locArray.length - 2) { if (i < latLngList.size() - 2) {
urlBuilder.append("|"); urlBuilder.append("|");
} }
} }
} }
} urlBuilder.append("&mode=driving");
} //APiキーの設定
urlBuilder.append("&key=").append("AIzaSyBQ1Ak-I2NL5TP4K59ZI0VgzKk6HNZuusw");
webView.loadUrl(urlBuilder.toString()); String urlString = urlBuilder.toString();
Log.d("Maps", "Directions API URL: " + urlString);
// Directions APIにリクエストを送信してレスポンスを取得
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
BufferedReader br = new BufferedReader(isr);
StringBuilder jsonResults = new StringBuilder();
String lineString;
while ((lineString = br.readLine()) != null) {
jsonResults.append(lineString);
}
br.close();
Log.d("Maps", "API response: " + jsonResults.toString());
// レスポンスからルート情報を取得してポリラインで描画
JsonObject jsonObject = new Gson().fromJson(jsonResults.toString(), JsonObject.class);
JsonArray routes = jsonObject.getAsJsonArray("routes");
if (routes.size() > 0) {
JsonObject route = routes.get(0).getAsJsonObject();
JsonObject polyline = route.getAsJsonObject("overview_polyline");
String encodedString = polyline.get("points").getAsString();
List<LatLng> points = decodePoly(encodedString);
Log.d("Maps", "Polyline points: " + points);
runOnUiThread(() -> mMap.addPolyline(new PolylineOptions().addAll(points).width(5).color(Color.BLUE)));
} else {
// ルートが見つからなかった場合のエラーメッセージを表示
JsonPrimitive errorMessage = jsonObject.getAsJsonPrimitive("error_message");
if (errorMessage != null) {
Log.e("Maps", "エラーが発生しました。原因は以下: " + errorMessage.getAsString());
} else {
Log.e("Maps", "原因不明のエラー");
}
}
} catch (Exception e) {
Log.e("Maps", "ルートの描画に失敗しました", e);
}
}).start();
}
// エンコードされた文字列から座標情報をデコードするためのメソッド
private List<LatLng> decodePoly(String encoded) {
List<LatLng> poly = new ArrayList<>(); // 座標情報を格納するリスト
int index = 0, len = encoded.length();// 文字列のインデックスと長さ
int latInt = 0, lng = 0; // 緯度と経度の初期値
// 文字列の長さに達するまで繰り返す
while (index < len) {
int b, shift = 0, result = 0;
// バイト値を取得しビットシフトとOR演算を行って座標値を復元する
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
latInt += dlat;
shift = 0;
result = 0;
// バイト値を取得しビットシフトとOR演算を行って座標値を復元する
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
// LatLngオブジェクトを作成してリストに追加する
LatLng p = new LatLng((((double) latInt / 1E5)), (((double) lng / 1E5)));
poly.add(p);
}
// 座標情報のリストを返す
return poly;
}
// Colorクラスを使用して与えられた色から色相値を計算するメソッド
private float getHueFromColor(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);//整数の色値をHSV色相彩度明度の形式に変換し色相値を取得します
return hsv[0];
}
//mapにピンを追加するメソッド
private void addPinToMap(String locationName, LatLng position, int color) {
// マーカーオプションを作成し位置タイトル色を設定する
Marker marker = mMap.addMarker(new MarkerOptions().position(position).title(locationName).icon(BitmapDescriptorFactory.defaultMarker(getHueFromColor(color))));
if (marker != null) {
marker.setTag(locationName);
}
}
// スクロールビューに位置情報を追加するメソッド
// スクロールビューに位置情報を追加するメソッド
// スクロールビューに位置情報を追加するメソッド
private void addLocationToScrollView(String locationName, int color) {
runOnUiThread(() -> {
try {
// テキストビューの作成
TextView textView = new TextView(this);
textView.setText(locationName);
textView.setTextSize(20);
textView.setPadding(16, 16, 16, 16);
textView.setTextColor(Color.BLACK); // 文字色を黒に設定
textView.setBackgroundColor(Color.WHITE); // 背景色を白に設定
// 円を作成
ShapeDrawable circle = new ShapeDrawable(new OvalShape());
circle.setIntrinsicWidth(30);
circle.setIntrinsicHeight(30);
circle.getPaint().setColor(color);
// 左側に円を表示するためにDrawableを設定
textView.setCompoundDrawablesWithIntrinsicBounds(circle, null, null, null);
textView.setCompoundDrawablePadding(16);
// テキストビューにクリックリスナーを追加
textView.setOnClickListener(v -> {
for (int j = 0; j < nameList.size(); j++) {
if (nameList.get(j).equals(locationName)) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLngList.get(j), 17));
break;
}
}
});
// ボーダーラインの作成
View border = new View(this);
border.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, // 横幅は親と同じ
2 // 高さは2dp
));
border.setBackgroundColor(Color.GRAY); // ボーダーラインの色を設定
// レイアウトの作成
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(border);
// スクロールビューにレイアウトを追加
locationsName.addView(layout);
} catch (Exception e) {
Log.e("Maps", "エラーが発生しました。原因は以下", e);
}
});
}
private int getNextColor() {
int color = COLORS[colorIndex];
colorIndex = (colorIndex + 1) % COLORS.length;
return color;
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (view == backMain) { if (view.getId() == R.id.BackMain) {
Intent backMain = new Intent(Maps.this, MainActivity.class); finish();
startActivity(backMain);
} }
} }
@Override
//マーカーがクリックされた際の処理を行うメソッド
public boolean onMarkerClick(Marker marker) {
// マーカーから場所の名前を取得します
String locationName = (String) marker.getTag();
// 場所の名前がnullではない場合に処理を実行します
if (locationName != null) {
// マーカーのタイトルとして場所の名前を設定します
marker.setTitle(locationName);
// マーカーの情報ウィンドウを表示します
marker.showInfoWindow();
}
// デフォルトの動作も実行するためにfalseを返します
return false;
}
} }

View File

@ -31,6 +31,8 @@ public class MyDataClass {
private String secondDayParentEndTimeString; private String secondDayParentEndTimeString;
private String latLngString; private String latLngString;
private String ScheduleDayString;
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) { public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
this.patronNameString = patronName; this.patronNameString = patronName;
@ -245,4 +247,13 @@ public class MyDataClass {
public String getLatLngString() { public String getLatLngString() {
return latLngString; return latLngString;
} }
public void setScheduleDay(String ScheduleDayString) {
this.ScheduleDayString = ScheduleDayString;
}
public String getScheduleDay() {
return ScheduleDayString;
}
} }

View File

@ -1,14 +0,0 @@
package com.example.oplogy;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class RootSearchActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.root_search);
}
}

View File

@ -2,7 +2,6 @@ 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.DatePickerDialog;
import android.app.TimePickerDialog; import android.app.TimePickerDialog;
@ -10,7 +9,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.widget.Button; import android.widget.Button;
import android.widget.DatePicker; import android.widget.DatePicker;
@ -25,7 +23,6 @@ import androidx.fragment.app.FragmentActivity;
import androidx.room.Room; import androidx.room.Room;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -33,42 +30,36 @@ import java.util.concurrent.Executors;
public class SetUpActivity extends FragmentActivity public class SetUpActivity extends FragmentActivity
implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener { implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
String teacherName; String teacherNameString;
String startPoint; String startPointString;
String firstDay; String firstDayString;
String secondDay; String secondDayString;
String thirdDay; String thirdDayString;
String startTime; String startTimeString;
String endTime; String endTimeString;
String intervalTime; String intervalTimeString;
String startBreakTime; String startBreakTimeString;
String endBreakTime; String endBreakTimeString;
int totalStudent; int totalStudentString;
private TextView textViewTeacherName; String stringYearString;
private TextView textViewStartPoint; String stringMonthString;
private TextView textViewStartTime; String stringDayOfMonthString;
private TextView textViewEndTime; String stringHourOfDayString;
private TextView textViewStartBreakTime; String stringMinuteString;
private TextView textViewEndBreakTime; Button setFirstDay;
private TextView textViewTotalStudent; Button setSecondDay;
private int intIsDateSelected; Button setThirdDay;
private int intIsStartTimeSelected; Button setStartTimeButton;
Button setEndTimeButton;
String stringYear; private TextView setTeacherName;
String stringMonth; private TextView setStartPoint;
String stringDayOfMonth; private TextView setStartTime;
private TextView setEndTime;
private TextView setStartBreakTime;
String stringHourOfDay; private TextView setEndBreakTime;
String stringMinute; private TextView setTotalStudent;
private int isDateSelectedInt;
Button buttonFirstDay; private int isStartTimeSelectedInt;
Button buttonSecondDay;
Button buttonThirdDay;
Button buttonStartTimeButton;
Button buttonEndTimeButton;
@SuppressLint("MissingInflatedId") @SuppressLint("MissingInflatedId")
@Override @Override
@ -76,82 +67,79 @@ public class SetUpActivity extends FragmentActivity
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_up); setContentView(R.layout.activity_set_up);
int classId= getIntent().getIntExtra("classId", 100000); int classIdInt = getIntent().getIntExtra("classId", 100000);
textViewTeacherName = findViewById(R.id.teacherName); //先生の名前 setTeacherName = findViewById(R.id.teacherName); //先生の名前
textViewStartPoint = findViewById(R.id.startPoint); //開始地点 setStartPoint = findViewById(R.id.startPoint); //開始地点
buttonFirstDay = findViewById(R.id.setFirstDayButton); //1日目の日付 setFirstDay = findViewById(R.id.setFirstDayButton); //1日目の日付
buttonSecondDay = findViewById(R.id.setSecondDayButton); //2日目の日付 setSecondDay = findViewById(R.id.setSecondDayButton); //2日目の日付
buttonThirdDay = findViewById(R.id.setThirdDayButton); //3日目の日付 setThirdDay = findViewById(R.id.setThirdDayButton); //3日目の日付
buttonStartTimeButton = findViewById(R.id.startTimeSetButton); //開始時刻を設定するボタン setStartTimeButton = findViewById(R.id.startTimeSetButton); //開始時刻を設定するボタン
textViewStartTime = findViewById(R.id.startTime); //開始時刻を出力するTextView setStartTime = findViewById(R.id.startTime); //開始時刻を出力するTextView
buttonEndTimeButton = findViewById(R.id.endTimeSetButton); //終了時刻を設定するボタン setEndTimeButton = findViewById(R.id.endTimeSetButton); //終了時刻を設定するボタン
textViewEndTime = findViewById(R.id.endTime); //終了時刻を出力するTextView setEndTime = findViewById(R.id.endTime); //終了時刻を出力するTextView
RadioButton radioButtonTenMinute = findViewById(R.id.tenMinute); //訪問間隔10分 RadioButton setTenMinute = findViewById(R.id.tenMinute); //訪問間隔10分
RadioButton radioButtonFifteenMinute = findViewById(R.id.fifteenMinute); //訪問間隔15分 RadioButton setFifteenMinute = findViewById(R.id.fifteenMinute); //訪問間隔15分
RadioButton radioButtonThirtyMinute = findViewById(R.id.thirtyMinute); //訪問間隔30分 RadioButton setThirtyMinute = findViewById(R.id.thirtyMinute); //訪問間隔30分
textViewStartBreakTime = findViewById(R.id.startBreakTime); //休憩開始時刻 setStartBreakTime = findViewById(R.id.startBreakTime); //休憩開始時刻
textViewStartBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG); setStartBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
textViewEndBreakTime = findViewById(R.id.endBreakTime); //休憩終了時刻 setEndBreakTime = findViewById(R.id.endBreakTime); //休憩終了時刻
textViewEndBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG); setEndBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
textViewTotalStudent = findViewById(R.id.totalStudent); //クラスの人数 setTotalStudent = findViewById(R.id.totalStudent); //クラスの人数
ImageView toMain = findViewById(R.id.toMain); ImageView toMain = findViewById(R.id.toMain);
Button setUp = findViewById(R.id.setUpButton); //画面下の設定ボタン Button setUp = findViewById(R.id.setUpButton); //画面下の設定ボタン
Button reset = findViewById(R.id.resetButton); Button reset = findViewById(R.id.resetButton);
toMain.setOnClickListener(view -> { toMain.setOnClickListener(view -> {
Intent intent = new Intent(SetUpActivity.this,MainActivity.class); //main画面へ戻る処理 Intent intent = new Intent(SetUpActivity.this, SettingView.class); //main画面へ戻る処理
startActivity(intent); startActivity(intent);
}); });
setUp.setOnClickListener(view -> { setUp.setOnClickListener(view -> {
teacherName = textViewTeacherName.getText().toString(); //各変数に値を挿入 teacherNameString = setTeacherName.getText().toString(); //各変数に値を挿入
Log.d(TAG, "Teacher Name: " + teacherName); startPointString = setStartPoint.getText().toString();
startPoint = textViewStartPoint.getText().toString(); firstDayString = setFirstDay.getText().toString();
Log.d(TAG, "Start Point: " + startPoint); secondDayString = setSecondDay.getText().toString();
Log.d(TAG, "First Day:" + firstDay); thirdDayString = setThirdDay.getText().toString();
Log.d(TAG, "Second Day:" + secondDay); startTimeString = setStartTime.getText().toString();
Log.d(TAG, "Third Day:" + thirdDay); endTimeString = setEndTime.getText().toString();
Log.d(TAG, "Start Time" + startTime); startBreakTimeString = setStartBreakTime.getText().toString();
Log.d(TAG, "End Time" + endTime); endBreakTimeString = setEndBreakTime.getText().toString();
if (radioButtonTenMinute.isChecked()){ //ラジオボタンの状態を取得
intervalTime = "10";
} else if (radioButtonFifteenMinute.isChecked()) {
intervalTime = "15";
} else if (radioButtonThirtyMinute.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);
Log.d(TAG, "Total Student" + totalStudent);
Log.d(TAG, "onClick: できてるよ");
// クラスの人数を数値に変換して取得
try { try {
totalStudent = Integer.parseInt(textViewTotalStudent.getText().toString()); totalStudentString = Integer.parseInt(setTotalStudent.getText().toString());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
totalStudent = 0; // デフォルト値を設定するかエラー処理を追加することも考慮する必要があります Toast.makeText(SetUpActivity.this, "記入欄にすべて入力を済ませてから押してください", Toast.LENGTH_SHORT).show();
}
// 入力データのバリデーション
if (TextUtils.isEmpty(teacherName) || TextUtils.isEmpty(startPoint) || TextUtils.isEmpty(startTime)
|| TextUtils.isEmpty(firstDay) || TextUtils.isEmpty(secondDay) || TextUtils.isEmpty(thirdDay)
|| TextUtils.isEmpty(endTime) || Objects.equals(intervalTime, "0") || TextUtils.isEmpty(startBreakTime)
|| TextUtils.isEmpty(endBreakTime) || totalStudent <= 0) {
Toast.makeText(SetUpActivity.this, "必須項目を入力してください", Toast.LENGTH_SHORT).show();
return; return;
} }
Log.d(TAG, "Teacher Name: " + teacherNameString);
Log.d(TAG, "Start Point: " + startPointString);
Log.d(TAG, "First Day:" + firstDayString);
Log.d(TAG, "Second Day:" + secondDayString);
Log.d(TAG, "Third Day:" + thirdDayString);
Log.d(TAG, "Start Time" + startTimeString);
Log.d(TAG, "End Time" + endTimeString);
if (setTenMinute.isChecked()) { //ラジオボタンの状態を取得
intervalTimeString = "10";
} else if (setFifteenMinute.isChecked()) {
intervalTimeString = "15";
} else if (setThirtyMinute.isChecked()) {
intervalTimeString = "30";
} else {
intervalTimeString = "0";
}
Log.d(TAG, "Interval Time" + intervalTimeString);
Log.d(TAG, "Start Break Time" + startBreakTimeString);
Log.d(TAG, "End Break Time" + endBreakTimeString);
Log.d(TAG, "Total Student" + totalStudentString);
Log.d(TAG, "onClick: できてるよ");
// データベースへの登録処理 // データベースへの登録処理
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
@ -164,19 +152,19 @@ public class SetUpActivity extends FragmentActivity
SetUpTableDao setUpTableDao = db.setUpTableDao(); SetUpTableDao setUpTableDao = db.setUpTableDao();
// Roomの操作を行う // Roomの操作を行う
SetUpTable setUpTable = new SetUpTable( SetUpTable setUpTable = new SetUpTable(
teacherName, teacherNameString,
startPoint, startPointString,
startTime, startTimeString,
endTime, endTimeString,
intervalTime, intervalTimeString,
startBreakTime, startBreakTimeString,
endBreakTime, endBreakTimeString,
totalStudent, totalStudentString,
classId classIdInt
); );
// 同じ名前のエントリが存在するかどうかを確認 // 同じ名前のエントリが存在するかどうかを確認
SetUpTable existingSetUpTable = setUpTableDao.findByName(teacherName); SetUpTable existingSetUpTable = setUpTableDao.findByName(teacherNameString);
if (existingSetUpTable != null) { if (existingSetUpTable != null) {
// エントリが存在する場合はそのエントリを更新 // エントリが存在する場合はそのエントリを更新
setUpTable.setId(existingSetUpTable.getId()); // 既存のIDを設定 setUpTable.setId(existingSetUpTable.getId()); // 既存のIDを設定
@ -189,86 +177,65 @@ public class SetUpActivity extends FragmentActivity
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 sharedPreferences = getSharedPreferences("visitingDate", MODE_PRIVATE);
SharedPreferences.Editor editor= sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
//editorに値を渡す editor.putString("day1", firstDayString);
editor.putString("day1",firstDay); //1日目 editor.putString("day2", secondDayString);
editor.putString("day2",secondDay); //2日目 editor.putString("day3", thirdDayString);
editor.putString("day3",thirdDay); //3日目
editor.apply(); editor.apply();
}); });
}); });
//DatePicker用 setFirstDay.setOnClickListener(v -> {
buttonFirstDay.setOnClickListener(v ->{ isDateSelectedInt = 1;
intIsDateSelected = 1; //ボタンの判別Date
showDatePickerDialog(); //DatePickerの表示 showDatePickerDialog(); //DatePickerの表示
}); });
buttonSecondDay.setOnClickListener(v ->{ setSecondDay.setOnClickListener(v -> {
intIsDateSelected = 2; isDateSelectedInt = 2;
showDatePickerDialog(); showDatePickerDialog();
}); });
buttonThirdDay.setOnClickListener(v ->{ setThirdDay.setOnClickListener(v -> {
intIsDateSelected = 3; isDateSelectedInt = 3;
showDatePickerDialog(); showDatePickerDialog();
}); });
//TimePicker用 setStartTimeButton.setOnClickListener(v -> {
buttonStartTimeButton.setOnClickListener(v -> { isStartTimeSelectedInt = 1; //ボタンの判別
intIsStartTimeSelected = 1; //ボタンの判別Time showTimePickerDialog(); //TimePickerの表示
showTimePickerDialog(); //TimePickerの表示
}); });
buttonEndTimeButton.setOnClickListener(v -> { setEndTimeButton.setOnClickListener(v -> {
intIsStartTimeSelected = 2; isStartTimeSelectedInt = 2;
showTimePickerDialog(); showTimePickerDialog();
}); });
textViewStartBreakTime.setOnClickListener(v -> { setStartBreakTime.setOnClickListener(v -> {
intIsStartTimeSelected = 3; isStartTimeSelectedInt = 3;
showTimePickerDialog(); showTimePickerDialog();
}); });
textViewEndBreakTime.setOnClickListener(v -> { setEndBreakTime.setOnClickListener(v -> {
intIsStartTimeSelected = 4; isStartTimeSelectedInt = 4;
showTimePickerDialog(); showTimePickerDialog();
}); });
//リセットボタンの処理 //リセットボタンの処理
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去 reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
textViewTeacherName.setText(""); setTeacherName.setText("");
textViewStartPoint.setText(""); setStartPoint.setText("");
buttonFirstDay.setText(""); setTenMinute.setChecked(false);
buttonSecondDay.setText(""); setFifteenMinute.setChecked(false);
buttonThirdDay.setText(""); setThirtyMinute.setChecked(false);
radioButtonTenMinute.setChecked(false); setStartBreakTime.setText("");
radioButtonFifteenMinute.setChecked(false); setEndBreakTime.setText("");
radioButtonThirtyMinute.setChecked(false); setTotalStudent.setText("");
textViewStartTime.setText("");
textViewEndTime.setText("");
textViewStartBreakTime.setText("");
textViewEndBreakTime.setText("");
textViewTotalStudent.setText("");
teacherName = "";
startPoint = "";
firstDay = "";
secondDay = "";
thirdDay = "";
startTime = "";
endTime = "";
intervalTime = "";
startBreakTime = "";
endBreakTime ="" ;
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> { executor.execute(() -> {
@ -279,32 +246,32 @@ public class SetUpActivity extends FragmentActivity
}); });
} }
@Override @Override
public void onDateSet(DatePicker datePicker, int year, int month, int dayOfMonth) { //Dateを成形する public void onDateSet(DatePicker datePicker, int year, int month, int dayOfMonth) { //Dateを成形する
// DatePickerDialogで選択された日付を処理する // DatePickerDialogで選択された日付を処理する
String str = String.format(Locale.JAPAN, "%02d/%02d", month + 1, dayOfMonth); // TextViewに表示する日付の形式を設定 String str = String.format(Locale.JAPAN, "%02d/%02d", month + 1, dayOfMonth); // TextViewに表示する日付の形式を設定
if (intIsDateSelected == 1) { if (isDateSelectedInt == 1) {
stringYear = String.valueOf(year); // stringYearString = String.valueOf(year); //
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1); // stringMonthString = String.format(Locale.JAPAN, "%02d", month + 1); //
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth); // stringDayOfMonthString = String.format(Locale.JAPAN, "%02d", dayOfMonth); //
firstDay = stringYear + stringMonth + stringDayOfMonth; //8桁の文字列を作成 )20240604 firstDayString = stringYearString + stringMonthString + stringDayOfMonthString;
buttonFirstDay.setText(str); //buttonにformatされた文字列を挿入 setFirstDay.setText(str);
} else if (isDateSelectedInt == 2) {
} else if (intIsDateSelected == 2) { stringYearString = String.valueOf(year);
stringYear = String.valueOf(year); stringMonthString = String.format(Locale.JAPAN, "%02d", month + 1);
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1); stringDayOfMonthString = String.format(Locale.JAPAN, "%02d", dayOfMonth);
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth); secondDayString = stringYearString + stringMonthString + stringDayOfMonthString;
secondDay = stringYear + stringMonth + stringDayOfMonth; setSecondDay.setText(str);
buttonSecondDay.setText(str);
} else if (intIsDateSelected == 3) { } else if (isDateSelectedInt == 3) {
stringYear = String.valueOf(year); stringYearString = String.valueOf(year);
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1); stringMonthString = String.format(Locale.JAPAN, "%02d", month + 1);
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth); stringDayOfMonthString = String.format(Locale.JAPAN, "%02d", dayOfMonth);
thirdDay = stringYear + stringMonth + stringDayOfMonth; thirdDayString = stringYearString + stringMonthString + stringDayOfMonthString;
buttonThirdDay.setText(str); setThirdDay.setText(str);
} }
} }
@ -314,38 +281,38 @@ public class SetUpActivity extends FragmentActivity
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
String str = String.format(Locale.JAPAN, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定 String str = String.format(Locale.JAPAN, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
if (intIsStartTimeSelected == 1) { if (isStartTimeSelectedInt == 1) {
stringHourOfDay = String.format("%02d", hourOfDay); // stringHourOfDayString = String.format("%02d", hourOfDay);
stringMinute = String.format("%02d", minute); // stringMinuteString = String.format("%02d", minute);
startTime = stringHourOfDay + stringMinute; //4桁の文字列を作成 0930 startTimeString = stringHourOfDayString + stringMinuteString;
textViewStartTime.setText(str); //textViewにformatされている文字列を挿入 setStartTime.setText(str);
} else if (intIsStartTimeSelected == 2) { } else if (isStartTimeSelectedInt == 2) {
stringHourOfDay = String.format("%02d", hourOfDay); stringHourOfDayString = String.format("%02d", hourOfDay);
stringMinute = String.format("%02d", minute); stringMinuteString = String.format("%02d", minute);
endTime = stringHourOfDay + stringMinute; endTimeString = stringHourOfDayString + stringMinuteString;
textViewEndTime.setText(str); setEndTime.setText(str);
} else if (intIsStartTimeSelected == 3) { } else if (isStartTimeSelectedInt == 3) {
stringHourOfDay = String.format("%02d", hourOfDay); stringHourOfDayString = String.format("%02d", hourOfDay);
stringMinute = String.format("%02d", minute); stringMinuteString = String.format("%02d", minute);
startBreakTime =stringHourOfDay + stringMinute; startBreakTimeString = stringHourOfDayString + stringMinuteString;
textViewStartBreakTime.setText(" " + str + " "); setStartBreakTime.setText(" " + str + " ");
} else if (intIsStartTimeSelected == 4) { } else if (isStartTimeSelectedInt == 4) {
stringHourOfDay = String.format("%02d", hourOfDay); stringHourOfDayString = String.format("%02d", hourOfDay);
stringMinute = String.format("%02d", minute); stringMinuteString = String.format("%02d", minute);
endBreakTime = stringHourOfDay + stringMinute; endBreakTimeString = stringHourOfDayString + stringMinuteString;
textViewEndBreakTime.setText(" " + str + " "); setEndBreakTime.setText(" " + str + " ");
} }
} }
private void showDatePickerDialog() { //DatePickerDialogを表示する private void showDatePickerDialog() {
DialogFragment newFragment = new DatePick(); DialogFragment newFragment = new DatePick();
newFragment.show(getSupportFragmentManager(), "datePicker"); newFragment.show(getSupportFragmentManager(), "datePicker");
} }
private void showTimePickerDialog() { // TimePickerDialogを表示する private void showTimePickerDialog() { // Dialogを表示する
DialogFragment newFragment = new TimePick(); DialogFragment newFragment = new TimePick();
newFragment.show(getSupportFragmentManager(), "timePicker"); newFragment.show(getSupportFragmentManager(), "timePicker");
} }

View File

@ -1,5 +1,4 @@
package com.example.oplogy; package com.example.oplogy;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.PrimaryKey; import androidx.room.PrimaryKey;
@ -22,7 +21,7 @@ public class SetUpTable {
//コンストラクタ //コンストラクタ
public SetUpTable(String teacherName, String startPoint, String startTime, String endTime, public SetUpTable(String teacherName, String startPoint, String startTime, String endTime,
String intervalTime, String startBreakTime, String endBreakTime, int totalStudent, int classId) { String intervalTime, String startBreakTime, String endBreakTime, int totalStudent,int classId) {
this.teacherName = teacherName; this.teacherName = teacherName;
this.startPoint = startPoint; this.startPoint = startPoint;
this.startTime = startTime; this.startTime = startTime;
@ -33,53 +32,41 @@ public class SetUpTable {
this.totalStudent = totalStudent; this.totalStudent = totalStudent;
this.classId = classId; this.classId = classId;
} }
//getter //getter
public int getId() { public int getId() {
return id; return id;
} }
public String getTeacherName() { public String getTeacherName() {
return teacherName; return teacherName;
} }
public String getStartPoint() { public String getStartPoint() {
return startPoint; return startPoint;
} }
public String getStartTime() { public String getStartTime() {
return startTime; return startTime;
} }
public String getEndTime() { public String getEndTime() {
return endTime; return endTime;
} }
public int getTotalStudent() { public int getTotalStudent() {
return totalStudent; return totalStudent;
} }
//setter //setter
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public void setTeacherName(String teacherName) { public void setTeacherName(String teacherName) {
this.teacherName = teacherName; this.teacherName = teacherName;
} }
public void setStartPoint(String startPoint) { public void setStartPoint(String startPoint) {
this.startPoint = startPoint; this.startPoint = startPoint;
} }
public void setStartTime(String startTime) { public void setStartTime(String startTime) {
this.startTime = startTime; this.startTime = startTime;
} }
public void setEndTime(String endTime) { public void setEndTime(String endTime) {
this.endTime = endTime; this.endTime = endTime;
} }
public void setTotalStudent(int totalStudent) { public void setTotalStudent(int totalStudent) {
this.totalStudent = totalStudent; this.totalStudent = totalStudent;
} }

View File

@ -1,5 +1,4 @@
package com.example.oplogy; package com.example.oplogy;
import androidx.room.Dao; import androidx.room.Dao;
import androidx.room.Insert; import androidx.room.Insert;
import androidx.room.Query; import androidx.room.Query;
@ -11,7 +10,6 @@ import java.util.List;
public interface SetUpTableDao { public interface SetUpTableDao {
@Insert @Insert
void insertAll(SetUpTable... setUpTables); void insertAll(SetUpTable... setUpTables);
//更新処理 //更新処理
@Update @Update
void update(SetUpTable setUpTable); void update(SetUpTable setUpTable);
@ -20,7 +18,6 @@ public interface SetUpTableDao {
//削除処理 //削除処理
@Query("DELETE FROM SetUpTable") @Query("DELETE FROM SetUpTable")
void deleteAll(); void deleteAll();
//全件取得 //全件取得
@Query("SELECT * FROM SetUpTable") @Query("SELECT * FROM SetUpTable")
List<SetUpTable> getAll(); List<SetUpTable> getAll();
@ -30,24 +27,20 @@ public interface SetUpTableDao {
@Query("SELECT totalStudent FROM SetUpTable") @Query("SELECT totalStudent FROM SetUpTable")
int getTotalStudent(); int getTotalStudent();
//開始時間と終了時間の取得 //開始時間と終了時間の取得
@Query("SELECT startTime FROM SetUpTable") @Query("SELECT startTime FROM SetUpTable")
String getStartTime(); String getStartTime();
@Query("SELECT endTime FROM SetUpTable") @Query("SELECT endTime FROM SetUpTable")
String getEndTime(); String getEndTime();
//教師名の取得 //教師名の取得
@Query("SELECT teacherName FROM SetUpTable")
String getTeacherName();
@Query("SELECT intervalTime FROM SetUpTable") @Query("SELECT intervalTime FROM SetUpTable")
String getIntervalTime(); String getIntervalTime();
@Query("SELECT StartBreakTime FROM SetUpTable") @Query("SELECT StartBreakTime FROM SetUpTable")
String getStartBreakTime(); String getStartBreakTime();
@Query("SELECT EndBreakTime FROM SetUpTable") @Query("SELECT EndBreakTime FROM SetUpTable")
String getEndBreakTime(); String getEndBreakTime();
//クラスIDの取得 //クラスIDの取得
@Query("SELECT classId FROM SetUpTable") @Query("SELECT classId FROM SetUpTable")
int getClassId(); int getClassId();

View File

@ -0,0 +1,190 @@
package com.example.oplogy;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class SettingView extends AppCompatActivity implements View.OnClickListener {
// formコピー用のURL
private static final String URL_TO_COPY = "https://docs.google.com/forms/d/e/1FAIpQLScKI_ca01nO7die7SqZyThiqa7NB7gcucMJtiV_-sc3eZX6KQ/viewform";
private View backButton;
private View creatUUID;
private View imageUuid;
private View setUp;
private View imageSetup;
private View formURL;
private View imageFormURL;
private AlertDialog alertDialog;
private int classId;
private FirestoreReception_classIdDatabase firestoreReception_classIdDatabase;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_view);
// 戻るボタンの処理
backButton = findViewById(R.id.BackMain_fromSetting);
backButton.setOnClickListener(this);
// ID作成用のインテント
creatUUID = findViewById(R.id.creatUUID);
creatUUID.setOnClickListener(this);
imageUuid = findViewById(R.id.imageUuid);
imageUuid.setOnClickListener(this);
// セットアップ用のインテント
setUp = findViewById(R.id.setUp);
setUp.setOnClickListener(this);
imageSetup = findViewById(R.id.imageSetup);
imageSetup.setOnClickListener(this);
// formコピー用のインテント
formURL = findViewById(R.id.formURL);
formURL.setOnClickListener(this);
imageFormURL = findViewById(R.id.imageFormURL);
imageFormURL.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (view == backButton) {
Intent intent = new Intent(SettingView.this, MainActivity.class);
startActivity(intent);
}
// ID作成のクリック処理
if (view == creatUUID) {
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
}
if (view == imageUuid) {
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
}
// セットアップのクリック処理
if (view == setUp) {
Intent toSetup = new Intent(SettingView.this, SetUpActivity.class);
toSetup.putExtra("classId", classId);
startActivity(toSetup);
}
if (view == imageSetup) {
Intent toSetup = new Intent(SettingView.this, SetUpActivity.class);
startActivity(toSetup);
}
// formコピー用のクリック処理
if (view == formURL) {
copyUrlToClipboard(URL_TO_COPY);
}
if (view == imageFormURL) {
copyUrlToClipboard(URL_TO_COPY);
}
}
//ID作成表示に関する処理
private void showUUIDYesNoDialog() {
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
List<Integer> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("ID");
builder.setMessage("あなたのIDを表示/もしくは新規で作成しますか?");
//作成処理
builder.setPositiveButton("作成", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
classId = CreateUUID.generateUUID(classIdList);
// 生成されたIDを表示するメソッド
showClassIdDialog("生成されたID", classId);
}
});
//表示処理
builder.setNegativeButton("表示", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//roomを扱うため非同期処理
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
// 現在のクラスIDを取得
int currentClassId = getCurrentClassIdFromRoom();
if (currentClassId == 0) {
currentClassId = classId;
}
final int showDialogClassId = currentClassId;
runOnUiThread(() -> {
// 現在のクラスIDを表示するダイアログ
showClassIdDialog("現在のID", showDialogClassId);
});
});
executor.shutdown();
}
});
alertDialog = builder.create();
alertDialog.show();
}
//Roomから現在のクラスIDを取得するメソッド
private int getCurrentClassIdFromRoom() {
AppDatabase db = getDatabaseInstance();
SetUpTableDao setUpTableDao = db.setUpTableDao();
// 現在のクラスIDを取得
return setUpTableDao.getClassId();
}
//クラスIDを表示するダイアログ
private void showClassIdDialog(String title, int classId) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(title);
builder.setMessage("ID: " + classId);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
//クリップボードにURLをコピーする処理
private void copyUrlToClipboard(String url) {
try {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("URL", url);
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toast.makeText(this, "GoogleFormのURLをコピーしました", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "エラー コピーできませんでした", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Toast.makeText(this, "Error copying URL: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
// データベースのインスタンスを取得するメソッド
private AppDatabase getDatabaseInstance() {
return Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
}
}

View File

@ -1,7 +1,9 @@
package com.example.oplogy; package com.example.oplogy;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -11,11 +13,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SubmissionActivity extends AppCompatActivity { public class SubmissionActivity extends AppCompatActivity {
private final List<SubmissionStudent> studentsList = new ArrayList<>();
private RecyclerView recyclerView; private RecyclerView recyclerView;
private SubmissionAdapter submissionAdapter; private SubmissionAdapter submissionAdapter;
private List<SubmissionStudent> students = new ArrayList<>();
ArrayList<Integer> studentNumbers = new ArrayList<>();
private int totalStudent = 10;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -24,17 +24,12 @@ public class SubmissionActivity extends AppCompatActivity {
// 戻るボタンの処理 // 戻るボタンの処理
ImageView backButton = findViewById(R.id.BackMain_fromSubmission); ImageView backButton = findViewById(R.id.BackMain_fromSubmission);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> finish());
finish();
});
// インテントから提出状況の生徒の数を取得
studentNumbers = getIntent().getIntegerArrayListExtra("submissionStudents");
// RecyclerViewとアダプターの初期化
recyclerView = findViewById(R.id.recyclerView); recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setLayoutManager(new LinearLayoutManager(this));
submissionAdapter = new SubmissionAdapter(students); submissionAdapter = new SubmissionAdapter(studentsList);
recyclerView.setAdapter(submissionAdapter); recyclerView.setAdapter(submissionAdapter);
// 生徒のリストを取得 // 生徒のリストを取得
@ -43,15 +38,18 @@ public class SubmissionActivity extends AppCompatActivity {
private void fetchStudents() { private void fetchStudents() {
// インテントから生徒のリストを取得 // インテントから生徒のリストを取得
ArrayList<SubmissionStudent> submissionStudents = getIntent().getParcelableArrayListExtra("submissionStudents"); ArrayList<SubmissionStudent> submissionStudentsList = getIntent().getParcelableArrayListExtra("submissionStudents");
// 生徒のリストを反復処理しそれをRecyclerViewに表示 if (submissionStudentsList != null) {
for (SubmissionStudent student : submissionStudents) { Log.d("SubmissionActivity", "Size of submissionStudentsList: " + submissionStudentsList.size());
students.add(student);
studentsList.addAll(submissionStudentsList);
} else {
Log.e("SubmissionActivity", "submissionStudentsList is null");
Toast.makeText(this, "生徒のリストが取得できませんでした", Toast.LENGTH_SHORT).show();
} }
// データが変更されたことをアダプターに通知 // データが変更されたことをアダプターに通知
submissionAdapter.notifyDataSetChanged(); submissionAdapter.notifyDataSetChanged();
} }
} }

View File

@ -6,13 +6,57 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.List; import java.util.List;
public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.StudentViewHolder> { public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.StudentViewHolder> {
private List<SubmissionStudent> students; private final List<SubmissionStudent> studentsList;
public SubmissionAdapter(List<SubmissionStudent> students) {
this.studentsList = students;
}
@NonNull
@Override
public StudentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_submission, parent, false);
return new StudentViewHolder(view);
}
@Override
public void onBindViewHolder(StudentViewHolder holder, int position) {
SubmissionStudent student = studentsList.get(position);
holder.studentNumberTextView.setText(String.valueOf(student.getStudentNumber()));
updateStatus(holder, student.isSubmitted());
}
@Override
public int getItemCount() {
return studentsList.size();
}
//真偽値に応じて提出済みか未提出をセットする
private void updateStatus(StudentViewHolder holder, boolean isSubmitted) {
if (isSubmitted) {
holder.statusTextView.setText("提出済み");
setColors(holder, Color.BLACK, Color.WHITE);
} else {
holder.statusTextView.setText("未提出");
setColors(holder, Color.RED, Color.WHITE);
}
}
//真偽値に応じて色をセットする
private void setColors(StudentViewHolder holder, int backgroundColor, int textColor) {
holder.statusTextView.setBackgroundColor(backgroundColor);
holder.statusTextView.setTextColor(textColor);
holder.studentNumberTextView.setBackgroundColor(backgroundColor);
holder.studentNumberTextView.setTextColor(textColor);
}
public static class StudentViewHolder extends RecyclerView.ViewHolder { public static class StudentViewHolder extends RecyclerView.ViewHolder {
public TextView studentNumberTextView; public TextView studentNumberTextView;
@ -25,40 +69,4 @@ public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.St
statusTextView = view.findViewById(R.id.statusTextView); statusTextView = view.findViewById(R.id.statusTextView);
} }
} }
public SubmissionAdapter(List<SubmissionStudent> students) {
this.students = students;
}
@Override
public StudentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_submission, parent, false);
return new StudentViewHolder(view);
}
@Override
public void onBindViewHolder(StudentViewHolder holder, int position) {
SubmissionStudent student = students.get(position);
holder.studentNumberTextView.setText(String.valueOf(student.getStudentNumber()));
// 提出済みかどうかで表示を変える
if (student.isSubmitted()) {
holder.statusTextView.setText("提出済み");
holder.statusTextView.setBackgroundColor(Color.BLACK);
holder.statusTextView.setTextColor(Color.WHITE);
holder.studentNumberTextView.setBackgroundColor(Color.BLACK);
holder.studentNumberTextView.setTextColor(Color.WHITE);
} else {
holder.statusTextView.setText("未提出");
holder.statusTextView.setBackgroundColor(Color.RED);
holder.statusTextView.setTextColor(Color.WHITE);
holder.studentNumberTextView.setBackgroundColor(Color.RED);
holder.studentNumberTextView.setTextColor(Color.WHITE);
}
}
@Override
public int getItemCount() {
return students.size();
}
} }

View File

@ -1,19 +1,18 @@
package com.example.oplogy; package com.example.oplogy;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class SubmissionStudent implements Parcelable { public class SubmissionStudent implements Parcelable {
private int studentNumber; private int studentNumberInt;
private boolean submitted; private boolean submitted;
public SubmissionStudent(int studentNumber, boolean submitted) { public SubmissionStudent(int studentNumber, boolean submitted) {
this.studentNumber = studentNumber; this.studentNumberInt = studentNumber;
this.submitted = submitted; this.submitted = submitted;
} }
protected SubmissionStudent(Parcel in) { protected SubmissionStudent(Parcel in) {
studentNumber = in.readInt(); studentNumberInt = in.readInt();
submitted = in.readByte() != 0; submitted = in.readByte() != 0;
} }
@ -30,7 +29,7 @@ public class SubmissionStudent implements Parcelable {
}; };
public int getStudentNumber() { public int getStudentNumber() {
return studentNumber; return studentNumberInt;
} }
public boolean isSubmitted() { public boolean isSubmitted() {
@ -44,7 +43,7 @@ public class SubmissionStudent implements Parcelable {
@Override @Override
public void writeToParcel(Parcel parcel, int i) { public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(studentNumber); parcel.writeInt(studentNumberInt);
parcel.writeByte((byte) (submitted ? 1 : 0)); parcel.writeByte((byte) (submitted ? 1 : 0));
} }
} }

View File

@ -2,7 +2,6 @@ package com.example.oplogy;
import android.app.Dialog; import android.app.Dialog;
import android.app.TimePickerDialog; import android.app.TimePickerDialog;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.widget.TimePicker; import android.widget.TimePicker;
@ -12,20 +11,20 @@ import androidx.fragment.app.DialogFragment;
import java.util.Calendar; import java.util.Calendar;
public class TimePick extends DialogFragment implements public class TimePick extends DialogFragment implements
TimePickerDialog.OnTimeSetListener { TimePickerDialog.OnTimeSetListener{
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { // TimePeckerの生成 public Dialog onCreateDialog(Bundle savedInstanceState) { // TimePeckerの生成
final Calendar c = Calendar.getInstance(); final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY); int hourInt = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE); int minuteInt = c.get(Calendar.MINUTE);
return new TimePickerDialog((Context) getActivity(), return new TimePickerDialog(getActivity(),
(TimePickerDialog.OnTimeSetListener) getActivity(), hour, minute, true); (TimePickerDialog.OnTimeSetListener) getActivity(), hourInt, minuteInt, true);
} }
@Override @Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { public void onTimeSet(TimePicker view, int hourOfDayInt, int minuteInt) {
} }
} }

View File

@ -1,14 +0,0 @@
package com.example.oplogy;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class TutorialActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tutorial);
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -22,10 +23,9 @@
android:id="@+id/toMain" android:id="@+id/toMain"
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="60dp" android:layout_height="60dp"
android:layout_gravity="start" android:layout_gravity="left"
android:layout_marginStart="10dp" android:layout_marginLeft="10dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"/>
android:contentDescription="@string/todo" />
<TextView <TextView
@ -52,7 +52,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:autofillHints="" android:autofillHints=""
android:inputType="text" android:inputType=""
tools:ignore="LabelFor" /> tools:ignore="LabelFor" />
</LinearLayout> </LinearLayout>
@ -76,7 +76,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/startpoint" android:hint="@string/startpoint"
android:autofillHints="" android:autofillHints=""
android:inputType="text" android:inputType=""
tools:ignore="LabelFor" /> tools:ignore="LabelFor" />
</LinearLayout> </LinearLayout>
@ -91,7 +91,7 @@
<TextView <TextView
android:layout_width="90sp" android:layout_width="90sp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/setUpDate" android:text="日付設定"
android:gravity="center"/> android:gravity="center"/>
<!-- <TextView--> <!-- <TextView-->
@ -109,7 +109,7 @@
android:id="@+id/setFirstDayButton" android:id="@+id/setFirstDayButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/firstDay" android:text="1日目"
android:layout_marginStart="7sp" android:layout_marginStart="7sp"
android:layout_marginEnd="7sp" android:layout_marginEnd="7sp"
tools:ignore="DuplicateIds" /> tools:ignore="DuplicateIds" />
@ -118,7 +118,7 @@
android:id="@+id/setSecondDayButton" android:id="@+id/setSecondDayButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/secondDay" android:text="2日目"
android:layout_marginStart="7sp" android:layout_marginStart="7sp"
android:layout_marginEnd="7sp" android:layout_marginEnd="7sp"
tools:ignore="DuplicateIds" /> tools:ignore="DuplicateIds" />
@ -127,7 +127,7 @@
android:id="@+id/setThirdDayButton" android:id="@+id/setThirdDayButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/threeDay" android:text="3日目"
android:layout_marginStart="7sp" android:layout_marginStart="7sp"
android:layout_marginEnd="7sp" android:layout_marginEnd="7sp"
tools:ignore="DuplicateIds" /> tools:ignore="DuplicateIds" />
@ -151,7 +151,7 @@
android:id="@+id/startTime" android:id="@+id/startTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/notSetUp" android:hint="未設定"
android:textSize="20sp" android:textSize="20sp"
android:textAlignment="center" android:textAlignment="center"
android:autofillHints="" android:autofillHints=""
@ -186,7 +186,7 @@
android:id="@+id/endTime" android:id="@+id/endTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/notSetUp" android:hint="未設定"
android:textSize="20sp" android:textSize="20sp"
android:textAlignment="center" android:textAlignment="center"
android:autofillHints="" android:autofillHints=""

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="13"
tools:context=".SettingView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10">
<ImageView
android:id="@+id/BackMain_fromSetting"
android:layout_width="36dp"
android:layout_height="74dp"
android:layout_weight="3"
android:src="@drawable/back_button" />
<TextView
android:id="@+id/Setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="7"
android:padding="8dp"
android:text="設定"
android:textSize="40dp" />
</LinearLayout>
<!-- ID作成のレイアウト-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="3"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:id="@+id/imageUuid"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="16dp"
android:src="@drawable/createid" />
<TextView
android:id="@+id/creatUUID"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="left"
android:text="ID作成"
android:textSize="50dp" />
</LinearLayout>
<!-- セットアップのレイアウト-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="3"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:id="@+id/imageSetup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="16dp"
android:src="@drawable/settingsetup" />
<TextView
android:id="@+id/setUp"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="left"
android:text="家庭訪問情報"
android:textSize="36dp"
android:textStyle="bold" />
</LinearLayout>
<!-- フォームのURLのレイアウト-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="3"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:id="@+id/imageFormURL"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="16dp"
android:src="@drawable/form" />
<TextView
android:id="@+id/formURL"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="left"
android:text="GoogleformのURL"
android:textSize="28dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

View File

@ -1,146 +1,148 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="20" android:weightSum="20"
tools:context=".MainActivity"> tools:context=".MainActivity">
<Space <Space
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="2"/> android:layout_weight="2" />
<!-- ID作成のレイアウト--> <!-- タイトルのレイアウト-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="3"
android:weightSum="2"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageUuid"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/checked_image"
android:layout_weight="1"
/>
<TextView
android:id="@+id/creatUUID"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="left"
android:text="ID作成"
android:textSize="50dp"
/>
</LinearLayout>
<!-- セットアップのレイアウト-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="3"
android:weightSum="2"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageSetup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/checked_image"
android:layout_weight="1"
/>
<TextView
android:id="@+id/setUp"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:text="セットアップ"
android:textSize="40dp"
android:textStyle="bold"
android:layout_weight="1"
android:gravity="left"
android:layout_gravity="center"/>
</LinearLayout>
<!-- ルート表示のレイアウト-->
<LinearLayout <LinearLayout
android:layout_width="400dp" android:layout_width="400dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="3"
android:weightSum="2"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="horizontal"> android:layout_weight="4"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:id="@+id/imageTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/app_icon" />
<TextView
android:id="@+id/title"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="left"
android:text="OPLOGY"
android:textSize="60dp"
android:textStyle="bold" />
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2" />
<!-- ルート表示のレイアウト-->
<LinearLayout
android:layout_width="400dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="3"
android:orientation="horizontal"
android:weightSum="2">
<ImageView <ImageView
android:id="@+id/imageRoot" android:id="@+id/imageRoot"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/pin"
android:layout_weight="1" android:layout_weight="1"
/> android:src="@drawable/pin" />
<TextView <TextView
android:id="@+id/root" android:id="@+id/root"
android:layout_width="99dp" android:layout_width="99dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="ルート表示" android:layout_gravity="center"
android:textSize="40dp"
android:textStyle="bold"
android:layout_weight="1" android:layout_weight="1"
android:gravity="left" android:gravity="left"
android:layout_gravity="center"/> android:text="ルート表示"
android:textSize="40dp"
android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<Space <Space
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3"/> android:layout_weight="0.5" />
<!-- 提出状況のレイアウト--> <!-- 提出状況のレイアウト-->
<LinearLayout <LinearLayout
android:layout_width="350dp" android:layout_width="350dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="3"
android:layout_gravity="center" android:layout_gravity="center"
android:weightSum="2" android:layout_weight="3"
android:orientation="horizontal"> android:orientation="horizontal"
android:weightSum="2">
<ImageView <ImageView
android:id="@+id/imageSubmission" android:id="@+id/imageSubmission"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/submission"
android:layout_weight="1" android:layout_weight="1"
/> android:src="@drawable/submission" />
<TextView <TextView
android:id="@+id/submission" android:id="@+id/submission"
android:layout_width="99dp" android:layout_width="99dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="提出状況" android:layout_gravity="center"
android:textSize="40dp"
android:textStyle="bold"
android:layout_weight="1" android:layout_weight="1"
android:gravity="left" android:gravity="left"
android:layout_gravity="center"/> android:text="提出状況"
android:textSize="40dp"
android:textStyle="bold" />
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<!-- 諸々の設定のレイアウト-->
<LinearLayout
android:layout_width="350dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="3"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:id="@+id/imageSetting"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/setting" />
<TextView
android:id="@+id/setting"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="left"
android:text="設定"
android:textSize="40dp"
android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -20,28 +20,39 @@
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="90dp" android:layout_height="90dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_weight="5" /> android:layout_weight="3" />
<TextView <Spinner
android:id="@+id/date" android:id="@+id/date"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="90dp"
android:layout_weight="4" android:layout_weight="7" />
android:hint="今日の日付"
android:textSize="40dp" />
</LinearLayout> </LinearLayout>
<!-- Webの処理 --> <fragment
<WebView android:id="@+id/map"
android:id="@+id/webView" android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="6" /> android:layout_weight="6"
tools:context=".Maps" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal"
>
<ScrollView <ScrollView
android:id="@+id/scrollable" android:id="@+id/scrollable"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="300dp"
android:layout_weight="3" /> >
<LinearLayout
android:id="@+id/locationsName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</ScrollView>
</LinearLayout> </LinearLayout>
</LinearLayout>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RootSearchActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -4,7 +4,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/studentNumberTextView" android:id="@+id/studentNumberTextView"
android:layout_width="0dp" android:layout_width="0dp"
@ -22,10 +21,10 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:text="提出状況" android:background="@android:color/white"
android:textSize="36sp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingStart="8dp" android:paddingStart="8dp"
android:background="@android:color/white" android:text="提出状況"
android:textColor="@android:color/black" /> android:textColor="@android:color/black"
</LinearLayout> android:textSize="36sp" />
</LinearLayout>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -10,7 +9,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
@ -29,15 +28,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="4" android:layout_weight="4"
android:hint="提出状況" android:hint="提出状況"
android:textSize="40dp"
android:padding="8dp" android:padding="8dp"
/> android:textSize="40dp" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
/> android:layout_weight="9"
android:scrollbars="vertical" />
</LinearLayout> </LinearLayout>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TutorialActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" /> <background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon> </adaptive-icon>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" /> <background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon> </adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View File

@ -1,8 +1,9 @@
<resources> <resources>
<string name="app_name">oplogy</string> <string name="app_name">Oplogy</string>
<string name="maps_api_key">AIzaSyBqLqPm76UFpwbpU8b3oiH0wbkhosrPWpU</string>
<string name="title_activity_maps">MapsActivity</string> <string name="title_activity_maps">MapsActivity</string>
<string name="setUp">設定</string> <string name="setUp">設定</string>
<string name="reset">リセット</string> <string name="reset">データ削除</string>
<string name="teacherName">担任の名前</string> <string name="teacherName">担任の名前</string>
<string name="startPoint">開始地点</string> <string name="startPoint">開始地点</string>
<string name="startTime">開始時刻</string> <string name="startTime">開始時刻</string>
@ -11,29 +12,8 @@
<string name="breakTime">休憩時間</string> <string name="breakTime">休憩時間</string>
<string name="totalStudent">生徒の人数</string> <string name="totalStudent">生徒の人数</string>
<string name="timeSet">時刻設定</string> <string name="timeSet">時刻設定</string>
<string name="Back">🔙</string>
<string name="startpoint">住所</string> <string name="startpoint">住所</string>
<string name="tenMinute">10分</string> <string name="tenMinute">10分</string>
<string name="fifteenMinute">15分</string> <string name="fifteenMinute">15分</string>
<string name="thirtyMinute">30分</string> <string name="thirtyMinute">30分</string>
<string name="todo">TODO</string>
<string name="setUpDate">日付設定</string>
<string name="firstDay">1日目</string>
<string name="secondDay">2日目</string>
<string name="threeDay">3日目</string>
<string name="notSetUp">未設定</string>
<string-array name="months_array">
<item>1月</item>
<item>2月</item>
<item>3月</item>
<item>4月</item>
<item>5月</item>
<item>6月</item>
<item>7月</item>
<item>8月</item>
<item>9月</item>
<item>10月</item>
<item>11月</item>
<item>12月</item>
</string-array>
</resources> </resources>