diff --git a/android/app/build.gradle b/android/app/build.gradle index f960b1f..4aa7e18 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -94,4 +94,5 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.google.android.gms:play-services-location:18.0.0' // このバージョンは最新のものにしてください } diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index a42e013..6513a94 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.dvox.gifunavi"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a4562a9..a96c3a8 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.dvox.gifunavi"> @@ -42,7 +42,7 @@   diff --git a/android/app/src/main/kotlin/com/dvox/gifunavi/LocationService.kt b/android/app/src/main/kotlin/com/dvox/gifunavi/LocationService.kt new file mode 100644 index 0000000..0eb3875 --- /dev/null +++ b/android/app/src/main/kotlin/com/dvox/gifunavi/LocationService.kt @@ -0,0 +1,241 @@ +package com.dvox.gifunavi // この部分を変更 + +import android.location.Location +import android.Manifest +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.Service +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.location.LocationManager +import android.os.Build +import android.os.IBinder +import android.util.Log +import androidx.core.app.ActivityCompat +import androidx.core.app.NotificationCompat +import androidx.core.content.ContextCompat +import com.google.android.gms.location.FusedLocationProviderClient +import com.google.android.gms.location.LocationCallback +import com.google.android.gms.location.LocationRequest +import com.google.android.gms.location.LocationResult +import com.google.android.gms.location.LocationServices +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale +import android.app.Notification + +data class GpsData( + val id: Int, + val team_name: String, + val event_code: String, + val lat: Double, + val lon: Double, + val is_checkin: Int, + val created_at: Long +) + +class GpsDatabaseHelper(private val context: Context) { + fun insertGps(gpsData: GpsData) { + Log.d("LocationService", "Android: insertGps.") + + // ここにデータベースへの挿入処理を実装する + } + + companion object { + fun getInstance(context: Context): GpsDatabaseHelper { + Log.d("LocationService", "Android: GpsDatabaseHelper.") + return GpsDatabaseHelper(context) + } + } +} + +class LocationService : Service() { + private lateinit var fusedLocationClient: FusedLocationProviderClient + + override fun onBind(intent: Intent?): IBinder? { + return null + } + + override fun onCreate() { + super.onCreate() + Log.d("LocationService", "Android: onCreate.") + + fusedLocationClient = LocationServices.getFusedLocationProviderClient(this) + + // GPSデバイスが有効になっているか確認する + val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager + if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + Log.d("LocationService", "GPS is disabled.") + // GPSが無効の場合の処理を追加する(例: ユーザーにGPSを有効にするように促すなど) + }else{ + Log.d("LocationService", "GPS is enabled.") + } + + // フォアグラウンドサービスの設定 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val CHANNEL_ID = "location" + val channel = NotificationChannel(CHANNEL_ID, "Location", NotificationManager.IMPORTANCE_DEFAULT) + val notificationManager = getSystemService(NotificationManager::class.java) // この行を追加 + + Log.d("LocationService", "Android: Foreground service.") + + notificationManager?.createNotificationChannel(channel) + } + val notification = NotificationCompat.Builder(this, "location") + .setContentTitle("Tracking location...") + .setContentText("Location: null") + .setSmallIcon(android.R.drawable.ic_menu_mylocation) // リソースが存在しないため0を設定 + .setOngoing(true) + .build() + Log.d("LocationService", "Android: Foreground service 2.") + + startForeground(1, notification) + } + + override fun onDestroy() { + super.onDestroy() + Log.d("LocationService", "Android: onDestroy.") + fusedLocationClient.removeLocationUpdates(locationCallback) + stopForeground(true) + stopSelf() + } + + companion object { + private const val NOTIFICATION_ID = 1 + private const val CHANNEL_ID = "location_service_channel" + } + + private fun createNotification(): Notification { + Log.d("LocationService", "Android: createNotification Notification.") + val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID) + .setContentTitle("Location Service") + .setContentText("Running...") + .setSmallIcon(android.R.drawable.ic_menu_mylocation) + .setPriority(NotificationCompat.PRIORITY_DEFAULT) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val channelName = "Location Service Channel" + val channelDescription = "Channel for Location Service" + val importance = NotificationManager.IMPORTANCE_DEFAULT + val channel = NotificationChannel(CHANNEL_ID, channelName, importance).apply { + description = channelDescription + } + val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + notificationManager.createNotificationChannel(channel) + } + + return notificationBuilder.build() + } + + private fun createNotificationChannel() { + Log.d("LocationService", "Android: createNotificationChannel.") + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val channel = NotificationChannel( + CHANNEL_ID, + "Location Service Channel", + NotificationManager.IMPORTANCE_DEFAULT + ) + val manager = getSystemService(NotificationManager::class.java) + manager.createNotificationChannel(channel) + } + } + + private var lastLocation: Location? = null + + private val locationCallback = object : LocationCallback() { + override fun onLocationResult(locationResult: LocationResult) { + val currentLocation = locationResult.lastLocation + //Log.d("LocationService", "Android: onLocationResult.") + + if (currentLocation != null) { + val accuracy = currentLocation.accuracy + if (accuracy <= 30) { + var lastLocation = lastLocation + if (lastLocation == null || currentLocation.distanceTo(lastLocation) >= 10) { + val lat = currentLocation.latitude + val lon = currentLocation.longitude + val currentTime = System.currentTimeMillis() + + // GPS データをデバッグ用に表示 + val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()) + val formattedTime = sdf.format(Date(currentTime)) + //Log.d("LocationService", "Latitude: $lat, Longitude: $lon, Time: $formattedTime, Accuracy: $accuracy") + + // GPS データをデータベースに保存 + GlobalScope.launch { + addGPStoDB(lat, lon, currentTime) + } + + lastLocation = currentLocation + } + } else { + Log.d("LocationService", "Android: GPS accuracy is above 30m. Skipping data saving.") + } + } else { + Log.d("LocationService", "Android: No GPS signal received.") + } + } + } + + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + Log.d("LocationService", "Android: onStartCommand.") + + // 位置情報の権限チェックとGPS有効化の確認を行う + if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager + if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + val locationRequest = LocationRequest.create().apply { + priority = LocationRequest.PRIORITY_HIGH_ACCURACY + interval = 10000 + fastestInterval = 5000 + } + fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null) + } else { + Log.d("LocationService", "GPS is disabled.") + // GPSが無効の場合の処理を追加する(例: ユーザーにGPSを有効にするように促すなど) + } + } else { + Log.d("LocationService", "Location permission is not granted.") + // 位置情報の権限が許可されていない場合の処理を追加する + } + + // Foregroundサービスを開始 + startForeground(NOTIFICATION_ID, createNotification()) + + return START_STICKY + } + + private suspend fun addGPStoDB(lat: Double, lng: Double, timestamp: Long, isCheckin: Int = 0) { + try { + val context = applicationContext + val preferences = context.getSharedPreferences("RogPreferences", Context.MODE_PRIVATE) + val teamName = preferences.getString("team_name", "") ?: "" + val eventCode = preferences.getString("event_code", "") ?: "" + + + if (teamName.isNotEmpty() && eventCode.isNotEmpty()) { + val gpsData = GpsData( + id = 0, + team_name = teamName, + event_code = eventCode, + lat = lat, + lon = lng, + is_checkin = isCheckin, + created_at = timestamp + ) + + val db = GpsDatabaseHelper.getInstance(context) + db.insertGps(gpsData) + Log.d("LocationService", "Android: addGPStoDB.") + + } + } catch (e: Exception) { + Log.e("LocationService", "Error adding GPS data to DB", e) + } + } +} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/dvox/gifunavi/MainActivity.kt b/android/app/src/main/kotlin/com/dvox/gifunavi/MainActivity.kt new file mode 100644 index 0000000..ea4b328 --- /dev/null +++ b/android/app/src/main/kotlin/com/dvox/gifunavi/MainActivity.kt @@ -0,0 +1,114 @@ +package com.dvox.gifunavi // この部分を変更 + +import android.Manifest +import android.app.ActivityManager +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.os.Build +import android.os.Bundle +import android.widget.Toast +import androidx.annotation.NonNull +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.MethodChannel +import android.util.Log + +class MainActivity: FlutterActivity() { + private val CHANNEL = "location" + + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { + call, result -> + when (call.method) { + "startLocationService" -> { + Log.d("MainActivity", "Android: called startLocationService.") + //val intent = Intent(this, LocationService::class.java) + startLocationService() + result.success(null) + } + "stopLocationService" -> { + Log.d("MainActivity", "Android: called stopLocationService.") + //val intent = Intent(this, LocationService::class.java) + stopLocationService() + result.success(null) + } + else -> { + result.notImplemented() + } + } + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + Log.d("MainActivity", "Android: onCreate.") + + // 位置情報の権限をリクエストする + if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), PERMISSION_REQUEST_CODE) + } else { + // startLocationService() // アプリ起動時にLocationServiceを開始する ==> main.dartで制御する。 + } + } + + + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + if (requestCode == PERMISSION_REQUEST_CODE) { + if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + // startLocationService() + + Log.d("MainActivity", "Android: PERMISSION_GRANTED.") + } else { + // 位置情報の権限が拒否された場合の処理 + Toast.makeText(this, "Location permission denied.", Toast.LENGTH_SHORT).show() + } + } + } + + companion object { + private const val PERMISSION_REQUEST_CODE = 1 + } + + private fun startLocationService() { + Log.d("MainActivity", "Android: startLocationService.") + + if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + if (!isServiceRunning(LocationService::class.java)) { + val intent = Intent(this, LocationService::class.java) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Log.d("MainActivity", "startForegroundService") + startForegroundService(intent) + } else { + Log.d("MainActivity", "startService") + startService(intent) + } + } else { + Log.d("MainActivity", "Location service is already running.") + } + } else { + Log.d("MainActivity", "Location permission is not granted.") + // 位置情報の権限が許可されていない場合の処理を追加する + } + } + + private fun stopLocationService() { + Log.d("MainActivity", "Android: stopLocationService.") + val intent = Intent(this, LocationService::class.java) + stopService(intent) + } + + private fun isServiceRunning(serviceClass: Class<*>): Boolean { + val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager + for (service in manager.getRunningServices(Int.MAX_VALUE)) { + if (serviceClass.name == service.service.className) { + return true + } + } + return false + } +} diff --git a/android/app/src/main/kotlin/com/example/rogapp/LocationService.kt b/android/app/src/main/kotlin/com/example/rogapp/LocationService.kt deleted file mode 100644 index 5f1ef6f..0000000 --- a/android/app/src/main/kotlin/com/example/rogapp/LocationService.kt +++ /dev/null @@ -1,98 +0,0 @@ -import android.app.NotificationChannel -import android.app.NotificationManager -import android.app.Service -import android.content.Context -import android.content.Intent -import android.os.Build -import android.os.IBinder -import androidx.core.app.NotificationCompat - -class LocationService : Service() { - - override fun onBind(intent: Intent?): IBinder? { - return null - } - - override fun onCreate() { - super.onCreate() - // フォアグラウンドサービスの設定 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channel = NotificationChannel( - "location", - "Location", - NotificationManager.IMPORTANCE_LOW - ) - val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - notificationManager.createNotificationChannel(channel) - } - val notification = NotificationCompat.Builder(this, "location") - .setContentTitle("Tracking location...") - .setContentText("Location: null") - .setSmallIcon(R.drawable.ic_launcher) - .setOngoing(true) - .build() - startForeground(1, notification) - } - override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - // バックグラウンドでの位置情報取得処理を実装 - val locationSettings = LocationSettings.Builder() - .setAccuracy(LocationAccuracy.HIGH) - .setDistanceFilter(100.0f) - .build() - - try { - Geolocator.getPositionStream(locationSettings) - .catch { e -> - // エラーハンドリング - println("Location Error: $e") - null - } - .filterNotNull() - .filter { position -> - // GPS信号がlow以上の場合のみ記録 - position.accuracy <= 100 - } - .onEach { position -> - val lat = position.latitude - val lng = position.longitude - val timestamp = System.currentTimeMillis() - - // データベースに位置情報を保存 - addGPStoDB(lat, lng, timestamp) - } - .launchIn(CoroutineScope(Dispatchers.IO)) - } catch (e: Exception) { - println("Error starting background tracking: $e") - } - - return START_STICKY - } - - private fun addGPStoDB(lat: Double, lng: Double, isCheckin: Int = 0) { - try { - val context = applicationContext - val preferences = context.getSharedPreferences("RogPreferences", Context.MODE_PRIVATE) - val teamName = preferences.getString("team_name", "") ?: "" - val eventCode = preferences.getString("event_code", "") ?: "" - - if (teamName.isNotEmpty() && eventCode.isNotEmpty()) { - val gpsData = GpsData( - id = 0, - team_name = teamName, - event_code = eventCode, - lat = lat, - lon = lng, - is_checkin = isCheckin, - created_at = System.currentTimeMillis() - ) - - GlobalScope.launch { - val db = GpsDatabaseHelper.getInstance(context) - db.insertGps(gpsData) - } - } - } catch (e: Exception) { - println("Error adding GPS data to DB: $e") - } - } -} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/example/rogapp/MainActivity.kt b/android/app/src/main/kotlin/com/example/rogapp/MainActivity.kt deleted file mode 100644 index 4b5d3a9..0000000 --- a/android/app/src/main/kotlin/com/example/rogapp/MainActivity.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.example.rogapp - -import io.flutter.embedding.android.FlutterActivity - -import androidx.annotation.NonNull -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugin.common.MethodChannel - -class MainActivity: FlutterActivity() { - private val CHANNEL = "location" - - override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { - super.configureFlutterEngine(flutterEngine) - MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { - call, result -> - when (call.method) { - "startLocationService" -> { - val intent = Intent(this, LocationService::class.java) - startService(intent) - result.success(null) - } - "stopLocationService" -> { - val intent = Intent(this, LocationService::class.java) - stopService(intent) - result.success(null) - } - else -> { - result.notImplemented() - } - } - } - } -} diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/FMDB-FMDB.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/FMDB-FMDB.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/FMDB-FMDB.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/Flutter.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/Flutter.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/Flutter.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/MTBBarcodeScanner.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/MTBBarcodeScanner.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/MTBBarcodeScanner.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/Pods-Runner.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/Pods-Runner.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/Pods-Runner.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift-ReachabilitySwift.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift-ReachabilitySwift.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift-ReachabilitySwift.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation-camera_avfoundation_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation-camera_avfoundation_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation-camera_avfoundation_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/connectivity_plus.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/connectivity_plus.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/connectivity_plus.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/device_info_plus-device_info_plus_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/device_info_plus-device_info_plus_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/device_info_plus-device_info_plus_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/device_info_plus.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/device_info_plus.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/device_info_plus.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/flutter_compass.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/flutter_compass.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/flutter_compass.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/flutter_keyboard_visibility.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/flutter_keyboard_visibility.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/flutter_keyboard_visibility.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/geolocator_apple.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/geolocator_apple.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/geolocator_apple.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/image_gallery_saver.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/image_gallery_saver.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/image_gallery_saver.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios-image_picker_ios_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios-image_picker_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios-image_picker_ios_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/isar_flutter_libs.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/isar_flutter_libs.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/isar_flutter_libs.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/package_info_plus-package_info_plus_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/package_info_plus-package_info_plus_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/package_info_plus-package_info_plus_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/package_info_plus.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/package_info_plus.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/package_info_plus.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation-path_provider_foundation_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation-path_provider_foundation_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation-path_provider_foundation_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple-permission_handler_apple_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple-permission_handler_apple_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple-permission_handler_apple_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios-pointer_interceptor_ios_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios-pointer_interceptor_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios-pointer_interceptor_ios_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/qr_code_scanner.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/qr_code_scanner.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/qr_code_scanner.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation-shared_preferences_foundation_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation-shared_preferences_foundation_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation-shared_preferences_foundation_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/sqflite-sqflite_ios_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/sqflite-sqflite_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/sqflite-sqflite_ios_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/sqflite.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/sqflite.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/sqflite.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios-url_launcher_ios_privacy.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios-url_launcher_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios-url_launcher_ios_privacy.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios.build/dgph differ diff --git a/android/build/ios/Pods.build/Release-iphonesimulator/webview_flutter_wkwebview.build/dgph b/android/build/ios/Pods.build/Release-iphonesimulator/webview_flutter_wkwebview.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/android/build/ios/Pods.build/Release-iphonesimulator/webview_flutter_wkwebview.build/dgph differ diff --git a/android/gradle.properties b/android/gradle.properties index efc7201..1c2ee17 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -5,3 +5,4 @@ RELEASE_STORE_FILE=release-key.keystore RELEASE_STORE_PASSWORD=SachikoMiyata123 RELEASE_KEY_ALIAS=release_key RELEASE_KEY_PASSWORD=SachikoMiyata123 +org.gradle.jvmargs=--add-opens=java.base/java.util=ALL-UNNAMED \ No newline at end of file diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..b1624c4 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/FMDB-FMDB.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/FMDB-FMDB.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/FMDB-FMDB.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/Flutter.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/Flutter.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/Flutter.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/MTBBarcodeScanner.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/MTBBarcodeScanner.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/MTBBarcodeScanner.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/Pods-Runner.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/Pods-Runner.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/Pods-Runner.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift-ReachabilitySwift.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift-ReachabilitySwift.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift-ReachabilitySwift.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/ReachabilitySwift.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation-camera_avfoundation_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation-camera_avfoundation_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation-camera_avfoundation_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/camera_avfoundation.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/connectivity_plus.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/connectivity_plus.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/connectivity_plus.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/device_info_plus-device_info_plus_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/device_info_plus-device_info_plus_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/device_info_plus-device_info_plus_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/device_info_plus.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/device_info_plus.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/device_info_plus.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/flutter_compass.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/flutter_compass.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/flutter_compass.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/flutter_keyboard_visibility.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/flutter_keyboard_visibility.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/flutter_keyboard_visibility.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/geolocator_apple.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/geolocator_apple.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/geolocator_apple.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/image_gallery_saver.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/image_gallery_saver.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/image_gallery_saver.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios-image_picker_ios_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios-image_picker_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios-image_picker_ios_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/image_picker_ios.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/isar_flutter_libs.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/isar_flutter_libs.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/isar_flutter_libs.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/package_info_plus-package_info_plus_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/package_info_plus-package_info_plus_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/package_info_plus-package_info_plus_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/package_info_plus.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/package_info_plus.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/package_info_plus.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation-path_provider_foundation_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation-path_provider_foundation_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation-path_provider_foundation_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/path_provider_foundation.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple-permission_handler_apple_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple-permission_handler_apple_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple-permission_handler_apple_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/permission_handler_apple.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios-pointer_interceptor_ios_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios-pointer_interceptor_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios-pointer_interceptor_ios_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/pointer_interceptor_ios.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/qr_code_scanner.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/qr_code_scanner.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/qr_code_scanner.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation-shared_preferences_foundation_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation-shared_preferences_foundation_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation-shared_preferences_foundation_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/shared_preferences_foundation.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/sqflite-sqflite_ios_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/sqflite-sqflite_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/sqflite-sqflite_ios_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/sqflite.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/sqflite.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/sqflite.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios-url_launcher_ios_privacy.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios-url_launcher_ios_privacy.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios-url_launcher_ios_privacy.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/url_launcher_ios.build/dgph differ diff --git a/lib/build/ios/Pods.build/Release-iphonesimulator/webview_flutter_wkwebview.build/dgph b/lib/build/ios/Pods.build/Release-iphonesimulator/webview_flutter_wkwebview.build/dgph new file mode 100644 index 0000000..f807d76 Binary files /dev/null and b/lib/build/ios/Pods.build/Release-iphonesimulator/webview_flutter_wkwebview.build/dgph differ diff --git a/lib/main.dart b/lib/main.dart index 99a0fa4..65e975b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -52,7 +52,12 @@ void saveGameState() async { Get.find(); IndexController indexController = Get.find(); SharedPreferences pref = await SharedPreferences.getInstance(); - pref.setInt("user_id", indexController.currentUser[0]["user"]["id"]); + debugPrint("indexController.currentUser = ${indexController.currentUser}"); + if(indexController.currentUser.isNotEmpty) { + pref.setInt("user_id", indexController.currentUser[0]["user"]["id"]); + }else{ + debugPrint("User is empty...."); + } pref.setBool("is_in_rog", destinationController.isInRog.value); pref.setBool( "rogaining_counted", destinationController.rogainingCounted.value); @@ -79,6 +84,8 @@ void restoreGame() async { SharedPreferences pref = await SharedPreferences.getInstance(); IndexController indexController = Get.find(); int? savedUserId = pref.getInt("user_id"); + //int? currUserId = indexController.currentUser[0]['user']['id']; + //debugPrint("savedUserId=${savedUserId}, currentUser=${currUserId}"); if (indexController.currentUser.isNotEmpty && indexController.currentUser[0]["user"]["id"] == savedUserId) { DestinationController destinationController = @@ -127,11 +134,15 @@ void main() async { // startMemoryMonitoring(); // 2024-4-8 Akira: メモリ使用量のチェックを開始 See #2810 Get.put(SettingsController()); // これを追加 + /* runZonedGuarded(() { runApp(const ProviderScope(child: MyApp())); }, (error, stackTrace) { ErrorService.reportError(error, stackTrace, deviceInfo); }); + */ + + runApp(const ProviderScope(child: MyApp())); //runApp(const MyApp()); } @@ -307,6 +318,11 @@ Future stopBackgroundTracking() async { debugPrint("バックグラウンド処理:停止しました。"); await positionStream?.cancel(); positionStream = null; + }else if(Platform.isAndroid && background==true){ + background=false; + debugPrint("バックグラウンド処理:停止しました。"); + await positionStream?.cancel(); + positionStream = null; } } @@ -354,38 +370,54 @@ class _MyAppState extends State with WidgetsBindingObserver { // Get.find(); switch (state) { case AppLifecycleState.resumed: - // Foreground に戻った時の処理 - debugPrint(" ==(Status Changed)==> RESUMED. フォアグラウンドに戻りました"); - locationController.resumePositionStream(); - //print("RESUMED"); - restoreGame(); - - // バックグラウンド処理を停止 + // バックグラウンド処理を停止 if (Platform.isIOS && destinationController.isRunningBackgroundGPS) { + // Foreground に戻った時の処理 + debugPrint(" ==(Status Changed)==> RESUMED. フォアグラウンドに戻りました"); + locationController.resumePositionStream(); + //print("RESUMED"); + restoreGame(); + stopBackgroundTracking(); destinationController.isRunningBackgroundGPS=false; destinationController.restartGPS(); - } else if (Platform.isAndroid) { - const platform = MethodChannel('location'); - platform.invokeMethod('stopLocationService'); + } else if (Platform.isAndroid ) { + if( destinationController.isRunningBackgroundGPS ){ + const platform = MethodChannel('location'); + platform.invokeMethod('stopLocationService'); + destinationController.isRunningBackgroundGPS=false; + destinationController.restartGPS(); + debugPrint("stopped android location service.."); + } + + debugPrint("==(Status Changed)==> RESUMED. android フォアグラウンドに戻りました"); + locationController.resumePositionStream(); + //print("RESUMED"); + restoreGame(); + + }else{ + debugPrint("==(Status Changed)==> RESUMED 不明状態"); } break; case AppLifecycleState.inactive: // アプリが非アクティブになったときに発生します。 - // これは、別のアプリやシステムのオーバーレイ(着信通話やアラームなど)によって一時的に中断された状態です。 - debugPrint(" ==(Status Changed)==> PAUSED. 非アクティブ処理。"); - //locationController.resumePositionStream(); - // 追加: フロントエンドのGPS信号のlistenを停止 - locationController.stopPositionStream(); + if (Platform.isIOS && !destinationController.isRunningBackgroundGPS) { // iOSはバックグラウンドでもフロントの処理が生きている。 + // これは、別のアプリやシステムのオーバーレイ(着信通話やアラームなど)によって一時的に中断された状態です。 + debugPrint(" ==(Status Changed)==> INACTIVE. 非アクティブ処理。"); + //locationController.resumePositionStream(); + + // 追加: フロントエンドのGPS信号のlistenを停止 + locationController.stopPositionStream(); - if (Platform.isIOS ) { // iOSはバックグラウンドでもフロントの処理が生きている。 destinationController.isRunningBackgroundGPS=true; startBackgroundTracking(); - }else if(Platform.isAndroid){ - const platform = MethodChannel('location'); - platform.invokeMethod('startLocationService'); + }else if(Platform.isAndroid && !destinationController.isRunningBackgroundGPS){ + debugPrint(" ==(Status Changed)==> INACTIVE. 非アクティブ処理。"); + }else{ + debugPrint("==(Status Changed)==> INACTIVE 不明状態"); + } saveGameState(); break; @@ -393,6 +425,19 @@ class _MyAppState extends State with WidgetsBindingObserver { // バックグラウンドに移行したときの処理 //locationController.resumePositionStream(); debugPrint(" ==(Status Changed)==> PAUSED. バックグラウンド処理。"); + if (Platform.isIOS && !destinationController.isRunningBackgroundGPS) { + debugPrint("iOS already running background GPS processing when it's inactive"); + + } else if(Platform.isAndroid && !destinationController.isRunningBackgroundGPS) { + debugPrint( + " ==(Status Changed)==> PAUSED. Android バックグラウンド処理。"); + locationController.stopPositionStream(); + const platform = MethodChannel('location'); + platform.invokeMethod('startLocationService'); + //platform.invokeMethod('stopLocationService'); + destinationController.isRunningBackgroundGPS = true; + //startBackgroundTracking(); + } saveGameState(); break; case AppLifecycleState.detached: diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 544f876..6aa24e8 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -112,7 +112,7 @@ class DestinationController extends GetxController { DateTime lastGPSDataReceivedTime = DateTime.now(); DateTime lastPopupShownTime = DateTime.now().subtract(Duration(minutes: 10)); bool isPopupShown = false; - bool hasReceivedGPSData = false; + bool hasReceivedGPSData = true; var isCheckingIn = false.obs; // チェックイン操作中はtrueになり、重複してポップアップが出ないようにするもの。 @@ -161,31 +161,36 @@ class DestinationController extends GetxController { */ void showGPSDataNotReceivedPopup() { - Get.dialog( - AlertDialog( - title: Text('GPS信号が受信できません'), - content: Text('GPS信号が受信できる場所に移動してください。'), - actions: [ - TextButton( - onPressed: () => Get.back(), - child: Text('OK'), - ), - ], - ), - ); + if (Get.context != null) { + Get.dialog( + AlertDialog( + title: Text('GPS信号が受信できません'), + content: Text('GPS信号が受信できる場所に移動してください。'), + actions: [ + TextButton( + onPressed: () => Get.back(), + child: Text('OK'), + ), + ], + ), + ); + } else { + // Get.contextがnullの場合の処理を追加 + print('GPS signal not received, but context is null'); + } } // 最後に有効なGPSデータを受け取ってから10分以上経過している場合にのみメッセージを表示するようにします。 // void checkGPSDataReceived() { if (!hasReceivedGPSData) { - // GPS信号を全く受信していない。 - if (!isPopupShown) { - // ポップアップしていない。 - showGPSDataNotReceivedPopup(); - lastPopupShownTime = DateTime.now(); - isPopupShown = true; - } + //debugPrint("GPS信号を全く受信していない。"); + if (!isPopupShown) { + // ポップアップしていない。 + showGPSDataNotReceivedPopup(); + lastPopupShownTime = DateTime.now(); + isPopupShown = true; + } } else { if (DateTime.now().difference(lastGPSDataReceivedTime).inSeconds >= 600) { // 前回GPS信号を受信してから10分経過。 @@ -946,7 +951,7 @@ class DestinationController extends GetxController { is_checkin: isCheckin, created_at: DateTime.now().millisecondsSinceEpoch); var res = await db.insertGps(gps_data); - //debugPrint("Saved GPS data into DB..."); + debugPrint("Saved GPS data into DB...:${gps_data}"); } } catch (err) { print("errr ready gps ${err}"); @@ -1188,7 +1193,7 @@ class DestinationController extends GetxController { // ゲームを開始する関数です。 // Future startGame() async { - //print("------ starting game ------"); + debugPrint("------ starting game ------"); if (game_started == false) { await checkForCheckin(); } @@ -1206,6 +1211,7 @@ class DestinationController extends GetxController { // bool inError=false; bool isRunningBackgroundGPS=false; + int activeEngineCount = 0; @override void onInit() async { @@ -1215,6 +1221,8 @@ class DestinationController extends GetxController { // MapControllerの初期化完了を待機するフラグを設定 WidgetsBinding.instance.addPostFrameCallback((_) { + //checkGPSDataReceived(); removed 2024-5-4 + isMapControllerReady = true; }); @@ -1280,7 +1288,7 @@ class DestinationController extends GetxController { startGame(); - checkGPSDataReceived(); + //checkGPSDataReceived(); } void restartGPS(){ @@ -1308,8 +1316,11 @@ class DestinationController extends GetxController { // double prevLat = 0.0; // 直前の位置 double prevLon = 0.0; + bool gpsDebugMode=false; void handleLocationUpdate(LocationMarkerPosition? position) async { + //debugPrint("DestinationController.handleLocationUpdate"); + try { //final DestinationController destinationController = Get.find(); //final signalStrength = locationController.getGpsSignalStrength(); @@ -1399,7 +1410,7 @@ class DestinationController extends GetxController { lastGPSCollectedTime = DateTime.now(); prevLat = position.latitude; prevLon = position.longitude; - debugPrint("フロントエンドでのGPS保存(時間差:${difference.inSeconds}, 距離差:${distanceToDest}) : Time=${lastGPSCollectedTime}"); + gpsDebugMode ? debugPrint("フロントエンドでのGPS保存(時間差:${difference.inSeconds}, 距離差:${distanceToDest}) : Time=${lastGPSCollectedTime}"):null; } } } diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index f2b1e8d..3945201 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -104,7 +104,7 @@ class IndexPage extends GetView { // タップすることでGPS信号の強弱をシミュレーションできるようにする // Akira 2024-4-5 // - /* +/* Obx(() { if (locationController.isSimulationMode) { return DropdownButton( @@ -122,34 +122,11 @@ class IndexPage extends GetView { }).toList(), ); } else { - return InkWell( - onTap: () { - locationController.setSimulatedSignalStrength('high'); - }, - child: const Icon(Icons.info), - ); + return Container(); } }), + */ - */ - /* - Obx(() => locationController.isSimulationMode - ? DropdownButton( - value: locationController.getSimulatedSignalStrength(), - onChanged: (value) { - locationController.setSimulatedSignalStrength(value!); - }, - items: ['low', 'medium', 'high','real'] - .map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ) - : Container(), - ), - */ ], ), // bottomNavigationBar: BottomAppBar( diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index aec0ddd..1d6e496 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -25,24 +25,10 @@ class LoginPage extends StatelessWidget { backgroundColor: Colors.white, automaticallyImplyLeading: false, ), -/* 2024-04-03 Updated by Akira . See https://wiki.sumasen.net/issues/2796?issue_count=1&issue_position=1 - appBar: AppBar( - elevation: 0, - backgroundColor: Colors.white, - leading: IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: const Icon( - Icons.arrow_back_ios, - size: 20, - color: Colors.black, - )), - ), -*/ body: indexController.currentUser.isEmpty ? SizedBox( width: double.infinity, + child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ @@ -129,30 +115,6 @@ class LoginPage extends StatelessWidget { emailController.text, passwordController.text, context); -/* - try { - bool isLoggedIn = await indexController.login(emailController.text, passwordController.text,context); - if (isLoggedIn) { - Get.offAllNamed(AppPages.INDEX); - } else { - Get.snackbar( - "Login Failed", - "Invalid email or password", - icon: const Icon(Icons.error, color: Colors.red), - snackPosition: SnackPosition.BOTTOM, - ); - } - } catch (e) { - Get.snackbar( - "Error", - "An error occurred during login", - icon: const Icon(Icons.error, color: Colors.red), - snackPosition: SnackPosition.BOTTOM, - ); - } finally { - indexController.isLoading.value = false; - } -*/ // ここまで }, color: Colors.indigoAccent[400], shape: RoundedRectangleBorder( @@ -165,16 +127,6 @@ class LoginPage extends StatelessWidget { fontSize: 16, color: Colors.white70), ), -/* - child: Obx( - () => indexController.isLoading.value - ? const CircularProgressIndicator(color: Colors.white) - : const Text( - "ログイン", - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 16, color: Colors.white70), - ), - ), -*/ // ここまで ), const SizedBox( height: 5.0, @@ -223,7 +175,7 @@ class LoginPage extends StatelessWidget { ), )), const SizedBox( - height: 5, + height: 3, ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -280,6 +232,7 @@ class LoginPage extends StatelessWidget { ), ], ), + ) : TextButton( onPressed: () { diff --git a/lib/services/location_service.dart b/lib/services/location_service.dart index 54005f4..ea3c56e 100644 --- a/lib/services/location_service.dart +++ b/lib/services/location_service.dart @@ -7,6 +7,8 @@ import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/utils/const.dart'; class LocationService { + + static Future loadLocationsFor( String perfecture, String cat) async { final IndexController indexController = Get.find(); diff --git a/lib/utils/location_controller.dart b/lib/utils/location_controller.dart index 0e261a5..92015bc 100644 --- a/lib/utils/location_controller.dart +++ b/lib/utils/location_controller.dart @@ -39,6 +39,8 @@ class LocationController extends GetxController { LatLng? lastValidLocation; DateTime lastGPSDataReceivedTime = DateTime.now(); // 最後にGPSデータを受け取った時刻 + bool gpsDebugMode = false; + /* // GPSシミュレーション用のメソッドを追加 void setSimulationMode(bool value) { isSimulationMode = value; @@ -52,7 +54,7 @@ class LocationController extends GetxController { bool isSimulationMode = false; // GPS信号強度をシミュレートするための変数 - final Rx _simulatedSignalStrength = Rx('low'); + final Rx _simulatedSignalStrength = Rx('high'); // GPS信号強度をシミュレートするための関数 void setSimulatedSignalStrength(String strength) { @@ -72,31 +74,38 @@ class LocationController extends GetxController { return _simulatedSignalStrength.value; } + */ + // // ====== Akira , GPS信号強度をシミュレート ==== ここまで - // GPS信号が弱い場合のフラグ. 本番では、true,high にする。 - bool isGpsSignalWeak = true; - RxString latestSignalStrength = 'low'.obs; + // GPS信号が弱い場合のフラグ. 本番では、false,high にする。 + bool isGpsSignalWeak = false; + RxString latestSignalStrength = 'high'.obs; //final _latestSignalStrength = 'low'.obs; // 初期値を設定 //String get latestSignalStrength => _latestSignalStrength.value; Stream get gpsSignalStrengthStream => latestSignalStrength.stream; + bool isRunningBackgroundGPS=false; + int activeEngineCount = 0; // GPS信号の強弱を判断するメソッドを追加. 10m 以内:強、30m以内:中、それ以上:弱 // String getGpsSignalStrength(Position? position) { if (position == null) { + gpsDebugMode ? debugPrint("getGpsSignalStrength position is null.") : null; latestSignalStrength.value = "low"; isGpsSignalWeak = true; return 'low'; } final accuracy = position.accuracy; - //debugPrint("getGpsSignalStrength : ${accuracy}"); + gpsDebugMode ? debugPrint("getGpsSignalStrength : ${accuracy}") : null; + /* if(isSimulationMode){ return _simulatedSignalStrength.value; // GPS信号強度シミュレーション }else { + */ if (accuracy <= 10) { latestSignalStrength.value = "high"; isGpsSignalWeak = false; @@ -110,7 +119,7 @@ class LocationController extends GetxController { isGpsSignalWeak = true; return 'low'; } - } + // } } // 現在位置を調整するメソッドを追加 @@ -130,7 +139,7 @@ class LocationController extends GetxController { //debugPrint("=== adjustCurrentLocation (Position:Get and return Valid location:${position} ... )==="); lastValidLocation = LatLng(position.latitude, position.longitude); } - return lastValidLocation ?? LatLng(position.latitude, position.longitude); + return lastValidLocation ?? LatLng(lastValidLocation!.latitude, lastValidLocation!.longitude); } //===== Akira Added 2024-4-9 end @@ -256,7 +265,7 @@ class LocationController extends GetxController { // 位置情報の設定を行います。z11 // Set up the location options const locationOptions = - LocationSettings(accuracy: LocationAccuracy.high, distanceFilter: 0); + LocationSettings(accuracy: LocationAccuracy.medium, distanceFilter: 0); // 既存の位置情報のストリームをキャンセルします。 await positionStream?.cancel(); @@ -265,11 +274,14 @@ class LocationController extends GetxController { // positionStream = Geolocator.getPositionStream(locationSettings: locationOptions).listen( (Position? position) { + gpsDebugMode ? debugPrint("Position = ${position}"):null; final signalStrength = getGpsSignalStrength(position); if (signalStrength == 'low') { isGpsSignalWeak = true; + gpsDebugMode ? debugPrint("LocationController.getPositionStream : isGpsSignalWeak = ${isGpsSignalWeak}"):null; } else { isGpsSignalWeak = false; + gpsDebugMode ? debugPrint("LocationController.getPositionStream : isGpsSignalWeak = ${isGpsSignalWeak}"):null; } final DestinationController destinationController = Get.find(); @@ -349,9 +361,15 @@ class LocationController extends GetxController { void handleLocationUpdate(LocationMarkerPosition? position) async { - if (position != null) { - //debugPrint("position = ${position}"); - /* + //debugPrint("locationController.handleLocationUpdate"); + try { + if (position != null) { + double currentLat = position.latitude; + double currentLon = position.longitude; + //debugPrint("Flutter: Received GPS signal. Latitude: $currentLat, Longitude: $currentLon"); + + //debugPrint("position = ${position}"); + /* currentPosition.value = position; final locationMarkerPosition = LocationMarkerPosition( latitude: position.latitude, @@ -359,8 +377,13 @@ class LocationController extends GetxController { accuracy: position.accuracy, ); */ - lastGPSDataReceivedTime = DateTime.now(); // 最後にGPS信号を受け取った時刻 - locationMarkerPositionStreamController.add(position); + lastGPSDataReceivedTime = DateTime.now(); // 最後にGPS信号を受け取った時刻 + locationMarkerPositionStreamController.add(position); + }else{ + gpsDebugMode ? debugPrint("Flutter: No GPS signal received."):null; + } + } catch( e ) { + debugPrint("Flutter: Error in handleLocationUpdate: $e"); } } diff --git a/lib/utils/string_values.dart b/lib/utils/string_values.dart index bb821ad..caf9ee4 100644 --- a/lib/utils/string_values.dart +++ b/lib/utils/string_values.dart @@ -31,7 +31,7 @@ class StringValues extends Translations{ 'no_values': 'No Values', 'email_and_password_required': 'Email and password required', 'rogaining_user_need_tosign_up': "Rogaining participants do need to sign up.", - 'add_location': 'Add Location', + 'add_location': 'Gifu', 'select_travel_mode':'Select your travel mode', 'walking':'Walking', 'driving': 'Driving', @@ -105,7 +105,7 @@ class StringValues extends Translations{ 'no_values': '値なし', 'email_and_password_required': 'メールとパスワードが必要です', 'rogaining_user_need_tosign_up': "ロゲイニング参加者はサインアップの必要はありません。", - 'add_location': '目的地選択', + 'add_location': '岐阜', 'select_travel_mode':'移動モードを選択してください', 'walking':'歩行', 'driving': '自動車利用', diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index ba4a817..53799cd 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -87,6 +87,7 @@ class _MapWidgetState extends State with WidgetsBindingObserver { } void _resetIdleTimer() { + debugPrint("_resetIdleTimer..."); _timer?.cancel(); _startIdleTimer(); } @@ -101,15 +102,20 @@ class _MapWidgetState extends State with WidgetsBindingObserver { } // added by Akira + /* @override void didChangeAppLifecycleState(AppLifecycleState state) { + debugPrint("MapWidget:didChangeAppLifecycleState...state=${state}"); + if (state == AppLifecycleState.resumed) { _resetTimer(); } } + */ // _centerMapOnUser を10秒間でコール void _startIdleTimer() { + //debugPrint("_startIdleTimer ...."); final settingsController = Get.find(); if (!settingsController.autoReturnDisabled.value) { _timer = Timer(settingsController.timerDuration.value, _centerMapOnUser); @@ -118,13 +124,16 @@ class _MapWidgetState extends State with WidgetsBindingObserver { // タイマーをリセットして_startIdleTimer をコール void _resetTimer() { + //debugPrint("_resetTimer ...."); _timer?.cancel(); _startIdleTimer(); } // マッぷを現在位置を中心にする。 void _centerMapOnUser() { + //debugPrint("_centerMapOnUser ...."); if (mounted) { + //debugPrint("_centerMapOnUser => centering ...."); destinationController.centerMapToCurrentLocation(); } } diff --git a/pubspec.lock b/pubspec.lock index f59d5f2..9b63280 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -205,10 +205,10 @@ packages: dependency: "direct main" description: name: device_info_plus - sha256: "50fb435ed30c6d2525cbfaaa0f46851ea6131315f213c0d921b0e407b34e3b84" + sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91 url: "https://pub.dev" source: hosted - version: "10.0.1" + version: "10.1.0" device_info_plus_platform_interface: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ee204fd..0c808aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,13 +38,14 @@ dependencies: flutter_map: ^6.0.1 geolocator: ^10.1.0 permission_handler: ^11.3.1 +# flutter_dev_tools: ^0.0.2 # permission_handler: ^11.1.0 <== older # permission_handler 11.2.0 (11.3.1 available) # permission_handler_android 12.0.3 (12.0.5 available) # permission_handler_apple 9.3.0 (9.4.4 available) # permission_handler_platform_interface 4.1.0 (4.2.1 available) package_info_plus: ^6.0.0 - device_info_plus: ^10.0.1 + device_info_plus: ^10.1.0 google_api_availability: ^5.0.0 tuple: ^2.0.0 latlong2: ^0.9.0