Merge pull request '菊池' (#38) from AlsoMaps into master
Reviewed-on: #38
This commit is contained in:
commit
bf24921cd7
|
@ -52,3 +52,11 @@ dependencies {
|
|||
implementation "androidx.room:room-runtime:$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ライブラリの追加
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_FINE_LOCATION"
|
||||
tools:ignore="CoarseFineLocation" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -31,7 +34,7 @@
|
|||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyBQ1Ak-I2NL5TP4K59ZI0VgzKk6HNZuusw" />
|
||||
android:value="AIzaSyBqLqPm76UFpwbpU8b3oiH0wbkhosrPWpU" />
|
||||
|
||||
<activity
|
||||
android:name=".Maps"
|
||||
|
@ -46,6 +49,9 @@
|
|||
<activity
|
||||
android:name=".RootSearchActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".CreateUUID"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".DialogFragment"
|
||||
android:exported="false" />
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.room.TypeConverter;
|
||||
|
||||
import com.google.firebase.Timestamp;
|
||||
|
|
|
@ -7,8 +7,8 @@ import android.widget.DatePicker;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DatePick extends DialogFragment implements
|
||||
DatePickerDialog.OnDateSetListener {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class DialogFragment extends AppCompatActivity {
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.util.Log;
|
|||
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.firestore.CollectionReference;
|
||||
import com.google.firebase.firestore.DocumentSnapshot;
|
||||
import com.google.firebase.firestore.FirebaseFirestore;
|
||||
import com.google.firebase.firestore.QueryDocumentSnapshot;
|
||||
import com.google.firebase.firestore.QuerySnapshot;
|
||||
|
@ -12,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
public class FirestoreReception_classIdDatabase {
|
||||
private FirebaseFirestore db;
|
||||
private List<Integer> classIdList= new ArrayList<>();
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.example.oplogy;
|
|||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -15,17 +14,12 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import androidx.room.Room;
|
||||
|
||||
import com.google.firebase.firestore.FirebaseFirestore;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
|
@ -55,7 +49,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
//取得するためのクラスID
|
||||
private int classId;
|
||||
private final AppDatabase appDatabase = null;
|
||||
private String address;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -140,28 +135,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
// ルート作成のクリック処理
|
||||
if (view == root) {
|
||||
imageRoot.setImageResource(R.drawable.pin);
|
||||
if (isClassIdSet()) {
|
||||
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) {
|
||||
imageRoot.setImageResource(R.drawable.pin);
|
||||
fetchDataAndCreateRoute();
|
||||
|
@ -181,7 +157,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
}
|
||||
}
|
||||
|
||||
//IDに関する処理
|
||||
//UUIDを表示するかのダイアログ
|
||||
private void showUUIDYesNoDialog() {
|
||||
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
|
||||
List<Integer> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
|
||||
|
@ -189,30 +165,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("クラスID");
|
||||
builder.setMessage("あなたのクラスIDを表示/もしくは新規で作成しますか?");
|
||||
builder.setMessage("あなたのクラスIDを表示しますか?");
|
||||
|
||||
builder.setPositiveButton("作成", new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
classId = CreateUUID.generateUUID(classIdList);
|
||||
// 生成されたクラスIDを表示するメソッド
|
||||
showClassIdDialog("生成されたクラスID",classId);
|
||||
Toast.makeText(MainActivity.this, "クラスID: " + classId, Toast.LENGTH_SHORT).show();
|
||||
imageUuid.setImageResource(R.drawable.checked_image);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("表示", new DialogInterface.OnClickListener() {
|
||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//roomを扱うため非同期処理
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.execute(() -> {
|
||||
// 現在のクラスIDを取得
|
||||
int currentClassId = getCurrentClassIdFromRoom();
|
||||
runOnUiThread(() -> {
|
||||
// 現在のクラスIDを表示するダイアログ
|
||||
showClassIdDialog("現在のクラスID",currentClassId);
|
||||
});
|
||||
});
|
||||
executor.shutdown();
|
||||
Log.d("DialogNO", "DialogでNoが選ばれました");
|
||||
imageUuid.setImageResource(R.drawable.checked_image);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -220,47 +187,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
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();
|
||||
}
|
||||
|
||||
private boolean isClassIdSet() {
|
||||
// classIdが0より大きい場合、trueを返す
|
||||
return classId > 0;
|
||||
}
|
||||
|
||||
private CompletableFuture<Boolean> isSetupExists(int classId) {
|
||||
final ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
AppDatabase db = getDatabaseInstance();
|
||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||
List<SetUpTable> checkData = setUpTableDao.getAll();
|
||||
for (SetUpTable setUpTable : checkData) {
|
||||
if (setUpTable.classId == classId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, executorService).whenComplete((result, throwable) -> executorService.shutdown());
|
||||
}
|
||||
|
||||
//ルート作成の非同期処理
|
||||
private void fetchDataAndCreateRoute() {
|
||||
|
@ -317,15 +243,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
//final宣言することによって、スレッドセーフになる(ラムダ式内で使えるようにする)
|
||||
final List<MyDataClass> finalMyDataList = myDataList;
|
||||
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
|
||||
String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext());
|
||||
CreateRoot createRoot = new CreateRoot(MainActivity.this);
|
||||
Boolean notDuplicates = createRoot.receiveData(finalMyDataList, getApplicationContext());
|
||||
|
||||
runOnUiThread(() -> {
|
||||
if ( !startPointLatLngString.equals("")) {
|
||||
if (notDuplicates) {
|
||||
Log.d("MainActivity", "スケジュール作成成功");
|
||||
saveMyDataList(finalMyDataList);
|
||||
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
||||
toRoot.putExtra("startPointLatLngString", startPointLatLngString);
|
||||
startActivity(toRoot);
|
||||
} else {
|
||||
//保護者の重複による警告ダイアログ
|
||||
|
@ -337,19 +261,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
executor.shutdown();
|
||||
});
|
||||
}
|
||||
private void saveMyDataList(List<MyDataClass> myDataList) {
|
||||
// 共有プリファレンスのインスタンスを取得
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
|
||||
// MyDataListをJSON形式に変換
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(myDataList);
|
||||
|
||||
// JSON形式のデータを共有プリファレンスに保存
|
||||
editor.putString("myDataList", json);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private void showErrorDialog(List<MyDataClass> myDataList) {
|
||||
List<Integer> studentNumbers = new ArrayList<>();
|
||||
|
@ -376,7 +287,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
|
||||
private AppDatabase getDatabaseInstance() {
|
||||
return Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").fallbackToDestructiveMigration().build();
|
||||
return Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,32 +1,57 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
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.example.oplogy.databinding.MapsBinding;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
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;
|
||||
ImageView backMain;
|
||||
private GoogleMap mMap;
|
||||
private MapsBinding binding;
|
||||
private ArrayList<Parcelable> myDataList;
|
||||
private LinearLayout locationsName;
|
||||
private Spinner dateSpinner;
|
||||
private static final int[] COLORS = new int[]{
|
||||
Color.BLUE, Color.RED, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.YELLOW
|
||||
};
|
||||
private int colorIndex = 0;
|
||||
private List<LatLng> latLngList = new ArrayList<>();
|
||||
private List<String> nameList = new ArrayList<>();
|
||||
private List<Integer> colorList = new ArrayList<>();
|
||||
|
||||
private Map<String, Runnable> dateMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -35,91 +60,282 @@ public class Maps extends FragmentActivity implements View.OnClickListener {
|
|||
binding = MapsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
|
||||
backMain = findViewById(R.id.BackMain);
|
||||
backMain.setOnClickListener(this);
|
||||
|
||||
webView = findViewById(R.id.webView);
|
||||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
locationsName = findViewById(R.id.locationsName);
|
||||
|
||||
// startPointLatLngStringの取得
|
||||
String startPointLatLngString = getIntent().getStringExtra("startPointLatLngString");
|
||||
//MyDataListの取得
|
||||
List<MyDataClass> myDataList = getMyDataList();
|
||||
// 日付を入れる処理
|
||||
String dateData = "6月3日/6月4日/6月5日/6月6日/6月7日";
|
||||
|
||||
String latlngString = "";
|
||||
for (int i = -1; i < myDataList.size(); i++) {
|
||||
if (i < 0) {
|
||||
//家庭訪問の開始地点の緯度経度
|
||||
latlngString += startPointLatLngString + "/";
|
||||
} else {
|
||||
//各家庭の緯度経度
|
||||
String latlng = myDataList.get(i).getLatLngString();
|
||||
int startIndex = latlng.indexOf("(") + 1;
|
||||
int endIndex = latlng.indexOf(")");
|
||||
String latlngOnly = latlng.substring(startIndex, endIndex);
|
||||
latlngString += latlngOnly;
|
||||
if (i < myDataList.size() - 1) {
|
||||
latlngString += "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d("Maps", "startPointLatLngString" + startPointLatLngString);
|
||||
Log.d("Maps", "latlngString" + latlngString);
|
||||
loadMapInWebView(latlngString);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
String[] dates = dateData.split("/");
|
||||
for (String date : dates) {
|
||||
adapter.add(date);
|
||||
}
|
||||
|
||||
// 共有プリファレンスからMyDataListを取得するメソッド
|
||||
private List<MyDataClass> getMyDataList() {
|
||||
// 共有プリファレンスのインスタンスを取得
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||
// 各日付に対応するRunnableを設定する
|
||||
dateMap.put("6月3日", this::firstMapAndNames);
|
||||
dateMap.put("6月4日", this::secondMapAndNames);
|
||||
dateMap.put("6月5日", this::thirdMapAndNames);
|
||||
// 必要に応じて追加の日付に対応するメソッドをここに追加
|
||||
dateMap.put("6月6日", this::additionalMapAndNames);
|
||||
dateMap.put("6月7日", this::additionalMapAndNames2);
|
||||
|
||||
// 共有プリファレンスからJSON形式のデータを取得
|
||||
String json = sharedPreferences.getString("myDataList", "");
|
||||
dateSpinner = findViewById(R.id.date);
|
||||
dateSpinner.setAdapter(adapter);
|
||||
|
||||
// JSON形式のデータをMyDataListに変換
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<MyDataClass>>() {
|
||||
}.getType();
|
||||
List<MyDataClass> myDataList = gson.fromJson(json, type);
|
||||
|
||||
return myDataList;
|
||||
dateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
String selectedItem = (String) parent.getItemAtPosition(position);
|
||||
Runnable mapLoader = dateMap.get(selectedItem);
|
||||
if (mapLoader != null) {
|
||||
mapLoader.run();
|
||||
}
|
||||
}
|
||||
|
||||
// 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");
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (locArray.length > 0) {
|
||||
urlBuilder.append("&origin=").append(locArray[0]);
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
mMap.setOnMarkerClickListener(this);
|
||||
firstMapAndNames(); // 最初に表示するデータセットをロード
|
||||
}
|
||||
|
||||
if (locArray.length > 1) {
|
||||
urlBuilder.append("&destination=").append(locArray[locArray.length - 1]);
|
||||
private void firstMapAndNames() {
|
||||
String locationData = "35.09050879999539,136.87845379325216/35.091950716938875,136.8826598363985/35.09273643623442,136.88154941341296/35.09473643623442,136.88154941341296/35.09673643623442,136.88154941341296";
|
||||
String nameData = "名古屋港水族館/2番目/3番目/4番目/5番目";
|
||||
loadMapAndNames(locationData, nameData);
|
||||
}
|
||||
|
||||
if (locArray.length > 2) {
|
||||
private void secondMapAndNames() {
|
||||
String locationData2 = "35.09050879999539,136.87845379325216/35.091950716938875,136.8826598363985/35.09273643623442,136.88154941341296";
|
||||
String nameData2 = "名古屋港水族館/2番目/3番目";
|
||||
loadMapAndNames(locationData2, nameData2);
|
||||
}
|
||||
|
||||
private void thirdMapAndNames() {
|
||||
String locationData3 = "35.09050879999539,136.87845379325216/35.091950716938875,136.8826598363985";
|
||||
String nameData3 = "名古屋港水族館/2番目";
|
||||
loadMapAndNames(locationData3, nameData3);
|
||||
}
|
||||
|
||||
// 追加の日付に対応するメソッド
|
||||
private void additionalMapAndNames() {
|
||||
String locationData4 = "35.09050879999539,136.87845379325216/35.091950716938875,136.8826598363985/35.09300000000000,136.88300000000000";
|
||||
String nameData4 = "名古屋港水族館/2番目/3番目";
|
||||
loadMapAndNames(locationData4, nameData4);
|
||||
}
|
||||
|
||||
private void additionalMapAndNames2() {
|
||||
String locationData5 = "35.09050879999539,136.87845379325216/35.091950716938875,136.8826598363985/35.09400000000000,136.88400000000000";
|
||||
String nameData5 = "名古屋港水族館/2番目/3番目";
|
||||
loadMapAndNames(locationData5, nameData5);
|
||||
}
|
||||
|
||||
private void loadMapAndNames(String locationData, String nameData) {
|
||||
try {
|
||||
latLngList.clear();
|
||||
nameList.clear();
|
||||
colorList.clear();
|
||||
locationsName.removeAllViews();
|
||||
mMap.clear();
|
||||
|
||||
String[] locArray = locationData.split("/");
|
||||
String[] nameArray = nameData.split("/");
|
||||
|
||||
for (int i = 0; i < locArray.length; i++) {
|
||||
String[] latLng = locArray[i].split(",");
|
||||
if (latLng.length == 2) {
|
||||
double latitude = Double.parseDouble(latLng[0]);
|
||||
double longitude = Double.parseDouble(latLng[1]);
|
||||
LatLng position = new LatLng(latitude, longitude);
|
||||
latLngList.add(position);
|
||||
|
||||
String name = nameArray.length > i ? nameArray[i] : "Unknown";
|
||||
nameList.add(name);
|
||||
|
||||
int color = getNextColor();
|
||||
colorList.add(color);
|
||||
|
||||
addPinToMap(name, position, color);
|
||||
addLocationToScrollView(name, color);
|
||||
}
|
||||
}
|
||||
|
||||
if (!latLngList.isEmpty()) {
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLngList.get(0), 17));
|
||||
drawRoute();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("Maps", "Error loading maps and names", e);
|
||||
}
|
||||
}
|
||||
|
||||
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=");
|
||||
for (int i = 1; i < locArray.length - 1; i++) {
|
||||
urlBuilder.append(locArray[i]);
|
||||
if (i < locArray.length - 2) {
|
||||
for (int i = 1; i < latLngList.size() - 1; i++) {
|
||||
urlBuilder.append("via:").append(latLngList.get(i).latitude).append(",").append(latLngList.get(i).longitude);
|
||||
if (i < latLngList.size() - 2) {
|
||||
urlBuilder.append("|");
|
||||
}
|
||||
}
|
||||
}
|
||||
urlBuilder.append("&mode=driving");
|
||||
urlBuilder.append("&key=").append(getString(R.string.maps_api_key));
|
||||
|
||||
URL url = new URL(urlBuilder.toString());
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
StringBuilder jsonResults = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
jsonResults.append(line);
|
||||
}
|
||||
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", "Error: " + errorMessage.getAsString());
|
||||
} else {
|
||||
Log.e("Maps", "No routes found and no error message provided");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("Maps", "Error drawing route", e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private List<LatLng> decodePoly(String encoded) {
|
||||
List<LatLng> poly = new ArrayList<>();
|
||||
int index = 0, len = encoded.length();
|
||||
int lat = 0, lng = 0;
|
||||
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
b = encoded.charAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
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 p = new LatLng((((double) lat / 1E5)), (((double) lng / 1E5)));
|
||||
poly.add(p);
|
||||
}
|
||||
|
||||
return poly;
|
||||
}
|
||||
|
||||
private float getHueFromColor(int color) {
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
return hsv[0];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
webView.loadUrl(urlBuilder.toString());
|
||||
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.setBackgroundColor(color);
|
||||
|
||||
View underline = new View(this);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
3
|
||||
);
|
||||
params.setMargins(0, 0, 0, 16);
|
||||
underline.setLayoutParams(params);
|
||||
underline.setBackgroundColor(Color.BLACK);
|
||||
|
||||
locationsName.addView(textView);
|
||||
locationsName.addView(underline);
|
||||
} catch (Exception e) {
|
||||
Log.e("Maps", "Error adding location to scroll view", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int getNextColor() {
|
||||
int color = COLORS[colorIndex];
|
||||
colorIndex = (colorIndex + 1) % COLORS.length;
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view == backMain) {
|
||||
Intent backMain = new Intent(Maps.this, MainActivity.class);
|
||||
startActivity(backMain);
|
||||
if (view.getId() == R.id.BackMain) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClick(Marker marker) {
|
||||
String locationName = (String) marker.getTag();
|
||||
if (locationName != null) {
|
||||
marker.setTitle(locationName);
|
||||
marker.showInfoWindow();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.firebase.Timestamp;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,7 +30,7 @@ public class MyDataClass {
|
|||
private Long secondDayTimezoneLong;
|
||||
private String secondDayParentStartTimeString;
|
||||
private String secondDayParentEndTimeString;
|
||||
private String latLngString;
|
||||
private LatLng latLng;
|
||||
|
||||
|
||||
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
|
||||
|
@ -238,11 +239,11 @@ public class MyDataClass {
|
|||
return secondDayStartDateString;
|
||||
}
|
||||
|
||||
public void setLatLngString(String latLng) {
|
||||
this.latLngString = latLng;
|
||||
public void setLatLng(LatLng latLng) {
|
||||
this.latLng=latLng;
|
||||
}
|
||||
|
||||
public String getLatLngString() {
|
||||
return latLngString;
|
||||
public LatLng getLatLng() {
|
||||
return latLng;
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
|
@ -25,7 +24,6 @@ import androidx.fragment.app.FragmentActivity;
|
|||
import androidx.room.Room;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
@ -44,15 +42,15 @@ public class SetUpActivity extends FragmentActivity
|
|||
String startBreakTime;
|
||||
String endBreakTime;
|
||||
int totalStudent;
|
||||
private TextView textViewTeacherName;
|
||||
private TextView textViewStartPoint;
|
||||
private TextView textViewStartTime;
|
||||
private TextView textViewEndTime;
|
||||
private TextView textViewStartBreakTime;
|
||||
private TextView textViewEndBreakTime;
|
||||
private TextView textViewTotalStudent;
|
||||
private int intIsDateSelected;
|
||||
private int intIsStartTimeSelected;
|
||||
private TextView setTeacherName;
|
||||
private TextView setStartPoint;
|
||||
private TextView setStartTime;
|
||||
private TextView setEndTime;
|
||||
private TextView setStartBreakTime;
|
||||
private TextView setEndBreakTime;
|
||||
private TextView setTotalStudent;
|
||||
private int isDateSelected;
|
||||
private int isStartTimeSelected;
|
||||
|
||||
String stringYear;
|
||||
String stringMonth;
|
||||
|
@ -62,11 +60,11 @@ public class SetUpActivity extends FragmentActivity
|
|||
String stringHourOfDay;
|
||||
String stringMinute;
|
||||
|
||||
Button buttonFirstDay;
|
||||
Button buttonSecondDay;
|
||||
Button buttonThirdDay;
|
||||
Button buttonStartTimeButton;
|
||||
Button buttonEndTimeButton;
|
||||
Button setFirstDay;
|
||||
Button setSecondDay;
|
||||
Button setThirdDay;
|
||||
Button setStartTimeButton;
|
||||
Button setEndTimeButton;
|
||||
|
||||
|
||||
|
||||
|
@ -78,28 +76,28 @@ public class SetUpActivity extends FragmentActivity
|
|||
|
||||
int classId= getIntent().getIntExtra("classId", 100000);
|
||||
|
||||
textViewTeacherName = findViewById(R.id.teacherName); //先生の名前
|
||||
textViewStartPoint = findViewById(R.id.startPoint); //開始地点
|
||||
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
||||
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
||||
|
||||
buttonFirstDay = findViewById(R.id.setFirstDayButton); //1日目の日付
|
||||
buttonSecondDay = findViewById(R.id.setSecondDayButton); //2日目の日付
|
||||
buttonThirdDay = findViewById(R.id.setThirdDayButton); //3日目の日付
|
||||
setFirstDay = findViewById(R.id.setFirstDayButton); //1日目の日付
|
||||
setSecondDay = findViewById(R.id.setSecondDayButton); //2日目の日付
|
||||
setThirdDay = findViewById(R.id.setThirdDayButton); //3日目の日付
|
||||
|
||||
buttonStartTimeButton = findViewById(R.id.startTimeSetButton); //開始時刻を設定するボタン
|
||||
textViewStartTime = findViewById(R.id.startTime); //開始時刻を出力するTextView
|
||||
buttonEndTimeButton = findViewById(R.id.endTimeSetButton); //終了時刻を設定するボタン
|
||||
textViewEndTime = findViewById(R.id.endTime); //終了時刻を出力するTextView
|
||||
setStartTimeButton = findViewById(R.id.startTimeSetButton); //開始時刻を設定するボタン
|
||||
setStartTime = findViewById(R.id.startTime); //開始時刻を出力するTextView
|
||||
setEndTimeButton = findViewById(R.id.endTimeSetButton); //終了時刻を設定するボタン
|
||||
setEndTime = findViewById(R.id.endTime); //終了時刻を出力するTextView
|
||||
|
||||
RadioButton radioButtonTenMinute = findViewById(R.id.tenMinute); //訪問間隔(10分)
|
||||
RadioButton radioButtonFifteenMinute = findViewById(R.id.fifteenMinute); //訪問間隔(15分)
|
||||
RadioButton radioButtonThirtyMinute = findViewById(R.id.thirtyMinute); //訪問間隔(30分)
|
||||
RadioButton setTenMinute = findViewById(R.id.tenMinute); //訪問間隔(10分)
|
||||
RadioButton setFifteenMinute = findViewById(R.id.fifteenMinute); //訪問間隔(15分)
|
||||
RadioButton setThirtyMinute = findViewById(R.id.thirtyMinute); //訪問間隔(30分)
|
||||
|
||||
textViewStartBreakTime = findViewById(R.id.startBreakTime); //休憩開始時刻
|
||||
textViewStartBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||
textViewEndBreakTime = findViewById(R.id.endBreakTime); //休憩終了時刻
|
||||
textViewEndBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||
setStartBreakTime = findViewById(R.id.startBreakTime); //休憩開始時刻
|
||||
setStartBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||
setEndBreakTime = findViewById(R.id.endBreakTime); //休憩終了時刻
|
||||
setEndBreakTime.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||
|
||||
textViewTotalStudent = findViewById(R.id.totalStudent); //クラスの人数
|
||||
setTotalStudent = findViewById(R.id.totalStudent); //クラスの人数
|
||||
|
||||
ImageView toMain = findViewById(R.id.toMain);
|
||||
Button setUp = findViewById(R.id.setUpButton); //画面下の設定ボタン
|
||||
|
@ -112,20 +110,20 @@ public class SetUpActivity extends FragmentActivity
|
|||
|
||||
setUp.setOnClickListener(view -> {
|
||||
|
||||
teacherName = textViewTeacherName.getText().toString(); //各変数に値を挿入
|
||||
teacherName = setTeacherName.getText().toString(); //各変数に値を挿入
|
||||
Log.d(TAG, "Teacher Name: " + teacherName);
|
||||
startPoint = textViewStartPoint.getText().toString();
|
||||
startPoint = setStartPoint.getText().toString();
|
||||
Log.d(TAG, "Start Point: " + startPoint);
|
||||
Log.d(TAG, "First Day:" + firstDay);
|
||||
Log.d(TAG, "Second Day:" + secondDay);
|
||||
Log.d(TAG, "Third Day:" + thirdDay);
|
||||
Log.d(TAG, "Start Time" + startTime);
|
||||
Log.d(TAG, "End Time" + endTime);
|
||||
if (radioButtonTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
||||
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
||||
intervalTime = "10";
|
||||
} else if (radioButtonFifteenMinute.isChecked()) {
|
||||
} else if (setFifteenMinute.isChecked()) {
|
||||
intervalTime = "15";
|
||||
} else if (radioButtonThirtyMinute.isChecked()) {
|
||||
} else if (setThirtyMinute.isChecked()) {
|
||||
intervalTime = "30";
|
||||
} else {
|
||||
intervalTime = "0";
|
||||
|
@ -133,25 +131,10 @@ public class SetUpActivity extends FragmentActivity
|
|||
Log.d(TAG, "Interval Time" + intervalTime);
|
||||
Log.d(TAG, "Start Break Time" + startBreakTime);
|
||||
Log.d(TAG, "End Break Time" + endBreakTime);
|
||||
totalStudent = Integer.parseInt(setTotalStudent.getText().toString()); //数値型に変更
|
||||
Log.d(TAG, "Total Student" + totalStudent);
|
||||
Log.d(TAG, "onClick: できてるよ");
|
||||
|
||||
// クラスの人数を数値に変換して取得
|
||||
try {
|
||||
totalStudent = Integer.parseInt(textViewTotalStudent.getText().toString());
|
||||
} catch (NumberFormatException e) {
|
||||
totalStudent = 0; // デフォルト値を設定するか、エラー処理を追加することも考慮する必要があります
|
||||
}
|
||||
|
||||
// 入力データのバリデーション
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// データベースへの登録処理
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
|
@ -192,10 +175,9 @@ public class SetUpActivity extends FragmentActivity
|
|||
SharedPreferences sharedPreferences=getSharedPreferences("visitingDate",MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor= sharedPreferences.edit();
|
||||
|
||||
//editorに値を渡す
|
||||
editor.putString("day1",firstDay); //1日目
|
||||
editor.putString("day2",secondDay); //2日目
|
||||
editor.putString("day3",thirdDay); //3日目
|
||||
editor.putString("day1",firstDay);
|
||||
editor.putString("day2",secondDay);
|
||||
editor.putString("day3",thirdDay);
|
||||
|
||||
editor.apply();
|
||||
|
||||
|
@ -204,71 +186,52 @@ public class SetUpActivity extends FragmentActivity
|
|||
|
||||
});
|
||||
|
||||
//DatePicker用
|
||||
buttonFirstDay.setOnClickListener(v ->{
|
||||
intIsDateSelected = 1; //ボタンの判別(Date)
|
||||
setFirstDay.setOnClickListener(v ->{
|
||||
isDateSelected = 1;
|
||||
showDatePickerDialog(); //DatePickerの表示
|
||||
});
|
||||
|
||||
buttonSecondDay.setOnClickListener(v ->{
|
||||
intIsDateSelected = 2;
|
||||
setSecondDay.setOnClickListener(v ->{
|
||||
isDateSelected = 2;
|
||||
showDatePickerDialog();
|
||||
});
|
||||
|
||||
buttonThirdDay.setOnClickListener(v ->{
|
||||
intIsDateSelected = 3;
|
||||
setThirdDay.setOnClickListener(v ->{
|
||||
isDateSelected = 3;
|
||||
showDatePickerDialog();
|
||||
});
|
||||
|
||||
//TimePicker用
|
||||
buttonStartTimeButton.setOnClickListener(v -> {
|
||||
intIsStartTimeSelected = 1; //ボタンの判別(Time)
|
||||
setStartTimeButton.setOnClickListener(v -> {
|
||||
isStartTimeSelected = 1; //ボタンの判別
|
||||
showTimePickerDialog(); //TimePickerの表示
|
||||
});
|
||||
|
||||
buttonEndTimeButton.setOnClickListener(v -> {
|
||||
intIsStartTimeSelected = 2;
|
||||
setEndTimeButton.setOnClickListener(v -> {
|
||||
isStartTimeSelected = 2;
|
||||
showTimePickerDialog();
|
||||
});
|
||||
|
||||
textViewStartBreakTime.setOnClickListener(v -> {
|
||||
intIsStartTimeSelected = 3;
|
||||
setStartBreakTime.setOnClickListener(v -> {
|
||||
isStartTimeSelected = 3;
|
||||
showTimePickerDialog();
|
||||
});
|
||||
|
||||
textViewEndBreakTime.setOnClickListener(v -> {
|
||||
intIsStartTimeSelected = 4;
|
||||
setEndBreakTime.setOnClickListener(v -> {
|
||||
isStartTimeSelected = 4;
|
||||
showTimePickerDialog();
|
||||
});
|
||||
|
||||
//リセットボタンの処理
|
||||
|
||||
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
|
||||
textViewTeacherName.setText("");
|
||||
textViewStartPoint.setText("");
|
||||
buttonFirstDay.setText("");
|
||||
buttonSecondDay.setText("");
|
||||
buttonThirdDay.setText("");
|
||||
radioButtonTenMinute.setChecked(false);
|
||||
radioButtonFifteenMinute.setChecked(false);
|
||||
radioButtonThirtyMinute.setChecked(false);
|
||||
textViewStartTime.setText("");
|
||||
textViewEndTime.setText("");
|
||||
textViewStartBreakTime.setText("");
|
||||
textViewEndBreakTime.setText("");
|
||||
textViewTotalStudent.setText("");
|
||||
|
||||
teacherName = "";
|
||||
startPoint = "";
|
||||
firstDay = "";
|
||||
secondDay = "";
|
||||
thirdDay = "";
|
||||
startTime = "";
|
||||
endTime = "";
|
||||
intervalTime = "";
|
||||
startBreakTime = "";
|
||||
endBreakTime ="" ;
|
||||
|
||||
setTeacherName.setText("");
|
||||
setStartPoint.setText("");
|
||||
setTenMinute.setChecked(false);
|
||||
setFifteenMinute.setChecked(false);
|
||||
setThirtyMinute.setChecked(false);
|
||||
setStartBreakTime.setText("");
|
||||
setEndBreakTime.setText("");
|
||||
setTotalStudent.setText("");
|
||||
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.execute(() -> {
|
||||
|
@ -284,27 +247,26 @@ public class SetUpActivity extends FragmentActivity
|
|||
// DatePickerDialogで選択された日付を処理する
|
||||
String str = String.format(Locale.JAPAN, "%02d/%02d", month + 1, dayOfMonth); // TextViewに表示する日付の形式を設定
|
||||
|
||||
if (intIsDateSelected == 1) {
|
||||
if (isDateSelected == 1) {
|
||||
stringYear = String.valueOf(year); //年
|
||||
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1); //月
|
||||
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth); //日
|
||||
firstDay = stringYear + stringMonth + stringDayOfMonth; //8桁の文字列を作成 例)20240604
|
||||
buttonFirstDay.setText(str); //buttonにformatされた文字列を挿入
|
||||
|
||||
} else if (intIsDateSelected == 2) {
|
||||
firstDay = stringYear + stringMonth + stringDayOfMonth;
|
||||
setFirstDay.setText(str);
|
||||
} else if (isDateSelected == 2) {
|
||||
stringYear = String.valueOf(year);
|
||||
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1);
|
||||
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
||||
secondDay = stringYear + stringMonth + stringDayOfMonth;
|
||||
buttonSecondDay.setText(str);
|
||||
setSecondDay.setText(str);
|
||||
|
||||
|
||||
} else if (intIsDateSelected == 3) {
|
||||
} else if (isDateSelected == 3) {
|
||||
stringYear = String.valueOf(year);
|
||||
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1);
|
||||
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
||||
thirdDay = stringYear + stringMonth + stringDayOfMonth;
|
||||
buttonThirdDay.setText(str);
|
||||
setThirdDay.setText(str);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -314,38 +276,38 @@ public class SetUpActivity extends FragmentActivity
|
|||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
String str = String.format(Locale.JAPAN, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
||||
|
||||
if (intIsStartTimeSelected == 1) {
|
||||
stringHourOfDay = String.format("%02d", hourOfDay); //時
|
||||
stringMinute = String.format("%02d", minute); //分
|
||||
startTime = stringHourOfDay + stringMinute; //4桁の文字列を作成 例)0930
|
||||
textViewStartTime.setText(str); //textViewにformatされている文字列を挿入
|
||||
if (isStartTimeSelected == 1) {
|
||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||
stringMinute = String.format("%02d", minute);
|
||||
startTime = stringHourOfDay + stringMinute;
|
||||
setStartTime.setText(str);
|
||||
|
||||
} else if (intIsStartTimeSelected == 2) {
|
||||
} else if (isStartTimeSelected == 2) {
|
||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||
stringMinute = String.format("%02d", minute);
|
||||
endTime = stringHourOfDay + stringMinute;
|
||||
textViewEndTime.setText(str);
|
||||
setEndTime.setText(str);
|
||||
|
||||
} else if (intIsStartTimeSelected == 3) {
|
||||
} else if (isStartTimeSelected == 3) {
|
||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||
stringMinute = String.format("%02d", minute);
|
||||
startBreakTime =stringHourOfDay + stringMinute;
|
||||
textViewStartBreakTime.setText(" " + str + " ");
|
||||
setStartBreakTime.setText(" " + str + " ");
|
||||
|
||||
} else if (intIsStartTimeSelected == 4) {
|
||||
} else if (isStartTimeSelected == 4) {
|
||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
||||
stringMinute = String.format("%02d", minute);
|
||||
endBreakTime = stringHourOfDay + stringMinute;
|
||||
textViewEndBreakTime.setText(" " + str + " ");
|
||||
setEndBreakTime.setText(" " + str + " ");
|
||||
}
|
||||
}
|
||||
|
||||
private void showDatePickerDialog() { //DatePickerDialogを表示する
|
||||
private void showDatePickerDialog() {
|
||||
DialogFragment newFragment = new DatePick();
|
||||
newFragment.show(getSupportFragmentManager(), "datePicker");
|
||||
}
|
||||
|
||||
private void showTimePickerDialog() { // TimePickerDialogを表示する
|
||||
private void showTimePickerDialog() { // Dialogを表示する
|
||||
DialogFragment newFragment = new TimePick();
|
||||
newFragment.show(getSupportFragmentManager(), "timePicker");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
|
@ -33,53 +32,41 @@ public class SetUpTable {
|
|||
this.totalStudent = totalStudent;
|
||||
this.classId = classId;
|
||||
}
|
||||
|
||||
//getter
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTeacherName() {
|
||||
return teacherName;
|
||||
}
|
||||
|
||||
public String getStartPoint() {
|
||||
return startPoint;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public int getTotalStudent() {
|
||||
return totalStudent;
|
||||
}
|
||||
|
||||
//setter
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setTeacherName(String teacherName) {
|
||||
this.teacherName = teacherName;
|
||||
}
|
||||
|
||||
public void setStartPoint(String startPoint) {
|
||||
this.startPoint = startPoint;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public void setTotalStudent(int totalStudent) {
|
||||
this.totalStudent = totalStudent;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
|
@ -11,7 +10,6 @@ import java.util.List;
|
|||
public interface SetUpTableDao {
|
||||
@Insert
|
||||
void insertAll(SetUpTable... setUpTables);
|
||||
|
||||
//更新処理
|
||||
@Update
|
||||
void update(SetUpTable setUpTable);
|
||||
|
@ -20,7 +18,6 @@ public interface SetUpTableDao {
|
|||
//削除処理
|
||||
@Query("DELETE FROM SetUpTable")
|
||||
void deleteAll();
|
||||
|
||||
//全件取得
|
||||
@Query("SELECT * FROM SetUpTable")
|
||||
List<SetUpTable> getAll();
|
||||
|
@ -30,32 +27,21 @@ public interface SetUpTableDao {
|
|||
|
||||
@Query("SELECT totalStudent FROM SetUpTable")
|
||||
int getTotalStudent();
|
||||
|
||||
//開始時間と終了時間の取得
|
||||
@Query("SELECT startTime FROM SetUpTable")
|
||||
String getStartTime();
|
||||
|
||||
@Query("SELECT endTime FROM SetUpTable")
|
||||
String getEndTime();
|
||||
|
||||
//教師名の取得
|
||||
@Query("SELECT teacherName FROM SetUpTable")
|
||||
String getTeacherName();
|
||||
@Query("SELECT intervalTime FROM SetUpTable")
|
||||
String getIntervalTime();
|
||||
|
||||
@Query("SELECT StartBreakTime FROM SetUpTable")
|
||||
String getStartBreakTime();
|
||||
|
||||
@Query("SELECT EndBreakTime FROM SetUpTable")
|
||||
String getEndBreakTime();
|
||||
|
||||
//クラスIDの取得
|
||||
@Query("SELECT classId FROM SetUpTable")
|
||||
int getClassId();
|
||||
|
||||
@Query("SELECT startPoint FROM setuptable")
|
||||
String getStartPoint();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.oplogy.databinding.SubmissionBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -40,7 +42,6 @@ public class SubmissionActivity extends AppCompatActivity {
|
|||
// 生徒のリストを取得
|
||||
fetchStudents();
|
||||
}
|
||||
|
||||
private void fetchStudents() {
|
||||
// インテントから生徒のリストを取得
|
||||
ArrayList<SubmissionStudent> submissionStudents = getIntent().getParcelableArrayListExtra("submissionStudents");
|
||||
|
|
|
@ -5,9 +5,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.StudentViewHolder> {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -22,10 +23,9 @@
|
|||
android:id="@+id/toMain"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginStart="10dp"
|
||||
android:src="@drawable/back_button"
|
||||
android:contentDescription="@string/todo" />
|
||||
android:layout_gravity="left"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:src="@drawable/back_button"/>
|
||||
|
||||
|
||||
<TextView
|
||||
|
@ -52,7 +52,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints=""
|
||||
android:inputType="text"
|
||||
android:inputType=""
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -76,7 +76,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:hint="@string/startpoint"
|
||||
android:autofillHints=""
|
||||
android:inputType="text"
|
||||
android:inputType=""
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -91,7 +91,7 @@
|
|||
<TextView
|
||||
android:layout_width="90sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/setUpDate"
|
||||
android:text="日付設定"
|
||||
android:gravity="center"/>
|
||||
|
||||
<!-- <TextView-->
|
||||
|
@ -109,7 +109,7 @@
|
|||
android:id="@+id/setFirstDayButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/firstDay"
|
||||
android:text="1日目"
|
||||
android:layout_marginStart="7sp"
|
||||
android:layout_marginEnd="7sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
@ -118,7 +118,7 @@
|
|||
android:id="@+id/setSecondDayButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/secondDay"
|
||||
android:text="2日目"
|
||||
android:layout_marginStart="7sp"
|
||||
android:layout_marginEnd="7sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
@ -127,7 +127,7 @@
|
|||
android:id="@+id/setThirdDayButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/threeDay"
|
||||
android:text="3日目"
|
||||
android:layout_marginStart="7sp"
|
||||
android:layout_marginEnd="7sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
@ -151,7 +151,7 @@
|
|||
android:id="@+id/startTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/notSetUp"
|
||||
android:hint="未設定"
|
||||
android:textSize="20sp"
|
||||
android:textAlignment="center"
|
||||
android:autofillHints=""
|
||||
|
@ -186,7 +186,7 @@
|
|||
android:id="@+id/endTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/notSetUp"
|
||||
android:hint="未設定"
|
||||
android:textSize="20sp"
|
||||
android:textAlignment="center"
|
||||
android:autofillHints=""
|
||||
|
|
|
@ -72,6 +72,11 @@
|
|||
</LinearLayout>
|
||||
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"/>
|
||||
|
||||
|
||||
<!-- ルート表示のレイアウト-->
|
||||
<LinearLayout
|
||||
|
@ -102,11 +107,6 @@
|
|||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"/>
|
||||
|
||||
|
||||
<!-- 提出状況のレイアウト-->
|
||||
<LinearLayout
|
||||
|
|
|
@ -20,28 +20,33 @@
|
|||
android:layout_width="40dp"
|
||||
android:layout_height="90dp"
|
||||
android:src="@drawable/back_button"
|
||||
android:layout_weight="5" />
|
||||
android:layout_weight="3" />
|
||||
|
||||
<TextView
|
||||
<Spinner
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="4"
|
||||
android:hint="今日の日付"
|
||||
android:textSize="40dp" />
|
||||
android:layout_height="90dp"
|
||||
android:layout_weight="7" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Webの処理 -->
|
||||
<WebView
|
||||
android:id="@+id/webView"
|
||||
<fragment
|
||||
android:id="@+id/map"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="6" />
|
||||
android:layout_weight="6"
|
||||
tools:context=".Maps" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3" />
|
||||
|
||||
android:layout_weight="3">
|
||||
<LinearLayout
|
||||
android:id="@+id/locationsName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<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="setUp">設定</string>
|
||||
<string name="reset">リセット</string>
|
||||
|
@ -11,29 +12,8 @@
|
|||
<string name="breakTime">休憩時間</string>
|
||||
<string name="totalStudent">生徒の人数</string>
|
||||
<string name="timeSet">時刻設定</string>
|
||||
<string name="Back">🔙</string>
|
||||
<string name="startpoint">住所</string>
|
||||
<string name="tenMinute">10分</string>
|
||||
<string name="fifteenMinute">15分</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>
|
Loading…
Reference in New Issue
Block a user